diff --git a/src/lib/diff/diff.cpp b/src/lib/diff/diff.cpp index af7be6ee3..2790fc03e 100644 --- a/src/lib/diff/diff.cpp +++ b/src/lib/diff/diff.cpp @@ -32,8 +32,10 @@ #include "lib/error.hpp" +#include "lib/format-util.hpp" #include "lib/diff/diff-language.hpp" #include "lib/diff/gen-node.hpp" +#include "lib/variant.hpp" namespace lib { @@ -49,9 +51,18 @@ namespace diff{ Ref Ref::THIS ("_THIS_"); Ref Ref::CHILD ("_CHILD_"); Ref Ref::ATTRIBS("_ATTRIBS_"); - - /** Implementation of content equality test */ + + + + /** Implementation of content equality test + * @throws error::Logic when the given other DataCap + * does not hold a value of the same type than + * this DataCap. + * @remarks since the GenNode::ID is generated including a type hash, + * the equality operator of GenNode ensures this content test + * is only called on a compatible DataCap. + */ bool DataCap::operator== (DataCap const& o) const { @@ -92,5 +103,11 @@ namespace diff{ unConst(this)->accept(visitor); return visitor; } - + + DataCap::operator string() const + { + return "DataCap|"+string(this->buffer()); + } + + }} // namespace lib::diff diff --git a/src/lib/diff/gen-node.hpp b/src/lib/diff/gen-node.hpp index 2279ba5cb..79218166c 100644 --- a/src/lib/diff/gen-node.hpp +++ b/src/lib/diff/gen-node.hpp @@ -95,20 +95,18 @@ #define LIB_DIFF_GEN_NODE_H -#include "lib/hash-indexed.hpp" ///< @warning needs to be first, see explanation in lib/hash-standard.hpp - #include "lib/error.hpp" -#include "lib/variant.hpp" -#include "lib/time/timevalue.hpp" -#include "lib/diff/record.hpp" #include "lib/idi/entry-id.hpp" +#include "lib/time/timevalue.hpp" //#include "lib/util.hpp" //#include "lib/format-string.hpp" //#include "lib/format-util.hpp" +#include "lib/diff/record.hpp" #include "lib/variant.hpp" #include "lib/util.hpp" //#include +#include #include //#include @@ -178,6 +176,7 @@ namespace diff{ DataCap& operator= (DataCap&&) =default; bool operator== (DataCap const&) const; + operator string() const; }; @@ -247,6 +246,12 @@ namespace diff{ + /** @internal diagnostics helper. Need to include format-helper.cpp */ + operator string() const + { + return "GenNode-"+string(idi)+"-"+string(data); + } + bool isNamed() const { @@ -405,7 +410,7 @@ namespace diff{ inline string Rec::renderAttribute (GenNode const& a) { - return a.idi.getSym() +" = "+string(a.data); + return a.idi.getSym() +" = "+ string(a.data); } template<> diff --git a/src/lib/format-util.hpp b/src/lib/format-util.hpp index dc7ef0e5a..ef472797d 100644 --- a/src/lib/format-util.hpp +++ b/src/lib/format-util.hpp @@ -37,6 +37,7 @@ #ifndef LIB_FORMAT_UTIL_H #define LIB_FORMAT_UTIL_H +#include "lib/hash-standard.hpp" #include "lib/meta/trait.hpp" #include "lib/itertools.hpp" #include "lib/symbol.hpp" @@ -209,4 +210,4 @@ namespace util { } // namespace util -#endif +#endif /*LIB_FORMAT_UTIL_H*/ diff --git a/src/lib/hash-indexed.hpp b/src/lib/hash-indexed.hpp index 7069d296f..325b2c706 100644 --- a/src/lib/hash-indexed.hpp +++ b/src/lib/hash-indexed.hpp @@ -56,6 +56,7 @@ #include "lib/hash-value.h" #include "lib/hash-standard.hpp" +#include "lib/error.hpp" extern "C" { #include "lib/luid.h" diff --git a/src/lib/meta/virtual-copy-support.hpp b/src/lib/meta/virtual-copy-support.hpp index 0e502f579..0fea250de 100644 --- a/src/lib/meta/virtual-copy-support.hpp +++ b/src/lib/meta/virtual-copy-support.hpp @@ -126,7 +126,6 @@ namespace lib { namespace meta{ using std::move; - using util::unConst; using std::is_move_constructible; using std::is_copy_constructible; diff --git a/src/lib/variant.hpp b/src/lib/variant.hpp index 9902e1746..c5fb04477 100644 --- a/src/lib/variant.hpp +++ b/src/lib/variant.hpp @@ -78,10 +78,12 @@ #define LIB_VARIANT_H +#include "lib/error.hpp" #include "lib/meta/typelist.hpp" #include "lib/meta/typelist-util.hpp" #include "lib/meta/generator.hpp" #include "lib/meta/virtual-copy-support.hpp" +#include "lib/util.hpp" #include #include @@ -434,16 +436,17 @@ namespace lib { template Variant::operator string() const { - return string(buffer()); + return "Variant|" + string(buffer()); } template template Variant::Buff::operator string() const { - return "Variant|" -#ifdef LIB_FORMAT_UTIL_H - + util::str (this->access(), +#ifndef LIB_FORMAT_UTIL_H + return string("-?-")+typeid(TY).name()+"-?-"; +#else + return util::str (this->access(), (util::tyStr()+"|").c_str()) #endif ; diff --git a/tests/library/diff/gen-node-basic-test.cpp b/tests/library/diff/gen-node-basic-test.cpp index 6fe4e4ca3..8d0ff2f0d 100644 --- a/tests/library/diff/gen-node-basic-test.cpp +++ b/tests/library/diff/gen-node-basic-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/gen-node.hpp" #include "lib/diff/record.hpp" #include "lib/time/timevalue.hpp" @@ -31,6 +32,7 @@ //#include //#include //#include +#include #include using util::isnil; @@ -44,6 +46,8 @@ using lib::time::TimeSpan; //using std::vector; //using std::swap; using std::fabs; +using std::cout; +using std::endl; namespace lib { @@ -143,6 +147,8 @@ namespace test{ CHECK ("ham" == n3.data.get().get("ham").idi.getSym()); CHECK (n3.data.get().get("ham").isNamed()); CHECK (!n3.isNamed()); + + cout << string(n3) <