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

Inheritance diagram for ispanstream:
Collaboration diagram for ispanstream:

Public Member Functions

 ispanstream ()
 Default construct - empty. More...
 
 ispanstream (const char *buffer, size_t nbytes)
 Construct (shallow copy) for character array and number of bytes. More...
 
 ispanstream (stdFoam::span< char > s)
 Construct (shallow copy) from span character content. More...
 
 ispanstream (stdFoam::span< const char > s)
 Construct (shallow copy) from span character content. More...
 
std::streampos input_pos () const
 The current get position within the buffer (tellg) More...
 
std::streamsize capacity () const
 The get buffer capacity. More...
 
std::streamsize remaining () const
 The number of characters remaining in the get area. Same as (capacity() - input_pos()) More...
 
UList< char > list () const
 Span of the input characters (is modifiable!) More...
 
auto view () const -> decltype(buffer_type::view())
 A string_view (c++17) or span view (older c++) of buffer contents. More...
 
std::string str () const
 For istringstream compatibility, return the buffer as string copy. More...
 
void rewind ()
 Rewind the stream, clearing any old errors. More...
 
void reset (const char *buffer, size_t nbytes)
 Reset the get buffer area. More...
 
void reset (const std::string &s)
 Reset the get buffer area to use the data from a string. More...
 
void debug_info (Ostream &os) const
 Some information about the input buffer position/capacity. More...
 

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. More...
 
 in_base ()=default
 Default construct. More...
 
 in_base (char *s, std::streamsize n)
 Construct for character array (can be nullptr) and number of bytes. More...
 
void resetg (char *s, std::streamsize n)
 Reset get buffer with character data (can be nullptr) and count. More...
 
std::streamsize span_tellg () const
 The current buffer get position. More...
 
std::streamsize span_capacity () const
 The get buffer capacity. More...
 
std::streamsize span_remaining () const
 The number of characters remaining in the get area. More...
 
char * data_bytes () const
 The span data (start of input characters) More...
 
std::streamsize size_bytes () const
 The span size (number of input characters) More...
 
stdFoam::span< const char > view () const
 
void info (Ostream &os) const
 Some information about the input buffer position/capacity. 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

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

Constructor & Destructor Documentation

◆ ispanstream() [1/4]

ispanstream ( )
inline

Default construct - empty.

Definition at line 105 of file ISpanStream.H.

◆ ispanstream() [2/4]

ispanstream ( const char *  buffer,
size_t  nbytes 
)
inline

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

Definition at line 114 of file ISpanStream.H.

◆ ispanstream() [3/4]

ispanstream ( stdFoam::span< char >  s)
inlineexplicit

Construct (shallow copy) from span character content.

Definition at line 134 of file ISpanStream.H.

◆ ispanstream() [4/4]

ispanstream ( stdFoam::span< const char >  s)
inlineexplicit

Construct (shallow copy) from span character content.

Definition at line 143 of file ISpanStream.H.

Member Function Documentation

◆ input_pos()

std::streampos input_pos ( ) const
inline

The current get position within the buffer (tellg)

Definition at line 155 of file ISpanStream.H.

References memorybuf::in_base::span_tellg().

Referenced by ispanstream::debug_info(), ISpanStream::input_pos(), and ISpanStream::tellg().

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

References memorybuf::in_base::span_capacity().

Referenced by ISpanStream::capacity(), ispanstream::debug_info(), and ISpanStream::size().

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

References memorybuf::in_base::span_remaining().

Referenced by ISpanStream::remaining().

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

◆ list()

UList<char> list ( ) const
inline

Span of the input characters (is modifiable!)

Definition at line 180 of file ISpanStream.H.

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

Referenced by ISpanStream::list().

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

◆ view()

auto view ( ) const -> decltype(buffer_type::view())
inline

A string_view (c++17) or span view (older c++) of buffer contents.

Definition at line 192 of file ISpanStream.H.

References memorybuf::in_base::view().

Referenced by ISpanStream::view().

Here is the call graph for this function:
Here is the caller 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 202 of file ISpanStream.H.

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

Referenced by ISpanStream::str().

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

◆ rewind()

void rewind ( )
inline

Rewind the stream, clearing any old errors.

Definition at line 214 of file ISpanStream.H.

References clear().

Referenced by ISpanStream::rewind().

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

◆ reset() [1/2]

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

Reset the get buffer area.

Definition at line 223 of file ISpanStream.H.

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

Referenced by ISpanStream::reset().

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

◆ reset() [2/2]

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

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

Definition at line 232 of file ISpanStream.H.

References clear(), 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 241 of file ISpanStream.H.

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

Referenced by ISpanStream::print().

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: