]> git.tdb.fi Git - libs/gl.git/blobdiff - source/core/tag.h
Use Tag to identify uniforms in Program and ProgramData
[libs/gl.git] / source / core / tag.h
diff --git a/source/core/tag.h b/source/core/tag.h
new file mode 100644 (file)
index 0000000..dbc0b3e
--- /dev/null
@@ -0,0 +1,34 @@
+#ifndef MSP_GL_TAG_H_
+#define MSP_GL_TAG_H_
+
+#include <string>
+#include <msp/strings/lexicalcast.h>
+
+namespace Msp {
+namespace GL {
+
+/**
+Provides transparent string-to-hash conversion for faster comparison.  An empty
+string is guaranteed to have an id of 0.
+*/
+struct Tag
+{
+       unsigned id;
+
+       Tag(): id(0) { }
+       Tag(const char *);
+       Tag(const std::string &s);
+
+       std::string str() const;
+
+       bool operator<(Tag t) const { return id<t.id; }
+       bool operator==(Tag t) const { return id==t.id; }
+       bool operator!=(Tag t) const { return id!=t.id; }
+};
+
+void operator<<(LexicalConverter &, Tag);
+
+} // namespace GL
+} // namespace Msp
+
+#endif