HDK
|
#include <UT_StringStream.h>
Public Member Functions | |
UT_StringStreamBuffer (std::ios_base::openmode mode=(std::ios_base::in|std::ios_base::out), const char *buf=nullptr, exint len=-1) | |
const char * | buffer () const |
exint | length () const |
int64 | getMemoryUsage (bool inclusive) const |
void | reset () |
const UT_WorkBuffer & | str () |
void | swap (UT_WorkBuffer &buf) |
void | stealIntoString (UT_String &s) |
void | stealIntoStringHolder (UT_StringHolder &s) |
An a string buffer based on UT_WorkBuffer. Supports both input and output. Provides cleaner semantics than UT_OStrStream, which is based on the obsolete std::strstream class. Unlike UT_OStrStream, it is not necessary to manage the stream's memory externally, if it was dynamically allocated, or add a null byte termination. For example, this code:
Turns into:
Note that the explicit requirement for null termination, and the call to freeze
to relinquish the buffer use, are both gone.
However, the downside is that you cannot pass explicit buffers to the stream. On the other hand, you should not be using fixed-sized buffers for output streams in the first place.
There's also support for input and input/output buffers, using UT_IStringStream and UT_StringStream. Class for the memory storage and stream buffering.
std::streambuf provides buffered reading and writing to an underlying stream. A UT_WorkBuffer is used for the underlying storage. Like a file, seeking past the end of the existing data is allowed.
The get buffer (reading) is defined by the eback(), gptr(), and egptr() pointers. These pointers are all nullptr iff the stream does not allow reading. myGPos >= 0 when seeked past the end of the existing data. In this situation, eback() == egptr() to prevent methods from pulling values from the get buffer.
The put buffer (writing) is defined by the pbase(), pptr(), and epptr() pointers. These pointers are all nullptr iff the stream does not allow writing. myPPos >= 0 when seeked past the end of the existing data. In this situation, pbase() == epptr() to prevent methods from putting values into the put buffer.
Definition at line 65 of file UT_StringStream.h.
|
inline |
Definition at line 24 of file UT_StringStreamImpl.h.
|
inline |
Definition at line 73 of file UT_StringStream.h.
|
inline |
Definition at line 76 of file UT_StringStream.h.
Definition at line 74 of file UT_StringStream.h.
Definition at line 59 of file UT_StringStreamImpl.h.
Definition at line 81 of file UT_StringStreamImpl.h.
|
inline |
Definition at line 89 of file UT_StringStreamImpl.h.
|
inline |
Definition at line 66 of file UT_StringStreamImpl.h.
|
inline |
Definition at line 73 of file UT_StringStreamImpl.h.