Abstract File Reader class.
More...
|
| FileReader (const FileReader &)=delete |
| Copy constructor.
|
|
| FileReader (FileReader &&)=delete |
| Move constructor.
|
|
FileReader & | operator= (const FileReader &)=delete |
| Copy assignment operator.
|
|
FileReader & | operator= (FileReader &&)=delete |
| Move assignment operator.
|
|
virtual | ~FileReader ()=default |
| Destructor.
|
|
|
void | deinitialize () |
| Deinitialize the file reader.
|
|
virtual FileType | determineFileType () |
| Virtual Function to determine the File Type.
|
|
auto | eof () const |
| Check whether the end of file is reached.
|
|
| FileReader ()=default |
| Default constructor.
|
|
size_t | getCurrentLineNumber () const |
| Get the current line number.
|
|
std::filesystem::path | getFilepath () |
| Returns the path of the file.
|
|
auto & | getline (std::string &str) |
| Reads a line from the filestream.
|
|
bool | good () const |
| Fast error checking.
|
|
GuiResult | guiConfig (const char *vFilters, const std::vector< std::string > &extensions, size_t id, const std::string &nameId) |
| ImGui config.
|
|
auto & | ignore (std::streamsize count, int delim) |
| Extracts and discards characters from the input stream until and including delim.
|
|
bool | initialize () |
| Initialize the file reader.
|
|
auto | peek () |
| Looking ahead in the stream.
|
|
auto & | read (char *__s, std::streamsize __n) |
| Extraction without delimiters.
|
|
virtual void | readHeader () |
| Virtual Function to read the Header of a file.
|
|
auto | readsome (char *s, std::streamsize count) |
| Extracts up to count immediately available characters from the input stream. The extracted characters are stored into the character array pointed to by s.
|
|
void | resetReader () |
| Moves the read cursor to the start.
|
|
void | restore (const json &j) |
| Restores the node from a json object.
|
|
json | save () const |
| Saves the node into a json object.
|
|
auto & | seekg (std::streamoff pos, std::ios_base::seekdir dir) |
| Changing the current read position.
|
|
std::streampos | tellg () |
| Getting the current read position.
|
|
|
FileType | _fileType |
| File Type.
|
|
std::vector< std::string > | _headerColumns |
| Header Columns of a CSV file.
|
|
std::string | _path |
| Path to the file.
|
|
Abstract File Reader class.
◆ FileType
File Type Enumeration.
Enumerator |
---|
NONE | Not specified.
|
BINARY | Binary data.
|
ASCII | Ascii text data.
|
◆ GuiResult
Results enum for the gui config.
Enumerator |
---|
PATH_UNCHANGED | No changes made.
|
PATH_CHANGED | The path changed and exists.
|
PATH_CHANGED_INVALID | The path changed but does not exist or is invalid.
|
◆ determineFileType()
virtual FileType NAV::FileReader::determineFileType |
( |
| ) |
|
|
protectedvirtual |
Virtual Function to determine the File Type.
- Returns
- The File path which was recognized
◆ getline()
auto & NAV::FileReader::getline |
( |
std::string & | str | ) |
|
|
inlineprotected |
Reads a line from the filestream.
- Parameters
-
str | String to read the line into |
◆ good()
bool NAV::FileReader::good |
( |
| ) |
const |
|
inlineprotected |
Fast error checking.
- Returns
- True if no error flags are set. A wrapper around rdstate.
◆ guiConfig()
GuiResult NAV::FileReader::guiConfig |
( |
const char * | vFilters, |
|
|
const std::vector< std::string > & | extensions, |
|
|
size_t | id, |
|
|
const std::string & | nameId ) |
|
protected |
ImGui config.
- Parameters
-
[in] | vFilters | Filter to apply for file names |
[in] | extensions | Extensions to filter |
[in] | id | Unique id for creating the dialog uid |
[in] | nameId | Name of the node triggering the window used for logging |
- Returns
- True if changes occurred
◆ ignore()
auto & NAV::FileReader::ignore |
( |
std::streamsize | count, |
|
|
int | delim ) |
|
inlineprotected |
Extracts and discards characters from the input stream until and including delim.
- Parameters
-
count | number of characters to extract |
delim | delimiting character to stop the extraction at. It is also extracted. |
- Returns
- The filestream
◆ peek()
auto NAV::FileReader::peek |
( |
| ) |
|
|
inlineprotected |
Looking ahead in the stream.
- Returns
- The next character, or eof(). If, after constructing the sentry object, good() is false, returns traits::eof(). Otherwise reads but does not extract the next input character.
◆ read()
auto & NAV::FileReader::read |
( |
char * | __s, |
|
|
std::streamsize | __n ) |
|
inlineprotected |
Extraction without delimiters.
- Parameters
-
__s | A character array. |
__n | Maximum number of characters to store. |
- Returns
- The filestream if the stream state is good(), extracts characters and stores them into __s until one of the following happens: - __n characters are stored - the input sequence reaches end-of-file, in which case the error state is set to failbit|eofbit.
- Note
- This function is not overloaded on signed char and unsigned char.
◆ readHeader()
virtual void NAV::FileReader::readHeader |
( |
| ) |
|
|
protectedvirtual |
Virtual Function to read the Header of a file.
The base implementation reads a CSV file header
- Attention
- If your file does not have a header, this functions needs to be overridden with an empty function
◆ readsome()
auto NAV::FileReader::readsome |
( |
char * | s, |
|
|
std::streamsize | count ) |
|
inlineprotected |
Extracts up to count immediately available characters from the input stream. The extracted characters are stored into the character array pointed to by s.
- Parameters
-
[out] | s | pointer to the character array to store the characters to |
[in] | count | maximum number of characters to read |
- Returns
- The number of characters actually extracted.
◆ restore()
void NAV::FileReader::restore |
( |
const json & | j | ) |
|
|
protected |
Restores the node from a json object.
- Parameters
-
[in] | j | Json object with the node state |
◆ seekg()
auto & NAV::FileReader::seekg |
( |
std::streamoff | pos, |
|
|
std::ios_base::seekdir | dir ) |
|
inlineprotected |
Changing the current read position.
- Parameters
-
pos | A file offset object. |
dir | The direction in which to seek. |
- Returns
- The filestream if fail() is not true, calls rdbuf()->pubseekoff(__off,__dir). If that function fails, sets failbit.
- Note
- This function first clears eofbit. It does not count the number of characters extracted, if any, and therefore does not affect the next call to gcount().
◆ tellg()
std::streampos NAV::FileReader::tellg |
( |
| ) |
|
|
inlineprotected |
Getting the current read position.
- Returns
- A file position object. If fail() is not false, returns pos_type(-1) to indicate failure. Otherwise returns rdbuf()->pubseekoff(0,cur,in).
- Note
- This function does not count the number of characters extracted, if any, and therefore does not affect the next call to gcount(). At variance with putback, unget and seekg, eofbit is not cleared first.
The documentation for this class was generated from the following file:
- /home/runner/work/INSTINCT/INSTINCT/src/Nodes/DataProvider/Protocol/FileReader.hpp