Similar to std::ostringstream, but with the ability to swap character content. Has some similarity to std::ospanstream (C++23). More...
#include <OCharStream.H>


Public Member Functions | |
| ocharstream () | |
| Default construct - empty. | |
| ocharstream (List< char > &&buffer) | |
| Move construct from List. | |
| template<int SizeMin> | |
| ocharstream (DynamicList< char, SizeMin > &&buffer) | |
| Move construct from DynamicList. | |
| 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 | reserve (std::streamsize n) |
| Reserve output space for at least this amount. Applies a min-size and capacity doubling. | |
| void | reserve_exact (std::streamsize n) |
| Reserve output space for at least this amount. Does not apply min-size or capacity doubling etc. | |
| void | extend (std::streamsize count) |
Increase (reserve) space for another count entries. | |
| void | extend_exact (std::streamsize count) |
Increase (reserve) space for another count entries. | |
| 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 |
| A list span of current output contents (is modifiable!!). | |
| std::string | str () const |
| For ostringstream compatibility, return the buffer as string copy. | |
| void | swap (List< char > &other) |
| Exchange stream content and parameter contents, reset positions. | |
| template<int SizeMin> | |
| void | swap (DynamicList< char, SizeMin > &other) |
| Exchange stream content and parameter contents, reset positions. | |
| DynamicList< char > | release () |
| Reset buffer and return contents. | |
| void | debug_info (Ostream &os) const |
| Some information about the output buffer position/capacity. | |
| void | print (Ostream &os) const |
| Information about stream. | |
| void | push_back (char c) |
| Append a single character to the end. | |
| void | pop_back (int n=1) |
| Rewind the end by 1 or more elements. | |
| void | append (std::streamsize count, char c) |
| Append repeated character content. | |
| void | append (const char *data, std::streamsize count) |
| Append character content - like a plain write(). | |
| 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_dynamic | |
| virtual int | overflow (int_type c=traits_type::eof()) |
| Handle overflow. | |
| virtual std::streamsize | xsputn (const char *s, std::streamsize n) |
| Put sequence of characters. | |
| out_dynamic () | |
| Default construct - no initial reserved number of bytes. | |
| out_dynamic (size_t nbytes) | |
| Default construct with initial reserved number of bytes. | |
| out_dynamic (::Foam::List< char > &&buffer) | |
| Move construct from List. | |
| template<int SizeMin> | |
| out_dynamic (::Foam::DynamicList< char, SizeMin > &&buffer) | |
| Move construct from DynamicList (uses entire capacity). | |
| void | sync_pbuffer () |
| Sync put buffer pointers to agree with list dimensions. | |
| void | reserve (const std::streamsize len) |
| Increase capacity (if needed) and adjust buffer pointers. Applies a min-size and capacity doubling. | |
| void | reserve_exact (const std::streamsize len) |
| Increase capacity for at least this size. Does not apply min-size or capacity doubling etc. | |
| void | extend (std::streamsize count) |
Increase (reserve) space for another count entries. | |
| void | extend_exact (std::streamsize count) |
Increase (reserve) space for another count entries. | |
| void | clearStorage () |
| Clear storage. | |
| void | shrink_to_fit () |
| Shrink storage to addressed storage. | |
| void | swap (List< char > &other) |
| Exchange buffer content and parameter contents, reset positions. | |
| template<int SizeMin> | |
| void | swap (DynamicList< char, SizeMin > &other) |
| Exchange buffer content and parameter contents, reset positions. | |
| DynamicList< char > | release () |
| Reset buffer and return contents as a DynamicList. The list size corresponds to the region of output. | |
| void | shrink () |
| Same as shrink_to_fit(). | |
| 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. | |
| Static Protected Member Functions inherited from memorybuf::out_dynamic | |
| static constexpr label | min_size () noexcept |
| Normal lower capacity limit. | |
| static constexpr label | max_size () noexcept |
| The largest storage size. | |
| static constexpr label | max_size_2 () noexcept |
| The 1/2 of max_size() - rounded to power-of-two. | |
| static constexpr label | max_size_4 () noexcept |
| The 1/4 of max_size() - rounded to power-of-two. | |
Similar to std::ostringstream, but with the ability to swap character content. Has some similarity to std::ospanstream (C++23).
Definition at line 63 of file OCharStream.H.
|
inline |
Default construct - empty.
Definition at line 79 of file OCharStream.H.
Referenced by ocharstream(), and ocharstream().

|
inline |
Move construct from List.
Definition at line 88 of file OCharStream.H.
References ocharstream(), and swap().

|
inline |
Move construct from DynamicList.
Definition at line 99 of file OCharStream.H.
References ocharstream(), and swap().

|
inline |
The current output position within the buffer (tellp).
Definition at line 112 of file OCharStream.H.
References memorybuf::out_base::span_tellp().
Referenced by debug_info().


|
inline |
The number of bytes outputted.
Definition at line 120 of file OCharStream.H.
References memorybuf::out_base::size_bytes().
Referenced by append(), append(), extend(), extend_exact(), and overwrite().


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


|
inline |
Reserve output space for at least this amount. Applies a min-size and capacity doubling.
Definition at line 137 of file OCharStream.H.
References n, and memorybuf::out_dynamic::reserve().

|
inline |
Reserve output space for at least this amount. Does not apply min-size or capacity doubling etc.
Definition at line 146 of file OCharStream.H.
References n, and memorybuf::out_dynamic::reserve_exact().

|
inline |
Increase (reserve) space for another count entries.
Definition at line 154 of file OCharStream.H.
References count(), and memorybuf::out_dynamic::extend().

|
inline |
Increase (reserve) space for another count entries.
Definition at line 162 of file OCharStream.H.
References count(), and memorybuf::out_dynamic::extend_exact().

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

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

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

|
inline |
A list span of current output contents (is modifiable!!).
Definition at line 204 of file OCharStream.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 218 of file OCharStream.H.
References memorybuf::out_base::data_bytes(), and memorybuf::out_base::size_bytes().

|
inline |
Exchange stream content and parameter contents, reset positions.
Definition at line 230 of file OCharStream.H.
References memorybuf::out_dynamic::swap().
Referenced by ocharstream(), and ocharstream().


|
inline |
Exchange stream content and parameter contents, reset positions.
Definition at line 240 of file OCharStream.H.
References memorybuf::out_dynamic::swap().

|
inline |
Reset buffer and return contents.
Definition at line 249 of file OCharStream.H.
References memorybuf::out_dynamic::release().

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


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

|
inline |
Append a single character to the end.
Definition at line 275 of file OCharStream.H.
|
inline |
Rewind the end by 1 or more elements.
Definition at line 280 of file OCharStream.H.
References n, and memorybuf::out_base::pop_back().

|
inline |
Append repeated character content.
Definition at line 285 of file OCharStream.H.
References count(), and memorybuf::out_dynamic::extend().

|
inline |
Append character content - like a plain write().
Definition at line 300 of file OCharStream.H.
References count(), memorybuf::out_dynamic::extend(), and write().

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

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

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

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

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