C++ API Reference for Intel® Data Analytics Acceleration Library 2019

daal_string.h
1 
2 /*******************************************************************************
3 * Copyright 2014-2018 Intel Corporation.
4 *
5 * This software and the related documents are Intel copyrighted materials, and
6 * your use of them is governed by the express license under which they were
7 * provided to you (License). Unless the License provides otherwise, you may not
8 * use, modify, copy, publish, distribute, disclose or transmit this software or
9 * the related documents without Intel's prior written permission.
10 *
11 * This software and the related documents are provided as is, with no express
12 * or implied warranties, other than those that are expressly stated in the
13 * License.
14 *******************************************************************************/
15 
16 /*
17 //++
18 // Intel(R) DAAL string class.
19 //--
20 */
21 
22 #ifndef __DAAL_STRING__
23 #define __DAAL_STRING__
24 
25 #include <string>
26 #include "base.h"
27 
28 namespace daal
29 {
30 namespace services
31 {
32 namespace interface1
33 {
44 class DAAL_EXPORT String : public Base
45 {
46 public:
50  String();
51 
57  explicit String(size_t length, char placeholder = '\0');
58 
64  explicit String(const char *begin, const char *end);
65 
70  String(const std::string &str)
71  {
72  initialize(str.c_str(), str.size());
73  }
74 
80  String(const char *str, size_t capacity = 0);
81 
86  String(const String &str);
87 
91  ~String();
92 
96  String &operator = (const String &other);
97 
102  size_t length() const;
103 
108  void add(const String &str);
109 
114  String &operator+ (const String &str);
115 
121  char operator[] (size_t index) const;
122 
128  char get(size_t index) const;
129 
134  const char *c_str() const;
135 
136  static const int __DAAL_STR_MAX_SIZE;
138 private:
139  char *_c_str;
140 
141  void reset();
142 
143  void initialize(const char *str, const size_t length);
144 };
158 class StringView : public Base
159 {
160 public:
164  StringView() :
165  _cStr(NULL),
166  _length(0) { }
167 
173  explicit StringView(const char *cstr, size_t length) :
174  _cStr(cstr),
175  _length(length) { }
176 
181  const char *c_str() const
182  {
183  return _cStr;
184  }
185 
190  size_t size() const
191  {
192  return _length;
193  }
194 
199  bool empty() const
200  {
201  return (_cStr == NULL) || (_length == 0);
202  }
203 
209  char operator[] (size_t index) const
210  {
211  DAAL_ASSERT( index < _length );
212  return _cStr[index];
213  }
214 
219  const char *begin() const
220  {
221  return _cStr;
222  }
223 
228  const char *end() const
229  {
230  return _cStr + _length;
231  }
232 
233 private:
234  const char *_cStr;
235  size_t _length;
236 };
239 } // namespace interface1
240 
241 using interface1::String;
242 using interface1::StringView;
243 
244 } // namespace services
245 } // namespace daal
246 
247 #endif
daal::services::interface1::StringView::StringView
StringView()
Definition: daal_string.h:164
daal
Definition: algorithm_base_common.h:31
daal::services::interface1::StringView::operator[]
char operator[](size_t index) const
Definition: daal_string.h:209
daal::services::interface1::String::__DAAL_STR_MAX_SIZE
static const int __DAAL_STR_MAX_SIZE
Definition: daal_string.h:136
daal::services::interface1::String::String
String(const std::string &str)
Definition: daal_string.h:70
daal::services::interface1::StringView::c_str
const char * c_str() const
Definition: daal_string.h:181
daal::services::interface1::StringView::size
size_t size() const
Definition: daal_string.h:190
daal::services::interface1::StringView::end
const char * end() const
Definition: daal_string.h:228
daal::services::interface1::StringView::begin
const char * begin() const
Definition: daal_string.h:219
daal::services::interface1::StringView::StringView
StringView(const char *cstr, size_t length)
Definition: daal_string.h:173
daal::Base
Base class for Intel(R) Data Analytics Acceleration Library objects
Definition: base.h:39
daal::services::interface1::StringView::empty
bool empty() const
Definition: daal_string.h:199
daal::services::interface1::String
Class that implements functionality of the string, an object that represents a sequence of characters...
Definition: daal_string.h:44
daal::services::interface1::StringView
Class that implements functionality of the string but doesn't manage provided memory, user is responsible for correct memory management and deallocation.
Definition: daal_string.h:158

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