dex.cf.document
CF Document Model
This module defines the concrete syntax tree (CST) types for CF documents. The document model preserves all metadata needed for roundtrip fidelity, including comments, source locations, original formatting, and quote styles.
The primary types are:
CfDocument— The root container for a CF fileCfNode— A value node in the document treeCfMember— A key-value pair in an objectCfComment— A comment (line or block)Copyright
© 2025 Dejan LekićBSD-3-Clause
Types 7
Comment style enumeration.
Indicates which comment syntax was used in the original source.
A comment in a CF document.
Preserves both the decoded content and the original raw text for roundtrip fidelity.
string textComment content without delimitersCommentStyle styleWhich comment syntax was usedLocation locSource location of the commentstring rawTextOriginal text including delimiters (for exact reproduction)Node type enumeration for CF values.
Represents the semantic type of a CfNode.
A member (key-value pair) in a CF object.
Preserves all metadata needed for roundtrip fidelity.
string keyDecoded key textstring rawKeyOriginal key text (quoted or unquoted)Location keyLocSource location of the keybool hasEqualsWhether `=` was used (vs `:`)SeparatorStyle separatorThe separator after this memberCfNode * valueThe value nodeCfComment[] leadingCommentsComments before this memberCfComment[] trailingCommentsInline comment after this memberA lightweight reference wrapper for CfNode that enables natural chaining.
This wrapper allows idiomatic D syntax like doc["server"]["port"].as!long by providing opIndex that returns another CfNodeRef.
Example:
auto doc = parseCFDocument(`server { host = "localhost", port = 8080 }`);
auto port = doc["server"]["port"].as!long; // 8080
auto missing = doc["nonexistent"]["key"].as!string; // "" (safe, no crash)private CfNode * ptrbool isNull() @property const @safe pure nothrowReturns true if this is a null value node or an invalid reference.bool isScalar() @property const @safe pure nothrowReturns true if this is a scalar (non-container) value.size_t length() @property const @safe pure nothrowReturns the number of elements (for arrays) or members (for objects).T getOr(T)(string key, T defaultValue = T.init) const @safe pure nothrowGets a value by key with a default fallback.A node in the CF document tree.
Represents a value in the document, preserving all metadata for roundtrip fidelity. The type field indicates which value field is active.
CfNodeType typeThe semantic type of this nodeLocation locSource position of the node's first tokenCfComment[] leadingCommentsComments that appear before this nodeCfComment[] trailingCommentsInline comment after this node on the same linestring stringValueFor STRING, DATE, TIME, DATETIME: the decoded string contentlong longValueFor INTEGER: signed valueulong ulongValueFor INTEGER: unsigned value (when value exceeds long range)double doubleValueFor FLOAT: the numeric valuebool boolValueFor BOOLEAN: the boolean valueQuoteStyle quoteStyleFor strings: which quote form was usedstring rawValueOriginal text representation (e.g., 0xFF, 1_000, "hello")CfMember[] membersOrdered key-value pairs (for OBJECT)bool hasExplicitBracesFalse for the implicit top-level objectCfNode *[] elementsOrdered elements (for ARRAY)CfNode makeInteger(long value, string raw = "", Location loc = Location.init) @safe pureCreates an integer node.CfNode makeFloat(double value, string raw = "", Location loc = Location.init) @safe pureCreates a float node.CfNode makeString(string value, string raw = "", QuoteStyle style = QuoteStyle.DOUBLE,
Location loc = Location.init) @safe pureCreates a string node.CfNode makeObject(bool explicitBraces = true, Location loc = Location.init) @safe pureCreates an empty object node.A CF document.
The root container for a parsed CF file. The root node is always an OBJECT with hasExplicitBraces = false for the implicit top-level object.
CfNode rootThe root node (always an OBJECT)string sourceSource filenameCfComment[] trailingCommentsComments after the last memberCfNodeRef opIndex(size_t index) @safe pure nothrowIndex operator for integer index (for when root is array-like).T getOr(T)(string key, T defaultValue = T.init) const @safe pure nothrowGet value with default, forwarded to root.Functions 36
bool isNull(const(CfNode) * self) @property @safe pure nothrowReturns true if this is a null value node (or pointer is null).bool isObject(const(CfNode) * self) @property @safe pure nothrowReturns true if this is an object node.bool isArray(const(CfNode) * self) @property @safe pure nothrowReturns true if this is an array node.bool isString(const(CfNode) * self) @property @safe pure nothrowReturns true if this is a string node.bool isInteger(const(CfNode) * self) @property @safe pure nothrowReturns true if this is an integer node.bool isFloat(const(CfNode) * self) @property @safe pure nothrowReturns true if this is a float node.bool isBoolean(const(CfNode) * self) @property @safe pure nothrowReturns true if this is a boolean node.bool isDate(const(CfNode) * self) @property @safe pure nothrowReturns true if this is a date node.bool isTime(const(CfNode) * self) @property @safe pure nothrowReturns true if this is a time node.bool isDateTime(const(CfNode) * self) @property @safe pure nothrowReturns true if this is a datetime node.bool isTemporal(const(CfNode) * self) @property @safe pure nothrowReturns true if this is any temporal type (date, time, or datetime).bool isScalar(const(CfNode) * self) @property @safe pure nothrowReturns true if this is a scalar (non-container) value.size_t length(const(CfNode) * self) @property @safe pure nothrowReturns the number of elements (for arrays) or members (for objects).bool hasKey(const(CfNode) * self, string key) @property @safe pure nothrowChecks if an object contains the given key.T getOr(T)(const(CfNode) * self, string key, T defaultValue = T.init) @safe pure nothrowGets a member's value with a default fallback.T as(T)(const(CfNode) * self) @safe pure nothrowType-safe value extraction for const CfNode pointers (UFCS).