#include <ustring.hh>
Collaboration diagram for otk::ustring:
This class does not handle extended 8-bit ASCII charsets like ISO-8859-1.
More info on Unicode and UTF-8 can be found here: http://www.cl.cam.ac.uk/~mgk25/unicode.html
This does not subclass std::string, because std::string was intended to be a final class. For instance, it does not have a virtual destructor.
Definition at line 103 of file ustring.hh.
Public Types | |
typedef std::string::size_type | size_type |
typedef std::string::difference_type | difference_type |
typedef unichar | value_type |
Public Methods | |
ustring (bool utf8=true) | |
~ustring () | |
ustring (const ustring &other) | |
ustring & | operator= (const ustring &other) |
ustring (const std::string &src, bool utf8=true) | |
ustring (const char *src, bool utf8=true) | |
ustring & | operator+= (const ustring &src) |
ustring & | operator+= (const char *src) |
ustring & | operator+= (char c) |
ustring::size_type | size () const |
ustring::size_type | bytes () const |
ustring::size_type | capacity () const |
ustring::size_type | max_size () const |
bool | empty () const |
void | clear () |
ustring & | erase (size_type i, size_type n=npos) |
void | resize (size_type n, char c='\0') |
value_type | operator[] (size_type i) const |
bool | operator== (const ustring &other) const |
bool | operator== (const std::string &other) const |
bool | operator== (const char *other) const |
const char * | data () const |
const char * | c_str () const |
bool | utf8 () const |
void | setUtf8 (bool utf8) |
Static Public Attributes | |
const size_type | npos = std::string::npos |
Private Attributes | |
std::string | _string |
bool | _utf8 |
|
Definition at line 109 of file ustring.hh. |
|
Definition at line 108 of file ustring.hh. |
|
Definition at line 111 of file ustring.hh. |
|
Definition at line 114 of file ustring.cc.
00115 : _utf8(utf8) 00116 { 00117 } |
|
Definition at line 119 of file ustring.cc.
00120 { 00121 } |
|
Definition at line 123 of file ustring.cc.
|
|
Definition at line 135 of file ustring.cc.
|
|
Definition at line 140 of file ustring.cc.
|
|
Definition at line 173 of file ustring.cc. References _string. Referenced by otk::RenderControl::drawString(), otk::Font::measureString(), and otk::Property::set().
00174 { 00175 return _string.size(); 00176 } |
|
Definition at line 252 of file ustring.cc. References _string. Referenced by otk::RenderControl::drawString(), otk::Font::measureString(), and otk::Property::set().
00253 { 00254 return _string.c_str(); 00255 } |
|
Definition at line 178 of file ustring.cc. References _string.
00179 { 00180 return _string.capacity(); 00181 } |
|
Definition at line 193 of file ustring.cc. References _string.
00194 { 00195 _string.erase(); 00196 } |
|
Definition at line 247 of file ustring.cc. References _string.
00248 { 00249 return _string.data(); 00250 } |
|
Definition at line 188 of file ustring.cc. References _string. Referenced by ob::Client::updateIconTitle(), and ob::Client::updateTitle().
00189 { 00190 return _string.empty(); 00191 } |
|
Definition at line 198 of file ustring.cc. References _string, npos, size_type, and otk::utf8_byte_offset(). Referenced by ob::Frame::adjustSize(), and resize().
00199 { 00200 if (_utf8) { 00201 // find a proper offset 00202 size_type utf_i = utf8_byte_offset(_string.c_str(), i); 00203 if (utf_i != npos) { 00204 // if the offset is not npos, find a proper length for 'n' 00205 size_type utf_n = utf8_byte_offset(_string.data() + utf_i, n, 00206 _string.size() - utf_i); 00207 _string.erase(utf_i, utf_n); 00208 } 00209 } else 00210 _string.erase(i, n); 00211 00212 return *this; 00213 } |
|
Definition at line 183 of file ustring.cc. References _string.
00184 { 00185 return _string.max_size(); 00186 } |
|
Definition at line 158 of file ustring.cc. References _string.
00159 { 00160 _string += c; 00161 return *this; 00162 } |
|
Definition at line 152 of file ustring.cc. References _string.
00153 { 00154 _string += src; 00155 return *this; 00156 } |
|
Definition at line 145 of file ustring.cc. References _string, and _utf8.
00146 { 00147 assert(_utf8 == src._utf8); 00148 _string += src._string; 00149 return *this; 00150 } |
|
Definition at line 128 of file ustring.cc. References _string, and _utf8.
|
|
Definition at line 242 of file ustring.cc. References _string.
00243 { 00244 return _string == other; 00245 } |
|
Definition at line 237 of file ustring.cc. References _string.
00238 { 00239 return _string == other; 00240 } |
|
Definition at line 232 of file ustring.cc. References _string, and _utf8.
|
|
Definition at line 227 of file ustring.cc. References _string, otk::utf8_get_char(), and otk::utf8_offset_to_ptr().
00228 { 00229 return utf8_get_char(utf8_offset_to_ptr(_string.data(), i)); 00230 } |
|
Definition at line 215 of file ustring.cc. References _string, erase(), size(), and size_type. Referenced by ob::LabelWidget::renderForeground(), otk::Label::renderForeground(), and otk::FocusLabel::renderForeground().
|
|
Definition at line 262 of file ustring.cc. References _utf8.
00263 { 00264 _utf8 = utf8; 00265 } |
|
Definition at line 164 of file ustring.cc. References _string, and otk::utf8_ptr_to_offset(). Referenced by ob::Frame::adjustSize(), ob::LabelWidget::renderForeground(), otk::Label::renderForeground(), otk::FocusLabel::renderForeground(), and resize().
00165 { 00166 if (_utf8) { 00167 const char *const pdata = _string.data(); 00168 return utf8_ptr_to_offset(pdata, pdata + _string.size()); 00169 } else 00170 return _string.size(); 00171 } |
|
Definition at line 257 of file ustring.cc. References _utf8. Referenced by otk::RenderControl::drawString(), otk::Font::measureString(), and otk::Property::set().
00258 { 00259 return _utf8; 00260 } |
|
Definition at line 104 of file ustring.hh. Referenced by bytes(), c_str(), capacity(), clear(), data(), empty(), erase(), max_size(), operator+=(), operator=(), operator==(), operator[](), resize(), and size(). |
|
Definition at line 105 of file ustring.hh. Referenced by operator+=(), operator=(), operator==(), setUtf8(), and utf8(). |
|
Definition at line 118 of file ustring.hh. Referenced by erase(). |