<?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[sgetc sbumpc snextc und eof]]></title><description><![CDATA[<p>hola leute</p>
<p>wenn ich z.b. mit snextc nen character hole und ich eof bekomme, muss ich dann von hand das eofbit im istream setzen oder wird das vom streambuf uebernommen ?</p>
<p>Meep Meep</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/311105/sgetc-sbumpc-snextc-und-eof</link><generator>RSS for Node</generator><lastBuildDate>Tue, 04 Aug 2026 00:32:58 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/311105.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 27 Nov 2012 09:47:40 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to sgetc sbumpc snextc und eof on Tue, 27 Nov 2012 09:47:40 GMT]]></title><description><![CDATA[<p>hola leute</p>
<p>wenn ich z.b. mit snextc nen character hole und ich eof bekomme, muss ich dann von hand das eofbit im istream setzen oder wird das vom streambuf uebernommen ?</p>
<p>Meep Meep</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2275027</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2275027</guid><dc:creator><![CDATA[Meep Meep]]></dc:creator><pubDate>Tue, 27 Nov 2012 09:47:40 GMT</pubDate></item><item><title><![CDATA[Reply to sgetc sbumpc snextc und eof on Tue, 27 Nov 2012 10:58:34 GMT]]></title><description><![CDATA[<p>Meep Meep schrieb:</p>
<blockquote>
<p>wenn ich z.b. mit snextc nen character hole und ich eof bekomme, muss ich dann von hand das eofbit im istream setzen oder wird das vom streambuf uebernommen ?</p>
</blockquote>
<p>Ja - Du musst selbst das eofbit setzen, und ggf. das badbit, falls der streambuf eine Exception wirft. Der streambuf selbst kann das gar nicht, da es keine Verbindung vom streambuf-Objekt zum Stream-Objekt gibt. Die Assoziation ist immer umgekehrt, Stream-&gt;streambuf.</p>
<p>Das failbit setzt Du beim lesenden Stream genau dann, wenn das was da gelesen werden soll, aus Format-Gründen nicht geht oder dem zu lesenden Objekt nicht zugeordnet werden kann. Beispiel: Du möchtest eine Zahl bestehend aus Ziffern lesen, aber findest als erstes Zeichen einen Buchstaben vor.</p>
<p>Gruß<br />
Werner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2275062</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2275062</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Tue, 27 Nov 2012 10:58:34 GMT</pubDate></item><item><title><![CDATA[Reply to sgetc sbumpc snextc und eof on Tue, 27 Nov 2012 14:12:07 GMT]]></title><description><![CDATA[<p>danke mal fuer die antwort.<br />
welche exception sollte vom streambuf geworfen werden ?</p>
<p>Meep Meep</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2275129</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2275129</guid><dc:creator><![CDATA[Meep Meep]]></dc:creator><pubDate>Tue, 27 Nov 2012 14:12:07 GMT</pubDate></item><item><title><![CDATA[Reply to sgetc sbumpc snextc und eof on Tue, 27 Nov 2012 16:38:08 GMT]]></title><description><![CDATA[<p>Hier ist ein Beispiel von Werner, vielleicht hilft Dir das: <a href="http://www.c-plusplus.net/forum/p2267197#2267197" rel="nofollow">http://www.c-plusplus.net/forum/p2267197#2267197</a></p>
<p>Vielleicht überwältigt es Dich auch, aber was soll's.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2275210</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2275210</guid><dc:creator><![CDATA[Eisflamme]]></dc:creator><pubDate>Tue, 27 Nov 2012 16:38:08 GMT</pubDate></item><item><title><![CDATA[Reply to sgetc sbumpc snextc und eof on Tue, 27 Nov 2012 21:20:01 GMT]]></title><description><![CDATA[<p>Meep Meep schrieb:</p>
<blockquote>
<p>welche exception sollte vom streambuf geworfen werden ?</p>
</blockquote>
<p>Jede erdenkliche. Ein std::streambuf ist nur eine Schnittstelle mit ein wenig Basisfunktionalität.</p>
<p>Dahinter kann sich irgendein Zeichen lieferndes (oder konsumierendes) Objekt (bzw. Device) befinden, die mit allen möglichen Problemen konfrontiert werden kann. CDs die unterm Lesen ausfahren, ein Netzwerk, bei dem der Stecker gezogen wird oder ein Treiber, der einfach seinen Dienst aufgibt. In jedem Fall kann (muss nicht) eine Exception geworfen werden.</p>
<p>Gruß<br />
Werner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2275292</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2275292</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Tue, 27 Nov 2012 21:20:01 GMT</pubDate></item><item><title><![CDATA[Reply to sgetc sbumpc snextc und eof on Wed, 28 Nov 2012 10:18:05 GMT]]></title><description><![CDATA[<p>hola</p>
<p>waere das ein eine korrekte implementierung die alles abdeckt ?<br />
(nein ich erfinde das rad nicht neu, ist nur zur uebung)</p>
<pre><code>template&lt;class CHAR&gt;
inline bool read_line(txl::istream_iterator&lt;CHAR&gt; &amp;iter, const txl::istream_iterator&lt;CHAR&gt; &amp;end, std::basic_string&lt;CHAR&gt; &amp;str, const CHAR c = '\n')
{
   while(iter != end &amp;&amp; *iter != c)
   {
      str.append(1, *iter);
      ++iter;
   }
   if(iter != end)
      ++iter;

   return iter != end;
}

template&lt;class CHAR&gt;
inline std::basic_istream&lt;CHAR&gt;&amp; read_line(std::basic_istream&lt;CHAR&gt; &amp;is, std::basic_string&lt;CHAR&gt; &amp;str, const CHAR c = '\n')
{
   if(!is.good())
      return is;

   txl::istream_iterator&lt;CHAR&gt; iter(is), end;
   try
   {
      if(read_line(iter,end, str, c) == false)
      {
         is.setstate(std::ios_base::eofbit);
      }
   }
   catch(...)
   {
      if(is.exceptions() &amp; std::ios_base::badbit)
         throw;
      else
         is.setstate(std::ios_base::badbit);
   }

   return is;
}
</code></pre>
<p>Meep Meep</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2275396</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2275396</guid><dc:creator><![CDATA[Meep Meep]]></dc:creator><pubDate>Wed, 28 Nov 2012 10:18:05 GMT</pubDate></item><item><title><![CDATA[Reply to sgetc sbumpc snextc und eof on Wed, 28 Nov 2012 12:27:41 GMT]]></title><description><![CDATA[<p>Meep Meep schrieb:</p>
<blockquote>
<p>waere das ein eine korrekte implementierung die alles abdeckt ?</p>
</blockquote>
<p>Hallo Meep Meep,</p>
<p>Um kurz zu antworten - nein.<br />
Schau Dir mal <a href="http://www.c-plusplus.net/forum/p2256837#2256837" rel="nofollow">diesen Thread</a> an, wo ich mich zum Lesen auf Streambuf-Ebene auslasse.</p>
<p>Die wichtigsten Dinge sind: es fehlt das <a href="http://www.cplusplus.com/reference/istream/istream/sentry/" rel="nofollow">sentry-Objekt</a> und Du solltest nicht innerhalb des try-catch-Blocks <a href="http://en.cppreference.com/w/cpp/io/basic_ios/setstate" rel="nofollow">setstate</a> aufrufen, weil das könnte wieder eine Exception werfen.</p>
<p>Gruß<br />
Werner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2275438</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2275438</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Wed, 28 Nov 2012 12:27:41 GMT</pubDate></item></channel></rss>