ARTS
2.4.0(git:4fb77825)
|
A smart class to hold the text for parsing. More...
#include <sourcetext.h>
Public Member Functions | |
SourceText () | |
Default constructor. More... | |
void | AppendFile (const String &name) |
Appends contents of file to the source text. More... | |
char | Current () |
Return the current character. More... | |
bool | reachedEot () |
Check if the current position reached the end. More... | |
void | AdvanceChar () |
Advance position pointer by one character. More... | |
void | AdvanceLine () |
Advances position pointer by one line. More... | |
const String & | File () |
Return the filename associated with the current position. More... | |
Index | Line () |
Return the line number, but for the file that is associated with the current position. More... | |
Index | MarkedLine () |
Return the marked line number, but for the file that is associated with the current position. More... | |
Index | LineRaw () |
Return the line index. More... | |
Index | ColumnRaw () |
Return the column index. More... | |
Index | Column () |
Return the current column. More... | |
Index | MarkedColumn () |
Return the current marked column. More... | |
void | SetPosition (Index line, Index column) |
Set current position. More... | |
void | SetMark () |
Mark current position. More... | |
void | Init () |
This sets the pointer to the first existing character in the text. More... | |
bool & | LineBreak () |
Read the line break flag. More... | |
bool | LineBreak () const |
Const version of LineBreak. More... | |
Private Member Functions | |
Index | GetSourceLine (const Index line) |
Return the line number, but for the file that is associated with the given position. More... | |
Private Attributes | |
ArrayOfString | mText |
The text. More... | |
Index | mLine |
Line position in the text. More... | |
Index | mColumn |
Column position in the text. More... | |
Index | mMarkedLine |
Marked line position in the text. More... | |
Index | mMarkedColumn |
Marked column position in the text. More... | |
ArrayOfIndex | mSfLine |
Remember where which source file starts. More... | |
ArrayOfString | mSfName |
Names associated with. More... | |
bool | mLineBreak |
Is set to true if the last operation caused a line break. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const SourceText &text) |
Output operator for SourceText. More... | |
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.
Definition at line 36 of file sourcetext.h.
|
inline |
Default constructor.
Definition at line 39 of file sourcetext.h.
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 29 of file sourcetext.cc.
References Column(), File(), Line(), mColumn, mLine, mLineBreak, mText, Array< base >::nelem(), and Absorption::nelem().
Referenced by ArtsParser::eat_whitespace(), ArtsParser::find_named_arguments(), ArtsParser::parse_intvector(), ArtsParser::parse_matrix(), ArtsParser::parse_method(), ArtsParser::parse_method_args(), ArtsParser::parse_numvector(), ArtsParser::parse_String(), ArtsParser::parse_Stringvector(), ArtsParser::read_integer(), ArtsParser::read_name(), ArtsParser::read_numeric(), and ArtsParser::skip_to_next_argument().
void SourceText::AdvanceLine | ( | ) |
Advances position pointer by one line.
Eot | The end of the text is reached. |
Definition at line 48 of file sourcetext.cc.
References Column(), File(), Line(), mColumn, mLine, mLineBreak, mText, Array< base >::nelem(), and Absorption::nelem().
Referenced by ArtsParser::eat_whitespace(), and ArtsParser::skip_to_next_argument().
void SourceText::AppendFile | ( | const String & | name | ) |
Appends contents of file to the source text.
Definition at line 22 of file sourcetext.cc.
References mSfLine, mSfName, mText, Array< base >::nelem(), and read_text_from_file().
Referenced by ArtsParser::ArtsParser().
|
inline |
Return the current column.
Definition at line 89 of file sourcetext.h.
References mColumn.
Referenced by AdvanceChar(), AdvanceLine(), ArtsParser::at_end_of_argument(), Current(), ArtsParser::eat_whitespace(), ArtsParser::find_named_arguments(), Init(), ArtsParser::parse_agenda(), ArtsParser::parse_generic_input(), ArtsParser::parse_generic_output(), ArtsParser::parse_intvector_from_string(), ArtsParser::parse_main(), ArtsParser::parse_matrix(), ArtsParser::parse_method(), ArtsParser::parse_method_args(), ArtsParser::parse_numvector_from_string(), ArtsParser::parse_specific_input(), ArtsParser::parse_specific_output(), ArtsParser::parse_String(), ArtsParser::parse_stringarray_from_string(), ArtsParser::read_integer(), ArtsParser::read_name(), ArtsParser::read_name_or_value(), ArtsParser::read_numeric(), ArtsParser::set_gin_to_default(), ArtsParser::skip_to_next_argument(), and ArtsParser::tasklist_insert_set_delete().
|
inline |
Return the column index.
Definition at line 86 of file sourcetext.h.
References mColumn.
Referenced by ArtsParser::find_named_arguments(), ArtsParser::parse_method_args(), and ArtsParser::skip_to_next_argument().
|
inline |
Return the current character.
Definition at line 48 of file sourcetext.h.
References Column(), File(), Line(), mColumn, mLine, mText, and reachedEot().
Referenced by ArtsParser::at_end_of_argument(), ArtsParser::eat_whitespace(), ArtsParser::find_named_arguments(), ArtsParser::parse_agenda(), ArtsParser::parse_generic_input(), ArtsParser::parse_intvector(), ArtsParser::parse_matrix(), 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(), ArtsParser::read_numeric(), and ArtsParser::skip_to_next_argument().
const String & SourceText::File | ( | ) |
Return the filename associated with the current position.
Definition at line 60 of file sourcetext.cc.
References mLine, mSfLine, mSfName, and Array< base >::nelem().
Referenced by AdvanceChar(), AdvanceLine(), ArtsParser::at_end_of_argument(), Current(), ArtsParser::eat_whitespace(), ArtsParser::find_named_arguments(), Init(), ArtsParser::parse_agenda(), ArtsParser::parse_generic_input(), ArtsParser::parse_generic_output(), ArtsParser::parse_intvector_from_string(), ArtsParser::parse_main(), ArtsParser::parse_matrix(), ArtsParser::parse_method(), ArtsParser::parse_method_args(), ArtsParser::parse_numvector_from_string(), ArtsParser::parse_specific_input(), ArtsParser::parse_specific_output(), ArtsParser::parse_String(), ArtsParser::parse_stringarray_from_string(), ArtsParser::read_integer(), ArtsParser::read_name(), ArtsParser::read_name_or_value(), ArtsParser::read_numeric(), ArtsParser::set_gin_to_default(), ArtsParser::skip_to_next_argument(), and ArtsParser::tasklist_insert_set_delete().
Return the line number, but for the file that is associated with the given position.
Definition at line 93 of file sourcetext.cc.
References mSfLine, and Array< base >::nelem().
Referenced by Line(), and MarkedLine().
void SourceText::Init | ( | ) |
This sets the pointer to the first existing character in the text.
(First few lines could be empty).
Definition at line 74 of file sourcetext.cc.
References Column(), File(), Line(), mColumn, mLine, mLineBreak, mText, Array< base >::nelem(), and Absorption::nelem().
Referenced by ArtsParser::parse_main().
|
inline |
Return the line number, but for the file that is associated with the current position.
Definition at line 76 of file sourcetext.h.
References GetSourceLine(), and mLine.
Referenced by AdvanceChar(), AdvanceLine(), ArtsParser::at_end_of_argument(), Current(), ArtsParser::eat_whitespace(), ArtsParser::find_named_arguments(), Init(), ArtsParser::parse_agenda(), ArtsParser::parse_generic_input(), ArtsParser::parse_generic_output(), ArtsParser::parse_intvector_from_string(), ArtsParser::parse_main(), ArtsParser::parse_matrix(), ArtsParser::parse_method(), ArtsParser::parse_method_args(), ArtsParser::parse_numvector_from_string(), ArtsParser::parse_specific_input(), ArtsParser::parse_specific_output(), ArtsParser::parse_String(), ArtsParser::parse_stringarray_from_string(), ArtsParser::read_integer(), ArtsParser::read_name(), ArtsParser::read_name_or_value(), ArtsParser::read_numeric(), ArtsParser::set_gin_to_default(), ArtsParser::skip_to_next_argument(), and ArtsParser::tasklist_insert_set_delete().
|
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 112 of file sourcetext.h.
References mLineBreak.
Referenced by ArtsParser::parse_String(), ArtsParser::read_integer(), ArtsParser::read_name(), and ArtsParser::read_numeric().
|
inline |
Const version of LineBreak.
Definition at line 116 of file sourcetext.h.
References mLineBreak.
|
inline |
Return the line index.
Definition at line 83 of file sourcetext.h.
References mLine.
Referenced by ArtsParser::find_named_arguments(), ArtsParser::parse_method_args(), and ArtsParser::skip_to_next_argument().
|
inline |
Return the current marked column.
Definition at line 92 of file sourcetext.h.
References mMarkedColumn.
Referenced by ArtsParser::parse_method_args().
|
inline |
Return the marked line number, but for the file that is associated with the current position.
Definition at line 80 of file sourcetext.h.
References GetSourceLine(), and mMarkedLine.
Referenced by ArtsParser::parse_method_args().
|
inline |
Check if the current position reached the end.
Definition at line 55 of file sourcetext.h.
References mColumn, mLine, mText, and Array< base >::nelem().
Referenced by Current(), and ArtsParser::parse_main().
|
inline |
Mark current position.
Definition at line 101 of file sourcetext.h.
References mColumn, mLine, mMarkedColumn, and mMarkedLine.
Referenced by ArtsParser::parse_method().
Set current position.
Definition at line 95 of file sourcetext.h.
References mColumn, and mLine.
Referenced by ArtsParser::parse_generic_input(), ArtsParser::parse_generic_output(), ArtsParser::parse_method_args(), ArtsParser::parse_specific_input(), ArtsParser::parse_specific_output(), and ArtsParser::skip_to_next_argument().
|
friend |
Output operator for SourceText.
(Only used for debugging)
Definition at line 107 of file sourcetext.cc.
|
private |
Column position in the text.
(0 based!)
Definition at line 133 of file sourcetext.h.
Referenced by AdvanceChar(), AdvanceLine(), Column(), ColumnRaw(), Current(), Init(), reachedEot(), SetMark(), and SetPosition().
|
private |
Line position in the text.
(0 based!)
Definition at line 130 of file sourcetext.h.
Referenced by AdvanceChar(), AdvanceLine(), Current(), File(), Init(), Line(), LineRaw(), reachedEot(), SetMark(), and SetPosition().
|
private |
Is set to true if the last operation caused a line break.
Has to be cleared explicitly!
Definition at line 149 of file sourcetext.h.
Referenced by AdvanceChar(), AdvanceLine(), Init(), and LineBreak().
|
private |
Marked column position in the text.
(0 based!)
Definition at line 139 of file sourcetext.h.
Referenced by MarkedColumn(), and SetMark().
|
private |
Marked line position in the text.
(0 based!)
Definition at line 136 of file sourcetext.h.
Referenced by MarkedLine(), and SetMark().
|
private |
Remember where which source file starts.
Definition at line 142 of file sourcetext.h.
Referenced by AppendFile(), File(), and GetSourceLine().
|
private |
Names associated with.
Definition at line 145 of file sourcetext.h.
Referenced by AppendFile(), and File().
|
private |
The text.
Definition at line 127 of file sourcetext.h.
Referenced by AdvanceChar(), AdvanceLine(), AppendFile(), Current(), Init(), operator<<(), and reachedEot().