]> icculus.org git repositories - mikachu/openbox.git/blob - otk/userstring.hh
add 'userstring', a std::string with a flag for UTF-8
[mikachu/openbox.git] / otk / userstring.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 #ifndef   __userstring_hh
3 #define   __userstring_hh
4
5 #include <string>
6
7 //! userstring is a std::string with an extra flag specifying if the string is
8 //! UTF-8 encoded.
9 class userstring : public std::string
10 {
11 private:
12   bool _utf8;
13
14 public:
15   userstring(bool utf8) : std::string(), _utf8(utf8) {}
16   userstring(const userstring& s, bool utf8, size_type pos = 0,
17              size_type n = npos) : std::string(s, pos, n), _utf8(utf8) {}
18   userstring(const charT *s, bool utf8) : std::string(s), _utf8(utf8) {}
19   userstring(const charT* s, size_type n, bool utf8) : std::string(s, n),
20                                                        _utf8(utf8) {}
21   userstring(size_type n, charT c, bool utf8) : std::string(n, c),
22                                                 _utf8(utf8) {}
23
24   //! Returns if the string is encoded in UTF-8 or not
25   inline bool utf8() const { return _utf8; }
26 };
27
28 #endif // __userstring_hh