MdfNode
- Module
- MDF
- Header
#include "mdf/mdf_document.h"- Namespace
MDF
Constructors
| Signature | Name | Description |
|---|---|---|
MdfNode() = default | MdfNode | |
MdfNode(const std::string& type, const std::string& name = "") : m_type(type), m… | MdfNode |
Public functions
| Returns | Name | Description |
|---|---|---|
const std::string& | GetType | |
const std::string& | GetName | |
void | SetType | |
void | SetName | |
bool | HasProperty | |
const MdfValue& | GetProperty | |
const MdfValue* | TryGetProperty | nullptr when absent. |
void | SetProperty | |
void | SetProperty | |
void | SetProperty | |
::value && std::is_constructible<MdfValue, V&&>::value && !std::is_same<typename std::decay<V>::type, MdfValue>::value, int>::type = 0> void | SetProperty | Anything an MdfValue can be built from sets directly, so call sites need not spell MdfValue(...). |
bool | RemoveProperty | Keeps the sorted lookup index consistent. |
void | ReserveProperties | Worth calling when the final property count is known up front, as in the binary reader. |
const std::vector<std::pair<std::string, MdfValue>>& | GetProperties | |
MdfValue& | operator[] | |
const std::vector<std::string>& | GetComments | Comments, text encoding only. |
std::vector<std::string>& | GetComments | |
void | SetComments | |
const std::vector<std::string>& | GetTrailingComments | |
void | SetTrailingComments | |
const MdfPropertyComments& | GetPropertyCommentsAt | |
const MdfPropertyComments& | GetPropertyComments | |
void | SetPropertyComments | No-op when the key is absent — set the value first. |
void | SetPropertyCommentsAt | |
MdfNode& | AddChild | |
MdfNode& | AddChild | |
const std::vector<MdfNode>& | GetChildren | |
std::vector<MdfNode>& | GetChildren | |
const MdfNode* | FindChild | |
MdfNode* | FindChild | |
std::vector<const MdfNode*> | FindChildren | |
bool | RemoveChild | |
bool | RemoveChild | Removes the first child matching type, and name when non-empty, mirroring FindChild's match rule. |
MdfNode | Clone | |
void | SetSourcePos | Source position of the node's type identifier, set by the text parser. |
uint32_t | GetSourceLine | |
uint32_t | GetSourceColumn |
Function details
MdfNode
MdfNode() = defaultMdfNode
MdfNode(const std::string& type, const std::string& name = "") : m_type(type), m_name(name)GetType
const std::string& GetType() constGetName
const std::string& GetName() constSetType
void SetType(const std::string& type)SetName
void SetName(const std::string& name)HasProperty
inline bool HasProperty(const std::string& key) constGetProperty
inline const MdfValue& GetProperty(const std::string& key) constTryGetProperty
inline const MdfValue* TryGetProperty(const std::string& key) constnullptr when absent. Prefer over a HasProperty + GetProperty pair in hot paths.
SetProperty
inline void SetProperty(const std::string& key, const MdfValue& value)SetProperty
inline void SetProperty(const std::string& key, MdfValue&& value)SetProperty
inline void SetProperty(std::string&& key, MdfValue&& value)SetProperty
template<typename K, typename V, typename std::enable_if<std::is_constructible<std::string, K&&>::value && std::is_constructible<MdfValue, V&&>::value && !std::is_same<typename std::decay<V>::type, MdfValue>::value, int>::type = 0> void SetProperty(K&& key, V&& value)Anything an MdfValue can be built from sets directly, so call sites need not spell MdfValue(...). Constrained so MdfValue arguments keep taking the overloads above.
RemoveProperty
inline bool RemoveProperty(const std::string& key)Keeps the sorted lookup index consistent. False when the key is absent.
ReserveProperties
void ReserveProperties(size_t count)Worth calling when the final property count is known up front, as in the binary reader.
GetProperties
const std::vector<std::pair<std::string, MdfValue>>& GetProperties() constoperator[]
inline MdfValue& operator[](const std::string& key)GetComments
const std::vector<std::string>& GetComments() constComments, text encoding only. A node's own comments are the lines above its header; trailing comments sit inside the body after the last child, where a comment has nothing left to attach to. Property comments are indexed the way GetProperties() is, so the writer walks both in one pass; the sparse store costs nothing on the (usual) comment-free node.
GetComments
std::vector<std::string>& GetComments()SetComments
void SetComments(std::vector<std::string> comments)GetTrailingComments
const std::vector<std::string>& GetTrailingComments() constSetTrailingComments
void SetTrailingComments(std::vector<std::string> comments)GetPropertyCommentsAt
inline const MdfPropertyComments& GetPropertyCommentsAt(size_t index) constGetPropertyComments
inline const MdfPropertyComments& GetPropertyComments(const std::string& key) constSetPropertyComments
inline void SetPropertyComments(const std::string& key, MdfPropertyComments comments)No-op when the key is absent — set the value first.
SetPropertyCommentsAt
inline void SetPropertyCommentsAt(size_t index, MdfPropertyComments comments)AddChild
inline MdfNode& AddChild(const std::string& type, const std::string& name = "")AddChild
inline MdfNode& AddChild(MdfNode&& node)GetChildren
const std::vector<MdfNode>& GetChildren() constGetChildren
std::vector<MdfNode>& GetChildren()FindChild
inline const MdfNode* FindChild(const std::string& type, const std::string& name = "") constFindChild
inline MdfNode* FindChild(const std::string& type, const std::string& name = "")FindChildren
inline std::vector<const MdfNode*> FindChildren(const std::string& type) constRemoveChild
inline bool RemoveChild(size_t index)RemoveChild
inline bool RemoveChild(const std::string& type, const std::string& name = "")Removes the first child matching type, and name when non-empty, mirroring FindChild's match rule.
Clone
MdfNode Clone() constSetSourcePos
void SetSourcePos(uint32_t line, uint32_t column)Source position of the node's type identifier, set by the text parser. 0 means unknown — built in memory, or read from binary.
GetSourceLine
uint32_t GetSourceLine() constGetSourceColumn
uint32_t GetSourceColumn() const