]>
Dogcows Code - chaz/openbox/blob - otk/ustring.cc
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
4 # include "../config.h"
5 #endif // HAVE_CONFIG_H
23 ustring::ustring(const ustring
& other
)
24 : _string(other
._string
), _utf8(other
._utf8
)
28 ustring
& ustring::operator=(const ustring
& other
)
30 _string
= other
._string
;
35 ustring::ustring(const std::string
& src
)
36 : _string(src
), _utf8(true)
40 ustring::ustring(const char* src
)
41 : _string(src
), _utf8(true)
45 ustring
& ustring::operator+=(const ustring
& src
)
47 assert(_utf8
== src
._utf8
);
48 _string
+= src
._string
;
52 ustring
& ustring::operator+=(const char* src
)
58 ustring
& ustring::operator+=(char c
)
64 static ustring::size_type
find_utf8_offset(const char *str
, const char *pos
)
66 ustring::size_type offset
= 0;
69 str
+= g_utf8_skip
[*str
];
70 offset
+= g_utf8_skip
[*str
];
76 ustring::size_type
ustring::size() const
79 const char *const pdata
= _string
.data();
80 return find_utf8_offset(pdata
, pdata
+ _string
.size());
82 return _string
.size();
85 ustring::size_type
ustring::bytes() const
87 return _string
.size();
90 ustring::size_type
ustring::capacity() const
92 return _string
.capacity();
95 ustring::size_type
ustring::max_size() const
97 return _string
.max_size();
101 const char* ustring::data() const
103 return _string
.data();
106 const char* ustring::c_str() const
108 return _string
.c_str();
111 bool ustring::utf8() const
116 void ustring::setUtf8(bool utf8
)
This page took 0.048617 seconds and 5 git commands to generate.