Lumiera  0.pre.03
»edityourfreedom«
Record< VAL > Class Template Reference

#include "lib/diff/record.hpp"

Description

template<typename VAL>
class lib::diff::Record< VAL >

object-like record of data.

For symbolic representation of "objects". A Record holds both attributes (key-value data) plus a list of enclosed children, which are conceived to be within the "scope" of this Record. Optionally, a typeID (metadata) may be defined. Otherwise, this typeID defaults to "NIL". The representation of attributes depends on the actual value type, which somehow need the ability to encode the keys within the value data. By default, a specialisation is given for string, using the "key = val" syntax. Yet the most relevant use case is Record<GenNode> – using the embedded name-ID of the GenNode elements as key for attributes.

Record elements are meant to be immutable; they can be created from a defining collection. However, we provide a Mutator mechanism to allow for rebuilding and mutating symbolic data structures based on Records and GenNode. Essentially, Lumiera's diff framework relies on this.

Definition at line 143 of file record.hpp.

Public Types

using iterator = IterAdapter< ElmIter, const Record * >
 
using keyIter = TransformIter< scopeIter, string >
 
using scopeIter = typename iter_stl::_SeqT< const Storage >::Range
 
using valIter = TransformIter< scopeIter, Access >
 

Public Member Functions

 Record ()
 
template<typename A , typename C >
 Record (Symbol typeID, A &&att, C &&chi)
 
template<typename A , typename C >
 Record (Symbol typeID, std::initializer_list< A > const &&att, std::initializer_list< C > const &&chi)
 
template<typename SEQ >
 Record (SEQ const &con)
 
 Record (std::initializer_list< VAL > const &&ili)
 
 Record (Mutator const &mut)
 copy-initialise (or convert) from the given Mutator instance. More...
 
 Record (Mutator &&mut)
 
scopeIter attribs () const
 
size_t attribSize () const
 
iterator begin () const
 default iteration exposes all data within this "object", starting with the attributes More...
 
Access child (size_t idx) const
 
size_t childSize () const
 
bool contains (VAL const &val) const
 
bool empty () const
 
iterator end () const
 
Access get (string key) const
 
string getType () const
 
bool hasAttribute (string key) const
 
keyIter keys () const
 
 operator std::string () const
 for diagnostic purpose More...
 
scopeIter scope () const
 
valIter vals () const
 

Static Public Attributes

static const string TYPE_NIL
 
static const Symbol TYPE_NIL_SYM
 

Classes

class  Mutator
 

Friends

bool checkPoint (const Record *src, ElmIter &pos)
 Implementation of Iteration-logic: detect iteration end. More...
 
void iterNext (const Record *, ElmIter &pos)
 Implementation of Iteration-logic: pull next element. More...
 
class Mutator
 
bool operator!= (Record const &r1, Record const &r2)
 
bool operator== (Record const &r1, Record const &r2)
 

Private Types

using Access = typename RecordSetup< VAL >::Access
 
using ElmIter = typename RecordSetup< VAL >::ElmIter
 
using Storage = typename RecordSetup< VAL >::Storage
 

Private Member Functions

template<>
string buildAttribute (string const &key, X &&payload)
 
template<>
string extractKey (string const &v)
 
template<>
string extractTypeID (string const &v)
 
template<>
string extractVal (string const &v)
 
ElmIter findKey (string key) const
 
template<>
bool isAttribute (string const &v)
 
template<>
bool isTypeID (string const &v)
 
template<>
string renderAttribute (string const &attrib)
 

Static Private Member Functions

template<typename X >
static VAL buildAttribute (string const &key, X &&payload)
 
static string extractKey (VAL const &v)
 
static string extractTypeID (VAL const &v)
 
static Access extractVal (VAL const &v)
 
static bool isAttribute (VAL const &v)
 
static bool isTypeID (VAL const &v)
 
static string renderAttribute (VAL const &a)
 

Private Attributes

Storage attribs_
 
Storage children_
 
string type_
 

Member Typedef Documentation

◆ Storage

using Storage = typename RecordSetup<VAL>::Storage
private

Definition at line 145 of file record.hpp.

◆ ElmIter

using ElmIter = typename RecordSetup<VAL>::ElmIter
private

Definition at line 146 of file record.hpp.

◆ Access

using Access = typename RecordSetup<VAL>::Access
private

Definition at line 147 of file record.hpp.

◆ iterator

using iterator = IterAdapter<ElmIter, const Record*>

Definition at line 304 of file record.hpp.

◆ scopeIter

using scopeIter = typename iter_stl::_SeqT<const Storage>::Range

Definition at line 305 of file record.hpp.

◆ keyIter

using keyIter = TransformIter<scopeIter, string>

Definition at line 306 of file record.hpp.

◆ valIter

Definition at line 307 of file record.hpp.

Constructor & Destructor Documentation

◆ Record() [1/7]

Record ( )
inline

Definition at line 158 of file record.hpp.

◆ Record() [2/7]

Record ( Symbol  typeID,
A &&  att,
C &&  chi 
)
inline

Definition at line 163 of file record.hpp.

◆ Record() [3/7]

Record ( Symbol  typeID,
std::initializer_list< A > const &&  att,
std::initializer_list< C > const &&  chi 
)
inline

Definition at line 170 of file record.hpp.

◆ Record() [4/7]

Record ( SEQ const &  con)
inlineexplicit

Definition at line 179 of file record.hpp.

References Record< VAL >::extractTypeID(), Record< VAL >::isAttribute(), and Record< VAL >::isTypeID().

+ Here is the call graph for this function:

◆ Record() [5/7]

Record ( std::initializer_list< VAL > const &&  ili)
inline

Definition at line 193 of file record.hpp.

◆ Record() [6/7]

Record ( Mutator const &  mut)
inline

copy-initialise (or convert) from the given Mutator instance.

Remarks
need to code this explicitly, otherwise Record's build-from sequence templated ctor would kick in.
Warning
beware of initialiser lists. Record has a dedicated ctor to accept an initialiser list of GenNode elements, and GenNode's ctor is deliberately not explicit, to ease building argument lists wrapped in GenNodes. When writing initialisation expressions inline, the compiler might pick the conversion path through initialiser list, which means the contents of the Mutator end up wrapped into a GenNode, which in turn becomes the only child of the new Record.

Definition at line 291 of file record.hpp.

◆ Record() [7/7]

Record ( Mutator &&  mut)
inline

Definition at line 294 of file record.hpp.

Member Function Documentation

◆ operator std::string()

operator std::string ( ) const

for diagnostic purpose

Definition at line 780 of file record.hpp.

References Record< VAL >::attribs(), util::isnil(), util::join(), Record< VAL >::renderAttribute(), Record< VAL >::scope(), lib::transformIterator(), Record< VAL >::type_, and Record< VAL >::TYPE_NIL.

+ Here is the call graph for this function:

◆ attribSize()

size_t attribSize ( ) const
inline

Definition at line 205 of file record.hpp.

◆ childSize()

size_t childSize ( ) const
inline

Definition at line 211 of file record.hpp.

◆ empty()

bool empty ( ) const
inline

Definition at line 217 of file record.hpp.

Referenced by Record< VAL >::Mutator::accessLast(), and Record< VAL >::Mutator::empty().

+ Here is the caller graph for this function:

◆ getType()

string getType ( ) const
inline

Definition at line 225 of file record.hpp.

References Record< VAL >::type_.

Referenced by MutationMessage_test::demonstrate_treeApplication(), TreeMutatorBinding_test::mutateGenNode(), GenNodeBasic_test::objectShortcut(), DataCap::recordType(), DiffTreeApplication_test::run(), GenNodeBasic_test::sequenceIteration(), and GenNodeBasic_test::simpleUsage().

+ Here is the caller graph for this function:

◆ hasAttribute()

bool hasAttribute ( string  key) const
inline

Definition at line 231 of file record.hpp.

References Record< VAL >::findKey().

+ Here is the call graph for this function:

◆ contains()

bool contains ( VAL const &  val) const
inline

Definition at line 237 of file record.hpp.

References util::contains().

+ Here is the call graph for this function:

◆ get()

Access get ( string  key) const
inline

Definition at line 243 of file record.hpp.

References Record< VAL >::extractVal(), and Record< VAL >::findKey().

Referenced by MutationMessage_test::demonstrate_treeApplication(), WrappedStandardExeBuilder::invokeOriginalBuilder(), TreeMutatorBinding_test::mutateGenNode(), GenNodeBasic_test::objectShortcut(), DiffTreeApplication_test::run(), GenNodeBasic_test::simpleUsage(), and GenNodeBasic_test::symbolReference().

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

◆ child()

Access child ( size_t  idx) const
inline

Definition at line 253 of file record.hpp.

References util::toString().

Referenced by GenNodeBasic_test::sequenceIteration().

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

◆ begin()

iterator begin ( ) const
inline

default iteration exposes all data within this "object", starting with the attributes

Definition at line 310 of file record.hpp.

◆ end()

iterator end ( ) const
inline

Definition at line 311 of file record.hpp.

◆ attribs()

scopeIter attribs ( ) const
inline

Definition at line 313 of file record.hpp.

References lib::iter_stl::eachElm().

Referenced by Record< VAL >::keys(), TreeMutatorBinding_test::mutateGenNode(), Record< VAL >::operator std::string(), and Record< VAL >::vals().

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

◆ scope()

scopeIter scope ( ) const
inline

Definition at line 314 of file record.hpp.

References lib::iter_stl::eachElm().

Referenced by DataCap::childIter(), MutationMessage_test::demonstrate_treeApplication(), TreeMutatorBinding_test::mutateGenNode(), Record< VAL >::operator std::string(), DiffTreeApplication_test::run(), and Record< VAL >::Mutator::scope().

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

◆ keys()

keyIter keys ( ) const
inline

Definition at line 316 of file record.hpp.

References Record< VAL >::attribs(), Record< VAL >::extractKey(), and lib::transformIterator().

Referenced by MutationMessage_test::demonstrate_treeApplication(), and DiffTreeApplication_test::run().

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

◆ vals()

valIter vals ( ) const
inline

Definition at line 317 of file record.hpp.

References Record< VAL >::attribs(), Record< VAL >::extractVal(), and lib::transformIterator().

+ Here is the call graph for this function:

◆ isAttribute() [1/2]

static bool isAttribute ( VAL const &  v)
staticprivate

Referenced by Record< VAL >::Mutator::appendAttrib(), Record< VAL >::Mutator::genNode(), Record< VAL >::isTypeID(), and Record< VAL >::Record().

+ Here is the caller graph for this function:

◆ isTypeID() [1/2]

static bool isTypeID ( VAL const &  v)
staticprivate

Referenced by Record< VAL >::Mutator::genNode(), and Record< VAL >::Record().

+ Here is the caller graph for this function:

◆ extractTypeID() [1/2]

static string extractTypeID ( VAL const &  v)
staticprivate

Referenced by Record< VAL >::Mutator::genNode(), and Record< VAL >::Record().

+ Here is the caller graph for this function:

◆ renderAttribute() [1/2]

static string renderAttribute ( VAL const &  a)
staticprivate

Referenced by Record< VAL >::Mutator::genNode(), and Record< VAL >::operator std::string().

+ Here is the caller graph for this function:

◆ extractKey() [1/2]

static string extractKey ( VAL const &  v)
staticprivate

Referenced by Record< VAL >::findKey(), Record< VAL >::Mutator::genNode(), Record< VAL >::isTypeID(), Record< VAL >::keys(), Record< VAL >::renderAttribute(), and Record< VAL >::Mutator::set().

+ Here is the caller graph for this function:

◆ extractVal() [1/2]

static Access extractVal ( VAL const &  v)
staticprivate

Referenced by Record< VAL >::buildAttribute(), Record< VAL >::extractTypeID(), Record< VAL >::Mutator::genNode(), Record< VAL >::get(), Record< VAL >::renderAttribute(), and Record< VAL >::vals().

+ Here is the caller graph for this function:

◆ buildAttribute() [1/2]

static VAL buildAttribute ( string const &  key,
X &&  payload 
)
staticprivate

Referenced by Record< VAL >::Mutator::genNode(), and Record< VAL >::Mutator::set().

+ Here is the caller graph for this function:

◆ findKey()

ElmIter findKey ( string  key) const
inlineprivate

Definition at line 365 of file record.hpp.

References Record< VAL >::extractKey().

Referenced by Record< VAL >::get(), and Record< VAL >::hasAttribute().

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

◆ extractKey() [2/2]

string extractKey ( string const &  v)
inlineprivate

Definition at line 715 of file record.hpp.

References util::trim().

+ Here is the call graph for this function:

◆ extractVal() [2/2]

string extractVal ( string const &  v)
inlineprivate

Definition at line 726 of file record.hpp.

References util::trim().

+ Here is the call graph for this function:

◆ isAttribute() [2/2]

bool isAttribute ( string const &  v)
inlineprivate

Definition at line 737 of file record.hpp.

◆ isTypeID() [2/2]

bool isTypeID ( string const &  v)
inlineprivate

Definition at line 744 of file record.hpp.

References Record< VAL >::extractKey(), and Record< VAL >::isAttribute().

+ Here is the call graph for this function:

◆ extractTypeID() [2/2]

string extractTypeID ( string const &  v)
inlineprivate

Definition at line 752 of file record.hpp.

References Record< VAL >::extractVal().

+ Here is the call graph for this function:

◆ renderAttribute() [2/2]

string renderAttribute ( string const &  attrib)
inlineprivate

Definition at line 759 of file record.hpp.

References Record< VAL >::extractKey(), and Record< VAL >::extractVal().

+ Here is the call graph for this function:

◆ buildAttribute() [2/2]

string buildAttribute ( string const &  key,
X &&  payload 
)
inlineprivate

Definition at line 767 of file record.hpp.

References Record< VAL >::extractVal().

+ Here is the call graph for this function:

Member Data Documentation

◆ type_

string type_
private

◆ attribs_

◆ children_

◆ TYPE_NIL

◆ TYPE_NIL_SYM

const Symbol TYPE_NIL_SYM
static

Definition at line 156 of file record.hpp.

Referenced by Tangible::invoke().

Friends And Related Function Documentation

◆ Mutator

friend class Mutator
friend

Definition at line 298 of file record.hpp.

Referenced by GenNodeBasic_test::objectShortcut().

◆ iterNext

void iterNext ( const Record< VAL > *  ,
ElmIter pos 
)
friend

Implementation of Iteration-logic: pull next element.

Definition at line 323 of file record.hpp.

◆ checkPoint

bool checkPoint ( const Record< VAL > *  src,
ElmIter pos 
)
friend

Implementation of Iteration-logic: detect iteration end.

Remarks
seamless continuation of the iteration when reaching the end of the attribute collection. In this implementation, we use the default constructed ITER() to mark iteration end.

Definition at line 334 of file record.hpp.

◆ operator==

bool operator== ( Record< VAL > const &  r1,
Record< VAL > const &  r2 
)
friend

Definition at line 377 of file record.hpp.

◆ operator!=

bool operator!= ( Record< VAL > const &  r1,
Record< VAL > const &  r2 
)
friend

Definition at line 385 of file record.hpp.

+ Collaboration diagram for Record< VAL >:

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