<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[String trimmed und split]]></title><description><![CDATA[<p>Hallo!</p>
<p>Ich bin gerade dabei ein paar Klassen, welche vorher in Qt geschrieben waren, wieder ins &quot;reine&quot; C++ zu schreiben.</p>
<p>Jetzt hab ich allerdings ein kleines Problem, denn ich weiß im Moment grad nicht wie ich z.B. das hier umschreiben muss:</p>
<pre><code class="language-cpp">QString line = QString(file.readLine()).trimmed().split(&quot;#&quot;, QString::KeepEmptyParts).at(0).trimmed();
</code></pre>
<p>Könnte mir bitte jemand mal auf die Sprünge helfen und sagen was das Äquivalent zu trimmed und split ist, bzw. gibt es da überhaupt was, oder muss ich mir das selbst zusammenbasteln?</p>
<p>Eine Lib wie Boost kann ich nicht benutzen, ist zu groß für das Vorhaben.</p>
<p>Danke schon mal.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/299180/string-trimmed-und-split</link><generator>RSS for Node</generator><lastBuildDate>Thu, 13 Aug 2026 11:44:23 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/299180.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 04 Feb 2012 19:48:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to String trimmed und split on Sat, 04 Feb 2012 19:48:29 GMT]]></title><description><![CDATA[<p>Hallo!</p>
<p>Ich bin gerade dabei ein paar Klassen, welche vorher in Qt geschrieben waren, wieder ins &quot;reine&quot; C++ zu schreiben.</p>
<p>Jetzt hab ich allerdings ein kleines Problem, denn ich weiß im Moment grad nicht wie ich z.B. das hier umschreiben muss:</p>
<pre><code class="language-cpp">QString line = QString(file.readLine()).trimmed().split(&quot;#&quot;, QString::KeepEmptyParts).at(0).trimmed();
</code></pre>
<p>Könnte mir bitte jemand mal auf die Sprünge helfen und sagen was das Äquivalent zu trimmed und split ist, bzw. gibt es da überhaupt was, oder muss ich mir das selbst zusammenbasteln?</p>
<p>Eine Lib wie Boost kann ich nicht benutzen, ist zu groß für das Vorhaben.</p>
<p>Danke schon mal.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2176910</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2176910</guid><dc:creator><![CDATA[Cybertec]]></dc:creator><pubDate>Sat, 04 Feb 2012 19:48:29 GMT</pubDate></item><item><title><![CDATA[Reply to String trimmed und split on Sat, 04 Feb 2012 19:56:24 GMT]]></title><description><![CDATA[<p>Wenn du Boost nicht verwenden willst (keine Ahnung warum), dann musst du es selber schreiben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2176913</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2176913</guid><dc:creator><![CDATA[pyhax]]></dc:creator><pubDate>Sat, 04 Feb 2012 19:56:24 GMT</pubDate></item><item><title><![CDATA[Reply to String trimmed und split on Sat, 04 Feb 2012 19:57:39 GMT]]></title><description><![CDATA[<p>Hab doch gesagt das die Lib zu groß ist dafür.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2176914</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2176914</guid><dc:creator><![CDATA[Cybertec]]></dc:creator><pubDate>Sat, 04 Feb 2012 19:57:39 GMT</pubDate></item><item><title><![CDATA[Reply to String trimmed und split on Sat, 04 Feb 2012 19:59:52 GMT]]></title><description><![CDATA[<p>Was meinst du mit &quot;zu groß&quot; ? Das es die Größe deines Programms erhöht?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2176915</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2176915</guid><dc:creator><![CDATA[pyhax]]></dc:creator><pubDate>Sat, 04 Feb 2012 19:59:52 GMT</pubDate></item><item><title><![CDATA[Reply to String trimmed und split on Sat, 04 Feb 2012 20:01:06 GMT]]></title><description><![CDATA[<p>Wie kann eine Lib zu groß sein? Und selbst wenn du eine Definition dafür findest, wie kann die dann auf Boost zutreffen, aber nicht auf Qt?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2176917</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2176917</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Sat, 04 Feb 2012 20:01:06 GMT</pubDate></item><item><title><![CDATA[Reply to String trimmed und split on Sat, 04 Feb 2012 20:13:04 GMT]]></title><description><![CDATA[<p>Ja eben weil auch Qt zu groß ist haben wir uns umentscheiden das anders zu machen.</p>
<p>Ich hab die Lösung aber jetzt selbst gefunden, trimmed() brauch ich nicht mehr und für split() hab ich was eigenes gemacht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2176921</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2176921</guid><dc:creator><![CDATA[Cybertec]]></dc:creator><pubDate>Sat, 04 Feb 2012 20:13:04 GMT</pubDate></item><item><title><![CDATA[Reply to String trimmed und split on Sat, 04 Feb 2012 20:48:44 GMT]]></title><description><![CDATA[<p>Bitte antworte doch auch noch einmal auf Boost und das Thema zu groß. Würde mich jetzt sehr interessieren...</p>
<p>(Falls du es nicht merkst: Du wirst hier gerade in eine Falle gelockt. Wenn du hineinfällst, lernst du vielleicht etwas über Boost)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2176939</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2176939</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Sat, 04 Feb 2012 20:48:44 GMT</pubDate></item><item><title><![CDATA[Reply to String trimmed und split on Sat, 04 Feb 2012 20:57:00 GMT]]></title><description><![CDATA[<p>Ok, ich gebe zu noch nicht wirklich was mit Boost gemacht zu haben, und habe die Vorstellung das man die komplette Lib braucht bzw. mitliefern muss. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>Wahrscheinlich liege ich aber falsch, und es wird nur das benutzt was man braucht und man hat somit nicht die komplette Lib von z.B. 150MB dabei sondern nur 1MB?</p>
<p>Das ist wichtig weil eben auf einer DVD nur begrenzt Platz ist. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2176942</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2176942</guid><dc:creator><![CDATA[Cybertec]]></dc:creator><pubDate>Sat, 04 Feb 2012 20:57:00 GMT</pubDate></item><item><title><![CDATA[Reply to String trimmed und split on Sat, 04 Feb 2012 21:22:26 GMT]]></title><description><![CDATA[<p>Cybertec schrieb:</p>
<blockquote>
<p>Wahrscheinlich liege ich aber falsch, und es wird nur das benutzt was man braucht und man hat somit nicht die komplette Lib von z.B. 150MB dabei sondern nur 1MB?</p>
</blockquote>
<p>Nein, eher so 0. Boost ist größtenteils Header only. Also brauchst du ungefähr so viel Platz als wenn du die Funktion selbst geschrieben hättest.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2176955</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2176955</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Sat, 04 Feb 2012 21:22:26 GMT</pubDate></item><item><title><![CDATA[Reply to String trimmed und split on Sat, 04 Feb 2012 21:23:58 GMT]]></title><description><![CDATA[<p>Na gut, das war nur ein Beispiel mit den Zahlenwerten. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<p>Ok, dann kann ich ja beruhigt Boost benutzen bzw. mich erstmal einarbeiten.</p>
<p>Danke.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2176956</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2176956</guid><dc:creator><![CDATA[Cybertec]]></dc:creator><pubDate>Sat, 04 Feb 2012 21:23:58 GMT</pubDate></item><item><title><![CDATA[Reply to String trimmed und split on Sat, 04 Feb 2012 21:30:50 GMT]]></title><description><![CDATA[<p><a href="http://www.boost.org/doc/libs/1_49_0_beta1/doc/html/string_algo.html" rel="nofollow">http://www.boost.org/doc/libs/1_49_0_beta1/doc/html/string_algo.html</a></p>
<p>Zum Einstieg. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /><br />
Alles Header-only.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2176958</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2176958</guid><dc:creator><![CDATA[Ethon]]></dc:creator><pubDate>Sat, 04 Feb 2012 21:30:50 GMT</pubDate></item><item><title><![CDATA[Reply to String trimmed und split on Sat, 04 Feb 2012 21:33:38 GMT]]></title><description><![CDATA[<p>Danke für den Link, hatte das hier auch schon gefunden: <a href="http://www.boost.org/doc/libs/1_49_0_beta1/doc/html/string_algo/reference.html#header.boost.algorithm.string.split_hpp" rel="nofollow">http://www.boost.org/doc/libs/1_49_0_beta1/doc/html/string_algo/reference.html#header.boost.algorithm.string.split_hpp</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2176960</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2176960</guid><dc:creator><![CDATA[Cybertec]]></dc:creator><pubDate>Sat, 04 Feb 2012 21:33:38 GMT</pubDate></item><item><title><![CDATA[Reply to String trimmed und split on Sat, 04 Feb 2012 22:55:40 GMT]]></title><description><![CDATA[<p>Für sowas braucht man ne externe Lib? Vor allem da split ziemlich überdimensioniert ist, wenn man nur den ersten Teil haben will.</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
using namespace std;

string getFirstPart(const string&amp; input)
{
	static const char* whitespaces = &quot;\t\n\v\f\r &quot;;
	string::size_type begin = input.find_first_not_of(whitespaces);
	if(begin == string::npos)
		begin = 0;
	string result = input.substr(begin, input.find('#') - begin);
	string::size_type end = result.find_last_not_of(whitespaces);
	if(end != string::npos)
		result.erase(end + 1);
	return result;
}

int main()
{
    cout &lt;&lt; '&quot;' &lt;&lt; getFirstPart(&quot;&quot;) &lt;&lt; '&quot;' &lt;&lt; endl;
	cout &lt;&lt; '&quot;' &lt;&lt; getFirstPart(&quot;abc&quot;) &lt;&lt; '&quot;' &lt;&lt; endl;
	cout &lt;&lt; '&quot;' &lt;&lt; getFirstPart(&quot; a b c &quot;) &lt;&lt; '&quot;' &lt;&lt; endl;
	cout &lt;&lt; '&quot;' &lt;&lt; getFirstPart(&quot;#&quot;) &lt;&lt; '&quot;' &lt;&lt;  endl;
	cout &lt;&lt; '&quot;' &lt;&lt; getFirstPart(&quot; #abc&quot;) &lt;&lt; '&quot;' &lt;&lt; endl;
	cout &lt;&lt; '&quot;' &lt;&lt; getFirstPart(&quot; fo o #bar&quot;) &lt;&lt; '&quot;' &lt;&lt; endl;
	cout &lt;&lt; '&quot;' &lt;&lt; getFirstPart(&quot; fo o#bar&quot;) &lt;&lt; '&quot;' &lt;&lt; endl;
	cout &lt;&lt; '&quot;' &lt;&lt; getFirstPart(&quot;fo o#&quot;) &lt;&lt; '&quot;' &lt;&lt; endl;
	cout &lt;&lt; '&quot;' &lt;&lt; getFirstPart(&quot;fo o #bar&quot;) &lt;&lt; '&quot;' &lt;&lt; endl;
	cout &lt;&lt; '&quot;' &lt;&lt; getFirstPart(&quot;\rfoo\n#bar#baz&quot;) &lt;&lt; '&quot;' &lt;&lt; endl;
}
</code></pre>
<p><a href="http://ideone.com/XTakR" rel="nofollow">http://ideone.com/XTakR</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2176985</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2176985</guid><dc:creator><![CDATA[Michael E.]]></dc:creator><pubDate>Sat, 04 Feb 2012 22:55:40 GMT</pubDate></item><item><title><![CDATA[Reply to String trimmed und split on Sat, 04 Feb 2012 23:44:02 GMT]]></title><description><![CDATA[<p>Nein braucht man nicht, hatte es auch schon ohne Boost gemacht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2176996</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2176996</guid><dc:creator><![CDATA[Cybertec]]></dc:creator><pubDate>Sat, 04 Feb 2012 23:44:02 GMT</pubDate></item></channel></rss>