|
cppfig 0.1.0
Modern C++20 compile-time type-safe configuration library
|
Flat key-value .conf serializer — the default, zero-dependency serializer.
More...
#include <conf.h>
Public Types | |
| using | data_type = Value |
Static Public Member Functions | |
| static auto | Parse (std::istream &is) -> StatusOr< Value > |
Parses a .conf stream into a Value tree. | |
| static auto | ParseString (std::string_view str) -> StatusOr< Value > |
Parses a .conf string into a Value tree. | |
| static auto | Stringify (const Value &data) -> std::string |
Converts a Value tree to flat key = value lines. | |
| static auto | Merge (std::string_view existing, const Value &data) -> std::string |
Rewrites an existing .conf document, preserving its layout. | |
Flat key-value .conf serializer — the default, zero-dependency serializer.
File format:
Keys are the full dot-separated setting paths. There are no sections or grouping — each line is simply path = value.
Type inference during parsing:
true/false/yes/no/on/off → bool-) → int64"...") → string (quotes stripped)
|
inlinestatic |
Rewrites an existing .conf document, preserving its layout.
Regenerating the file from the Value tree sorts the keys and drops every comment the user wrote, which is user-hostile for a format whose whole point is being hand-editable. Merge instead walks the existing lines, updates the value of each key it recognises, leaves comments, blank lines and ordering alone, and appends the keys the file does not have yet.
Lines whose value is unchanged are emitted verbatim, so a save that changes nothing leaves the file byte-identical.
| existing | The current file contents. |
| data | The Value tree to write. |
Parses a .conf stream into a Value tree.
|
inlinestatic |
Parses a .conf string into a Value tree.
|
inlinestatic |
Converts a Value tree to flat key = value lines.