License
BSD-3-Clause
CDM ConfigStore — Lightweight config with format-preserving save.
This module provides a utility for applications that need:
var)The pattern:
var → discard CDMvar for reads/writesExample:
auto config = ConfigStore.load("app.cf");
// Read values
string host = config["server"]["host"].as!string;
// Modify values
config["server"]["port"] = 9090;
// Save with formatting preserved
config.save();Lightweight configuration store with format-preserving save.
Holds configuration data as var during runtime for low memory usage, and merges changes back into the original file format on save, preserving comments, indentation, quote styles, and other formatting.
var dataThe configuration data (lightweight runtime representation)string pathPath to the configuration fileCdmDocument.Format formatDetected or specified file formatprivate string[] _deletedPathsKeys that have been explicitly deleted (dot-separated paths)string delegate(string path) @safe fileReaderCustom file reader (for testing or virtual filesystems)void delegate(string path, string content) @safe fileWriterCustom file writer (for testing or virtual filesystems)CdmDocument delegate(string content, string path) @safe parserCustom parser (for format detection override)string delegate(CdmDocument doc) @safe writerCustom writer (for format detection override)ConfigStore load(string filePath,
CdmDocument.Format fmt = CdmDocument.Format.UNKNOWN) @safeLoad configuration from a file.ConfigStore loadString(string content, CdmDocument.Format fmt,
string sourcePath = "<string>") @safeLoad configuration from a string.Exception thrown when a CDM format parser/writer is not yet implemented.
this(string msg, string file = __FILE__, size_t line = __LINE__)void mergeIntoCdm(ref CdmNode node, var data) @trustedRecursively merge var data into a CDM node.void addNewMember(ref CdmNode node, string key, var value) @safeAdd a new member with contextually-appropriate formatting.void updateMemberValue(CdmMember * member, var value) @safeUpdate an existing member's value while preserving its formatting.void deleteFromCdm(ref CdmNode node, string keyPath) @trustedDelete a key path from a CDM node.bool removeMember(ref CdmNode node, string key) @safeRemove a member by key from an object node.CdmDocument parseCf(string content, string path) @safeParse CF format content into a CdmDocument.CdmDocument parseJson5(string content, string path) @safeParse JSON5 format content into a CdmDocument.CdmDocument parseSdl(string content, string path) @safeParse SDL format content into a CdmDocument.