Loading...
Searching...
No Matches
icharstream Class Reference

Similar to std::istringstream, but with the ability to swap character content. Has some similarity to std::ispanstream (C++23). More...

#include <ICharStream.H>

Inheritance diagram for icharstream:
Collaboration diagram for icharstream:

Public Member Functions

 icharstream ()
 Default construct - empty.
 icharstream (const char *buffer, size_t nbytes)
 Copy construct from content.
 icharstream (List< char > &&buffer)
 Move construct from List.
template<int SizeMin>
 icharstream (DynamicList< char, SizeMin > &&buffer)
 Move construct from DynamicList.
std::streampos input_pos () const
 The current get position within the buffer (tellg).
std::streamsize capacity () const
 The get buffer capacity.
std::streamsize remaining () const
 The number of characters remaining in the get area. Same as (capacity() - input_pos()).
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 buffer contents (caution: is modifiable!!).
std::string str () const
 For istringstream compatibility, return the buffer as string copy.
void rewind ()
 Rewind the stream, clearing any old errors.
void seek (std::streampos pos)
 Reposition the stream from the start.
void reset (const char *buffer, size_t nbytes)
 Reset stream content (copy), reset positions.
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 stream and return contents as a List.
void debug_info (Ostream &os) const
 Some information about the input buffer position/capacity.
void print (Ostream &os) const
 Information about stream.

Additional Inherited Members

Protected Member Functions inherited from memorybuf::in_dynamic
 in_dynamic ()=default
 Default construct - empty.
 in_dynamic (const char *s, std::streamsize n)
 Copy construct from content.
 in_dynamic (::Foam::List< char > &&buffer)
 Move construct from List.
template<int SizeMin>
 in_dynamic (::Foam::DynamicList< char, SizeMin > &&buffer)
 Move construct from DynamicList (added length only).
void sync_gbuffer ()
 Sync get buffer pointers to agree with list dimensions.
void reset (const char *s, std::streamsize n)
 Reset content (copy).
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. The list size and capacity are identical.
Protected Member Functions inherited from memorybuf::in_base
virtual std::streamsize xsgetn (char *s, std::streamsize n)
 Get sequence of characters from a fixed region.
 in_base ()=default
 Default construct.
 in_base (char *s, std::streamsize n)
 Construct for character array (can be nullptr) and number of bytes.
void resetg (char *s, std::streamsize n)
 Reset get buffer with character data (can be nullptr) and count.
std::streamsize span_tellg () const
 The current buffer get position.
std::streamsize span_capacity () const
 The get buffer capacity.
std::streamsize span_remaining () const
 The number of characters remaining in the get area.
char * data_bytes () const
 The span data (start of input characters).
std::streamsize size_bytes () const
 The span size (number of input characters).
bool in_range (std::streampos pos) const
 True if position is within the current input range.
auto view () const
 A string view of the current input region.
auto view (size_t pos, size_t len) const
 A sub-slice string view of the current input region.
void info (Ostream &os) const
 Some information about the input 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.

Detailed Description

Similar to std::istringstream, but with the ability to swap character content. Has some similarity to std::ispanstream (C++23).

Definition at line 62 of file ICharStream.H.

Constructor & Destructor Documentation

◆ icharstream() [1/4]

icharstream ( )
inline

Default construct - empty.

Definition at line 78 of file ICharStream.H.

Referenced by icharstream(), icharstream(), and icharstream().

Here is the caller graph for this function:

◆ icharstream() [2/4]

icharstream ( const char * buffer,
size_t nbytes )
inline

Copy construct from content.

Definition at line 87 of file ICharStream.H.

References icharstream(), and reset().

Here is the call graph for this function:

◆ icharstream() [3/4]

icharstream ( List< char > && buffer)
inline

Move construct from List.

Definition at line 97 of file ICharStream.H.

References icharstream(), and swap().

Here is the call graph for this function:

◆ icharstream() [4/4]

template<int SizeMin>
icharstream ( DynamicList< char, SizeMin > && buffer)
inline

Move construct from DynamicList.

Definition at line 108 of file ICharStream.H.

References icharstream(), and swap().

Here is the call graph for this function:

Member Function Documentation

◆ input_pos()

std::streampos input_pos ( ) const
inline

The current get position within the buffer (tellg).

Definition at line 121 of file ICharStream.H.

References memorybuf::in_base::span_tellg().

Referenced by debug_info().

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

◆ capacity()

std::streamsize capacity ( ) const
inline

The get buffer capacity.

Definition at line 129 of file ICharStream.H.

References memorybuf::in_base::span_capacity().

Referenced by debug_info().

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

◆ remaining()

std::streamsize remaining ( ) const
inline

The number of characters remaining in the get area. Same as (capacity() - input_pos()).

Definition at line 138 of file ICharStream.H.

References memorybuf::in_base::span_remaining().

Here is the call graph for this function:

◆ view() [1/2]

auto view ( ) const
inline

A string_view of buffer contents.

Definition at line 146 of file ICharStream.H.

References memorybuf::in_base::view().

Here is the call graph for this function:

◆ view() [2/2]

auto view ( size_t pos,
size_t len = std::string::npos ) const
inline

A sub-slice string view of the buffer contents.

Definition at line 151 of file ICharStream.H.

References Foam::pos(), and memorybuf::in_base::view().

Here is the call graph for this function:

◆ list()

UList< char > list ( ) const
inline

A list 'span' of buffer contents (caution: is modifiable!!).

Definition at line 159 of file ICharStream.H.

References memorybuf::in_base::data_bytes(), and memorybuf::in_base::size_bytes().

Here is the call graph for this function:

◆ str()

std::string str ( ) const
inline

For istringstream compatibility, return the buffer as string copy.

Use sparingly - it creates a full copy!!

Definition at line 173 of file ICharStream.H.

References memorybuf::in_base::data_bytes(), and memorybuf::in_base::size_bytes().

Here is the call graph for this function:

◆ rewind()

void rewind ( )
inline

Rewind the stream, clearing any old errors.

Definition at line 185 of file ICharStream.H.

◆ seek()

void seek ( std::streampos pos)
inline

Reposition the stream from the start.

Definition at line 194 of file ICharStream.H.

References memorybuf::in_base::in_range(), and Foam::pos().

Here is the call graph for this function:

◆ reset()

void reset ( const char * buffer,
size_t nbytes )
inline

Reset stream content (copy), reset positions.

Definition at line 206 of file ICharStream.H.

References memorybuf::in_dynamic::reset().

Referenced by icharstream().

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 stream content and parameter contents, reset positions.

Definition at line 215 of file ICharStream.H.

References memorybuf::in_dynamic::swap().

Referenced by icharstream(), and icharstream().

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 stream content and parameter contents, reset positions.

Definition at line 225 of file ICharStream.H.

References memorybuf::in_dynamic::swap().

Here is the call graph for this function:

◆ release()

DynamicList< char > release ( )
inline

Reset stream and return contents as a List.

Definition at line 234 of file ICharStream.H.

References memorybuf::in_dynamic::release().

Here is the call graph for this function:

◆ debug_info()

void debug_info ( Ostream & os) const
inline

Some information about the input buffer position/capacity.

Definition at line 244 of file ICharStream.H.

References capacity(), input_pos(), and os().

Referenced by print().

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

◆ print()

void print ( Ostream & os) const
inline

Information about stream.

Definition at line 252 of file ICharStream.H.

References debug_info(), and os().

Here is the call graph for this function:

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