String.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2011, SRI International (R)
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include <algorithm>
19 #include <string>
20 #include <limits>
21 
22 #include <OpenKarto/String.h>
23 
24 namespace karto
25 {
26 
30 
31 #ifndef _DEBUG
33  {
34  std::string m_String;
35  };
36 #endif
37 
39  : m_pStringPrivate(new StringPrivate())
40  {
41  }
42 
45  {
47  }
48 
49  String::String(const char* pString)
51  {
52  m_pStringPrivate->m_String = pString;
53  }
54 
55  String::String(const char* pString, kt_int32u size)
57  {
58  m_pStringPrivate->m_String = std::string(pString, size);
59  }
60 
61  String::String(const String& rOther)
63  {
65  }
66 
68  {
69  delete m_pStringPrivate;
70  }
71 
72  const char* String::ToCString() const
73  {
74  return m_pStringPrivate->m_String.c_str();
75  }
76 
78  {
79  return m_pStringPrivate->m_String.size();
80  }
81 
82  void String::Append(const String& rString)
83  {
84  m_pStringPrivate->m_String.append(rString.ToCString());
85  }
86 
88  {
89  return String(m_pStringPrivate->m_String.substr(index).c_str());
90  }
91 
93  {
94  return String(m_pStringPrivate->m_String.substr(index, length).c_str());
95  }
96 
97  kt_size_t String::Find(const String& rValue) const
98  {
99  return m_pStringPrivate->m_String.find(rValue.ToCString());
100  }
101 
102  kt_size_t String::FindFirstOf(const String& rValue) const
103  {
104  return m_pStringPrivate->m_String.find_first_of(rValue.ToCString());
105  }
106 
107  kt_size_t String::FindLastOf(const String& rValue) const
108  {
109  return m_pStringPrivate->m_String.find_last_of(rValue.ToCString());
110  }
111 
112  void String::Erase(kt_size_t index, kt_size_t length)
113  {
114  m_pStringPrivate->m_String.erase(index, length);
115  }
116 
118  {
119  return String('\n');
120  }
121 
123  {
124  m_pStringPrivate->m_String.clear();
125  }
126 
127  //String::operator const char *() const
128  //{
129  // return m_pStringPrivate->m_String.c_str();
130  //}
131 
133  {
134  if (&rOther != this)
135  {
137  }
138 
139  return *this;
140  }
141 
142  kt_bool String::operator==(const String& rOther) const
143  {
145  }
146 
147  kt_bool String::operator!=(const String& rOther) const
148  {
150  }
151 
152  kt_bool String::operator<( const String& rOther ) const
153  {
155  }
156 
157  kt_bool String::operator>( const String& rOther ) const
158  {
160  }
161 
163  {
164  return (m_pStringPrivate->m_String + rOther.m_pStringPrivate->m_String).c_str();
165  }
166 
167  karto::String String::operator+(const char* pChar)
168  {
169  return (m_pStringPrivate->m_String + std::string(pChar)).c_str();
170  }
171 
172  int String::operator[]( kt_int32u index ) const
173  {
174  return m_pStringPrivate->m_String[index];
175  }
176 
177 }
void Append(const String &rString)
Definition: String.cpp:82
bool kt_bool
Definition: Types.h:145
std::size_t kt_size_t
Definition: Types.h:138
std::string m_String
Definition: String.cpp:34
kt_bool operator<(const String &rOther) const
Definition: String.cpp:152
kt_size_t FindFirstOf(const String &rValue) const
Definition: String.cpp:102
kt_bool operator>(const String &rOther) const
Definition: String.cpp:157
kt_bool operator==(const String &rOther) const
Definition: String.cpp:142
String SubString(kt_size_t index) const
Definition: String.cpp:87
StringPrivate * m_pStringPrivate
Definition: String.h:242
String operator+(const String &rOther)
Definition: String.cpp:162
void Erase(kt_size_t index, kt_size_t length)
Definition: String.cpp:112
uint32_t kt_int32u
Definition: Types.h:111
virtual ~String()
Definition: String.cpp:67
static String NewLine()
Definition: String.cpp:117
kt_bool operator!=(const String &rOther) const
Definition: String.cpp:147
void Clear()
Definition: String.cpp:122
kt_size_t Find(const String &rValue) const
Definition: String.cpp:97
String & operator=(const String &rOther)
Definition: String.cpp:132
Definition: Any.cpp:20
int operator[](kt_int32u index) const
Definition: String.cpp:172
const char * ToCString() const
Definition: String.cpp:72
kt_size_t FindLastOf(const String &rValue) const
Definition: String.cpp:107
kt_size_t Size() const
Definition: String.cpp:77


nav2d_karto
Author(s): Sebastian Kasperski
autogenerated on Tue Nov 7 2017 06:02:36