![]() |
NDEVR
API Documentation
|
Implentation of Scanner, however all data is cached. More...
Public Member Functions | |
| BufferedScanner (const File &file, char delimiter='|', File::OpenMode mode=File::e_ascii_read) | |
| Constructs a BufferedScanner from a file, reading and caching the entire contents. | |
| BufferedScanner (const StringView &string, char delimiter='|') | |
| Constructs a BufferedScanner from a string view, caching the contents for scanning. | |
| uint01 * | getByteArray () final override |
| Returns a pointer to the raw byte array at the current read position. | |
| bool | nextLine () final override |
| Advances the scanner to the next line in the buffered data. | |
| bool | nextLine (String &string, bool clear_string=true) final override |
| Advances to the next line and writes it into the provided string. | |
| void | setFilePosition (uint08 file_position, bool read_line=true) final override |
| Sets the current read position within the buffered data. | |
| Public Member Functions inherited from Scanner | |
| 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. | |
| 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. | |
| 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. | |
| 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 | |
| String | m_file_buffer |
| The entire file or string contents cached in memory. | |
| Buffer< uint04 > | m_new_lines |
| Indices of newline positions within the buffered data. | |
| Protected Attributes inherited from Scanner | |
| 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. | |
Implentation of Scanner, however all data is cached.
Faster, but consumes more memory.
Definition at line 43 of file BufferedScanner.h.
| BufferedScanner::BufferedScanner | ( | const File & | file, |
| char | delimiter = '|', | ||
| File::OpenMode | mode = File::e_ascii_read ) |
Constructs a BufferedScanner from a file, reading and caching the entire contents.
| [in] | file | The file to read and buffer. |
| [in] | delimiter | The character used to separate columns within a line. |
| [in] | mode | The file open mode to use when reading the file. |
References File::e_ascii_read, and Scanner::file().
|
explicit |
Constructs a BufferedScanner from a string view, caching the contents for scanning.
| [in] | string | The string view to buffer and scan. |
| [in] | delimiter | The character used to separate columns within a line. |
|
finaloverridevirtual |
Returns a pointer to the raw byte array at the current read position.
Reimplemented from Scanner.
References getByteArray().
Referenced by getByteArray().
|
finaloverridevirtual |
Advances the scanner to the next line in the buffered data.
Reimplemented from Scanner.
References nextLine().
|
finaloverridevirtual |
Advances to the next line and writes it into the provided string.
| [in] | string | The string to receive the next line content. |
| [in] | clear_string | Whether to clear the string before writing the line. |
Reimplemented from Scanner.
Referenced by ShaderTools::compileShader(), and nextLine().
|
finaloverridevirtual |
Sets the current read position within the buffered data.
| [in] | file_position | The byte offset to seek to within the buffered data. |
| [in] | read_line | Whether to immediately read a line at the new position. |
Reimplemented from Scanner.
References setFilePosition().
Referenced by setFilePosition().