knowL: Knowledge Libraries
Loading...
Searching...
No Matches
knowCore::LexerTextStream Class Reference

#include <LexerTextStream.h>

Classes

struct  Element
 
struct  Private
 

Public Member Functions

 LexerTextStream (QIODevice *sstream)
 
 LexerTextStream (const QString &string)
 
void setDevice (QIODevice *sstream)
 
void setString (const QString &string)
 
Element getNextChar ()
 
Element getNextNonSeparatorChar ()
 
void unget (Element c)
 
std::tuple< Element, bool > getString (const QString &terminator)
 
std::tuple< Element, bool > getDigit (Element start)
 
bool eof () const
 
void setBufferSize (std::size_t _size)
 
std::size_t bufferSize ()
 
std::size_t currentBufferSize ()
 

Detailed Description

Implement convenient support for lexing SPARQL/Turtle-like languages.

It allows:

Constructor & Destructor Documentation

◆ LexerTextStream() [1/2]

LexerTextStream::LexerTextStream ( QIODevice * sstream)

Construct a stream reading from a QIODevice. With this constructor, LexerTextStream uses an internal buffer.

◆ LexerTextStream() [2/2]

LexerTextStream::LexerTextStream ( const QString & string)

Construct a stream reading from a QString. With this constructor, LexerTextStream 's internal buffer is equal to string.

Member Function Documentation

◆ bufferSize()

std::size_t LexerTextStream::bufferSize ( )
Returns
how many bytes are read in the buffer at once

◆ currentBufferSize()

std::size_t LexerTextStream::currentBufferSize ( )
Returns
the number of bytes currently held in the internal buffer

This value might differs from bufferSize for various reasons:

  • not enough data was available in the stream
  • if LexerTextStream was initialised with a string, the buffer is equal to the string and the currentBufferSize is equal to the length of the string
  • when reading a string, the entire string has to be contained in the buffer

◆ getDigit()

std::tuple< LexerTextStream::Element, bool > LexerTextStream::getDigit ( LexerTextStream::Element start)

Read a digit, the boolean is true if integer

◆ getNextChar()

LexerTextStream::Element LexerTextStream::getNextChar ( )
Returns
the next char and increment the column counter.

◆ getNextNonSeparatorChar()

LexerTextStream::Element LexerTextStream::getNextNonSeparatorChar ( )
Returns
the next char that is not a separator (space, tab, return...)

◆ getString()

std::tuple< LexerTextStream::Element, bool > LexerTextStream::getString ( const QString & terminator)

Read a string, the boolean is true if the terminator was found, false otherwise

◆ setBufferSize()

void LexerTextStream::setBufferSize ( std::size_t _size)

Set how many bytes are read in the buffer to _size.

◆ unget()

void LexerTextStream::unget ( LexerTextStream::Element c)

Cancel the reading of the previous char.


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