<?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[Iterator: Peek-Funktion?]]></title><description><![CDATA[<p>Sorry für den Titel wusste es nicht anders zu beschreiben.<br />
Kann man bei einem Iterator sehen was an nächster Stelle kommt ohne ihn zu kopieren?<br />
Grund ist, dass ich eine Liste übergeben bekomme, welche Felder zu einer SQL-Tabelle enthält. Und beim letzten Parameter bevor it == list.end() ist, muss ich das komma weglassen.<br />
Jetzt könnte ich den iterator jede Schleife kopieren und inkrementieren und kucken wo er hinzeigt. Aber das scheint mir nicht so ganz perfekt zu sein.</p>
<pre><code class="language-cpp">int NLSqlite::createTable( const std::string&amp; name, const NLSQLTableDescriptor::TTableList&amp; lst )
{
	if (m_db != NULL)
	{
		int result = 0;
		char* err = NULL;
		std::stringstream sql;
		sql &lt;&lt; &quot;create table &quot; &lt;&lt; name &lt;&lt; &quot; (&quot;;

		NLSQLTableDescriptor::TTableList::const_iterator it = lst.begin();
		for ( it; it != lst.end(); it++ )
		{
			const NLSQLTableDescriptor&amp; field = *it;
			sql &lt;&lt; field.getName() &lt;&lt; &quot; &quot; &lt;&lt; getFieldDescriptionByType(field.getType());
			sql &lt;&lt; &quot;, &quot;;
		}
		sql &lt;&lt; &quot;);&quot;;
		result = sqlite3_exec(m_db, sql.str().c_str(), sqlite_callback, this, &amp;err);
		if ( result != SQLITE_OK )
		{
			NLError(&quot;[NLSqlite] Unable to create table '&quot; + name + std::string(&quot;'. Message from SQLite3: '&quot;) + err + std::string(&quot;'.&quot;));
			NLError(&quot;[NLSqlite] SQL-String was: &quot; + sql.str());
		}	
		sqlite3_free(err);
		return result;
	}
	NLError(&quot;[NLSqlite] Cannot create a table with no database opened.&quot;);
	return -1;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/283402/iterator-peek-funktion</link><generator>RSS for Node</generator><lastBuildDate>Sat, 22 Aug 2026 15:59:16 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/283402.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 11 Mar 2011 07:47:33 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Iterator: Peek-Funktion? on Fri, 11 Mar 2011 07:47:33 GMT]]></title><description><![CDATA[<p>Sorry für den Titel wusste es nicht anders zu beschreiben.<br />
Kann man bei einem Iterator sehen was an nächster Stelle kommt ohne ihn zu kopieren?<br />
Grund ist, dass ich eine Liste übergeben bekomme, welche Felder zu einer SQL-Tabelle enthält. Und beim letzten Parameter bevor it == list.end() ist, muss ich das komma weglassen.<br />
Jetzt könnte ich den iterator jede Schleife kopieren und inkrementieren und kucken wo er hinzeigt. Aber das scheint mir nicht so ganz perfekt zu sein.</p>
<pre><code class="language-cpp">int NLSqlite::createTable( const std::string&amp; name, const NLSQLTableDescriptor::TTableList&amp; lst )
{
	if (m_db != NULL)
	{
		int result = 0;
		char* err = NULL;
		std::stringstream sql;
		sql &lt;&lt; &quot;create table &quot; &lt;&lt; name &lt;&lt; &quot; (&quot;;

		NLSQLTableDescriptor::TTableList::const_iterator it = lst.begin();
		for ( it; it != lst.end(); it++ )
		{
			const NLSQLTableDescriptor&amp; field = *it;
			sql &lt;&lt; field.getName() &lt;&lt; &quot; &quot; &lt;&lt; getFieldDescriptionByType(field.getType());
			sql &lt;&lt; &quot;, &quot;;
		}
		sql &lt;&lt; &quot;);&quot;;
		result = sqlite3_exec(m_db, sql.str().c_str(), sqlite_callback, this, &amp;err);
		if ( result != SQLITE_OK )
		{
			NLError(&quot;[NLSqlite] Unable to create table '&quot; + name + std::string(&quot;'. Message from SQLite3: '&quot;) + err + std::string(&quot;'.&quot;));
			NLError(&quot;[NLSqlite] SQL-String was: &quot; + sql.str());
		}	
		sqlite3_free(err);
		return result;
	}
	NLError(&quot;[NLSqlite] Cannot create a table with no database opened.&quot;);
	return -1;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2032572</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2032572</guid><dc:creator><![CDATA[[[global:former_user]]]]></dc:creator><pubDate>Fri, 11 Mar 2011 07:47:33 GMT</pubDate></item><item><title><![CDATA[Reply to Iterator: Peek-Funktion? on Fri, 11 Mar 2011 08:04:09 GMT]]></title><description><![CDATA[<p>Du kannst auch ab den zweiten Schleifendurchlauf vor <code>ql &lt;&lt; field.getName() &lt;&lt; &quot; &quot; &lt;&lt; getFieldDescriptionByType(field.getType());</code> ein Komma setzen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2032580</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2032580</guid><dc:creator><![CDATA[Rhombicosidodecahedron]]></dc:creator><pubDate>Fri, 11 Mar 2011 08:04:09 GMT</pubDate></item><item><title><![CDATA[Reply to Iterator: Peek-Funktion? on Fri, 11 Mar 2011 08:10:04 GMT]]></title><description><![CDATA[<p>Rhombicosidodecahedron schrieb:</p>
<blockquote>
<p>Du kannst auch ab den zweiten Schleifendurchlauf vor <code>ql &lt;&lt; field.getName() &lt;&lt; &quot; &quot; &lt;&lt; getFieldDescriptionByType(field.getType());</code> ein Komma setzen.</p>
</blockquote>
<p>Hmpf, daran habe ich natürlich nicht gedacht. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f576.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--sunglasses"
      title=":sunglasses:"
      alt="🕶"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
<pre><code class="language-cpp">int NLSqlite::createTable( const std::string&amp; name, const NLSQLTableDescriptor::TTableList&amp; lst )
{
	if (m_db != NULL)
	{
		int result = 0;
		char* err = NULL;
		std::stringstream sql;
		sql &lt;&lt; &quot;create table &quot; &lt;&lt; name &lt;&lt; &quot; (&quot;;

		NLSQLTableDescriptor::TTableList::const_iterator it = lst.begin();
		for ( it; it != lst.end(); it++ )
		{
			if ( it != lst.begin() )
			{
				sql &lt;&lt; &quot;, &quot;;
			}	

			const NLSQLTableDescriptor&amp; field = *it;
			sql &lt;&lt; field.getName() &lt;&lt; &quot; &quot; &lt;&lt; getFieldDescriptionByType(field.getType());				
		}		
		sql &lt;&lt; &quot;);&quot;;
		result = sqlite3_exec(m_db, sql.str().c_str(), sqlite_callback, this, &amp;err);
		if ( result != SQLITE_OK )
		{
			NLError(&quot;[NLSqlite] Unable to create table '&quot; + name + std::string(&quot;'. Message from SQLite3: '&quot;) + err + std::string(&quot;'.&quot;));
			NLError(&quot;[NLSqlite] SQL-String was: &quot; + sql.str());
		}	
		sqlite3_free(err);
		return result;
	}
	NLError(&quot;[NLSqlite] Cannot create a table with no database opened.&quot;);
	return -1;
}
</code></pre>
<p>Danke :).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2032583</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2032583</guid><dc:creator><![CDATA[[[global:former_user]]]]></dc:creator><pubDate>Fri, 11 Mar 2011 08:10:04 GMT</pubDate></item><item><title><![CDATA[Reply to Iterator: Peek-Funktion? on Fri, 11 Mar 2011 08:10:08 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">if((it + 1) == v.end())
</code></pre>
<p>ist das nächste Element das ende?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2032584</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2032584</guid><dc:creator><![CDATA[HighLigerBiMBam]]></dc:creator><pubDate>Fri, 11 Mar 2011 08:10:08 GMT</pubDate></item><item><title><![CDATA[Reply to Iterator: Peek-Funktion? on Fri, 11 Mar 2011 08:34:58 GMT]]></title><description><![CDATA[<p>HighLigerBiMBam schrieb:</p>
<blockquote>
<pre><code class="language-cpp">if((it + 1) == v.end())
</code></pre>
<p>ist das nächste Element das ende?</p>
</blockquote>
<p>Okay, so einfach.. manchmal vergesse ich die einfachsten Dinge. Schäme mich jetzt schon fast. :D.<br />
Aber danke.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2032597</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2032597</guid><dc:creator><![CDATA[[[global:former_user]]]]></dc:creator><pubDate>Fri, 11 Mar 2011 08:34:58 GMT</pubDate></item><item><title><![CDATA[Reply to Iterator: Peek-Funktion? on Fri, 11 Mar 2011 09:52:49 GMT]]></title><description><![CDATA[<p>Seit wann hat ein list-iterator einen operator + ? Oder ist das doch keine Liste?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2032625</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2032625</guid><dc:creator><![CDATA[314159265358979]]></dc:creator><pubDate>Fri, 11 Mar 2011 09:52:49 GMT</pubDate></item><item><title><![CDATA[Reply to Iterator: Peek-Funktion? on Fri, 11 Mar 2011 09:58:02 GMT]]></title><description><![CDATA[<p>Nur Random-Access-Iteratoren haben einen + Operator. Es gibt noch die Funktion advance, die einen Iterator n-mal inkrementieren kann, die wäre eventuell geeignet. Aber sie kopiert letztlich den Iterator auch bloß, und das schien ja nicht die bevorzugte Lösung zu sein. Und bei Input-Iteratoren funktioniert es auch nicht. Ich könnte mir vorstellen, dass man im Datenbankumfeld öfters mal mit Input/Output-Iteratoren zu tun hat.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2032630</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2032630</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Fri, 11 Mar 2011 09:58:02 GMT</pubDate></item><item><title><![CDATA[Reply to Iterator: Peek-Funktion? on Fri, 11 Mar 2011 10:03:03 GMT]]></title><description><![CDATA[<p>Ich weiß das alles. Weiters kopiert advance den Iterator nicht. <a href="http://www.cplusplus.com/reference/std/iterator/advance/" rel="nofollow">http://www.cplusplus.com/reference/std/iterator/advance/</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2032636</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2032636</guid><dc:creator><![CDATA[314159265358979]]></dc:creator><pubDate>Fri, 11 Mar 2011 10:03:03 GMT</pubDate></item><item><title><![CDATA[Reply to Iterator: Peek-Funktion? on Fri, 11 Mar 2011 10:04:46 GMT]]></title><description><![CDATA[<p>314159265358979 schrieb:</p>
<blockquote>
<p>Seit wann hat ein list-iterator einen operator + ? Oder ist das doch keine Liste?</p>
</blockquote>
<p>Blöde Sache habe ich nicht drauf geachtet, dass list nur einen Bidirektionalen-Iterator hat...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2032637</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2032637</guid><dc:creator><![CDATA[HighLigerBiMBam]]></dc:creator><pubDate>Fri, 11 Mar 2011 10:04:46 GMT</pubDate></item><item><title><![CDATA[Reply to Iterator: Peek-Funktion? on Fri, 11 Mar 2011 10:09:47 GMT]]></title><description><![CDATA[<p>314159265358979 schrieb:</p>
<blockquote>
<p>Ich weiß das alles.</p>
</blockquote>
<p>Ich wollte dich nicht belehren. Mein Posting war überhaupt nicht an dich gerichtet.</p>
<blockquote>
<p>Weiters kopiert advance den Iterator nicht.</p>
</blockquote>
<p>OK. Dann muss man halt selbst kopieren, in jedem Fall löst es das Problem nicht wirklich. Allerdings kommt man um das Kopieren so oder so nicht herum, <code>it+1</code> ist ja auch nur eine Kopie...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2032642</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2032642</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Fri, 11 Mar 2011 10:09:47 GMT</pubDate></item><item><title><![CDATA[Reply to Iterator: Peek-Funktion? on Fri, 11 Mar 2011 10:13:33 GMT]]></title><description><![CDATA[<p>Ich hab den Ansatz von Rhombicosidodecahedron genommen. Der ist der einfachste.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2032645</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2032645</guid><dc:creator><![CDATA[[[global:former_user]]]]></dc:creator><pubDate>Fri, 11 Mar 2011 10:13:33 GMT</pubDate></item></channel></rss>