Loading...
Searching...
No Matches
memorybuf::out_dynamic Class Reference

An output streambuf for memory access. More...

#include <memoryStreamBuffer.H>

Inheritance diagram for memorybuf::out_dynamic:
Collaboration diagram for memorybuf::out_dynamic:

Public Member Functions

 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().
Public Member Functions inherited from memorybuf::out_base
 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.

Static Public Member Functions

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.

Protected Member Functions

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.
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.

Detailed Description

An output streambuf for memory access.

Definition at line 608 of file memoryStreamBuffer.H.

Constructor & Destructor Documentation

◆ out_dynamic() [1/4]

out_dynamic ( )
inline

Default construct - no initial reserved number of bytes.

Definition at line 667 of file memoryStreamBuffer.H.

References sync_pbuffer().

Here is the call graph for this function:

◆ out_dynamic() [2/4]

out_dynamic ( size_t nbytes)
inline

Default construct with initial reserved number of bytes.

Definition at line 675 of file memoryStreamBuffer.H.

References sync_pbuffer().

Here is the call graph for this function:

◆ out_dynamic() [3/4]

out_dynamic ( ::Foam::List< char > && buffer)
inline

Move construct from List.

Definition at line 685 of file memoryStreamBuffer.H.

References sync_pbuffer().

Here is the call graph for this function:

◆ out_dynamic() [4/4]

template<int SizeMin>
out_dynamic ( ::Foam::DynamicList< char, SizeMin > && buffer)
inline

Move construct from DynamicList (uses entire capacity).

Definition at line 696 of file memoryStreamBuffer.H.

References sync_pbuffer().

Here is the call graph for this function:

Member Function Documentation

◆ overflow()

virtual int overflow ( int_type c = traits_type::eof())
inlineprotectedvirtual

Handle overflow.

Definition at line 628 of file memoryStreamBuffer.H.

References extend().

Here is the call graph for this function:

◆ xsputn()

virtual std::streamsize xsputn ( const char * s,
std::streamsize n )
inlineprotectedvirtual

Put sequence of characters.

Reimplemented from memorybuf::out_base.

Definition at line 644 of file memoryStreamBuffer.H.

References extend(), n, and s().

Here is the call graph for this function:

◆ min_size()

constexpr label min_size ( )
inlinestaticconstexprnoexcept

Normal lower capacity limit.

512 bytes is a bit arbitrary but consistent with std::stringstream

Definition at line 711 of file memoryStreamBuffer.H.

References Foam::noexcept.

Referenced by reserve().

Here is the caller graph for this function:

◆ max_size()

constexpr label max_size ( )
inlinestaticconstexprnoexcept

The largest storage size.

Definition at line 716 of file memoryStreamBuffer.H.

References UList< T >::max_size(), and Foam::noexcept.

Referenced by max_size_2(), and reserve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ max_size_2()

constexpr label max_size_2 ( )
inlinestaticconstexprnoexcept

The 1/2 of max_size() - rounded to power-of-two.

Definition at line 724 of file memoryStreamBuffer.H.

References max_size(), and Foam::noexcept.

Referenced by max_size_4(), and reserve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ max_size_4()

constexpr label max_size_4 ( )
inlinestaticconstexprnoexcept

The 1/4 of max_size() - rounded to power-of-two.

Definition at line 732 of file memoryStreamBuffer.H.

References max_size_2(), and Foam::noexcept.

Referenced by reserve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sync_pbuffer()

void sync_pbuffer ( )
inline

Sync put buffer pointers to agree with list dimensions.

Sets put pointer to the begin (rewind).

Definition at line 742 of file memoryStreamBuffer.H.

References memorybuf::out_base::resetp().

Referenced by clearStorage(), out_dynamic(), out_dynamic(), out_dynamic(), out_dynamic(), release(), reserve(), reserve_exact(), shrink_to_fit(), swap(), and swap().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reserve()

void reserve ( const std::streamsize len)
inline

Increase capacity (if needed) and adjust buffer pointers. Applies a min-size and capacity doubling.

Definition at line 751 of file memoryStreamBuffer.H.

References max_size(), max_size_2(), max_size_4(), min_size(), memorybuf::out_base::span_tellp(), and sync_pbuffer().

Referenced by extend(), and ocharstream::reserve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reserve_exact()

void reserve_exact ( const std::streamsize len)
inline

Increase capacity for at least this size. Does not apply min-size or capacity doubling etc.

Definition at line 809 of file memoryStreamBuffer.H.

References memorybuf::out_base::span_tellp(), and sync_pbuffer().

Referenced by extend_exact(), and ocharstream::reserve_exact().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ extend()

void extend ( std::streamsize count)
inline

Increase (reserve) space for another count entries.

Definition at line 824 of file memoryStreamBuffer.H.

References reserve(), and memorybuf::out_base::span_tellp().

Referenced by ocharstream::append(), ocharstream::append(), ocharstream::extend(), overflow(), and xsputn().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ extend_exact()

void extend_exact ( std::streamsize count)
inline

Increase (reserve) space for another count entries.

Definition at line 832 of file memoryStreamBuffer.H.

References reserve_exact(), and memorybuf::out_base::span_tellp().

Referenced by ocharstream::extend_exact().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clearStorage()

void clearStorage ( )
inline

Clear storage.

Definition at line 840 of file memoryStreamBuffer.H.

References sync_pbuffer().

Here is the call graph for this function:

◆ shrink_to_fit()

void shrink_to_fit ( )
inline

Shrink storage to addressed storage.

Definition at line 849 of file memoryStreamBuffer.H.

References memorybuf::out_base::span_tellp(), and sync_pbuffer().

Referenced by shrink().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ swap() [1/2]

void swap ( List< char > & other)
inline

Exchange buffer content and parameter contents, reset positions.

Definition at line 861 of file memoryStreamBuffer.H.

References List< T >::resize(), memorybuf::out_base::span_tellp(), UList< T >::swap(), and sync_pbuffer().

Referenced by ocharstream::swap(), and ocharstream::swap().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ swap() [2/2]

template<int SizeMin>
void swap ( DynamicList< char, SizeMin > & other)
inline

Exchange buffer content and parameter contents, reset positions.

Definition at line 873 of file memoryStreamBuffer.H.

References DynamicList< T, SizeMin >::capacity(), DynamicList< T, SizeMin >::resize(), memorybuf::out_base::span_tellp(), DynamicList< T, SizeMin >::swap(), and sync_pbuffer().

Here is the call graph for this function:

◆ release()

DynamicList< char > release ( )
inline

Reset buffer and return contents as a DynamicList. The list size corresponds to the region of output.

Definition at line 887 of file memoryStreamBuffer.H.

References DynamicList< T, SizeMin >::clearStorage(), UList< T >::empty(), DynamicList< T, SizeMin >::resize(), memorybuf::out_base::span_tellp(), and sync_pbuffer().

Referenced by ocharstream::release().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ shrink()

void shrink ( )
inline

Same as shrink_to_fit().

Definition at line 904 of file memoryStreamBuffer.H.

References shrink_to_fit().

Here is the call graph for this function:

The documentation for this class was generated from the following file: