4.2.0
Freundlich's C++ toolkit
Public Member Functions
fcppt::parse::basic_stream< Ch > Class Template Referenceabstract

Detailed Description

template<typename Ch>
class fcppt::parse::basic_stream< Ch >

The stream class used while parsing.

This class is the base class for all input streams. Semantically, a basic_stream points to an index 0 <= i <= n in a string a_1...a_n of type vector<Ch>. This index is before the next character that will be read, or in case i = n the end of the string is reached.

The position of a stream is an index plus the current line number l and column number c. These can be obtained as follows:

An actual implementation would keep track of these numbers when get_char and set_position are called. This is also the reason why std::basic_istream is not used, since implementing this with streambufs alone is impossible.

Public Member Functions

 basic_stream ()
 
virtual ~basic_stream ()=0
 
virtual fcppt::optional::object< Ch > get_char ()=0
 Returns the next character, if possible. If i = n, then the result is nothing. Otherwise, returns c_{i+1} and increments i. More...
 
virtual fcppt::parse::position< Ch > get_position () const =0
 Returns the current position. More...
 
virtual void set_position (fcppt::parse::position< Ch > const &)=0
 Sets the current position. More...
 

Constructor & Destructor Documentation

◆ basic_stream()

template<typename Ch >
fcppt::parse::basic_stream< Ch >::basic_stream ( )

◆ ~basic_stream()

template<typename Ch >
virtual fcppt::parse::basic_stream< Ch >::~basic_stream ( )
pure virtual

Member Function Documentation

◆ get_char()

template<typename Ch >
virtual fcppt::optional::object< Ch > fcppt::parse::basic_stream< Ch >::get_char ( )
pure virtual

Returns the next character, if possible. If i = n, then the result is nothing. Otherwise, returns c_{i+1} and increments i.

◆ get_position()

template<typename Ch >
virtual fcppt::parse::position< Ch > fcppt::parse::basic_stream< Ch >::get_position ( ) const
pure virtual

Returns the current position.

◆ set_position()

template<typename Ch >
virtual void fcppt::parse::basic_stream< Ch >::set_position ( fcppt::parse::position< Ch > const &  )
pure virtual

Sets the current position.

Note that the position contains line and column numbers. These must be consistent with the string that is currently being read. Therefore, arguments to this function should only be values returned from get_position.