94#ifndef LIB_DIFF_GEN_NODE_H
95#define LIB_DIFF_GEN_NODE_H
175 bool matchTxt (
string const&)
const;
186 operator string()
const;
197 const Rec* rec = unConst(
this)->maybeGet<
Rec>();
231 ID (X*,
string const& symbolicID)
233 idi::getTypeHash<X>())
248 operator string()
const
250 return "ID(\""+
getSym()+
"\")";
269 :
idi(&val, symbolicID)
274 :
GenNode(symbolicID, string(text))
320 data = std::forward<DataCap>(o.data);
321 idi = std::forward<ID>(o.idi);
331 operator string()
const
333 return "GenNode-"+string(
idi)+
"-"+string(
data);
349 bool contains (X
const& elm)
const;
369 struct ScopeExplorerIterator;
401 return ChildDataIter{ std::forward<Rec::scopeIter>(scopeIter)
413 return node.idi.getSym();
426 return not (n1 == n2);
483 return ID(typeID, symbolicID);
491 return "_CHILD_" + idi::generateSymbolicID<X>();
513 template<
typename ELM>
525 static const bool value = (
sizeof(
Yes)==
sizeof(check<ELM>(0)));
634 scopes_.emplace_back (current->data.expand());
655 Rec* val = unConst(
this)->maybeGet<
Rec>();
668 size_t level()
const {
return unConst(
this)->stateCore().depth(); }
681 for (
auto & n : *
this)
723 Rec* rec = maybeGet<Rec>();
724 if (rec)
return *rec;
733 Rec* rec = unConst(
this)->maybeGet<
Rec>();
734 if (rec)
return *rec;
743 Rec* nested = maybeGet<Rec>();
746 RecRef* ref = maybeGet<RecRef>();
747 if (ref and not ref->
empty())
763 Rec* nested = unConst(
this)->maybeAccessNestedRec();
764 return nested? nested->
getType()
765 : util::BOTTOM_INDICATOR;
771 return nullptr != unConst(
this)->maybeAccessNestedRec();
776 inline std::optional<X>
779 static_assert (not std::is_reference_v<X>
780 ,
"optional access only possible by value");
782 Rec* nested = unConst(
this)->maybeAccessNestedRec();
785 DataCap const& nestedAttributeData = nested->
get(key).data;
786 X* payload = unConst(nestedAttributeData).maybeGet<X>();
787 if (payload)
return *payload;
795 Rec* nested = unConst(
this)->maybeAccessNestedRec();
800 inline std::optional<X>
848 Ref(
string const& symbolicID)
874 data(
std::move(r.data)) { }
897 return GenNode{symbolicID, std::move(record_)};
932 return isTypeID(v)? v.data.get<
string>()
945 inline GenNode
const&
955 return a.idi.getSym() +
" = "+
string(a.data);
963 return GenNode{key, forward<X>(payload)};
977 template<
typename TYPES>
Another Lumiera Forward Iterator building block, based on incorporating a state type as »*State Core*...
bool matchRec(RecRef const &) const
bool matchTxt(string const &) const
bool matchBool(bool) const
DataCap & operator=(DataCap const &)=default
bool matchNum(int64_t) const
DataCap(DataCap const &)=default
Rec::scopeIter childIter() const
visit children of a nested Record<GenNode>
Rec * maybeAccessNestedRec()
bool matchDbl(double) const
bool hasAttribute(string key) const
bool matchTime(time::TimeValue) const
std::optional< X > retrieveAttribute(string key) const
peek into the attributes of a nested Record
bool matchData(DataCap const &) const
Implementation of content equality test, delgating to content.
string recordType() const
peek into the type field of a nested Record<GenNode>
bool matchLuid(hash::LuidH) const
DataCap(DataCap &&)=default
bool isNested() const
determine if payload constitutes a nested scope ("object")
ID(X *, string const &symbolicID)
ID(idi::BareEntryID &&rawD)
Building block for monad-like depth-first expansion of a GenNode.
GenNode const & yield() const
std::deque< ScopeIter > scopes_
friend bool operator==(ScopeExplorer const &s1, ScopeExplorer const &s2)
ScopeExplorer(GenNode const &n)
IterStateWrapper< DataCap::Locator > ScopeIter
wrapped record reference.
Target * get() const noexcept
void buildMutator(BufferHandle)
attachment point to receive and apply tree-diff changes.
object-like record of data.
static const string TYPE_NIL
operator std::string() const
for diagnostic purpose
static bool isAttribute(VAL const &v)
Access get(string key) const
static string extractTypeID(VAL const &v)
bool hasAttribute(string key) const
static VAL buildAttribute(string const &key, X &&payload)
IterAdapter< ElmIter, const Record * > iterator
static string renderAttribute(VAL const &a)
static Access extractVal(VAL const &v)
iter_stl::_SeqT< const Storage >::Range scopeIter
static bool isTypeID(VAL const &v)
static string extractKey(VAL const &v)
Hash implementation based on a lumiera unique object id (LUID) When invoking the default ctor,...
type erased baseclass for building a combined hash and symbolic ID.
string const & getSym() const
Duration is the internal Lumiera time metric.
Offset measures a distance in time.
A time interval anchored at a specific point in time.
basic constant internal time value.
Lumiera's internal time value datatype.
Bare symbolic and hash ID used for accounting of asset like entries.
Lumiera error handling (C++ interface).
std::vector< GenNode > Storage
Storage::const_iterator ElmIter
GenNode const & Access
using const reference data access relevant for handling large subtrees
string renderCompact(Rec const &rec)
compact textual representation of a Record<GenNode> (»object«).
RecordRef< GenNode > RecRef
meta::Types< int,int64_t,short,char,bool,double,string,time::Time,time::Offset,time::Duration,time::TimeSpan,hash::LuidH,RecRef,Rec > DataValues
Implementation namespace for support and library code.
bool startsWith(string const &str, string const &prefix)
check if string starts with a given prefix
Special collection to represent object-like data.
GenNode const & yield() const
const GenNode * get() const
Locator(GenNode const &n)
allow for storage in ordered containers, ordering based on the human-readable ID within the GenNode.
bool operator()(GenNode const &left, GenNode const &right) const
generic data element node within a tree
GenNode & operator=(GenNode const &o)
copy assignment
bool matches(short number) const
bool matches(GenNode const &o) const
bool matches(bool b) const
friend bool operator!=(GenNode const &n1, GenNode const &n2)
static GenNode::ID fabricateRefID(string const &symbolicID)
bool matches(Rec const &rec) const
friend string name(GenNode const &node)
bool matches(string text) const
TransformIter< Rec::scopeIter, DataCap const & > ChildDataIter
bool matches(const char *text) const
bool contains(X const &elm) const
Rec::scopeIter getChildren() const
bool matches(double number) const
bool hasAttribute(string key) const
friend bool operator==(GenNode const &n1, GenNode const &n2)
friend ChildDataIter childData(Rec::scopeIter &&scopeIter)
GenNode(string const &symbolicID, X &&val)
bool matches(hash::LuidH h) const
std::optional< X > retrieveAttribute(string key) const
mismatch tolerant convenience shortcut to peek into the attributes of a nested Record
GenNode(GenNode const &)=default
bool matches(time::TimeValue t) const
GenNode(GenNode &&)=default
GenNode(ID &&id, DataCap &&d)
bool matches(int number) const
bool matches(ID const &id) const
GenNode(string const &symbolicID, CStr text)
friend ChildDataIter childData(GenNode const &n)
visit the data of nested child elements
static string buildChildID()
static GenNode asAttribute(idi::BareEntryID &&rawID, X &&payload)
fabricate a GenNode with the literally given ID
bool matches(RecRef const &ref) const
bool matches(char number) const
ScopeExplorerIterator iterator
bool matches(int64_t number) const
Constructor for a specially crafted 'ref GenNode'.
Ref(GenNode &oNode)
build reference to a Record, using the original ID
static const Ref END
symbolic ID ref "_END_"
static const Ref I
symbolic ID ref "_I_"
Ref(string const &symbolicID)
create an empty ID stand-in.
static const Ref THIS
symbolic ID ref "_THIS_"
static const Ref NO
symbolic ID ref "_NO_"
static const Ref CHILD
symbolic ID ref "_CHILD_"
static const Ref ATTRIBS
symbolic ID ref "_ATTRIBS_"
metafunction to detect types able to be wrapped into a GenNode.
static Yes check(variant::CanBuildFrom< X, DataValues >::Type *)
a family of time value like entities and their relationships.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
A typesafe union record to carry embedded values of unrelated type.