|
FlatImage
A configurable Linux containerization system
|
JSON-based configuration database layer. More...
Namespaces | |
| namespace | ns_bind |
| Bind mount configuration management. | |
| namespace | ns_boot |
| Boot command configuration storage. | |
| namespace | ns_desktop |
| Desktop integration configuration management. | |
| namespace | ns_env |
| Environment variable database management. | |
| namespace | ns_recipe |
| Package recipe configuration management. | |
| namespace | ns_remote |
| Remote recipe repository URL management. | |
Classes | |
| class | Db |
| A type-safe wrapper around nlohmann::json for database operations. More... | |
Typedefs | |
| using | object_t = nlohmann::basic_json<>::object_t |
| using | KeyType = json_t::value_t |
Functions | |
| std::ostream & | operator<< (std::ostream &os, Db const &db) |
| Outputs the JSON data to an output stream. | |
| Value< Db > | read_file (fs::path const &path_file_db) |
| Deserializes a JSON file into a Db object. | |
| Value< void > | write_file (fs::path const &path_file_db, Db &db) |
| Serializes a Db object and writes it to a JSON file. | |
| template<ns_concept::StringRepresentable S> | |
| Value< Db > | from_string (S &&s) |
| Parses a JSON string and creates a Db object. | |
JSON-based configuration database layer.
Provides type-safe wrapper around nlohmann::json for FlatImage configuration storage and retrieval. Supports both owned and referenced JSON data, enabling flexible ownership semantics. Offers serialization/deserialization, element access, file I/O, and type-safe conversions with integrated error handling through the Value<T> pattern.
| Value< Db > ns_db::from_string | ( | S && | s | ) |
Parses a JSON string and creates a Db object.
Converts a string representation of JSON data into a Db object. The input must be convertible to std::string (via the StringRepresentable concept). Validates that the string is non-empty before attempting to parse. Uses nlohmann::json::parse() for deserialization. Returns an error if the string is empty or contains invalid JSON.
| S | Type that can be represented as a string (string_view, const char*, etc.) |
| s | The JSON string data to parse |
Definition at line 496 of file db.hpp.
|
inline |
Outputs the JSON data to an output stream.
Serializes the underlying nlohmann::json object and writes it to the provided output stream. This enables standard stream operations like std::cout << db. Uses nlohmann::json's built-in stream insertion operator for formatting.
| os | The target output stream |
| db | The database object to print |
Deserializes a JSON file into a Db object.
Reads a JSON file from the filesystem, parses its contents, and constructs a Db object wrapping the parsed JSON data. Validates that the file exists and can be opened before attempting to parse. Uses nlohmann::json::parse() for deserialization. Returns an error if the file doesn't exist, cannot be opened, or contains invalid JSON.
| path_file_db | Path to the JSON file to read |
Definition at line 444 of file db.hpp.
Serializes a Db object and writes it to a JSON file.
Converts the Db object's underlying JSON data to a formatted string with 2-space indentation and writes it to the specified file. Opens the file in truncate mode to overwrite any existing content. Closes the file after writing. Returns an error if the file cannot be opened or the JSON cannot be serialized.
| path_file_db | Path to the target JSON file |
| db | The database object to serialize and write |
Definition at line 474 of file db.hpp.