50 #include <boost/lexical_cast.hpp> 54 using boost::lexical_cast;
90 :
public Variant<DataValues>::Predicate
94 #define DERIVE_EQUALITY(_TY_) \ 95 virtual bool handle (_TY_ const& val) override { return (o_.get<_TY_>() == val); } 98 DERIVE_EQUALITY (int64_t)
99 DERIVE_EQUALITY (
short)
100 DERIVE_EQUALITY (
char)
101 DERIVE_EQUALITY (
bool)
102 DERIVE_EQUALITY (
double)
103 DERIVE_EQUALITY (
string)
109 DERIVE_EQUALITY (
Rec)
114 handle (
RecRef const& val)
override 116 return o_.matchRec(val);
125 EqualityTest visitor(o);
126 return accept(visitor);
131 DataCap::matchNum (int64_t num)
const 134 :
public Variant<DataValues>::Predicate
138 #define MATCH_NUMBER(_TY_) \ 139 virtual bool handle (_TY_ const& val) override { return val == num_; } 142 MATCH_NUMBER (int64_t)
145 MATCH_NUMBER (
double)
148 MatchNumber(int64_t num)
153 MatchNumber visitor(num);
154 return accept(visitor);
159 DataCap::matchDbl (
double d)
const 162 :
public Variant<DataValues>::Predicate
166 #define MATCH_DOUBLE(_TY_) \ 167 virtual bool handle (_TY_ const& val) override { return almostEqual (double(val), num_); } 170 MATCH_DOUBLE (int64_t)
173 MATCH_DOUBLE (
double)
176 MatchDouble(
double d)
181 MatchDouble visitor(d);
182 return accept(visitor);
187 DataCap::matchTxt (
string const& text)
const 190 :
public Variant<DataValues>::Predicate
194 #define MATCH_STRING(_TY_) \ 195 virtual bool handle (_TY_ const& val) override { return lexical_cast<string>(val) == txt_; } 198 MATCH_STRING (int64_t)
200 MATCH_STRING (
double)
203 virtual bool handle (
string const& str)
override {
return str == txt_; }
204 virtual bool handle (
char const& c )
override {
return 1 == txt_.length() && txt_.front() == c; }
207 MatchString(
string const& text)
212 MatchString visitor(text);
213 return accept(visitor);
221 :
public Variant<DataValues>::Predicate
225 #define MATCH_TIME(_TY_) \ 226 virtual bool handle (_TY_ const& val) override { return val == t_; } 240 MatchTime visitor(time);
241 return accept(visitor);
246 DataCap::matchBool (
bool b)
const 248 bool* val = unConst(
this)->maybeGet<
bool>();
249 return val && (b == *val);
254 DataCap::matchLuid (
LuidH hash)
const 256 LuidH* val = unConst(
this)->maybeGet<
LuidH>();
257 return val && (hash == *val);
262 DataCap::matchRec (
RecRef const& ref)
const 265 return matchRec (*ref.get());
269 return val && val->empty();
275 DataCap::matchRec (
Rec const& rec)
const 277 Rec* val = unConst(
this)->maybeGet<
Rec>();
281 if (r) val = r->get();
283 return val && (rec == *val);
289 DataCap::operator string()
const 291 return "DataCap|"+string(this->buffer());
303 return (n.isNamed()? n.idi.getSym()+
"=" :
"")
307 return (Rec::TYPE_NIL==rec.getType()?
"" : rec.getType())
310 + (isnil(rec.scope())?
"" :
"|")
319 return "Ref->" + (ref.empty()? util::BOTTOM_INDICATOR
333 :
public Variant<diff::DataValues>::Renderer
335 #define RENDER_CONTENT(_TY_) \ 336 virtual string handle (_TY_ const& val) override { return util::toString(val); } 339 RENDER_CONTENT (int64_t)
340 RENDER_CONTENT (
short)
341 RENDER_CONTENT (
char)
342 RENDER_CONTENT (
double)
343 RENDER_CONTENT (
bool)
348 #undef RENDER_CONTENT 350 virtual string handle (
string const& val)
override {
return val; }
351 virtual string handle (
LuidH const& val)
override {
return util::showHash(val, 2);}
353 virtual string handle (
Rec const& rec)
override {
return renderCompact(rec); }
357 return node.data.accept (visitor);
static const Ref I
symbolic ID ref "_I_"
Fundamental definitions for a representation of changes.
static const Ref CHILD
symbolic ID ref "_CHILD_"
string renderCompact(Rec const &rec)
compact textual representation of a Record<GenNode> (»object«).
Implementation namespace for support and library code.
Lumiera's internal time value datatype.
static const Ref END
symbolic ID ref "_END_"
bool matchData(DataCap const &) const
Implementation of content equality test, delgating to content.
A typesafe union record to carry embedded values of unrelated type.
wrapped record reference.
Utilities for quantisation (grid alignment) and comparisons.
Generic building block for tree shaped (meta)data structures.
static const Ref NO
symbolic ID ref "_NO_"
Lumiera error handling (C++ interface).
Hash implementation based on a lumiera unique object id (LUID) When invoking the default ctor...
static const Ref ATTRIBS
symbolic ID ref "_ATTRIBS_"
Offset measures a distance in time.
Duration is the internal Lumiera time metric.
bool almostEqual(double d1, double d2, unsigned int ulp=2)
epsilon comparison of doubles.
A time interval anchored at a specific point in time.
auto transformIterator(IT const &src, FUN processingFunc)
Build a TransformIter: convenience free function shortcut, picking up the involved types automaticall...
object-like record of data.
static const Ref THIS
symbolic ID ref "_THIS_"
basic constant internal time value.
generic data element node within a tree