SFCGAL
Public Types | Public Member Functions | List of all members
SFCGAL::tools::BasicInputStreamReader< CharType > Class Template Reference

Helper class to parse data from stream. More...

#include <InputStreamReader.h>

Public Types

typedef CharType char_type
 
typedef std::basic_string< char_typestring_type
 
typedef std::basic_istream< char_typeistream_type
 
typedef std::basic_istream< char_type >::pos_type pos_type
 

Public Member Functions

 BasicInputStreamReader (istream_type &s, bool skipWhiteSpaces=true)
 constructor with an input stream More...
 
bool match (char_type const &c)
 try to match a char in the input stream More...
 
bool imatch (char_type const &c)
 try to match a char in the input stream, case-insensitive variant More...
 
bool match (string_type const &str)
 try to match a string in the input stream More...
 
bool imatch (string_type const &str)
 try to match a string in the input stream, case-insensitive variant More...
 
template<typename T >
bool read (T &value)
 try to read a value in the input stream, restore state if read fails More...
 
void begin ()
 save input stream state (read position) More...
 
void commit ()
 validate read from input stream More...
 
void rollback ()
 restore stream state (read position) More...
 
bool eof () const
 test if read is complete (either tried to reader after eof, either on eof) More...
 
istream_types ()
 returns the wrapped stream More...
 
istream_type const & s () const
 returns the wrapped stream More...
 
string_type context (size_t nMax=20)
 returns a string corresponding to the current state More...
 

Detailed Description

template<typename CharType>
class SFCGAL::tools::BasicInputStreamReader< CharType >

Helper class to parse data from stream.

Member Typedef Documentation

◆ char_type

template<typename CharType >
typedef CharType SFCGAL::tools::BasicInputStreamReader< CharType >::char_type

◆ istream_type

template<typename CharType >
typedef std::basic_istream<char_type> SFCGAL::tools::BasicInputStreamReader< CharType >::istream_type

◆ pos_type

template<typename CharType >
typedef std::basic_istream<char_type>::pos_type SFCGAL::tools::BasicInputStreamReader< CharType >::pos_type

◆ string_type

template<typename CharType >
typedef std::basic_string<char_type> SFCGAL::tools::BasicInputStreamReader< CharType >::string_type

Constructor & Destructor Documentation

◆ BasicInputStreamReader()

template<typename CharType >
SFCGAL::tools::BasicInputStreamReader< CharType >::BasicInputStreamReader ( istream_type s,
bool  skipWhiteSpaces = true 
)
inline

constructor with an input stream

Member Function Documentation

◆ begin()

template<typename CharType >
void SFCGAL::tools::BasicInputStreamReader< CharType >::begin ( )
inline

save input stream state (read position)

◆ commit()

template<typename CharType >
void SFCGAL::tools::BasicInputStreamReader< CharType >::commit ( )
inline

validate read from input stream

◆ context()

template<typename CharType >
string_type SFCGAL::tools::BasicInputStreamReader< CharType >::context ( size_t  nMax = 20)
inline

returns a string corresponding to the current state

◆ eof()

template<typename CharType >
bool SFCGAL::tools::BasicInputStreamReader< CharType >::eof ( ) const
inline

test if read is complete (either tried to reader after eof, either on eof)

◆ imatch() [1/2]

template<typename CharType >
bool SFCGAL::tools::BasicInputStreamReader< CharType >::imatch ( char_type const &  c)
inline

try to match a char in the input stream, case-insensitive variant

◆ imatch() [2/2]

template<typename CharType >
bool SFCGAL::tools::BasicInputStreamReader< CharType >::imatch ( string_type const &  str)
inline

try to match a string in the input stream, case-insensitive variant

◆ match() [1/2]

template<typename CharType >
bool SFCGAL::tools::BasicInputStreamReader< CharType >::match ( char_type const &  c)
inline

try to match a char in the input stream

◆ match() [2/2]

template<typename CharType >
bool SFCGAL::tools::BasicInputStreamReader< CharType >::match ( string_type const &  str)
inline

try to match a string in the input stream

◆ read()

template<typename CharType >
template<typename T >
bool SFCGAL::tools::BasicInputStreamReader< CharType >::read ( T &  value)
inline

try to read a value in the input stream, restore state if read fails

◆ rollback()

template<typename CharType >
void SFCGAL::tools::BasicInputStreamReader< CharType >::rollback ( )
inline

restore stream state (read position)

◆ s() [1/2]

template<typename CharType >
istream_type & SFCGAL::tools::BasicInputStreamReader< CharType >::s ( )
inline

returns the wrapped stream

◆ s() [2/2]

template<typename CharType >
istream_type const & SFCGAL::tools::BasicInputStreamReader< CharType >::s ( ) const
inline

returns the wrapped stream