Bond 0.9
C++ Bond Runtime Library API Documentation
Loading...
Searching...
No Matches
Bond::CharStream Class Reference

An iterator over the contents of a stream of text. More...

#include <bond/compiler/charstream.h>

Public Member Functions

 CharStream (InputStream &stream)
 Constructs a CharStream object that iterates from the current position to the end of the given stream.
void Reset ()
 Resets the position of the stream back to the beginning.
void Reset (const StreamPos &pos)
 Resets the position of the stream back to the specified position.
void Sync ()
 Ensures that the underlying InputStream is seeked to the same position as this stream.
bool HasNext () const
 Returns whether any characters remain in the stream, including the appended space.
char Next ()
 Returns the next character in the stream and advances the stream's position.
const StreamPos & GetStreamPos () const
 Returns the stream's current position.

Detailed Description

An iterator over the contents of a stream of text.

CharStream is used internally by Lexer; it is unlikely that someone integrating Bond into their application will have to make direct use of it.

A single space is appended after the last character of the underlying stream, so that the end of the last token can be identified. The stream position tracks lines and columns as described by StreamPos.

Constructor & Destructor Documentation

◆ CharStream()

Bond::CharStream::CharStream ( InputStream & stream)
inlineexplicit

Constructs a CharStream object that iterates from the current position to the end of the given stream.

Parameters
streamThe underlying stream of characters over which this stream iterates. It is not copied, so it must outlive the CharStream.

Member Function Documentation

◆ GetStreamPos()

const StreamPos & Bond::CharStream::GetStreamPos ( ) const
inline

Returns the stream's current position.

◆ HasNext()

bool Bond::CharStream::HasNext ( ) const

Returns whether any characters remain in the stream, including the appended space.

◆ Next()

char Bond::CharStream::Next ( )

Returns the next character in the stream and advances the stream's position.

Returns a space once the end of the underlying stream is reached, without advancing past the appended space.

◆ Reset() [1/2]

void Bond::CharStream::Reset ( )
inline

Resets the position of the stream back to the beginning.

◆ Reset() [2/2]

void Bond::CharStream::Reset ( const StreamPos & pos)

Resets the position of the stream back to the specified position.

Parameters
posA position previously returned by GetStreamPos().

◆ Sync()

void Bond::CharStream::Sync ( )
inline

Ensures that the underlying InputStream is seeked to the same position as this stream.


The documentation for this class was generated from the following file:
  • include/bond/compiler/charstream.h