C++ API Reference for Intel® Data Analytics Acceleration Library 2020 Update 1

daal_string.h
1 
2 /*******************************************************************************
3 * Copyright 2014-2020 Intel Corporation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *******************************************************************************/
17 
18 /*
19 //++
20 // Intel(R) DAAL string class.
21 //--
22 */
23 
24 #ifndef __DAAL_STRING__
25 #define __DAAL_STRING__
26 
27 #include <string>
28 #include "base.h"
29 
30 namespace daal
31 {
32 namespace services
33 {
34 namespace interface1
35 {
46 class DAAL_EXPORT String : public Base
47 {
48 public:
52  String();
53 
59  explicit String(size_t length, char placeholder = '\0');
60 
67  DAAL_DEPRECATED explicit String(const char *begin, const char *end);
68 
74  DAAL_DEPRECATED String(const std::string &str)
75  {
76  initialize(str.c_str(), str.size());
77  }
78 
85  String(const char *str, size_t capacity = 0);
86 
91  String(const String &str);
92 
96  ~String();
97 
101  String &operator = (const String &other);
102 
107  size_t length() const;
108 
113  void add(const String &str);
114 
119  String &operator+ (const String &str);
120 
126  char operator[] (size_t index) const;
127 
133  char get(size_t index) const;
134 
139  const char *c_str() const;
140 
141  static const int __DAAL_STR_MAX_SIZE;
143 private:
144  char *_c_str;
145 
146  void reset();
147 
148  void initialize(const char *str, const size_t length);
149 };
163 class StringView : public Base
164 {
165 public:
169  StringView() :
170  _cStr(NULL),
171  _length(0) { }
172 
178  explicit StringView(const char *cstr, size_t length) :
179  _cStr(cstr),
180  _length(length) { }
181 
186  const char *c_str() const
187  {
188  return _cStr;
189  }
190 
195  size_t size() const
196  {
197  return _length;
198  }
199 
204  bool empty() const
205  {
206  return (_cStr == NULL) || (_length == 0);
207  }
208 
214  char operator[] (size_t index) const
215  {
216  DAAL_ASSERT( index < _length );
217  return _cStr[index];
218  }
219 
224  const char *begin() const
225  {
226  return _cStr;
227  }
228 
233  const char *end() const
234  {
235  return _cStr + _length;
236  }
237 
238 private:
239  const char *_cStr;
240  size_t _length;
241 };
244 } // namespace interface1
245 
246 using interface1::String;
247 using interface1::StringView;
248 
249 } // namespace services
250 } // namespace daal
251 
252 #endif
daal::services::interface1::StringView
Class that implements functionality of the string but doesn&#39;t manage provided memory, user is responsible for correct memory management and deallocation.
Definition: daal_string.h:163
daal::services::interface1::StringView::StringView
StringView(const char *cstr, size_t length)
Definition: daal_string.h:178
daal::services::interface1::StringView::c_str
const char * c_str() const
Definition: daal_string.h:186
daal::services::interface1::StringView::operator[]
char operator[](size_t index) const
Definition: daal_string.h:214
daal::Base
Base class for Intel(R) Data Analytics Acceleration Library objects
Definition: base.h:41
daal::services::interface1::String::__DAAL_STR_MAX_SIZE
static const int __DAAL_STR_MAX_SIZE
Definition: daal_string.h:141
daal::services::interface1::StringView::end
const char * end() const
Definition: daal_string.h:233
daal::services::interface1::StringView::empty
bool empty() const
Definition: daal_string.h:204
daal::services::interface1::StringView::size
size_t size() const
Definition: daal_string.h:195
daal::services::interface1::String::String
DAAL_DEPRECATED String(const std::string &str)
Definition: daal_string.h:74
daal::services::interface1::StringView::StringView
StringView()
Definition: daal_string.h:169
daal::services::interface1::String
Class that implements functionality of the string, an object that represents a sequence of characters...
Definition: daal_string.h:46
daal::services::interface1::StringView::begin
const char * begin() const
Definition: daal_string.h:224

For more complete information about compiler optimizations, see our Optimization Notice.