Lumiera  0.pre.03
»edit your freedom«
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 150 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

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
 
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
 
scopeIter scope () const
 
valIter vals () const
 

Static Public Attributes

static const string TYPE_NIL = string(TYPE_NIL_SYM)
 
static const Symbol TYPE_NIL_SYM = "NIL"
 

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_
 

Constructor & Destructor Documentation

◆ Record()

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 298 of file record.hpp.

Friends And Related Function Documentation

◆ iterNext

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

Implementation of Iteration-logic: pull next element.

Definition at line 331 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 342 of file record.hpp.

+ Collaboration diagram for Record< VAL >:

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