diff options
Diffstat (limited to 'lout')
-rw-r--r-- | lout/identity.cc | 16 | ||||
-rw-r--r-- | lout/identity.hh | 4 | ||||
-rw-r--r-- | lout/misc.hh | 5 |
3 files changed, 24 insertions, 1 deletions
diff --git a/lout/identity.cc b/lout/identity.cc index ebe95ef0..aecd9d5f 100644 --- a/lout/identity.cc +++ b/lout/identity.cc @@ -39,6 +39,22 @@ IdentifiableObject::Class::Class (IdentifiableObject::Class *parent, int id, this->className = className; } +void IdentifiableObject::Class::intoStringBuffer(misc::StringBuffer *sb) +{ + sb->append ("<class "); + sb->append (className); + sb->append (" ("); + sb->appendInt (id); + sb->append (")"); + + if (parent) { + sb->append (", parent: "); + parent->intoStringBuffer (sb); + } + + sb->append (">"); +} + HashTable <ConstString, IdentifiableObject::Class> *IdentifiableObject::classesByName = new HashTable<ConstString, IdentifiableObject::Class> (true, true); diff --git a/lout/identity.hh b/lout/identity.hh index 1f0b4bdf..df42b204 100644 --- a/lout/identity.hh +++ b/lout/identity.hh @@ -106,6 +106,8 @@ private: const char *className; Class (Class *parent, int id, const char *className); + + void intoStringBuffer(misc::StringBuffer *sb); }; static container::typed::HashTable <object::ConstString, @@ -121,7 +123,7 @@ protected: public: IdentifiableObject (); - virtual void intoStringBuffer(misc::StringBuffer *sb); + void intoStringBuffer(misc::StringBuffer *sb); /** * \brief Returns the class identifier. diff --git a/lout/misc.hh b/lout/misc.hh index cff8e05b..2ed5e1b0 100644 --- a/lout/misc.hh +++ b/lout/misc.hh @@ -515,6 +515,11 @@ public: * about memory management. */ inline void append(const char *str) { appendNoCopy(strdup(str)); } + inline void appendInt(int n) + { char buf[32]; sprintf (buf, "%d", n); append (buf); } + inline void appendPointer(void *p) + { char buf[32]; sprintf (buf, "%p", p); append (buf); } + inline void appendBool(bool b) { append (b ? "true" : "false"); } void appendNoCopy(char *str); const char *getChars(); void clear (); |