Class FileReader
Defined in File file_reader.hpp
Class Documentation
-
class FileReader
Wrapper class for file reading operations. Tries to open a file in the constructor. Error handling strategy can be decided by means of the ErrorMode argument.
cxx::FileReader reader("filename"); std::string str; if(reader.isOpen()) { reader.readLine(str); } // Terminates program execution, if file cannot be opened (or found): cxx::FileReader reader("filename", "path/to/file", cxx::FileReader::ErrorMode::Terminate);
Public Types
Public Functions
-
FileReader(const std::string &f_fileName, const std::string &f_filePath = "", ErrorMode f_errorMode = ErrorMode::Inform) noexcept
Opens a file and creates a FileReader object. The file path argument is optional and is ignored if empty. The error mode is evaluated when an error occurs.
-
FileReader(const FileReader&) = delete
-
FileReader(FileReader&&) = delete
-
FileReader &operator=(const FileReader&) = delete
-
FileReader &operator=(FileReader&&) = delete
-
~FileReader() noexcept = default
-
bool isOpen() const noexcept
Check if the associated file is open.
-
bool readLine(std::string &f_string) noexcept
Read one line from the file and store the result in f_string.
-
FileReader(const std::string &f_fileName, const std::string &f_filePath = "", ErrorMode f_errorMode = ErrorMode::Inform) noexcept