Lumiera  0.pre.03
»edit your freedom«
GenNode Struct Reference

#include "lib/diff/gen-node.hpp"

Description

generic data element node within a tree

Definition at line 222 of file gen-node.hpp.

Public Types

using ChildDataIter = TransformIter< Rec::scopeIter, DataCap const & >
 
using iterator = ScopeExplorerIterator
 

Public Member Functions

template<typename X >
 GenNode (X &&val)
 
template<typename X >
 GenNode (string const &symbolicID, X &&val)
 
 GenNode (string const &symbolicID, const char *text)
 
 GenNode (const char *text)
 
 GenNode (GenNode const &)=default
 
 GenNode (GenNode &&)=default
 
 GenNode (GenNode &o)
 
 GenNode (Ref const &r)
 
 GenNode (Ref &r)
 
 GenNode (Ref &&r)
 
iterator begin ()
 
iterator begin () const
 
template<typename X >
bool contains (X const &elm) const
 
iterator end ()
 
iterator end () const
 
Rec::scopeIter getChildren () const
 
bool hasAttribute (string key) const
 
bool hasChildren () const
 
bool isNamed () const
 
bool isNested () const
 
bool isTypeID () const
 
bool matches (GenNode const &o) const
 
bool matches (ID const &id) const
 
bool matches (int number) const
 
bool matches (int64_t number) const
 
bool matches (short number) const
 
bool matches (char number) const
 
bool matches (double number) const
 
bool matches (string text) const
 
bool matches (const char *text) const
 
bool matches (time::TimeValue t) const
 
bool matches (bool b) const
 
bool matches (hash::LuidH h) const
 
bool matches (RecRef const &ref) const
 
bool matches (Rec const &rec) const
 
 operator string () const
 
GenNodeoperator= (GenNode const &o)
 copy assignment More...
 
GenNodeoperator= (GenNode &&o)
 
template<typename X >
std::optional< X > retrieveAttribute (string key) const
 mismatch tolerant convenience shortcut to peek into the attributes of a nested Record
 

Static Public Member Functions

template<typename X >
static GenNode asAttribute (idi::BareEntryID &&rawID, X &&payload)
 fabricate a GenNode with the literally given ID
 

Public Attributes

DataCap data
 
ID idi
 

Classes

class  ID
 
struct  IDComparator
 allow for storage in ordered containers, ordering based on the human-readable ID within the GenNode. More...
 
class  ScopeExplorer
 Building block for monad-like depth-first expansion of a GenNode. More...
 
struct  ScopeExplorerIterator
 

Friends

ChildDataIter childData (GenNode const &n)
 visit the data of nested child elements More...
 
ChildDataIter childData (Rec::scopeIter &&scopeIter)
 
string name (GenNode const &node)
 
bool operator!= (GenNode const &n1, GenNode const &n2)
 
bool operator== (GenNode const &n1, GenNode const &n2)
 

Protected Member Functions

 GenNode (ID &&id, DataCap &&d)
 

Static Protected Member Functions

template<typename X >
static GenNode::ID fabricateRefID (string const &symbolicID)
 

Static Private Member Functions

template<typename X >
static string buildChildID ()
 

Constructor & Destructor Documentation

◆ GenNode()

GenNode ( ID &&  id,
DataCap &&  d 
)
inlineprotected

for dedicated builder subclasses

Definition at line 472 of file gen-node.hpp.

Member Function Documentation

◆ operator=()

GenNode& operator= ( GenNode const &  o)
inline

copy assignment

Remarks
we need to define our own version here for sake of sanity. The reason is that we use inline storage (embedded within lib::Variant) and that we deliberately erase the actual type of data stored inline. Because we still do want copy assignment, in case the payload data supports this, we use a "virtual copy operator", where in the end the storage buffer within lib::Variant has to decide if assignment is possible. Only data with the same type may be assigned and we prevent change of the (implicit) data type through assignment. This check might throw, and for that reason we're better off to perform the data assignment first. The probability for EntryID assignment to fail is low (but it may happen!).
Note
the use of inline storage turns swapping of data into an expensive operation, involving a temporary. This rules out the copy-and-swap idiom.

Definition at line 305 of file gen-node.hpp.

◆ operator string()

operator string ( ) const
inline

diagnostics helper

Definition at line 330 of file gen-node.hpp.

◆ matches()

bool matches ( GenNode const &  o) const
inline
Note
not comparing payload data. Use equality for that…

Definition at line 351 of file gen-node.hpp.

References GenNode::matches().

Referenced by ChildCollectionMutator< PAR, BIN >::accept_until(), TestWireTap< PAR >::accept_until(), TestWireTap< PAR >::acceptSrc(), GenNode::matches(), and TestWireTap< PAR >::matchSrc().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ childData

ChildDataIter childData ( GenNode const &  n)
friend

visit the data of nested child elements

Returns
an iterator over the DataCap elements of all children, in case this GenNode actually holds a Record. Otherwise an empty iterator.
Note
this iterator visits only the children, which are by definition unnamed. It does not visit attributes.

Definition at line 387 of file gen-node.hpp.

+ Inheritance diagram for GenNode:
+ Collaboration diagram for GenNode:

The documentation for this struct was generated from the following file: