Similar to std::ostringstream, but with an externally managed output buffer which makes it most similar to std::ospanstream (C++23). More...
#include <OSpanStream.H>


Public Member Functions | |
| ospanstream () | |
| Default construct - empty. | |
| ospanstream (char *buffer, size_t nbytes) | |
| Construct for character array and number of bytes. | |
| std::streampos | output_pos () const |
| The current output position within the buffer (tellp). | |
| std::streamsize | count () const |
| The number of bytes outputted. | |
| std::streamsize | capacity () const |
| The put buffer capacity. | |
| void | rewind () |
| Rewind the stream, clearing any old errors. | |
| void | seek (std::streampos pos) |
| Reposition the stream from the start. | |
| auto | view () const |
| A string_view of buffer contents. | |
| auto | view (size_t pos, size_t len=std::string::npos) const |
| A sub-slice string view of the buffer contents. | |
| UList< char > | list () const |
| Span of the current output characters (is modifiable!). | |
| std::string | str () const |
| For ostringstream compatibility, return the buffer as string copy. | |
| void | reset (char *buffer, size_t nbytes) |
| Reset the put buffer area. | |
| void | reset (std::string &s) |
| Reset the put buffer area to use the data area from a string. | |
| void | debug_info (Ostream &os) const |
| Some information about the output buffer position/capacity. | |
| void | print (Ostream &os) const |
| Information about stream. | |
| void | overwrite (std::streampos pos, char c) |
| Overwrite a single character. | |
| void | overwrite (std::streampos pos, const char *data, std::streamsize count) |
| Overwrite a sub-slice with character content. | |
| const char * | cdata_bytes () const |
| The output data (start of output characters). | |
| char * | data_bytes () |
| The output data (start of output characters). | |
| std::streamsize | size_bytes () const |
| The current number of output characters. | |
Additional Inherited Members | |
| Protected Member Functions inherited from memorybuf::out_base | |
| virtual std::streamsize | xsputn (const char *s, std::streamsize n) |
| Put sequence of characters to a fixed region. | |
| out_base ()=default | |
| Default construct. | |
| out_base (char *s, std::streamsize n) | |
| Construct for character array (can be nullptr) and number of bytes. | |
| void | resetp (char *s, std::streamsize n) |
| Reset put buffer with character data (can be nullptr) and count. | |
| std::streamsize | span_tellp () const |
| The current buffer put position. | |
| std::streamsize | span_capacity () const |
| The put buffer capacity. | |
| char * | data_bytes () const |
| The span data (start of output characters). | |
| std::streamsize | size_bytes () const |
| The span size (size of output buffer). | |
| bool | in_range (std::streampos pos) const |
| True if position is within the current output range. | |
| auto | view () const |
| A string view of the current output region. | |
| auto | view (size_t pos, size_t len) const |
| A sub-slice string view of the current output region. | |
| void | pop_back (int n=1) |
| Decrease the put area by 1 or more elements. | |
| void | overwrite (std::streampos pos, const char *data, std::streamsize count) |
| Overwrite a sub-slice with character content. | |
| void | overwrite (std::streampos pos, char c) |
| Overwrite a single character. | |
| void | info (Ostream &os) const |
| Some information about the output buffer position/capacity. | |
| Protected Member Functions inherited from memorybuf | |
| virtual std::streampos | seekoff (std::streamoff off, std::ios_base::seekdir way, std::ios_base::openmode which=std::ios_base::in|std::ios_base::out) |
| Set position pointer to relative position. | |
| virtual std::streampos | seekpos (std::streampos pos, std::ios_base::openmode which=std::ios_base::in|std::ios_base::out) |
| Set position pointer to absolute position. | |
Similar to std::ostringstream, but with an externally managed output buffer which makes it most similar to std::ospanstream (C++23).
Definition at line 102 of file OSpanStream.H.
|
inline |
Default construct - empty.
Definition at line 118 of file OSpanStream.H.
|
inline |
Construct for character array and number of bytes.
Definition at line 127 of file OSpanStream.H.
|
inline |
The current output position within the buffer (tellp).
Definition at line 139 of file OSpanStream.H.
References memorybuf::out_base::span_tellp().
Referenced by debug_info().


|
inline |
The number of bytes outputted.
Definition at line 147 of file OSpanStream.H.
References memorybuf::out_base::size_bytes().
Referenced by overwrite().


|
inline |
The put buffer capacity.
Definition at line 155 of file OSpanStream.H.
References memorybuf::out_base::span_capacity().
Referenced by debug_info().


|
inline |
Rewind the stream, clearing any old errors.
Definition at line 163 of file OSpanStream.H.
|
inline |
Reposition the stream from the start.
Definition at line 172 of file OSpanStream.H.
References memorybuf::out_base::in_range(), and Foam::pos().

|
inline |
A string_view of buffer contents.
Definition at line 184 of file OSpanStream.H.
References memorybuf::out_base::view().

|
inline |
A sub-slice string view of the buffer contents.
Definition at line 189 of file OSpanStream.H.
References Foam::pos(), and memorybuf::out_base::view().

|
inline |
Span of the current output characters (is modifiable!).
Definition at line 197 of file OSpanStream.H.
References memorybuf::out_base::data_bytes(), and memorybuf::out_base::size_bytes().

|
inline |
For ostringstream compatibility, return the buffer as string copy.
Use sparingly - it creates a full copy!!
Definition at line 211 of file OSpanStream.H.
References memorybuf::out_base::data_bytes(), and memorybuf::out_base::size_bytes().

|
inline |
Reset the put buffer area.
Definition at line 223 of file OSpanStream.H.
References memorybuf::out_base::resetp().

|
inline |
Reset the put buffer area to use the data area from a string.
Definition at line 232 of file OSpanStream.H.
References memorybuf::out_base::resetp(), and s().

|
inline |
Some information about the output buffer position/capacity.
Definition at line 242 of file OSpanStream.H.
References capacity(), os(), and output_pos().
Referenced by print().


|
inline |
Information about stream.
Definition at line 250 of file OSpanStream.H.
References debug_info(), and os().

|
inline |
Overwrite a single character.
Definition at line 258 of file OSpanStream.H.
References memorybuf::out_base::overwrite(), and Foam::pos().

|
inline |
Overwrite a sub-slice with character content.
Definition at line 266 of file OSpanStream.H.
References count(), memorybuf::out_base::overwrite(), and Foam::pos().

|
inline |
The output data (start of output characters).
Definition at line 279 of file OSpanStream.H.
References memorybuf::out_base::data_bytes().

|
inline |
The output data (start of output characters).
Definition at line 284 of file OSpanStream.H.
References memorybuf::out_base::data_bytes().

|
inline |
The current number of output characters.
Definition at line 289 of file OSpanStream.H.
References memorybuf::out_base::size_bytes().
