]>
Dogcows Code - chaz/openbox/blob - otk/userstring.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 #ifndef __userstring_hh
3 #define __userstring_hh
12 //! userstring is a std::string with an extra flag specifying if the string is
14 class userstring
: public std::string
17 //! A vector of userstrings
18 typedef std::vector
<userstring
> vector
;
24 userstring(bool utf8
) : std::string(), _utf8(utf8
) {}
25 userstring(const userstring
& s
, size_type pos
= 0,
26 size_type n
= npos
) : std::string(s
, pos
, n
), _utf8(s
._utf8
) {}
27 userstring(const char *s
, bool utf8
) : std::string(s
), _utf8(utf8
) {}
28 userstring(const char *s
, size_type n
, bool utf8
) : std::string(s
, n
),
30 userstring(size_type n
, char c
, bool utf8
) : std::string(n
, c
),
32 userstring(const_iterator first
, const_iterator last
, bool utf8
) :
33 std::string(first
, last
), _utf8(utf8
) {}
35 //! Returns if the string is encoded in UTF-8 or not
36 inline bool utf8() const { return _utf8
; }
38 inline void setUtf8(bool u
) { _utf8
= u
; }
40 inline userstring
& insert(size_type pos
, const userstring
& s
) {
41 assert(s
._utf8
== _utf8
);
42 std::string::insert(pos
, s
);
46 inline userstring
& insert(size_type pos
,
48 size_type pos1
, size_type n
) {
49 assert(s
._utf8
== _utf8
);
50 std::string::insert(pos
, s
, pos1
, n
);
54 inline userstring
& append(const userstring
& s
) {
55 assert(s
._utf8
== _utf8
);
56 std::string::append(s
);
60 inline userstring
& append(const userstring
& s
,
61 size_type pos
, size_type n
) {
62 assert(s
._utf8
== _utf8
);
63 std::string::append(s
, pos
, n
);
67 inline userstring
& assign(const userstring
& s
) {
68 assert(s
._utf8
== _utf8
);
69 std::string::assign(s
);
73 inline userstring
& assign(const userstring
& s
,
74 size_type pos
, size_type n
) {
75 assert(s
._utf8
== _utf8
);
76 std::string::assign(s
, pos
, n
);
80 inline userstring
& replace(size_type pos
, size_type n
,
81 const userstring
& s
) {
82 assert(s
._utf8
== _utf8
);
83 std::string::replace(pos
, n
, s
);
87 inline userstring
& replace(size_type pos
, size_type n
,
89 size_type pos1
, size_type n1
) {
90 assert(s
._utf8
== _utf8
);
91 std::string::replace(pos
, n
, s
, pos1
, n1
);
95 inline userstring
& operator=(const userstring
& s
) {
99 inline userstring
& operator+=(const userstring
& s
) {
104 #endif // __userstring_hh
This page took 0.036032 seconds and 4 git commands to generate.