46 std::filesystem::path filepath{
_path };
47 if (filepath.is_relative())
70 if (j.contains(
"path"))
72 j.at(
"path").get_to(
_path);
89 if (!std::filesystem::exists(filepath))
91 LOG_ERROR(
"File does not exist {}", filepath);
94 if (std::filesystem::is_directory(filepath))
96 LOG_ERROR(
"Path is a directory {}", filepath);
105 _filestream = std::ifstream(filepath, std::ios_base::in | std::ios_base::binary);
114 LOG_ERROR(
"Could not open file {}", filepath);
126 LOG_DEBUG(
"ASCII-File successfully initialized");
130 LOG_DEBUG(
"Binary-File successfully initialized");
156 auto filestreamHeader = std::ifstream(filepath);
160 std::getline(filestreamHeader, line);
161 filestreamHeader.close();
163 auto n = std::ranges::count(line,
',');
173 LOG_ERROR(
"Could not open file {}", filepath.string());
189 line.erase(line.begin(), std::ranges::find_if(line, [](
int ch) { return std::isalnum(ch); }));
191 std::stringstream lineStream(line);
194 while (std::getline(lineStream, cell,
','))
197 cell.erase(std::ranges::find_if(cell, [](
int ch) {
return std::iscntrl(ch); }), cell.end());
Config management for the Project.
Abstract File Reader class.
nlohmann::json json
json namespace
Text Help Marker (?) with Tooltip.
Utility class for logging to console and file.
#define LOG_DEBUG
Debug information. Should not be called on functions which receive observations (spamming)
#define LOG_ERROR
Error occurred, which stops part of the program to work, but not everything.
#define LOG_TRACE
Detailled info to trace the execution of the program. Should not be called on functions which receive...
Utility functions for working with std::strings.
bool initialize()
Initialize the file reader.
void restore(const json &j)
Restores the node from a json object.
std::string _path
Path to the file.
FileType
File Type Enumeration.
std::ifstream _filestream
File stream to read the file.
FileType _fileType
File Type.
std::filesystem::path getFilepath()
Returns the path of the file.
GuiResult
Results enum for the gui config.
@ 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.
std::vector< std::string > _headerColumns
Header Columns of a CSV file.
virtual FileType determineFileType()
Virtual Function to determine the File Type.
GuiResult guiConfig(const char *vFilters, const std::vector< std::string > &extensions, size_t id, const std::string &nameId)
ImGui config.
void resetReader()
Moves the read cursor to the start.
auto & getline(std::string &str)
Reads a line from the filestream.
json save() const
Saves the node into a json object.
virtual void readHeader()
Virtual Function to read the Header of a file.
std::streampos _dataStart
Start of the data in the file.
size_t _lineCnt
Line counter.
size_t _lineCntDataStart
Line counter data start.
void deinitialize()
Deinitialize the file reader.
std::filesystem::path GetInputPath()
Get the path where data files are searched.