Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

ogdf::LineBuffer Class Reference

This class maintains the input file and provides a convenient interface to handle it. More...

#include <ogdf/fileformats/LineBuffer.h>

Public Member Functions

 LineBuffer (istream &is)
 Construction. More...
 
 ~LineBuffer ()
 Destruction. More...
 
bool extractString (const LineBufferPosition &startPostion, const LineBufferPosition &endPosition, string &targetString)
 Copies the characters which have been extracted from the line buffer starting from position startPosition (including it) to endPosition (excluding it) to targetString. More...
 
char getCurrentCharacter () const
 Returns the character which is currently pointed to. More...
 
LineBufferPosition getCurrentPosition () const
 Returns the current position (as a copy) More...
 
int getInputFileLineCounter () const
 Returns line number of the most recently read line of the input file. More...
 
char moveToNextCharacter ()
 Moves to the next position; reading of new lines and handling of eof are done internally. More...
 
bool setCurrentPosition (const LineBufferPosition &newPosition)
 Sets the current position to new positon. More...
 
void skipWhitespace ()
 Moves to the next character until the currentCharacter is no whitespace. More...
 

Private Member Functions

bool isValidPosition (const LineBufferPosition &position) const
 Checks wether the given position is valid. More...
 

Private Attributes

LineBufferPosition m_currentPosition
 The current position in m_linBuf. More...
 
int m_inputFileLineCounter
 Contains the current line number of the input file;. More...
 
ArrayBuffer< string > m_linBuf
 Pointer to the line buffer. More...
 
ArrayBuffer< int > m_lineUpdateCountArray
 Contains for each line of the line buffer its update count. More...
 
int m_numberOfMostRecentlyReadLine
 The line which has been read from the file most recently; this does not have to be equal to m_currentPosition.m_lineNumber because of the lookahead facilities. More...
 
istream * m_pIs
 Handle to the input file. More...
 

Detailed Description

This class maintains the input file and provides a convenient interface to handle it.

Definition at line 114 of file LineBuffer.h.

Constructor & Destructor Documentation

◆ LineBuffer()

ogdf::LineBuffer::LineBuffer ( istream &  is)
explicit

Construction.

◆ ~LineBuffer()

ogdf::LineBuffer::~LineBuffer ( )

Destruction.

Member Function Documentation

◆ extractString()

bool ogdf::LineBuffer::extractString ( const LineBufferPosition &  startPostion,
const LineBufferPosition &  endPosition,
string &  targetString 
)

Copies the characters which have been extracted from the line buffer starting from position startPosition (including it) to endPosition (excluding it) to targetString.

Parameters
startPostionstart position
endPositionend position
targetStringstring [startPostion .. endPosition] of the LineBuffer
Returns
false if the startPosition is not valid, i.e. the string is too long; targetString will contain the message "String too long!"

◆ getCurrentCharacter()

char ogdf::LineBuffer::getCurrentCharacter ( ) const
inline

Returns the character which is currently pointed to.

Definition at line 154 of file LineBuffer.h.

◆ getCurrentPosition()

LineBufferPosition ogdf::LineBuffer::getCurrentPosition ( ) const
inline

Returns the current position (as a copy)

Definition at line 149 of file LineBuffer.h.

◆ getInputFileLineCounter()

int ogdf::LineBuffer::getInputFileLineCounter ( ) const
inline

Returns line number of the most recently read line of the input file.

Definition at line 163 of file LineBuffer.h.

◆ isValidPosition()

bool ogdf::LineBuffer::isValidPosition ( const LineBufferPosition &  position) const
private

Checks wether the given position is valid.

◆ moveToNextCharacter()

char ogdf::LineBuffer::moveToNextCharacter ( )

Moves to the next position; reading of new lines and handling of eof are done internally.

If end of file is reached the position will stuck to EOF character. The current character after moving is returned

◆ setCurrentPosition()

bool ogdf::LineBuffer::setCurrentPosition ( const LineBufferPosition &  newPosition)

Sets the current position to new positon.

Takes care if the given newPosition is valid.

Parameters
newPositionnew position
Returns
false if given position is invalid

◆ skipWhitespace()

void ogdf::LineBuffer::skipWhitespace ( )

Moves to the next character until the currentCharacter is no whitespace.

Member Data Documentation

◆ m_currentPosition

LineBufferPosition ogdf::LineBuffer::m_currentPosition
private

The current position in m_linBuf.

Definition at line 128 of file LineBuffer.h.

◆ m_inputFileLineCounter

int ogdf::LineBuffer::m_inputFileLineCounter
private

Contains the current line number of the input file;.

Definition at line 138 of file LineBuffer.h.

◆ m_linBuf

ArrayBuffer<string> ogdf::LineBuffer::m_linBuf
private

Pointer to the line buffer.

Definition at line 125 of file LineBuffer.h.

◆ m_lineUpdateCountArray

ArrayBuffer<int> ogdf::LineBuffer::m_lineUpdateCountArray
private

Contains for each line of the line buffer its update count.

Definition at line 122 of file LineBuffer.h.

◆ m_numberOfMostRecentlyReadLine

int ogdf::LineBuffer::m_numberOfMostRecentlyReadLine
private

The line which has been read from the file most recently; this does not have to be equal to m_currentPosition.m_lineNumber because of the lookahead facilities.

Definition at line 135 of file LineBuffer.h.

◆ m_pIs

istream* ogdf::LineBuffer::m_pIs
private

Handle to the input file.

Definition at line 119 of file LineBuffer.h.


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