SourceText Class Reference

A smart class to hold the text for parsing. More...

#include <parser.h>

List of all members.

Public Member Functions

 SourceText ()
 Default constructor.
void AppendFile (const String &name)
 Appends contents of file to the source text.
char Current ()
 Return the current character.
void AdvanceChar ()
 Advance position pointer by one character.
void AdvanceLine ()
 Advances position pointer by one line.
const StringFile ()
 Return the filename associated with the current position.
Index Line ()
 Return the line number, but for the file that is associated with the current position.
Index Column ()
 Return the current column.
void Init ()
 This sets the pointer to the first existing character in the text.
bool & LineBreak ()
 Read the line break flag.
bool LineBreak () const
 Const version of LineBreak.

Private Attributes

ArrayOfString mText
 The text.
Index mLine
 Line position in the text.
Index mColumn
 Column position in the text.
ArrayOfIndex mSfLine
 Remember where which source file starts.
ArrayOfString mSfName
 Names associated with.
bool mLineBreak
 Is set to true if the last operation caused a line break.

Friends

ostream & operator<< (ostream &os, const SourceText &text)
 Output operator for SourceText.


Detailed Description

A smart class to hold the text for parsing.

A variable of this class can hold not only the text of the ARTS Control file, but also a position in the text. This is handy for parsing. There is also a function to return the current character and functions to advance the position. (AdvanceChar advances the position to the next character, doing a line break if necessary; AdvanceLine goes to the next line.)

mLine and mColumn are 0 based, but Line and Column are 1 based.

Author:
Stefan Buehler

Definition at line 74 of file parser.h.


Constructor & Destructor Documentation

SourceText::SourceText (  )  [inline]

Default constructor.

Definition at line 78 of file parser.h.


Member Function Documentation

void SourceText::AppendFile ( const String name  ) 

Appends contents of file to the source text.

See also:
read_text_from_file

Definition at line 28 of file parser.cc.

char SourceText::Current (  )  [inline]

Return the current character.

Definition at line 85 of file parser.h.

void SourceText::AdvanceChar (  ) 

Advance position pointer by one character.

Sets mLineBreak if a line break occured.

Exceptions:
Eot The end of text is reached.

Definition at line 36 of file parser.cc.

void SourceText::AdvanceLine (  ) 

Advances position pointer by one line.

Exceptions:
Eot The end of the text is reached.

Definition at line 65 of file parser.cc.

const String & SourceText::File (  ) 

Return the filename associated with the current position.

Definition at line 87 of file parser.cc.

Index SourceText::Line (  ) 

Return the line number, but for the file that is associated with the current position.

Definition at line 102 of file parser.cc.

Index SourceText::Column (  )  [inline]

Return the current column.

Definition at line 108 of file parser.h.

void SourceText::Init (  ) 

This sets the pointer to the first existing character in the text.

(First few lines could be empty).

Definition at line 117 of file parser.cc.

bool& SourceText::LineBreak (  )  [inline]

Read the line break flag.

Set this to false before an operation that you want to monitor and check it afterwards.

Definition at line 116 of file parser.h.

bool SourceText::LineBreak (  )  const [inline]

Const version of LineBreak.

See also:
LineBreak

Definition at line 120 of file parser.h.


Friends And Related Function Documentation

ostream& operator<< ( ostream &  os,
const SourceText text 
) [friend]

Output operator for SourceText.

(Only used for debugging)

Definition at line 151 of file parser.cc.


Member Data Documentation

The text.

Definition at line 128 of file parser.h.

Line position in the text.

(0 based!)

Definition at line 131 of file parser.h.

Column position in the text.

(0 based!)

Definition at line 134 of file parser.h.

Remember where which source file starts.

Definition at line 137 of file parser.h.

Names associated with.

See also:
mSfLine.

Definition at line 140 of file parser.h.

bool SourceText::mLineBreak [private]

Is set to true if the last operation caused a line break.

Has to be cleared explicitly!

Definition at line 144 of file parser.h.


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

Generated on Wed Feb 4 08:17:36 2009 for ARTS by  doxygen 1.5.6