icharstream Class Reference

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

Inheritance diagram for icharstream:
Collaboration diagram for icharstream:

Public Member Functions

 icharstream ()
 Default construct - empty. More...
 
 icharstream (const char *buffer, size_t nbytes)
 Copy construct from content. More...
 
 icharstream (List< char > &&buffer)
 Move construct from List. More...
 
template<int SizeMin>
 icharstream (DynamicList< char, SizeMin > &&buffer)
 Move construct from DynamicList. 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 stream content (copy), reset positions. More...
 
void swap (List< char > &other)
 Exchange stream content and parameter contents, reset positions. More...
 
template<int SizeMin>
void swap (DynamicList< char, SizeMin > &other)
 Exchange stream content and parameter contents, reset positions. More...
 
DynamicList< char > release ()
 Reset stream and return contents as a List. 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_dynamic
 in_dynamic ()=default
 Default construct - empty. More...
 
 in_dynamic (const char *s, std::streamsize n)
 Copy construct from content. More...
 
 in_dynamic (::Foam::List< char > &&buffer)
 Move construct from List. More...
 
template<int SizeMin>
 in_dynamic (::Foam::DynamicList< char, SizeMin > &&buffer)
 Move construct from DynamicList (added length only) More...
 
void sync_gbuffer ()
 Sync get buffer pointers to agree with list dimensions. More...
 
void reset (const char *s, std::streamsize n)
 Reset content (copy) 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. More...
 
- 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 the ability to swap character content. Has some similarity to std::ispanstream (C++23)

Definition at line 64 of file ICharStream.H.

Constructor & Destructor Documentation

◆ icharstream() [1/4]

icharstream ( )
inline

Default construct - empty.

Definition at line 80 of file ICharStream.H.

◆ icharstream() [2/4]

icharstream ( const char *  buffer,
size_t  nbytes 
)
inline

Copy construct from content.

Definition at line 89 of file ICharStream.H.

References icharstream::reset().

Here is the call graph for this function:

◆ icharstream() [3/4]

icharstream ( List< char > &&  buffer)
inline

Move construct from List.

Definition at line 99 of file ICharStream.H.

References icharstream::swap().

Here is the call graph for this function:

◆ icharstream() [4/4]

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

Move construct from DynamicList.

Definition at line 110 of file ICharStream.H.

References icharstream::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 123 of file ICharStream.H.

References memorybuf::in_base::span_tellg().

Referenced by icharstream::debug_info(), ICharStream::input_pos(), and ICharStream::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 131 of file ICharStream.H.

References memorybuf::in_base::span_capacity().

Referenced by ICharStream::capacity(), icharstream::debug_info(), and ICharStream::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 140 of file ICharStream.H.

References memorybuf::in_base::span_remaining().

Referenced by ICharStream::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 148 of file ICharStream.H.

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

Referenced by ICharStream::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 160 of file ICharStream.H.

References memorybuf::in_base::view().

Referenced by ICharStream::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 170 of file ICharStream.H.

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

Referenced by ICharStream::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 182 of file ICharStream.H.

References clear().

Referenced by ICharStream::rewind().

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

◆ reset()

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

Reset stream content (copy), reset positions.

Definition at line 191 of file ICharStream.H.

References clear(), and memorybuf::in_dynamic::reset().

Referenced by icharstream::icharstream(), ICharStream::ICharStream(), and ICharStream::reset().

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 200 of file ICharStream.H.

References clear(), and memorybuf::in_dynamic::swap().

Referenced by icharstream::icharstream(), ICharStream::ICharStream(), and ICharStream::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 stream content and parameter contents, reset positions.

Definition at line 210 of file ICharStream.H.

References clear(), and 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 219 of file ICharStream.H.

References clear(), and memorybuf::in_dynamic::release().

Referenced by ICharStream::release().

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

◆ debug_info()

void debug_info ( Ostream os) const
inline

Some information about the input buffer position/capacity.

Definition at line 229 of file ICharStream.H.

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

Here is the call graph for this function:

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