]> git.tdb.fi Git - libs/gl.git/blob - source/core/tag.h
Use default member initializers for simple types
[libs/gl.git] / source / core / tag.h
1 #ifndef MSP_GL_TAG_H_
2 #define MSP_GL_TAG_H_
3
4 #include <string>
5 #include <msp/strings/lexicalcast.h>
6
7 namespace Msp {
8 namespace GL {
9
10 /**
11 Provides transparent string-to-hash conversion for faster comparison.  An empty
12 string is guaranteed to have an id of 0.
13 */
14 struct Tag
15 {
16         unsigned id = 0;
17
18         Tag() = default;
19         Tag(const char *);
20         Tag(const std::string &s);
21
22         std::string str() const;
23
24         bool operator<(Tag t) const { return id<t.id; }
25         bool operator==(Tag t) const { return id==t.id; }
26         bool operator!=(Tag t) const { return id!=t.id; }
27 };
28
29 void operator<<(LexicalConverter &, Tag);
30
31 } // namespace GL
32 } // namespace Msp
33
34 #endif