Skip to main content

StringFileReader Class

Abstract base class for reading file contents into a string. More...

Declaration

class helios::util::io::StringFileReader { ... }

Derived Classes

classBasicStringFileReader

Basic implementation of a string file reader. More...

Public Constructors Index

StringFileReader ()=default

Public Destructor Index

~StringFileReader ()=default

Public Member Functions Index

std::stringgetContents (const std::string &filename) const =0

Reads the entire contents of the file and returns them as a string. More...

boolreadInto (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()

helios::util::io::StringFileReader::StringFileReader ()
default

Default constructor.

Definition at line 37 of file StringFileReader.ixx.

Public Destructor

~StringFileReader()

virtual helios::util::io::StringFileReader::~StringFileReader ()
virtual default

Definition at line 32 of file StringFileReader.ixx.

Public Member Functions

getContents()

virtual std::string helios::util::io::StringFileReader::getContents (const std::string & filename)
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()

virtual bool helios::util::io::StringFileReader::readInto (const std::string & filename, std::string & contents)
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_

const helios::util::log::Logger& helios::util::io::StringFileReader::logger_ = helios::util::log::LogManager::loggerForScope(HELIOS_LOG_SCOPE)
protected static

The documentation for this class was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.