summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2003-01-12 19:42:44 +0000
committerDana Jansens <danakj@orodu.net>2003-01-12 19:42:44 +0000
commit718be4c9111f47349645003e3e68b4698cdeb955 (patch)
tree84b92010abe91c9bbf7505591dd3a3397bccd7b2
parent7bfe234d812f14eed1a7d20db9479780390adc99 (diff)
add 'userstring', a std::string with a flag for UTF-8
-rw-r--r--otk/userstring.hh28
1 files changed, 28 insertions, 0 deletions
diff --git a/otk/userstring.hh b/otk/userstring.hh
new file mode 100644
index 00000000..0690f802
--- /dev/null
+++ b/otk/userstring.hh
@@ -0,0 +1,28 @@
+// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
+#ifndef __userstring_hh
+#define __userstring_hh
+
+#include <string>
+
+//! userstring is a std::string with an extra flag specifying if the string is
+//! UTF-8 encoded.
+class userstring : public std::string
+{
+private:
+ bool _utf8;
+
+public:
+ userstring(bool utf8) : std::string(), _utf8(utf8) {}
+ userstring(const userstring& s, bool utf8, size_type pos = 0,
+ size_type n = npos) : std::string(s, pos, n), _utf8(utf8) {}
+ userstring(const charT *s, bool utf8) : std::string(s), _utf8(utf8) {}
+ userstring(const charT* s, size_type n, bool utf8) : std::string(s, n),
+ _utf8(utf8) {}
+ userstring(size_type n, charT c, bool utf8) : std::string(n, c),
+ _utf8(utf8) {}
+
+ //! Returns if the string is encoded in UTF-8 or not
+ inline bool utf8() const { return _utf8; }
+};
+
+#endif // __userstring_hh