Sources and registries
Collections of sources, units, schemas, functions, and node hierarchies.
-
OverrideItemTarget snt::dip::classify_override_item(const HierarchyList &hierarchy, const std::string &requested)
-
class BranchingList
Collection of DIPL branches and their selected cases.
Public Functions
-
inline BranchingList()
-
int register_case()
-
bool false_case()
-
void solve_case(const BaseNode::PointerType &node)
-
void prepare_node(const BaseNode::PointerType &node)
-
std::string clean_name(const std::string &node) const
-
bool is_internal_path(const std::string &path) const
Whether a path contains a parser-owned case component.
-
std::vector<size_t> active_case_ids() const
Current decision IDs, from outermost to innermost branch.
-
inline BranchingList()
-
struct Case
One conditional case in a DIPL branching structure.
-
struct Collection
Information about a collection, keyed or indexed
Public Members
-
std::string path
Fully qualified path of a collection.
-
std::vector<std::string> items
List of collection items.
-
Path::Kind kind
Collection path kind.
-
std::vector<std::string> schemas
List of item schemas.
-
ValueMetadata metadata
Metadata attached to this explicit group or collection node.
-
std::vector<std::string> children
Direct named children in declaration order for groups and items.
-
std::vector<MetadataConstraint> metadata_constraints
-
std::string path
-
struct EnvFunction
Traceable registered DIPL function.
Public Members
-
std::string id
Internal trace identifier, e.g. DIP0_FUNCTION0.
-
std::string name
Public function name used by DIPL.
-
FunctionKind kind
-
std::string id
-
struct EnvSchema
Reusable schema definition registered in a parsed DIPL environment.
Public Members
-
std::string name
-
std::string id
-
ValueMetadata metadata
Metadata on the definition, not inherited by instances.
-
std::vector<MetadataConstraint> instance_metadata_constraints
-
size_t source_line
Declaration line, or first body line for host schemas.
-
size_t registration_line
One-based host declaration line.
-
std::string name
-
struct EnvSource
Named DIPL source text together with its parsed nodes.
Public Members
-
std::string path
Original source path.
-
std::string code
Exact source text.
-
bool named_source
Whether source?path references can use this entry.
-
bool raw_text
Whether content is kept verbatim instead of parsed as DIPL.
-
bool table_text
Whether raw content was parsed as a table.
-
std::string table_path
Resolved table populated by this raw source, if any.
-
HierarchyList hierarchy
Hierarchy local to this source.
-
SchemaList schemas
Schemas available to imported collections.
-
ExplicitDeclarations declarations
Explicit source-local paths.
-
bool embedded
Whether code came from memory rather than path.
-
ValueMetadata metadata
Metadata declared at the source root.
-
std::string path
-
struct EnvUnit
Custom unit data
Public Members
-
std::string name
unit key
-
std::string definition
unit definition
-
size_t stack
number of the current unit system stack
-
std::string id
Internal trace identifier, e.g. DIP0_UNIT0.
-
size_t registration_order
Environment-local registration order.
-
std::string source_name
Parsed source containing the declaration, when available.
-
size_t source_line
One-based declaration line in that source.
-
std::string name
-
class FunctionList
Registry of functions callable from DIPL expressions.
Public Types
-
using DataFunctionType = std::function<ValueNodeData(const Environment&)>
-
using NodesFunctionType = std::function<ValueNode::ListType(const Environment&)>
Public Functions
-
void append_value(const std::string &name, DataFunctionType func, const std::string &parent_id = {})
Register a value function under a public name and trace parent identifier.
-
void append_nodes(const std::string &name, NodesFunctionType func, const std::string &parent_id = {})
Register a node-producing function under a public name and trace parent identifier.
-
DataFunctionType get_value(const std::string &name) const
Return the registered value-producing function.
- Parameters:
name – Function name to look up.
-
NodesFunctionType get_nodes(const std::string &name) const
-
const EnvFunction &get_value_info(const std::string &name) const
Return trace information for a registered value function.
-
const EnvFunction &get_nodes_info(const std::string &name) const
Return trace information for a registered node-producing function.
-
std::vector<EnvFunction> entries() const
Return trace information for all registered functions, ordered by name and kind.
-
using DataFunctionType = std::function<ValueNodeData(const Environment&)>
-
class HierarchyList
The main class that manages node hierarchy
Public Functions
-
void record(const BaseNode::PointerType &node, const std::vector<NodeDtype> &excluded, const std::function<std::string(const std::string&)> &collection_path = {})
Register node into the node hierarchy
- Parameters:
node – Node that should be registed
excluded – List of node types that will be ignored in a node hierarchy
-
void record_parent(const BaseNode::PointerType &node)
Update indentation context without creating nodes or collection items.
-
const Path get_current_path(size_t indent = 0, const std::string &path = "", bool show_item = true) const
Get path of the current hierarchy level
If indent and path is not provided, method returns the most recent path composed from parents in the stack. When provided, the method returns path relative to the given indent. E.g. if current path is ‘foo.bar.baz’ and group ‘bar’ has indent 2, than for input indent 2 and path
crackle, the following path will be constructed:foo.crackle.The paramer
show_itemstrips the item from the end of the collection path: e.g. instead offoo[bar]onlyfoois returned
-
std::string resolve_list_selectors(std::string path) const
Replace implicit list selectors with the current item indices.
-
const std::unordered_map<std::string, Collection> &get_collections() const
Gets a reference on a ll collections
- Returns:
Map of all collections
-
const Collection &get_collection(const std::string &path) const
Get reference to a specific collection
- Parameters:
path – Collection fully qualified path
- Returns:
Referenc on a collection
-
void set_collection(const std::string &path, Path::Kind kind, std::vector<std::string> schemas)
Set a new collection
- Parameters:
path – Collection fully qualified path
kind – Collection kind (map/list)
schemas – List of schemas applied to collection items
-
void set_collection(const std::string &path, Path::Kind kind, std::vector<std::string> schemas, std::vector<std::string> items)
Restore a collection and its item order from persisted environment data.
-
void import_subtree(const HierarchyList &source, const std::string &source_root, const std::string &target_root)
Copy evaluated collection structure under a new import path.
-
std::vector<std::string> subtree_schemas(const std::string &source_root) const
Names of schemas applied within a selected collection subtree.
-
void erase_collection(const std::string &path)
Remove a collection entry after parse-time path bookkeeping is complete.
-
void set_schemas(const std::string &path, std::vector<std::string> schemas)
Record schemas applied to an existing group or collection item.
-
void record_ordered_path(const std::string &path)
Record a resolved node path in its parent’s declaration order.
-
inline const std::vector<std::string> &root_children_order() const
Direct top-level DIPL child names in declaration order.
-
void merge_metadata(const std::string &path, const ValueMetadata &metadata)
Merge explicit metadata fields attached to a hierarchy node.
-
const bool has_collection(const std::string &path) const
Test if collection whith the given path exists
- Parameters:
path – Collection path that should be found
- Returns:
Returns true if collection exists, otherwise returns false
-
const size_t num_collections() const
Get number of collections
- Returns:
Number of collections
-
void record(const BaseNode::PointerType &node, const std::vector<NodeDtype> &excluded, const std::function<std::string(const std::string&)> &collection_path = {})
-
template<typename T>
class NodeList Ordered, named collection of DIPL nodes.
-
struct OverrideItemTarget
Static classification of a terminal collection-item override path. It does not evaluate the item or its child values.
Public Types
-
class OverrideList
Collected, exact-path value modifications applied before node evaluation.
Public Functions
-
void append(const BaseNode::PointerType &node)
Register one modification; a repeated target is an error.
-
void append(const BaseNode::ListType &nodes, size_t indent)
Atomically collect a body, expanding indentation into fully qualified target paths.
-
BaseNode::PointerType find(const std::string &path) const
Find a modification by fully qualified target path, or return nullptr.
-
void consume(const std::string &path)
Mark a target consumed after successful application.
-
std::vector<std::string> unresolved() const
Return all target paths not matched by a normal declaration.
-
size_t item_group_count() const
Number of terminal item groups, in registration order.
-
BaseNode::PointerType materialize_item_group(size_t index, const HierarchyList &hierarchy)
Return a new group for an absent item, or nullptr for an existing item.
-
void append(const BaseNode::PointerType &node)
-
struct Parent
Holds information about a paraent node in the hierarchy
Public Members
-
size_t indent
Indent of a parent node.
-
std::string name
Fully qualified node path.
-
std::vector<Path::CollectionAccess> collections
List of collections in the node path.
-
size_t indent
-
class SchemaList
Public Functions
-
SchemaList()
-
void append(const std::string &name, BaseNode::ListType &nodes, const std::string &parent_id = {}, const ValueMetadata &metadata = {}, size_t source_line = 0, const std::vector<MetadataConstraint> &instance_constraints = {})
Append a schema definition to the registry.
- Parameters:
name – Name used to identify the item.
nodes – Nodes defining the schema.
parent_id – Internal identifier of the registering source.
metadata – Metadata attached to the schema definition.
-
void append(const std::string &name, EnvSchema src, const std::string &parent_id = {})
Append a schema record, assigning an identifier when it has none.
-
void import_referenced_from(const SchemaList &source, const std::vector<std::string> &names)
Import selected definitions and their dependencies, rejecting conflicting names.
-
SchemaList()
-
class SourceList
Collection of named DIPL sources.
Public Functions
-
SourceList()
-
void append(const std::string &name, const std::filesystem::path &path, const std::string &code, const Source &parent)
Append an item to the collection.
-
SourceList()
-
class UnitList
List of custom units
Public Functions
-
UnitList()
Unit list constructor
-
void append(const std::string &name, const std::string &definition, const std::string &parent_id = {})
Append new custom unit from a name and a definition expression
- Parameters:
name – Name of a custom unit
definition – Expression that defines a new unit
parent_id – Internal identifier of the registering source.
-
void append(const std::string &name, EnvUnit data, const std::string &parent_id = {})
Append new custom unit from a name and a custom unit data
- Parameters:
name – Name of a custom unit
data – Custom unit data object
parent_id – Internal identifier of the registering source.
-
EnvUnit &at(const std::string &name)
Select custom unit data
- Parameters:
name – Name of a custom unit
- Returns:
Custom unit data
-
UnitList()