34#include <NDEVR/File.h>
35#include <NDEVR/String.h>
146 bool skipTo(
char location,
bool ignore_case =
false);
160 bool skipTo(
const char* location,
bool ignore_case =
false);
199 template<
class t_type>
206 template<
class t_type>
233 template<
class t_type>
241 template<
class t_type>
261 template<
class t_type>
The equivelent of std::vector but with a bit more control.
Logic for reading or writing to a file as well as navigating filesystems or other common file operati...
OpenMode
Specifies the mode in which a file is opened.
@ e_ascii_read
Open for ASCII text reading.
virtual uint01 * getByteArray()
Returns a pointer to the raw byte array at the current line position.
uint04 getLineLength() const
Returns the length of the current line.
bool m_ignore_empty_lines
Whether to skip empty lines when advancing.
uint04 m_cur_line_pos
The current character index within the current line.
bool m_ignore_white_space
Whether to skip leading whitespace when reading tokens.
char quoteCharacter() const
Returns the current quote character.
virtual bool nextLine(String &string, bool clear_string=true)
Advances to the next line and stores it in the provided string.
bool skipTo(const Buffer< char > &locations, bool ignore_case=false)
Skips forward until one of the specified characters is found.
t_type getNextHex()
Reads the next token as a hexadecimal value and returns it as the specified type.
void setIgnoreEmptyLines(bool ignore_new_lines)
Sets whether empty lines should be skipped when reading.
Scanner(const StringView &string, char delimiter='|')
Constructs a Scanner that reads from a string view.
virtual void setFilePosition(uint08 file_position, bool read_line=true)
Sets the file read position to the specified byte offset.
File m_file
The file being read, if constructed from a file.
uint08 m_data_size
The total size of the data source in bytes.
void moveForward(uint04 distance=1)
Moves the line position forward by the specified distance.
uint08 getCurrentFilePosition()
Returns the current byte position within the file.
Scanner(const String &string, char delimiter='|')
Constructs a Scanner that reads from a string.
bool skipTo(char location, bool ignore_case=false)
Skips forward until the specified character is found.
void setHasDelimiter(const bool has_delimiter)
Sets whether the scanner expects delimiters between tokens.
char m_delimiter
The delimiter character used to separate tokens.
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.
StringView getNext()
Reads and returns the next token as a StringView.
void setIgnoreWhiteSpace(bool ignore_white_space)
Sets whether leading whitespace should be ignored when reading tokens.
uint08 m_current_file_position
The current byte offset within the file.
File file() const
Returns the file associated with this scanner.
uint08 dataSize() const
Returns the total size of the data source in bytes.
const String & currentLine() const
Returns a const reference to the current line being parsed.
void setQuoteCharacter(char quote_character)
Sets the character used to denote quoted strings.
uint04 m_cur_column
The current column index for column-based reading.
void setDelimiter(char delimiter)
Sets the delimiter character used to separate tokens.
String m_current_line
The contents of the current line being parsed.
t_type getColumn(uint04 column)
Skips to the specified column index and returns the token there as the specified type.
bool m_has_delimiter
Whether the scanner expects delimiters between tokens.
bool hasNext() const
Checks whether there are more tokens available on the current line.
uint04 skipWhiteSpace()
Skips over any whitespace characters at the current position.
bool skipTo(const char *location, bool ignore_case=false)
Skips forward until the specified string is found.
virtual ~Scanner()
Destructor.
const char * getCurrent() const
Returns a pointer to the current character position in the line.
virtual bool nextLine()
Advances the scanner to the next line in the stream.
fltp04 getFilePercent()
Returns the percentage of the file that has been read.
Scanner(const File &file, char delimiter='|', File::OpenMode mode=File::e_ascii_read)
Constructs a Scanner that reads from a file.
String & currentLine()
Returns a mutable reference to the current line being parsed.
String m_time_format
The format string used for parsing time values.
t_type getNext(uint04 count)
Reads the next token of a fixed character count and returns it as the specified type.
uint04 m_current_line_size
The length of the current line in characters.
uint04 & linePosition()
Returns a mutable reference to the current position within the line.
uint04 skip()
Skips the current token and advances to the next delimiter.
TranslatedString getDebugPosition() const
Returns a human-readable string describing the current file and line position for debugging.
uint08 getCurrentLineNumber() const
Returns the current line number in the stream.
uint08 m_current_line_number
The current one-based line number in the stream.
void resetLinePosition()
Resets the line position back to the beginning of the current line.
char m_quote_character
The character used to denote quoted strings.
t_type peekNext()
Peeks at the next token without advancing the read position.
bool isComment(char comment) const
Checks if the current line begins with a comment character.
The core String View class for the NDEVR API.
t_type getAs() const
Converts a string into an object.
The core String class for the NDEVR API.
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
The primary namespace for the NDEVR SDK.
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...