From 662aa088c1710830ff30e4ff0b1b407a6d2cea4e Mon Sep 17 00:00:00 2001 From: dooglus Date: Thu, 27 Nov 2008 17:08:11 +0000 Subject: [PATCH] Add ValueBase::get_string() for debugging. Barely tested, but not used either. git-svn-id: https://synfig.svn.sourceforge.net/svnroot/synfig@2292 1f10aa63-cdf2-0310-b900-c93c546f37ac --- synfig-core/trunk/src/synfig/value.cpp | 34 ++++++++++++++++++++++++++++++++++ synfig-core/trunk/src/synfig/value.h | 4 ++++ 2 files changed, 38 insertions(+) diff --git a/synfig-core/trunk/src/synfig/value.cpp b/synfig-core/trunk/src/synfig/value.cpp index d80fbf9..0a85c9b 100644 --- a/synfig-core/trunk/src/synfig/value.cpp +++ b/synfig-core/trunk/src/synfig/value.cpp @@ -96,6 +96,40 @@ ValueBase::get(const char*)const return get(String()).c_str(); } +#ifdef _DEBUG +String +ValueBase::get_string() const +{ + switch(type) + { + case TYPE_NIL: return "Nil"; + case TYPE_BOOL: return strprintf("Bool (%s)", get(bool()) ? "true" : "false"); + case TYPE_INTEGER: return strprintf("Integer (%s)", get(int())); + case TYPE_ANGLE: return strprintf("Angle (%s)", Angle::deg(get(Angle())).get()); + + // All types after this point are larger than 32 bits + + case TYPE_TIME: return strprintf("Time (%s)", get(Time()).get_string().c_str()); + case TYPE_REAL: return strprintf("Real (%f)", get(Real())); + + // All types after this point are larger than 64 bits + + case TYPE_VECTOR: return strprintf("Vector (%f, %f)", get(Vector())[0], get(Vector())[1]); + case TYPE_COLOR: return strprintf("Color (%s)", get(Color()).get_string().c_str()); + case TYPE_SEGMENT: return strprintf("Segment ((%f, %f) to (%f, %f))", get(Segment()).p1[0], get(Segment()).p1[1], get(Segment()).p2[0], get(Segment()).p2[1]); + case TYPE_BLINEPOINT: return strprintf("BLinePoint (%s)", get(BLinePoint()).get_vertex()[0], get(BLinePoint()).get_vertex()[1]); + + // All types after this point require construction/destruction + + case TYPE_LIST: return strprintf("List (%d elements)", get(list_type()).size()); + case TYPE_CANVAS: return strprintf("Canvas (%s)", get(etl::loose_handle())->get_id().c_str()); + case TYPE_STRING: return strprintf("String (%s)", get(String()).c_str()); + case TYPE_GRADIENT: return strprintf("Gradient (%d cpoints)", get(Gradient()).size()); + default: return "Invalid type"; + } +} +#endif // _DEBUG + void ValueBase::set(Canvas* x) { diff --git a/synfig-core/trunk/src/synfig/value.h b/synfig-core/trunk/src/synfig/value.h index 5e38508..7079dba 100644 --- a/synfig-core/trunk/src/synfig/value.h +++ b/synfig-core/trunk/src/synfig/value.h @@ -238,6 +238,10 @@ public: { return get(etl::loose_handle()); } const char* get(const char*)const; const list_type& get_list()const { return get(list_type()); } + +#ifdef _DEBUG + String get_string() const; +#endif // _DEBUG // ======================================================================== -- 2.7.4