Skip to main content

StringFileReader.ixx File

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

Included Headers

#include <string> #include <helios.util.log.LogManager> #include <helios.util.log.Logger>

Namespaces Index

namespacehelios
namespaceutil

Utility functions and helper classes. More...

namespaceio

Input/output utilities. More...

Classes Index

classStringFileReader

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

Macro Definitions Index

#defineHELIOS_LOG_SCOPE   "helios::util::io.FileReader"

Description

Abstract base class for reading file contents into a string.

Macro Definitions

HELIOS_LOG_SCOPE

#define HELIOS_LOG_SCOPE   "helios::util::io.FileReader"

Definition at line 14 of file StringFileReader.ixx.

14#define HELIOS_LOG_SCOPE "helios::util::io.FileReader"

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file StringFileReader.ixx
3 * @brief Abstract base class for reading file contents into a string.
4 */
5module;
6
7#include <string>
8
9export module helios.util.io.StringFileReader;
10
11import helios.util.log.Logger;
12import helios.util.log.LogManager;
13
14#define HELIOS_LOG_SCOPE "helios::util::io.FileReader"
15export namespace helios::util::io {
16
17
18 /**
19 * @brief Abstract base class for reading file contents into a string.
20 *
21 */
23
24 protected:
25 /**
26 * @brief Shared logger instance for all StringFileReader objects.
27 */
29
30
31 public:
32 virtual ~StringFileReader() = default;
33
34 /**
35 * Default constructor.
36 */
37 StringFileReader() = default;
38
39 /**
40 * @brief Reads the entire contents of the file and returns them as a string.
41 *
42 * @param filename The path to the file to read.
43 * @return The contents of the file as a std::string. If reading fails, an empty string is returned.
44 *
45 * @throws std::runtime_error if the file operation fails.
46 */
47 [[nodiscard]] virtual std::string getContents(const std::string& filename) const = 0;
48
49 /**
50 * @brief Attempts to read the entire contents of the file into the provided string.
51 *
52 * @param filename The path to the file to read.
53 * @param contents Output parameter receiving the file contents on success.
54 * @return true if reading succeeded and `contents` was populated, otherwise false.
55 */
56 [[nodiscard]] virtual bool readInto( const std::string& filename, std::string& contents) const noexcept = 0;
57
58
59 };
60
61
62}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.