GenNode diagnostics -- debugging

This commit is contained in:
Fischlurch 2015-08-28 23:09:10 +02:00
parent 33a6294a9b
commit bb92b49340
8 changed files with 48 additions and 15 deletions

View file

@ -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

View file

@ -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 <vector>
#include <utility>
#include <string>
//#include <map>
@ -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<>

View file

@ -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*/

View file

@ -56,6 +56,7 @@
#include "lib/hash-value.h"
#include "lib/hash-standard.hpp"
#include "lib/error.hpp"
extern "C" {
#include "lib/luid.h"

View file

@ -126,7 +126,6 @@ namespace lib {
namespace meta{
using std::move;
using util::unConst;
using std::is_move_constructible;
using std::is_copy_constructible;

View file

@ -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 <type_traits>
#include <utility>
@ -434,16 +436,17 @@ namespace lib {
template<typename TYPES>
Variant<TYPES>::operator string() const
{
return string(buffer());
return "Variant|" + string(buffer());
}
template<typename TYPES>
template<typename TY>
Variant<TYPES>::Buff<TY>::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<TY>()+"|").c_str())
#endif
;

View file

@ -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 <utility>
//#include <string>
//#include <vector>
#include <iostream>
#include <cmath>
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<Rec>().get("ham").idi.getSym());
CHECK (n3.data.get<Rec>().get("ham").isNamed());
CHECK (!n3.isNamed());
cout << string(n3) <<endl; // diagnostic spam
}

View file

@ -22,6 +22,7 @@
#include "lib/test/run.hpp"
#include "lib/format-util.hpp"
#include "lib/test/test-helper.hpp"
#include "lib/diff/tree-mutator.hpp"
#include "lib/util.hpp"