Jump to content
  • Advertisement
Sign in to follow this  
renqilin

understanding std::streambuf

This topic is 4898 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i'm in a puzzle about std::streambuf. 1. what is streambuf::putback? and when it excute? 2. for the member function streambuf::overflow(int_type c), in case of (c == char_traits::eof()), what should happen? is there anyone can help me?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by renqilin
i'm in a puzzle about std::streambuf.

1. what is streambuf::putback? and when it excute?


well first off all its std::basic_streambuf, second there isn't a member function called "putback" how-ever there is a member function called "sputbackc" which pushes characters back into the input stream and its not virtual so its not mean't to be overridden, its envoked in streams.

Quote:
Original post by renqilin
2. for the member function streambuf::overflow(int_type c), in case of (c == char_traits::eof()), what should happen?


Well in std::basic_streambuf its a virtual member function that does usually nothing but return traits::eof() its mean't to be overriden by sub-types of basic_streambuf.

Quote:
Original post by renqilin
in case of (c == char_traits::eof()), what should happen?


it must transfer characters contained in the internal buffer to the external device and most likely return "my_char_traits::not_eof(c);" to indicate everything went okay. Now this depends on weather your doing buffered character transportation or not, if not you can just return "my_char_traits::not_eof(c)".

I recommend getting this book Standard C++ IOStreams and Locales: Advanced Programmer's Guide and Reference

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!