X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Frender%2Ftag.cpp;fp=source%2Frender%2Ftag.cpp;h=b5f860334e8a3792b7d8f4fe88f47e2dcd9a4e31;hb=20622e74de6753c5e4460a112c11ee913707e8e8;hp=c5824aec4e114d60b04c53acd00ae2b54072f7fe;hpb=1ce5df9e70385c8758eec39589a148e63238b0a8;p=libs%2Fgl.git diff --git a/source/render/tag.cpp b/source/render/tag.cpp index c5824aec..b5f86033 100644 --- a/source/render/tag.cpp +++ b/source/render/tag.cpp @@ -1,17 +1,54 @@ #include +#include #include +#include #include "tag.h" +using namespace std; + +namespace { + +#ifdef DEBUG +map tag_names; +#endif + +} + namespace Msp { namespace GL { Tag::Tag(const char *s): id((s && *s) ? hash32(s, strlen(s)) : 0) -{ } +{ +#ifdef DEBUG + if(s) + tag_names.insert(make_pair(*this, string(s))); +#endif +} Tag::Tag(const std::string &s): id(s.empty() ? 0 : hash32(s)) -{ } +{ +#ifdef DEBUG + if(!s.empty()) + tag_names.insert(make_pair(*this, s)); +#endif +} + +string Tag::str() const +{ +#ifdef DEBUG + map::const_iterator i=tag_names.find(*this); + if(i!=tag_names.end()) + return i->second; +#endif + return format("Tag(%d)", id); +} + +void operator<<(LexicalConverter &conv, Tag tag) +{ + conv.result(tag.str()); +} } // namespace GL } // namespace Msp