Loading...
Searching...
No Matches
ispanstream Class Reference

Similar to std::istringstream, but with an externally managed input buffer which makes it most similar to std::ispanstream (C++23). More...

#include <ISpanStream.H>

Inheritance diagram for ispanstream:
Collaboration diagram for ispanstream:

Public Member Functions

 ispanstream ()
 Default construct - empty.
 ispanstream (const char *buffer, size_t nbytes)
 Construct (shallow copy) for character array and number of bytes.
 ispanstream (std::string_view s)
 Construct (shallow copy) from std::string_view content.
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()).
UList< char > list () const
 A list span of the input characters (is modifiable!).
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.
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 the get buffer area.
void reset (const char *s)
 Reset the get buffer area to use the nul-terminated buffer.
void reset (const std::string &s)
 Reset the get buffer area to use the data from a string.
void reset (std::string_view s)
 Reset the get buffer area to use the data from a string_view.
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_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 an externally managed input buffer which makes it most similar to std::ispanstream (C++23).

This allows the input buffer to be filled or refilled from various sources without copying.

Definition at line 88 of file ISpanStream.H.

Constructor & Destructor Documentation

◆ ispanstream() [1/3]

ispanstream ( )
inline

Default construct - empty.

Definition at line 104 of file ISpanStream.H.

◆ ispanstream() [2/3]

ispanstream ( const char * buffer,
size_t nbytes )
inline

Construct (shallow copy) for character array and number of bytes.

Definition at line 113 of file ISpanStream.H.

◆ ispanstream() [3/3]

ispanstream ( std::string_view s)
inlineexplicit

Construct (shallow copy) from std::string_view content.

Definition at line 122 of file ISpanStream.H.

References s().

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 134 of file ISpanStream.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 142 of file ISpanStream.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 151 of file ISpanStream.H.

References memorybuf::in_base::span_remaining().

Here is the call graph for this function:

◆ list()

UList< char > list ( ) const
inline

A list span of the input characters (is modifiable!).

Definition at line 159 of file ISpanStream.H.

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

Here is the call graph for this function:

◆ view() [1/2]

auto view ( ) const
inline

A string_view of buffer contents.

Definition at line 171 of file ISpanStream.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 176 of file ISpanStream.H.

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

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 186 of file ISpanStream.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 198 of file ISpanStream.H.

◆ seek()

void seek ( std::streampos pos)
inline

Reposition the stream from the start.

Definition at line 207 of file ISpanStream.H.

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

Here is the call graph for this function:

◆ reset() [1/4]

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

Reset the get buffer area.

Definition at line 219 of file ISpanStream.H.

References memorybuf::in_base::resetg().

Referenced by reset().

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

◆ reset() [2/4]

void reset ( const char * s)
inline

Reset the get buffer area to use the nul-terminated buffer.

Definition at line 228 of file ISpanStream.H.

References reset(), and s().

Here is the call graph for this function:

◆ reset() [3/4]

void reset ( const std::string & s)
inline

Reset the get buffer area to use the data from a string.

Definition at line 236 of file ISpanStream.H.

References memorybuf::in_base::resetg(), and s().

Here is the call graph for this function:

◆ reset() [4/4]

void reset ( std::string_view s)
inline

Reset the get buffer area to use the data from a string_view.

Definition at line 245 of file ISpanStream.H.

References memorybuf::in_base::resetg(), and s().

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 254 of file ISpanStream.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 262 of file ISpanStream.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: