#include <sourcetext.h>
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 String & | File () |
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. |
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.
Definition at line 36 of file sourcetext.h.
SourceText::SourceText | ( | ) | [inline] |
void SourceText::AppendFile | ( | const String & | name | ) |
Appends contents of file to the source text.
Definition at line 24 of file sourcetext.cc.
References mSfLine, mSfName, mText, Array< base >::nelem(), and read_text_from_file().
Referenced by ArtsParser::ArtsParser().
char SourceText::Current | ( | ) | [inline] |
Return the current character.
Definition at line 47 of file sourcetext.h.
References mColumn, mLine, and mText.
Referenced by ArtsParser::assertain_character(), ArtsParser::eat_whitespace(), ArtsParser::parse_agenda(), ArtsParser::parse_generic_input(), ArtsParser::parse_intvector(), ArtsParser::parse_method(), ArtsParser::parse_method_args(), ArtsParser::parse_numvector(), ArtsParser::parse_String(), ArtsParser::parse_Stringvector(), ArtsParser::read_integer(), ArtsParser::read_name(), ArtsParser::read_name_or_value(), and ArtsParser::read_numeric().
void SourceText::AdvanceChar | ( | ) |
Advance position pointer by one character.
Sets mLineBreak if a line break occured.
Eot | The end of text is reached. |
Definition at line 33 of file sourcetext.cc.
References Column(), File(), Line(), mColumn, mLine, mLineBreak, mText, and Array< base >::nelem().
Referenced by ArtsParser::assertain_character(), ArtsParser::eat_whitespace(), ArtsParser::parse_intvector(), ArtsParser::parse_method(), ArtsParser::parse_method_args(), ArtsParser::parse_numvector(), ArtsParser::parse_String(), ArtsParser::parse_Stringvector(), ArtsParser::read_integer(), ArtsParser::read_name(), and ArtsParser::read_numeric().
void SourceText::AdvanceLine | ( | ) |
Advances position pointer by one line.
Eot | The end of the text is reached. |
Definition at line 62 of file sourcetext.cc.
References Column(), File(), Line(), mColumn, mLine, mLineBreak, mText, and Array< base >::nelem().
Referenced by ArtsParser::eat_whitespace().
const String & SourceText::File | ( | ) |
Return the filename associated with the current position.
Definition at line 84 of file sourcetext.cc.
References mLine, mSfLine, mSfName, and Array< base >::nelem().
Referenced by AdvanceChar(), AdvanceLine(), ArtsParser::assertain_character(), ArtsParser::eat_whitespace(), Init(), ArtsParser::parse_agenda(), ArtsParser::parse_generic_input(), ArtsParser::parse_generic_output(), ArtsParser::parse_method(), ArtsParser::parse_method_args(), ArtsParser::parse_specific_input(), ArtsParser::parse_specific_output(), ArtsParser::parse_String(), ArtsParser::read_integer(), ArtsParser::read_name(), ArtsParser::read_name_or_value(), ArtsParser::read_numeric(), ArtsParser::set_gin_to_default(), and ArtsParser::tasklist_insert_set_delete().
Index SourceText::Line | ( | ) |
Return the line number, but for the file that is associated with the current position.
Definition at line 99 of file sourcetext.cc.
References mLine, mSfLine, and Array< base >::nelem().
Referenced by AdvanceChar(), AdvanceLine(), ArtsParser::assertain_character(), ArtsParser::eat_whitespace(), Init(), ArtsParser::parse_generic_input(), ArtsParser::parse_generic_output(), ArtsParser::parse_method(), ArtsParser::parse_method_args(), ArtsParser::parse_specific_input(), ArtsParser::parse_specific_output(), ArtsParser::parse_String(), ArtsParser::read_integer(), ArtsParser::read_name(), ArtsParser::read_name_or_value(), ArtsParser::read_numeric(), ArtsParser::set_gin_to_default(), and ArtsParser::tasklist_insert_set_delete().
Index SourceText::Column | ( | ) | [inline] |
Return the current column.
Definition at line 70 of file sourcetext.h.
References mColumn.
Referenced by AdvanceChar(), AdvanceLine(), ArtsParser::assertain_character(), ArtsParser::eat_whitespace(), Init(), ArtsParser::parse_generic_input(), ArtsParser::parse_generic_output(), ArtsParser::parse_method(), ArtsParser::parse_method_args(), ArtsParser::parse_specific_input(), ArtsParser::parse_specific_output(), ArtsParser::parse_String(), ArtsParser::read_integer(), ArtsParser::read_name(), ArtsParser::read_name_or_value(), ArtsParser::read_numeric(), ArtsParser::set_gin_to_default(), and ArtsParser::tasklist_insert_set_delete().
void SourceText::Init | ( | ) |
This sets the pointer to the first existing character in the text.
(First few lines could be empty).
Definition at line 114 of file sourcetext.cc.
References Column(), File(), Line(), mColumn, mLine, mLineBreak, mText, and Array< base >::nelem().
Referenced by ArtsParser::parse_main().
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 78 of file sourcetext.h.
References mLineBreak.
Referenced by ArtsParser::parse_String(), ArtsParser::read_integer(), ArtsParser::read_name(), and ArtsParser::read_numeric().
bool SourceText::LineBreak | ( | ) | const [inline] |
Const version of LineBreak.
Definition at line 82 of file sourcetext.h.
References mLineBreak.
ostream& operator<< | ( | ostream & | os, | |
const SourceText & | text | |||
) | [friend] |
Output operator for SourceText.
(Only used for debugging)
Definition at line 148 of file sourcetext.cc.
ArrayOfString SourceText::mText [private] |
The text.
Definition at line 90 of file sourcetext.h.
Referenced by AdvanceChar(), AdvanceLine(), AppendFile(), Current(), Init(), and operator<<().
Index SourceText::mLine [private] |
Line position in the text.
(0 based!)
Definition at line 93 of file sourcetext.h.
Referenced by AdvanceChar(), AdvanceLine(), Current(), File(), Init(), and Line().
Index SourceText::mColumn [private] |
Column position in the text.
(0 based!)
Definition at line 96 of file sourcetext.h.
Referenced by AdvanceChar(), AdvanceLine(), Column(), Current(), and Init().
ArrayOfIndex SourceText::mSfLine [private] |
Remember where which source file starts.
Definition at line 99 of file sourcetext.h.
Referenced by AppendFile(), File(), and Line().
ArrayOfString SourceText::mSfName [private] |
Names associated with.
Definition at line 102 of file sourcetext.h.
Referenced by AppendFile(), and File().
bool SourceText::mLineBreak [private] |
Is set to true if the last operation caused a line break.
Has to be cleared explicitly!
Definition at line 106 of file sourcetext.h.
Referenced by AdvanceChar(), AdvanceLine(), Init(), and LineBreak().