41 #include <boost/lexical_cast.hpp> 45 using boost::lexical_cast;
81 :
public Variant<DataValues>::Predicate
85 #define DERIVE_EQUALITY(_TY_) \ 86 virtual bool handle (_TY_ const& val) override { return (o_.get<_TY_>() == val); } 89 DERIVE_EQUALITY (int64_t)
90 DERIVE_EQUALITY (
short)
91 DERIVE_EQUALITY (
char)
92 DERIVE_EQUALITY (
bool)
93 DERIVE_EQUALITY (
double)
94 DERIVE_EQUALITY (
string)
100 DERIVE_EQUALITY (
Rec)
105 handle (
RecRef const& val)
override 107 return o_.matchRec(val);
116 EqualityTest visitor(o);
117 return accept(visitor);
122 DataCap::matchNum (int64_t num)
const 125 :
public Variant<DataValues>::Predicate
129 #define MATCH_NUMBER(_TY_) \ 130 virtual bool handle (_TY_ const& val) override { return val == num_; } 133 MATCH_NUMBER (int64_t)
136 MATCH_NUMBER (
double)
139 MatchNumber(int64_t num)
144 MatchNumber visitor(num);
145 return accept(visitor);
150 DataCap::matchDbl (
double d)
const 153 :
public Variant<DataValues>::Predicate
157 #define MATCH_DOUBLE(_TY_) \ 158 virtual bool handle (_TY_ const& val) override { return almostEqual (double(val), num_); } 161 MATCH_DOUBLE (int64_t)
164 MATCH_DOUBLE (
double)
167 MatchDouble(
double d)
172 MatchDouble visitor(d);
173 return accept(visitor);
178 DataCap::matchTxt (
string const& text)
const 181 :
public Variant<DataValues>::Predicate
185 #define MATCH_STRING(_TY_) \ 186 virtual bool handle (_TY_ const& val) override { return lexical_cast<string>(val) == txt_; } 189 MATCH_STRING (int64_t)
191 MATCH_STRING (
double)
194 virtual bool handle (
string const& str)
override {
return str == txt_; }
195 virtual bool handle (
char const& c )
override {
return 1 == txt_.length() && txt_.front() == c; }
198 MatchString(
string const& text)
203 MatchString visitor(text);
204 return accept(visitor);
212 :
public Variant<DataValues>::Predicate
216 #define MATCH_TIME(_TY_) \ 217 virtual bool handle (_TY_ const& val) override { return val == t_; } 231 MatchTime visitor(time);
232 return accept(visitor);
237 DataCap::matchBool (
bool b)
const 239 bool* val = unConst(
this)->maybeGet<
bool>();
240 return val && (b == *val);
245 DataCap::matchLuid (
LuidH hash)
const 247 LuidH* val = unConst(
this)->maybeGet<
LuidH>();
248 return val && (hash == *val);
253 DataCap::matchRec (
RecRef const& ref)
const 256 return matchRec (*ref.get());
260 return val && val->empty();
266 DataCap::matchRec (
Rec const& rec)
const 268 Rec* val = unConst(
this)->maybeGet<
Rec>();
272 if (r) val = r->get();
274 return val && (rec == *val);
280 DataCap::operator string()
const 282 return "DataCap|"+string(this->buffer());
294 return (n.isNamed()? n.idi.getSym()+
"=" :
"")
298 return (Rec::TYPE_NIL==rec.getType()?
"" : rec.getType())
301 + (isnil(rec.scope())?
"" :
"|")
310 return "Ref->" + (ref.empty()? util::BOTTOM_INDICATOR
324 :
public Variant<diff::DataValues>::Renderer
326 #define RENDER_CONTENT(_TY_) \ 327 virtual string handle (_TY_ const& val) override { return util::toString(val); } 330 RENDER_CONTENT (int64_t)
331 RENDER_CONTENT (
short)
332 RENDER_CONTENT (
char)
333 RENDER_CONTENT (
double)
334 RENDER_CONTENT (
bool)
339 #undef RENDER_CONTENT 341 virtual string handle (
string const& val)
override {
return val; }
342 virtual string handle (
LuidH const& val)
override {
return util::showHash(val, 2);}
344 virtual string handle (
Rec const& rec)
override {
return renderCompact(rec); }
348 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