]> Dogcows Code - chaz/openbox/blob - otk/ustring.cc
begin conversion to ustring. add some more members.
[chaz/openbox] / otk / ustring.cc
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2
3 #ifdef HAVE_CONFIG_H
4 # include "../config.h"
5 #endif // HAVE_CONFIG_H
6
7 #include "ustring.hh"
8
9 extern "C" {
10 #include <assert.h>
11 }
12
13 namespace otk {
14
15 ustring::ustring()
16 {
17 }
18
19 ustring::~ustring()
20 {
21 }
22
23 ustring::ustring(const ustring& other)
24 : _string(other._string)
25 {
26 }
27
28 ustring& ustring::operator=(const ustring& other)
29 {
30 _string = other._string;
31 return *this;
32 }
33
34 ustring::ustring(const std::string& src)
35 : _string(src)
36 {
37 }
38
39 ustring::ustring(const char* src)
40 : _string(src)
41 {
42 }
43
44 static ustring::size_type find_offset(const char *str, const char *pos)
45 {
46 ustring::size_type offset = 0;
47
48 while (str < pos) {
49 str += g_utf8_skip[*str];
50 offset += g_utf8_skip[*str];
51 }
52
53 return offset;
54 }
55
56 ustring::size_type ustring::size() const
57 {
58 const char *const pdata = _string.data();
59 return find_offset(pdata, pdata + _string.size());
60 }
61
62 ustring::size_type ustring::length() const
63 {
64 const char *const pdata = _string.data();
65 return find_offset(pdata, pdata + _string.size());
66 }
67
68 ustring::size_type ustring::bytes() const
69 {
70 return _string.size();
71 }
72
73 ustring::size_type ustring::capacity() const
74 {
75 return _string.capacity();
76 }
77
78 ustring::size_type ustring::max_size() const
79 {
80 return _string.max_size();
81 }
82
83
84 const char* ustring::data() const
85 {
86 return _string.data();
87 }
88
89 const char* ustring::c_str() const
90 {
91 return _string.c_str();
92 }
93
94 }
This page took 0.044585 seconds and 5 git commands to generate.