memorybuf::out_dynamic Class Reference

An output streambuf for memory access. More...

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

Public Member Functions

 out_dynamic (size_t nbytes=512)
 Default construct with initial reserved number of bytes. More...
 
 out_dynamic (::Foam::List< char > &&buffer)
 Move construct from List. More...
 
template<int SizeMin>
 out_dynamic (::Foam::DynamicList< char, SizeMin > &&buffer)
 Move construct from DynamicList (uses entire capacity) More...
 
void reserve (const std::streamsize len)
 Increment capacity (if needed) and adjust buffer pointers. More...
 
void sync_pbuffer ()
 Sync put buffer pointers to agree with list dimensions. More...
 
void clearStorage ()
 Clear storage. More...
 
void shrink ()
 Shrink storage to addressed storage. More...
 
void swap (List< char > &other)
 Exchange buffer content and parameter contents, reset positions. More...
 
template<int SizeMin>
void swap (DynamicList< char, SizeMin > &other)
 Exchange buffer content and parameter contents, reset positions. More...
 
DynamicList< char > release ()
 Reset buffer and return contents as a DynamicList. The list size corresponds to the region of output. More...
 
- Public Member Functions inherited from memorybuf::out_base
 out_base ()=default
 Default construct. More...
 
 out_base (char *s, std::streamsize n)
 Construct for character array (can be nullptr) and number of bytes. More...
 
void resetp (char *s, std::streamsize n)
 Reset put buffer with character data (can be nullptr) and count. More...
 
std::streamsize span_tellp () const
 The current buffer put position. More...
 
std::streamsize span_capacity () const
 The put buffer capacity. More...
 
char * data_bytes () const
 The span data (start of output characters) More...
 
std::streamsize size_bytes () const
 The span size (size of output buffer) More...
 
stdFoam::span< const char > view () const
 
void info (Ostream &os) const
 Some information about the output buffer position/capacity. More...
 

Protected Member Functions

virtual int overflow (int_type c=traits_type::eof())
 Handle overflow. More...
 
virtual std::streamsize xsputn (const char *s, std::streamsize n)
 Put sequence of characters. More...
 
- 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. More...
 
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. More...
 

Detailed Description

An output streambuf for memory access.

Definition at line 499 of file memoryStreamBuffer.H.

Constructor & Destructor Documentation

◆ out_dynamic() [1/3]

out_dynamic ( size_t  nbytes = 512)
inline

Default construct with initial reserved number of bytes.

The value of 512 is a bit arbitrary, but consistent with std::stringstream

Definition at line 561 of file memoryStreamBuffer.H.

References memorybuf::out_dynamic::sync_pbuffer().

Here is the call graph for this function:

◆ out_dynamic() [2/3]

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

Move construct from List.

Definition at line 571 of file memoryStreamBuffer.H.

References memorybuf::out_dynamic::sync_pbuffer().

Here is the call graph for this function:

◆ out_dynamic() [3/3]

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

Move construct from DynamicList (uses entire capacity)

Definition at line 582 of file memoryStreamBuffer.H.

References memorybuf::out_dynamic::sync_pbuffer(), and List< T >::transfer().

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 519 of file memoryStreamBuffer.H.

References Foam::constant::universal::c, memorybuf::out_dynamic::reserve(), and memorybuf::out_base::span_tellp().

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 535 of file memoryStreamBuffer.H.

References Foam::BitOps::count(), n, memorybuf::out_dynamic::reserve(), s, and memorybuf::out_base::span_tellp().

Here is the call graph for this function:

◆ reserve()

void reserve ( const std::streamsize  len)
inline

Increment capacity (if needed) and adjust buffer pointers.

Definition at line 595 of file memoryStreamBuffer.H.

References Foam::max(), List< T >::resize(), UList< T >::size(), memorybuf::out_base::span_tellp(), and memorybuf::out_dynamic::sync_pbuffer().

Referenced by memorybuf::out_dynamic::overflow(), ocharstream::reserve(), and memorybuf::out_dynamic::xsputn().

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 625 of file memoryStreamBuffer.H.

References UList< T >::data(), memorybuf::out_base::resetp(), and UList< T >::size().

Referenced by memorybuf::out_dynamic::clearStorage(), memorybuf::out_dynamic::out_dynamic(), memorybuf::out_dynamic::release(), memorybuf::out_dynamic::reserve(), memorybuf::out_dynamic::shrink(), and memorybuf::out_dynamic::swap().

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 633 of file memoryStreamBuffer.H.

References List< T >::clear(), and memorybuf::out_dynamic::sync_pbuffer().

Here is the call graph for this function:

◆ shrink()

void shrink ( )
inline

Shrink storage to addressed storage.

Definition at line 642 of file memoryStreamBuffer.H.

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

Here is the call graph for this function:

◆ swap() [1/2]

void swap ( List< char > &  other)
inline

Exchange buffer content and parameter contents, reset positions.

Definition at line 654 of file memoryStreamBuffer.H.

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

Referenced by ocharstream::swap().

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

◆ swap() [2/2]

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

Exchange buffer content and parameter contents, reset positions.

Definition at line 666 of file memoryStreamBuffer.H.

References DynamicList< T, SizeMin >::capacity(), DynamicList< T, SizeMin >::resize(), memorybuf::out_base::span_tellp(), DynamicList< T, SizeMin >::swap(), and memorybuf::out_dynamic::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 680 of file memoryStreamBuffer.H.

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

Referenced by ocharstream::release().

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

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