X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=otk%2Fustring.hh;fp=otk%2Fustring.hh;h=02111a3379e89dde26e1a90b444226d6a6435cda;hb=4947902d269213edee40f3f31f97721fa0dd3877;hp=03f893d309333ea34b69203cbff93a9ae7d0c701;hpb=2aff07a250930db7e0eb69dd6cd776333fcb8b9a;p=chaz%2Fopenbox diff --git a/otk/ustring.hh b/otk/ustring.hh index 03f893d3..02111a33 100644 --- a/otk/ustring.hh +++ b/otk/ustring.hh @@ -106,8 +106,9 @@ private: #endif // DOXYGEN_IGNORE -//! This class provides a simple wrapper to a std::string that is encoded as -//! UTF-8. +//! This class provides a simple wrapper to a std::string that can be encoded +//! as UTF-8. The ustring::utf() member specifies if the given string is UTF-8 +//! encoded. ustrings default to specifying UTF-8 encoding. /*! This class does not handle extended 8-bit ASCII charsets like ISO-8859-1. @@ -120,7 +121,8 @@ private: */ class ustring { std::string _string; - + bool _utf8; + public: typedef std::string::size_type size_type; typedef std::string::difference_type difference_type; @@ -144,10 +146,15 @@ public: ustring(const std::string& src); ustring::ustring(const char* src); + // append to the string + + ustring& operator+=(const ustring& src); + ustring& operator+=(const char* src); + ustring& operator+=(char c); + // sizes ustring::size_type size() const; - ustring::size_type length() const; ustring::size_type bytes() const; ustring::size_type capacity() const; ustring::size_type max_size() const; @@ -156,7 +163,11 @@ public: const char* data() const; const char* c_str() const; + + // encoding + bool utf8() const; + void setUtf8(bool utf8); }; }