]> git.tdb.fi Git - libs/gl.git/blob - source/core/tag.cpp
Remove unnecessary std:: qualifiers from .cpp files
[libs/gl.git] / source / core / tag.cpp
1 #include <cstring>
2 #include <map>
3 #include <msp/core/hash.h>
4 #include <msp/strings/format.h>
5 #include "tag.h"
6
7 using namespace std;
8
9 namespace {
10
11 #ifdef DEBUG
12 map<Msp::GL::Tag, string> tag_names;
13 #endif
14
15 }
16
17 namespace Msp {
18 namespace GL {
19
20 Tag::Tag(const char *s):
21         id((s && *s) ? hash32(s, strlen(s)) : 0)
22 {
23 #ifdef DEBUG
24         if(s)
25                 tag_names.insert(make_pair(*this, string(s)));
26 #endif
27 }
28
29 Tag::Tag(const string &s):
30         id(s.empty() ? 0 : hash32(s))
31 {
32 #ifdef DEBUG
33         if(!s.empty())
34                 tag_names.insert(make_pair(*this, s));
35 #endif
36 }
37
38 string Tag::str() const
39 {
40 #ifdef DEBUG
41         map<Tag, string>::const_iterator i=tag_names.find(*this);
42         if(i!=tag_names.end())
43                 return i->second;
44 #endif
45         return format("Tag(%d)", id);
46 }
47
48 void operator<<(LexicalConverter &conv, Tag tag)
49 {
50         conv.result(tag.str());
51 }
52
53 } // namespace GL
54 } // namespace Msp