![]() |
NDEVR
API Documentation
|
Contains methods for easily reading objects in an ascii stream using set deliminators and line logic. More...
Public Member Functions | |
| Scanner (const File &file, char delimiter='|', File::OpenMode mode=File::e_ascii_read) | |
| Constructs a Scanner that reads from a file. | |
| Scanner (const String &string, char delimiter='|') | |
| Constructs a Scanner that reads from a string. | |
| Scanner (const StringView &string, char delimiter='|') | |
| Constructs a Scanner that reads from a string view. | |
| virtual | ~Scanner () |
| Destructor. | |
| String & | currentLine () |
| Returns a mutable reference to the current line being parsed. | |
| const String & | currentLine () const |
| Returns a const reference to the current line being parsed. | |
| uint08 | dataSize () const |
| Returns the total size of the data source in bytes. | |
| File | file () const |
| Returns the file associated with this scanner. | |
| virtual uint01 * | getByteArray () |
| Returns a pointer to the raw byte array at the current line position. | |
| template<class t_type> | |
| t_type | getColumn (uint04 column) |
| Skips to the specified column index and returns the token there as the specified type. | |
| const char * | getCurrent () const |
| Returns a pointer to the current character position in the line. | |
| uint08 | getCurrentFilePosition () |
| Returns the current byte position within the file. | |
| uint08 | getCurrentLineNumber () const |
| Returns the current line number in the stream. | |
| TranslatedString | getDebugPosition () const |
| Returns a human-readable string describing the current file and line position for debugging. | |
| fltp04 | getFilePercent () |
| Returns the percentage of the file that has been read. | |
| uint04 | getLineLength () const |
| Returns the length of the current line. | |
| StringView | getNext () |
| Reads and returns the next token as a StringView. | |
| template<class t_type> | |
| t_type | getNext () |
| Reads and returns the next token parsed as the specified type. | |
| void | getNext (String &next) |
| Reads the next token and stores it in the provided string. | |
| template<class t_type> | |
| t_type | getNext (uint04 count) |
| Reads the next token of a fixed character count and returns it as the specified type. | |
| template<class t_type> | |
| t_type | getNextHex () |
| Reads the next token as a hexadecimal value and returns it as the specified type. | |
| bool | hasNext () const |
| Checks whether there are more tokens available on the current line. | |
| bool | isComment (char comment) const |
| Checks if the current line begins with a comment character. | |
| uint04 & | linePosition () |
| Returns a mutable reference to the current position within the line. | |
| void | moveForward (uint04 distance=1) |
| Moves the line position forward by the specified distance. | |
| virtual bool | nextLine () |
| Advances the scanner to the next line in the stream. | |
| virtual bool | nextLine (String &string, bool clear_string=true) |
| Advances to the next line and stores it in the provided string. | |
| template<class t_type> | |
| t_type | peekNext () |
| Peeks at the next token without advancing the read position. | |
| char | quoteCharacter () const |
| Returns the current quote character. | |
| void | resetLinePosition () |
| Resets the line position back to the beginning of the current line. | |
| void | setDelimiter (char delimiter) |
| Sets the delimiter character used to separate tokens. | |
| virtual void | setFilePosition (uint08 file_position, bool read_line=true) |
| Sets the file read position to the specified byte offset. | |
| void | setHasDelimiter (const bool has_delimiter) |
| Sets whether the scanner expects delimiters between tokens. | |
| void | setIgnoreEmptyLines (bool ignore_new_lines) |
| Sets whether empty lines should be skipped when reading. | |
| void | setIgnoreWhiteSpace (bool ignore_white_space) |
| Sets whether leading whitespace should be ignored when reading tokens. | |
| void | setQuoteCharacter (char quote_character) |
| Sets the character used to denote quoted strings. | |
| uint04 | skip () |
| Skips the current token and advances to the next delimiter. | |
| bool | skipTo (char location, bool ignore_case=false) |
| Skips forward until the specified character is found. | |
| bool | skipTo (const Buffer< char > &locations, bool ignore_case=false) |
| Skips forward until one of the specified characters is found. | |
| bool | skipTo (const char *location, bool ignore_case=false) |
| Skips forward until the specified string is found. | |
| uint04 | skipWhiteSpace () |
| Skips over any whitespace characters at the current position. | |
Protected Attributes | |
| uint04 | m_cur_column |
| The current column index for column-based reading. | |
| uint04 | m_cur_line_pos |
| The current character index within the current line. | |
| uint08 | m_current_file_position |
| The current byte offset within the file. | |
| String | m_current_line |
| The contents of the current line being parsed. | |
| uint08 | m_current_line_number |
| The current one-based line number in the stream. | |
| uint04 | m_current_line_size |
| The length of the current line in characters. | |
| uint08 | m_data_size |
| The total size of the data source in bytes. | |
| char | m_delimiter |
| The delimiter character used to separate tokens. | |
| File | m_file |
| The file being read, if constructed from a file. | |
| bool | m_has_delimiter |
| Whether the scanner expects delimiters between tokens. | |
| bool | m_ignore_empty_lines |
| Whether to skip empty lines when advancing. | |
| bool | m_ignore_white_space = false |
| Whether to skip leading whitespace when reading tokens. | |
| char | m_quote_character |
| The character used to denote quoted strings. | |
| String | m_time_format |
| The format string used for parsing time values. | |
Contains methods for easily reading objects in an ascii stream using set deliminators and line logic.
|
explicit |
Constructs a Scanner that reads from a file.
| [in] | file | The file to read from. |
| [in] | delimiter | The character used to separate tokens on a line. |
| [in] | mode | The file open mode to use when opening the file. |
References File::e_ascii_read, and file().
|
explicit |
Constructs a Scanner that reads from a string view.
| [in] | string | The string view to parse. |
| [in] | delimiter | The character used to separate tokens. |
|
explicit |
Constructs a Scanner that reads from a string.
| [in] | string | The string to parse. |
| [in] | delimiter | The character used to separate tokens. |
|
inline |
Returns a mutable reference to the current line being parsed.
Definition at line 113 of file Scanner.h.
References m_current_line.
|
inline |
Returns a const reference to the current line being parsed.
Definition at line 108 of file Scanner.h.
References m_current_line.
Referenced by BoilerMaker::boiler(), ShaderTools::compileShader(), TranslationTools::processString(), and TranslationTools::setupFile().
| uint08 Scanner::dataSize | ( | ) | const |
Returns the total size of the data source in bytes.
|
inline |
|
inlinevirtual |
Returns a pointer to the raw byte array at the current line position.
Reimplemented in BufferedScanner.
Definition at line 302 of file Scanner.h.
References m_cur_line_pos, and m_current_line.
|
inline |
Skips to the specified column index and returns the token there as the specified type.
| [in] | column | The zero-based column index to retrieve. |
Definition at line 262 of file Scanner.h.
References getNext(), m_cur_column, m_cur_line_pos, and skip().
| const char * Scanner::getCurrent | ( | ) | const |
Returns a pointer to the current character position in the line.
| uint08 Scanner::getCurrentFilePosition | ( | ) |
Returns the current byte position within the file.
| uint08 Scanner::getCurrentLineNumber | ( | ) | const |
Returns the current line number in the stream.
| TranslatedString Scanner::getDebugPosition | ( | ) | const |
Returns a human-readable string describing the current file and line position for debugging.
| fltp04 Scanner::getFilePercent | ( | ) |
Returns the percentage of the file that has been read.
| uint04 Scanner::getLineLength | ( | ) | const |
Returns the length of the current line.
| StringView Scanner::getNext | ( | ) |
Reads and returns the next token as a StringView.
| t_type Scanner::getNext | ( | ) |
Reads and returns the next token parsed as the specified type.
Referenced by getColumn(), and peekNext().
| void Scanner::getNext | ( | String & | next | ) |
Reads the next token and stores it in the provided string.
| [in] | next | The string to receive the next token. |
|
inline |
Reads the next token of a fixed character count and returns it as the specified type.
| [in] | count | The number of characters to read. |
Definition at line 242 of file Scanner.h.
References StringView::getAs(), m_cur_line_pos, and m_current_line.
| t_type Scanner::getNextHex | ( | ) |
Reads the next token as a hexadecimal value and returns it as the specified type.
| bool Scanner::hasNext | ( | ) | const |
Checks whether there are more tokens available on the current line.
| bool Scanner::isComment | ( | char | comment | ) | const |
Checks if the current line begins with a comment character.
| [in] | comment | The character that denotes a comment line. |
|
inline |
Returns a mutable reference to the current position within the line.
Definition at line 179 of file Scanner.h.
References m_cur_line_pos.
| void Scanner::moveForward | ( | uint04 | distance = 1 | ) |
Moves the line position forward by the specified distance.
| [in] | distance | The number of characters to advance. |
|
virtual |
Advances the scanner to the next line in the stream.
Reimplemented in BufferedScanner.
Referenced by BoilerMaker::boiler(), TranslationTools::processString(), and TranslationTools::setupFile().
|
virtual |
Advances to the next line and stores it in the provided string.
| [in] | string | The string to receive the next line content. |
| [in] | clear_string | Whether to clear the string before writing to it. |
Reimplemented in BufferedScanner.
|
inline |
Peeks at the next token without advancing the read position.
Definition at line 207 of file Scanner.h.
References getNext(), m_cur_column, and m_cur_line_pos.
|
inline |
Returns the current quote character.
Definition at line 189 of file Scanner.h.
References m_quote_character.
| void Scanner::setDelimiter | ( | char | delimiter | ) |
Sets the delimiter character used to separate tokens.
| [in] | delimiter | The new delimiter character. |
|
virtual |
Sets the file read position to the specified byte offset.
| [in] | file_position | The byte offset to seek to. |
| [in] | read_line | Whether to immediately read the next line after seeking. |
Reimplemented in BufferedScanner.
|
inline |
Sets whether the scanner expects delimiters between tokens.
| [in] | has_delimiter | True if delimiters are present between tokens. |
Definition at line 174 of file Scanner.h.
References m_has_delimiter.
|
inline |
Sets whether empty lines should be skipped when reading.
| [in] | ignore_new_lines | True to skip empty lines automatically. |
Definition at line 285 of file Scanner.h.
References m_ignore_empty_lines.
|
inline |
Sets whether leading whitespace should be ignored when reading tokens.
| [in] | ignore_white_space | True to skip leading whitespace. |
Definition at line 290 of file Scanner.h.
References m_ignore_white_space.
|
inline |
Sets the character used to denote quoted strings.
| [in] | quote_character | The quote character to use. |
Definition at line 184 of file Scanner.h.
References m_quote_character.
| uint04 Scanner::skip | ( | ) |
Skips the current token and advances to the next delimiter.
Referenced by getColumn().
| bool Scanner::skipTo | ( | char | location, |
| bool | ignore_case = false ) |
Skips forward until the specified character is found.
| [in] | location | The character to search for. |
| [in] | ignore_case | Whether to perform a case-insensitive search. |
| bool Scanner::skipTo | ( | const Buffer< char > & | locations, |
| bool | ignore_case = false ) |
Skips forward until one of the specified characters is found.
| [in] | locations | A buffer of characters to search for. |
| [in] | ignore_case | Whether to perform a case-insensitive search. |
| bool Scanner::skipTo | ( | const char * | location, |
| bool | ignore_case = false ) |
Skips forward until the specified string is found.
| [in] | location | The string to search for. |
| [in] | ignore_case | Whether to perform a case-insensitive search. |
| uint04 Scanner::skipWhiteSpace | ( | ) |
Skips over any whitespace characters at the current position.