From bfb7bbd2f5fa8aa09d2b22e26ced9f94d5520126 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sun, 5 Jul 2015 03:17:39 +0200 Subject: [PATCH] implement Record: operator string() for diagnostics --- src/lib/diff/gen-node.hpp | 11 +- src/lib/diff/record.hpp | 48 ++++++-- .../generic-record-representation-test.cpp | 1 + wiki/thinkPad.ichthyo.mm | 112 ++++++++++++++---- 4 files changed, 141 insertions(+), 31 deletions(-) diff --git a/src/lib/diff/gen-node.hpp b/src/lib/diff/gen-node.hpp index cf395d6ac..f902b9895 100644 --- a/src/lib/diff/gen-node.hpp +++ b/src/lib/diff/gen-node.hpp @@ -237,9 +237,9 @@ namespace diff{ } bool - contains (GenNode const&) const + contains (GenNode const& elm) const { - UNIMPLEMENTED("containment check"); + return contains (elm.idi); } bool @@ -388,6 +388,13 @@ namespace diff{ return GenNode(v); ///TODO } + template<> + inline string + Rec::renderAttribute (GenNode const& a) + { + return "notyet = todo"; ////TODO + } + }} // namespace lib::diff #endif /*LIB_DIFF_GEN_NODE_H*/ diff --git a/src/lib/diff/record.hpp b/src/lib/diff/record.hpp index 07471ac63..44c48ac7f 100644 --- a/src/lib/diff/record.hpp +++ b/src/lib/diff/record.hpp @@ -88,8 +88,8 @@ #include "lib/iter-adapter.hpp" #include "lib/iter-adapter-stl.hpp" #include "lib/itertools.hpp" +#include "lib/util.hpp" -//#include "lib/util.hpp" //#include "lib/format-string.hpp" #include @@ -122,10 +122,10 @@ namespace diff{ * syntax. Yet the most relevant use case is \c Record -- using the * embedded name-ID of the GenNode elements as key for attributes. * - * Recode elements meant to be immutable; they can be created from a + * 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. Especially, Lumiera's diff framework relies on this. + * and GenNode. Essentially, Lumiera's diff framework relies on this. */ template class Record @@ -180,10 +180,8 @@ namespace diff{ // all default copy operations acceptable - operator std::string() const - { - return "nebbich"; ////TODO - } + /** for diagnostic purpose, include format-util.hpp */ + operator std::string() const; bool @@ -206,9 +204,9 @@ namespace diff{ } bool - contains (VAL const& ref) const + contains (VAL const& val) const { - return false; ////TODO + return util::contains (children_, val); } VAL const& @@ -304,6 +302,7 @@ namespace diff{ static bool isTypeID (VAL const& v); static string extractTypeID (VAL const& v); static VAL buildTypeAttribute (string const& typeID); + static string renderAttribute (VAL const& a); static string extractKey (VAL const& v); static VAL extractVal (VAL const& v); @@ -561,6 +560,37 @@ namespace diff{ return string(); ///TODO } + template<> + inline string + Record::renderAttribute (string const& attrib) + { + return extractKey(attrib) + " = " + string(extractVal(attrib)); + } + + + + + + /* === Diagnostics === */ + + template + Record::operator std::string() const + { +#ifndef LIB_FORMAT_UTIL_H + return "Record(...)"; +#else + using util::join; + using lib::transformIterator; + + return "Rec(" + + join (transformIterator (this->attribs(), renderAttribute)) + + "|{" + + join (this->scope()) + + "})" + ; +#endif + } + }} // namespace lib::diff diff --git a/tests/library/diff/generic-record-representation-test.cpp b/tests/library/diff/generic-record-representation-test.cpp index d6603335c..1e0f83509 100644 --- a/tests/library/diff/generic-record-representation-test.cpp +++ b/tests/library/diff/generic-record-representation-test.cpp @@ -23,6 +23,7 @@ #include "lib/test/run.hpp" #include "lib/test/test-helper.hpp" +#include "lib/format-util.hpp" #include "lib/diff/record.hpp" #include "lib/itertools.hpp" #include "lib/util.hpp" //////TODO necessary? diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 3e1c1ae36..d2fe9bbb6 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -52,7 +52,7 @@ - + @@ -112,8 +112,23 @@ - + + + + + + +

+ erledigt... ähm vertagt +

+

+ aber nicht wirklich; der workaround könnte schon die Lösung sein #963 +

+ + +
+ @@ -178,8 +193,10 @@ - - + + + + @@ -196,7 +213,7 @@ - + @@ -208,7 +225,6 @@ - @@ -228,6 +244,22 @@ + + + + + + + + + +

+ Mutator selber is noncopyable +

+ + +
+
@@ -264,20 +296,53 @@ + + + + + + +

+ nur auf dem Mutator +

+ + +
+
+ + + + + + +

+ dieser ist nicht kopierbar +

+

+ und muß dediziert erstellt werden +

+ + +
+
+
- - - + + + + + + - + - + @@ -287,7 +352,8 @@ scheidet aus, wegen Wertsemantik

-
+ +
@@ -327,7 +393,7 @@ - + @@ -337,10 +403,11 @@ heißt: in der Diff-Verarbeitung wird dieser spezielle check verwendet

-
+ + - + @@ -348,7 +415,7 @@ - + @@ -358,10 +425,11 @@ m.E. die einzig saubere Desgin-Variante!

-
+ +
- + @@ -397,7 +465,7 @@ - + @@ -407,7 +475,8 @@ heißt: wird direkt von standard-equality so behandelt

-
+ + @@ -513,6 +582,9 @@ + + +