cplusplus.com cplusplus.com
cplusplus.com   C++ : Reference : IOstream Library : stringbuf
- -
C++
Information
Documentation
Reference
Articles
Sourcecode
Forum
Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
IOstream Library
manipulators
classes:
· filebuf
· fstream
· ifstream
· ios
· iostream
· ios_base
· istream
· istringstream
· ofstream
· ostream
· ostringstream
· streambuf
· stringbuf
· stringstream
objects:
· cerr
· cin
· clog
· cout
types:
· fpos
· streamoff
· streampos
· streamsize
stringbuf
· stringbuf::stringbuf
public members:
· stringbuf::str
virtual members:
· stringbuf::overflow
· stringbuf::pbackfail
· stringbuf::seekoff
· stringbuf::seekpos
· stringbuf::setbuf
· stringbuf::underflow

-

stringbuf class
<sstream>

String stream buffer

Class hierarchy:

stringbuf

This class applies the functionality of the streambuf class to read and write from/to standard string objects.

Either on construction or by calling member str, the content of a string object is copied into the associated character sequence. Input/Output operations are conducted with a streambuf-compatible interface on this internal copy of the string, not on the original string object with which the object was initialized (if any).

The content of the internal string can be retrieved by calling member str.

Internally, stringbuf objects operate as defined in the streambuf class (see streambuf), with the particularity that the entire content of the string is used as both the controlled input sequence and the controlled output sequence, and made available on its entirety through the internal pointers.

The class overrides some virtual members inherited from streambuf to provide this specific functionality for strings.

Public members

(constructor) Construct a string stream buffer object (constructor member)
str Get/set the string content (public member function)

Public members inherited from streambuf:

getloc Get current locale (public member function)
in_avail Get number of characters available to read (public member function)
pubimbue Imbue locale (public member function)
pubseekoff Set internal position pointer to relative position (public member function)
pubseekpos Set internal position pointer to absolute position (public member function)
pubsetbuf Set buffer array (public member function)
pubsync Synchronize stream buffer (public member function)
sbumpc Get current character and increase get pointer (public member function)
sgetc Get current character (public member function)
sgetn Get sequence of characters (public member function)
snextc Increase get pointer and return next character (public member function)
sputbackc Put character back (public member function)
sputc Store character at current put position and increase put pointer (public member function)
sputn Write a sequence of characters (public member function)

Virtual protected members

The parent class streambuf defines several protected virtual functions that are called by the other member functions to perform the operations on the associated character sequence. Derived classes override these virtual member functions as necessary to provide the functionality for their specific types of buffer. stringbuf overrides the following:

setbuf Set buffer (virtual protected member function)
seekoff Set internal position pointer to relative position (virtual protected member function)
seekpos Set internal position pointer to absolute position (virtual protected member function)
underflow Get character (virtual protected member function)
pbackfail Put character back (virtual protected member function)
overflow Write character (virtual protected member function)

The remaining virtual protectected members are left with their by-default behavior defined in streambuf.

Protected members

The class also inherits several non-virtual protected members used by the public functions to access the internal pointers. See streambuf for more info.

© The C++ Resources Network, 2000-2007 - All rights reserved
Spotted an error? - contact us