StringFileReader Class
Abstract base class for reading file contents into a string. More...
Declaration
Derived Classes
| class | BasicStringFileReader |
|
Basic implementation of a string file reader. More... | |
Public Constructors Index
| StringFileReader ()=default | |
Public Destructor Index
| ~StringFileReader ()=default | |
Public Member Functions Index
| std::string | getContents (const std::string &filename) const =0 |
|
Reads the entire contents of the file and returns them as a string. More... | |
| bool | readInto (const std::string &filename, std::string &contents) const noexcept=0 |
|
Attempts to read the entire contents of the file into the provided string. More... | |
Protected Static Attributes Index
| static const helios::util::log::Logger & | logger_ = helios::util::log::LogManager::loggerForScope(HELIOS_LOG_SCOPE) |
|
Shared logger instance for all StringFileReader objects. More... | |
Description
Abstract base class for reading file contents into a string.
Definition at line 22 of file StringFileReader.ixx.
Public Constructors
StringFileReader()
| default |
Default constructor.
Definition at line 37 of file StringFileReader.ixx.
Public Destructor
~StringFileReader()
| virtual default |
Definition at line 32 of file StringFileReader.ixx.
Public Member Functions
getContents()
| nodiscard |
Reads the entire contents of the file and returns them as a string.
- Parameters
-
filename The path to the file to read.
- Returns
The contents of the file as a std::string. If reading fails, an empty string is returned.
- Exceptions
-
std::runtime_error if the file operation fails.
Definition at line 47 of file StringFileReader.ixx.
readInto()
| nodiscard noexcept |
Attempts to read the entire contents of the file into the provided string.
- Parameters
-
filename The path to the file to read.
contents Output parameter receiving the file contents on success.
- Returns
true if reading succeeded and `contents` was populated, otherwise false.
Definition at line 56 of file StringFileReader.ixx.
Protected Static Attributes
logger_
| protected static |
Shared logger instance for all StringFileReader objects.
Definition at line 28 of file StringFileReader.ixx.
Referenced by helios::util::io::BasicStringFileReader::getContents and helios::util::io::BasicStringFileReader::readInto.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.