OTB  9.0.0
Orfeo Toolbox
otbStringUtilities.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2023 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbStringUtilities_h
22 #define otbStringUtilities_h
23 
24 #include <algorithm>
25 #include <iterator>
26 #include <cassert>
27 #include <cstring>
28 #include <ostream>
29 #include <sstream>
30 #include <typeinfo>
31 #include <stdexcept>
32 #include <cctype>
33 #include <cstdarg>
34 #include <cmath>
35 #include <string>
36 #include "OTBCommonExport.h"
37 #include "otbMacro.h"
38 
39 namespace otb {
40 
43 
59 {
60  typedef char const value_type;
61  typedef char const& reference;
62  typedef char const& const_reference;
63  typedef char const* const_pointer;
64  typedef char const* pointer;
65  typedef std::size_t size_type;
66 
67 private:
70  {
71  typedef char const value_type;
72  typedef char const& reference;
73  typedef char const* pointer;
74  typedef std::size_t size_type;
75  typedef std::ptrdiff_t difference_type;
76  typedef std::random_access_iterator_tag iterator_category;
77 
78  explicit char_iterator(const_pointer p) : m_ptr(p) {}
79  char_iterator & operator++() { ++m_ptr; return *this; }
80  char_iterator operator++(int) { char_iterator tmp(*this); ++m_ptr; return tmp; }
81  char_iterator & operator--() { --m_ptr; return *this; }
82  char_iterator operator--(int) { char_iterator tmp(*this); --m_ptr; return tmp; }
83  const_reference operator*() const { return *m_ptr; }
84 
85  char_iterator & operator+=(difference_type off) { m_ptr += off; return *this; }
86  char_iterator & operator-=(difference_type off) { m_ptr -= off; return *this; }
87 
88  friend char_iterator operator+(char_iterator lhs, difference_type off) { return lhs += off; }
89  friend char_iterator operator+(difference_type off, char_iterator rhs) { return rhs += off; }
90  friend char_iterator operator-(char_iterator lhs, difference_type off) { return lhs -= off; }
91  friend char_iterator operator-(difference_type off, char_iterator rhs) { return rhs -= off; }
92 
93  friend difference_type operator-(char_iterator lhs, char_iterator rhs) { return lhs.m_ptr - rhs.m_ptr; }
94 
95  friend bool operator==(char_iterator lhs, char_iterator rhs) {
96  return lhs.m_ptr == rhs.m_ptr;
97  }
98  friend bool operator!=(char_iterator lhs, char_iterator rhs) {
99  return lhs.m_ptr != rhs.m_ptr;
100  }
101  friend bool operator<(char_iterator lhs, char_iterator rhs) {
102  return lhs.m_ptr < rhs.m_ptr;
103  }
104  private:
105  friend bool operator<=(char_iterator lhs, char_iterator rhs) {
106  return lhs.m_ptr <= rhs.m_ptr;
107  }
108  private:
110  };
111 
112 public:
113  // typedef char_iterator iterator;
115  // typedef std::reverse_iterator<char_iterator> reverse_iterator;
116  typedef std::reverse_iterator<char_iterator> const_reverse_iterator;
117 
121  string_view(std::string const& s)
122  : m_size(s.size()), m_first(s.c_str())
123  {}
124 
129  template <std::size_t N>
130  string_view(char const (&array)[N])
131  : m_size(N), m_first(&array[0])
132  {}
133 
137  string_view(char const* ptr)
138  : m_size(std::strlen(ptr)), m_first(ptr)
139  {}
140 #if 0
141  string_view(char const* first, char const* last)
142  : m_size(last-first), m_first(first)
143  {
144  assert(first <= last);
145  }
146 #endif
147 
151  template <typename II>
152  string_view(II first, size_type size_)
153  : m_size(size_), m_first(first)
154  {}
155 
159  template <typename II>
160  string_view(II first, II last)
161  : m_size(last-first), m_first(first)
162  {
163  assert(first <= last);
164  }
165 
167  static string_view null() { return string_view(build_empty());}
168 
173  bool belongs_to(char const* first, char const* last) const {
174  return first <= &*begin() && &*end() <= last;
175  }
176  template <std::size_t N>
177  bool belongs_to(char const (&array)[N]) const {
178  // N-1 because of terminal 0
179  return belongs_to(&array[0], &array[N-1]);
180  }
181  bool belongs_to(char const* ptr) const {
182  return belongs_to(&ptr[0], &ptr[std::strlen(ptr)]);
183  }
184  template <typename String>
185  bool belongs_to(String const& s) const{
186  return belongs_to(s.data(), s.data() + s.size());
187  }
189 
190  size_type size () const { return m_size; }
191  bool empty () const { return m_size == 0; }
192 
193  // iterator begin () { return iterator(m_first); }
194  // iterator end () { return iterator(m_first+m_size); }
195  const_iterator begin () const { return m_first; }
196  const_iterator end () const { return m_first+m_size; }
197  const_iterator cbegin () const { return m_first; }
198  const_iterator cend () const { return m_first+m_size; }
199 
200  // reverse_iterator rbegin () { return reverse_iterator(m_first+m_size); }
201  // reverse_iterator rend () { return reverse_iterator(m_first); }
206 
211  assert(p < size());
212  return *(m_first+p);
213  }
215 
219  const_reference front() const { assert(!empty()); return *begin(); }
220 
224  const_reference back () const { assert(!empty()); return *(end()-1); }
225 
229  const_pointer data () const { return &*m_first; }
230 
236  void remove_prefix(std::size_t n) { assert(n <= m_size); m_first += n; m_size -= n; }
237 
243  void remove_suffix(std::size_t n) { assert(n <= m_size); m_size -= n; }
244 private:
245  struct build_empty{};
248 
249  std::size_t m_size;
251 };
252 
253 inline
254 bool operator==(string_view const& lhs, string_view const& rhs)
255 {
256  return lhs.size() == rhs.size()
257  && std::equal(lhs.begin(), lhs.end(), rhs.begin());
258 }
259 inline
260 bool operator!=(string_view const& lhs, string_view const& rhs)
261 {
262  return ! (lhs == rhs);
263 }
264 
265 inline
266 std::ostream & operator<<(std::ostream & os, const string_view & v)
267 {
268  std::copy(v.begin(), v.end(), std::ostream_iterator<char>(os));
269  return os ;
270 }
271 
272 inline
273 std::string operator+(string_view const& lhs, string_view const& rhs)
274 {
275  std::string res(lhs.begin(), lhs.end());
276  res.append(rhs.begin(), rhs.end());
277  return res;
278 }
279 
281 inline
282 bool is_same_view(string_view const& lhs, string_view const& rhs)
283 {
284  return lhs.begin() == rhs.begin() && lhs.size() == rhs.size();
285 }
286 
288 inline
289 bool starts_with(string_view const& haystack, string_view const& needle)
290 {
291  return needle.size() <= haystack.size()
292  && std::equal(needle.begin(), needle.end(), haystack.begin());
293 }
294 
296 inline
297 bool ends_with(string_view const& haystack, string_view const& needle)
298 {
299  return needle.size() <= haystack.size()
300  && std::equal(needle.rbegin(), needle.rend(), haystack.rbegin());
301 }
302 
304 inline
305 string_view find(string_view const& haystack, string_view const& needle)
306 {
307  assert(!haystack.empty());
308  assert(!needle.empty());
309  const string_view::size_type size = needle.size();
310  if (haystack.size() < size) {
311  // std::cout << "haystack size < needle size!!!";
312  return string_view::null();
313  }
314  string_view::const_iterator const end = haystack.end() - size +1;
315  // std::cout << "comp up to:"
316  // << static_cast<void const*>(&*end) << "(" << (*end) << ")"
317  // ;
318  string_view::const_iterator it = haystack.begin();
319  for ( ; it != end ; ++it) {
320  string_view v(it, size);
321  assert(v.size() == size);
322  assert(v.belongs_to(haystack));
323  // std::cout << " check "
324  // << static_cast<void const*>(v.data())<<"["<<v.size()<<"] VS "
325  // << static_cast<void const*>(needle.data())<<"["<<needle.size()<<"]"
326  // ;
327  if (v == needle) {
328  return v;
329  }
330  }
331  assert(it+size-1 == haystack.end());
332  return string_view::null();
333 }
335 
337 inline
338 bool contains(string_view const& haystack, string_view const& needle)
339 {
340  return ! is_same_view(find(haystack, needle), string_view::null());
341 }
343 
344 
347 
354 template <typename Splitter>
356 {
358  typedef string_view const& const_reference;
359  typedef string_view const* const_pointer;
360  typedef std::forward_iterator_tag iterator_category;
361 
362  // build last
363  part_iterator(string_view const& global_string, Splitter s)
364  : m_global(global_string)
365  , m_splitter(s)
366  , m_crt(m_splitter(global_string))
367  {}
368  struct theend {};
369  part_iterator(string_view const& global_string, Splitter s, theend)
370  : m_global(global_string)
371  , m_splitter(s)
372  , m_crt(string_view::null())
373  {}
374 
376  assert(m_crt.belongs_to(m_global) && "Invariant check failure");
377  assert(! is_same_view(m_crt, string_view::null()) && "Don't iterate past end");
378  if (m_crt.end() == m_global.end()) {
380  } else {
381  string_view within(m_crt.end()+m_splitter.next_start(), m_global.end());
382  m_crt = m_splitter(within);
383  }
384  return *this;
385  }
387  part_iterator tmp(*this);
388  ++(*this);
389  return *this;
390  }
392  return m_crt;
393  }
395  return &m_crt;
396  }
397 
398  friend bool operator==(part_iterator const& lhs, part_iterator const& rhs) {
399  // std::cout << "<<"<<lhs<<">> ==?== <<"<<rhs<<">>" << std::endl;
400  assert(is_same_view(lhs.m_global, rhs.m_global));
401  return is_same_view(lhs.m_crt, rhs.m_crt); // TODO: too many tests
402  }
403  friend bool operator!=(part_iterator const& lhs, part_iterator const& rhs) {
404  return ! (lhs == rhs);
405  }
406 #if defined(BOOST_TEST_MODULE)
407  friend std::ostream & operator<<(std::ostream & os, const part_iterator & v)
408  {
409  return os << "split iterator on `" << v.m_crt
410  << "'("<<static_cast<void const*>(&*v.m_crt.begin()) <<"-"<<v.m_crt.size()<<")"<<", within `"
411  << v.m_global << "'";
412  }
413 #endif
414 private:
416  Splitter m_splitter;
418 };
419 
420 namespace details {
421  inline std::size_t len(char) { return 1; }
422  template <std::size_t N> inline std::size_t len(char const (&)[N])
423  { assert(N>0); return N-1; }
424  inline std::size_t len(char const* ptr) { return std::strlen(ptr); }
425  template <typename String> inline std::size_t len(String const& s) { return s.length(); }
426 } // details namespace
427 
434 template <typename Splitter>
436 {
437  part_range(string_view const& global_string, Splitter s)
438  : m_first(global_string, s)
439  , m_last(global_string, s, typename const_iterator::theend())
440  {}
442  const_iterator const& begin() const { return m_first; }
443  const_iterator const& end () const { return m_last; }
444 private:
447 };
449 
455 {
456  splitter_on_delim(char delim) : m_delimiter(delim) {}
457  string_view operator()(string_view const& within) const {
458  string_view res(within.begin(),
459  std::find(within.begin(), within.end(), m_delimiter)
460  );
461  return res ;
462  }
463  std::size_t next_start() const { return details::len(m_delimiter); }
464 private:
466 };
468 
488 template <typename String>
489 part_range<splitter_on_delim> split_on(String const& str, char delim) {
491 }
493 
494 
497 
517 template <typename T>
518 inline
519 T to(string_view const& v, string_view const& context)
520 {
521  T res ;
522  std::stringstream ss;
523  if (ss << v && (ss >> res >> std::ws).eof()) {
524  return res;
525  }
526  throw std::runtime_error("Cannot decode \""+v+"\" as \""+
527  typeid(T).name() + "\" while " + context);
528 }
530 
548 template <typename T>
549 inline
550 T to_with_default(string_view const& v, T const& def = T())
551 {
552  T res = def;
553  std::stringstream ss;
554  if (ss << v && (ss >> res >> std::ws).eof()) {
555  return res;
556  }
557  return def;
558 }
560 
561 namespace details {
576  template <typename Int> inline Int to_integer(string_view const& v, string_view const& context)
577  {
578  // string_view::data() isn't compatible with strtol => we emulate it
579 
580  // TODO: handle HEX, OCT, BIN, locales?
583 
584  bool is_negative = false;
585  Int res = 0;
586  if (it != end) {
587  switch (*it) {
588  case '-': is_negative = true;
590  case '+': ++it;
591  }
592  for ( ; it != end ; ++it) {
593  // only support arabic digits
594  if (!std::isdigit(*it)) {
595  throw std::runtime_error("Cannot decode "+v+" as integer while " + context);
596  }
597  res = 10 * res + *it - '0';
598  }
599  }
600  return is_negative ? -res : res;
601  }
602 
617  template <typename Int> inline Int to_integer(string_view const& v, Int const def)
618  {
619  // string_view::data() isn't compatible with strtol => we emulate it
620 
621  // TODO: handle HEX, OCT, BIN, locales?
624 
625  bool is_negative = false;
626  Int res = 0;
627  if (it != end) {
628  switch (*it) {
629  case '-': is_negative = true; /*[[fallthrough]]*/
630  case '+': ++it;
631  }
632  for ( ; it != end ; ++it) {
633  // only support arabic digits
634  if (!std::isdigit(*it)) {
635  return def;
636  }
637  res = 10 * res + *it - '0';
638  }
639  }
640  return is_negative ? -res : res;
641  }
642 
655  template <typename Int> inline Int to_uinteger(string_view const& v, string_view const& context)
656  {
657  // string_view::data() isn't compatible with strtol => we emulate it
658 
659  // TODO: handle HEX, OCT, BIN, locales?
662 
663  Int res = 0;
664  if (it != end) {
665  for ( ; it != end ; ++it) {
666  // only support arabic digits
667  if (!std::isdigit(*it)) {
668  throw std::runtime_error("Cannot decode "+v+" as integer while " + context);
669  }
670  res = 10 * res + *it - '0';
671  }
672  }
673  return res;
674  }
675 
690  template <typename Int> inline Int to_uinteger(string_view const& v, Int const def)
691  {
692  // string_view::data() isn't compatible with strtol => we emulate it
693 
694  // TODO: handle HEX, OCT, BIN, locales?
697 
698  Int res = 0;
699  if (it != end) {
700  for ( ; it != end ; ++it) {
701  // only support arabic digits
702  if (!std::isdigit(*it)) {
703  return def;
704  }
705  res = 10 * res + *it - '0';
706  }
707  }
708  return res;
709  }
710 
723  template <typename FloatType> inline FloatType to_float(string_view const& v, string_view const& context)
724  {
725  if (contains(v, "nan")) {
726  return std::nan("");
727  }
728  FloatType res = FloatType(); // 0-construction
729  if (!v.empty()) {
730  std::stringstream ss;
731  if (! (ss << v && (ss >> res >> std::ws).eof())) {
732  throw std::runtime_error("Cannot decode "+v+" as float value while " + context);
733  }
734  }
735  return res;
736  }
738 
754  template <typename FloatType> inline FloatType to_float(string_view const& v, FloatType const def)
755  {
756  if (contains(v, "nan")) {
757  return std::nan("");
758  }
759  FloatType res = FloatType(); // 0-construction
760  if (!v.empty()) {
761  std::stringstream ss;
762  if (! (ss << v && (ss >> res >> std::ws).eof())) {
763  return def;
764  }
765  }
766  return res;
767  }
769 
770  inline unsigned int decode_uint(string_view & v)
771  {
772  unsigned int res = 0;
773  for ( ; !v.empty() ; v.remove_prefix(1))
774  {
775  // only support arabic digits
776  if (!std::isdigit(v.front()))
777  break;
778  res = 10 * res + v.front() - '0';
779  }
780  return res;
781  }
782 } // otb::details namespace
783 
784 #define OTB_GENERATE_CONV(internal_to, type) \
785  template <> inline type to<type>(string_view const& v, string_view const& context) \
786  { return details::internal_to<type>(v, context); } \
787  template <> inline type to_with_default<type>(string_view const& v, type const& def) \
788  { return details::internal_to<type>(v, def); }
789 // Note: specialization doesn't support default arguments, but default argument
790 // T() will still work.
791 
793 OTB_GENERATE_CONV(to_uinteger, unsigned char);
794 OTB_GENERATE_CONV(to_integer, signed char);
795 OTB_GENERATE_CONV(to_uinteger, unsigned short);
798 OTB_GENERATE_CONV(to_uinteger, unsigned int);
800 OTB_GENERATE_CONV(to_uinteger, unsigned long);
801 #if defined(HAS_LONG_LONG) // TODO: add this configure option
802 OTB_GENERATE_CONV(to_integer, long long);
803 OTB_GENERATE_CONV(to_uinteger, unsigned long long);
804 #endif
806 OTB_GENERATE_CONV(to_float, double);
807 OTB_GENERATE_CONV(to_float, long double);
808 #undef OTB_GENERATE_CONV
809 
810 template <> inline std::string to<std::string>(string_view const& v, string_view const& /*context*/)
811 { return std::string(v.begin(), v.end()); }
812 
813 template <typename T> inline T const& to(T const& v, string_view const& /*context*/) { return v; }
814 
815 template <typename T> inline T const& to_with_default(T const& v, T const& /* default*/) { return v; }
816 
817 // template <> inline double to<double>(ossimplugins::string_view const& v)
818 // { return details::to_float<double>(v); }
820 
821 //~ OTBCommon_EXPORT int s_printf(char *str, std::size_t size, const char *format, ...);
822 //~ OTBCommon_EXPORT int vs_printf(char *str, std::size_t size, const char *format, std::va_list ap);
823 //~
824 //~ template <std::size_t size>
825 //~ inline
826 //~ int s_printf(char (&str)[size], const char *format, ...) {
827  //~ std::va_list ap;
828  //~ va_start(ap, format);
829  //~ const int res = vs_printf(str, size, format, ap);
830  //~ va_end(ap);
831  //~ return res;
832 //~ }
833 
840 OTBCommon_EXPORT string_view lstrip(string_view const& v, string_view const& c );
841 
848 OTBCommon_EXPORT string_view rstrip(string_view const& v, string_view const& c );
849 
850 
851 } // otb namespace
852 
853 
854 #endif
otb::string_view::remove_prefix
void remove_prefix(std::vcl_size_t n)
Definition: otbStringUtilities.h:236
otb::details::to_uinteger
Int to_uinteger(string_view const &v, Int const def)
Internal generic string to unsigned integer conversion (w/o exception). Tries to convert the input st...
Definition: otbStringUtilities.h:690
otb::part_range
Definition: otbStringUtilities.h:435
otb::string_view::char_iterator::operator-=
char_iterator & operator-=(difference_type off)
Definition: otbStringUtilities.h:86
otb::part_iterator::operator->
const_pointer operator->() const
Definition: otbStringUtilities.h:394
otb::string_view::null
static string_view null()
Definition: otbStringUtilities.h:167
otb::split_on
part_range< splitter_on_delim > split_on(String const &str, char delim)
Definition: otbStringUtilities.h:489
otb::splitter_on_delim::m_delimiter
char m_delimiter
Definition: otbStringUtilities.h:465
otb::string_view::const_reverse_iterator
std::reverse_iterator< char_iterator > const_reverse_iterator
Definition: otbStringUtilities.h:116
otb::string_view::size
size_type size() const
Definition: otbStringUtilities.h:190
otb::string_view::char_iterator::operator+
friend char_iterator operator+(difference_type off, char_iterator rhs)
Definition: otbStringUtilities.h:89
otb::string_view::char_iterator::operator-
friend char_iterator operator-(char_iterator lhs, difference_type off)
Definition: otbStringUtilities.h:90
otb::part_iterator::m_splitter
Splitter m_splitter
Definition: otbStringUtilities.h:416
otb::string_view::belongs_to
bool belongs_to(char const *ptr) const
Definition: otbStringUtilities.h:181
otb::part_iterator::reference
string_view & reference
Definition: otbStringUtilities.h:357
otb::string_view::char_iterator::operator+=
char_iterator & operator+=(difference_type off)
Definition: otbStringUtilities.h:85
otb::part_iterator::iterator_category
std::forward_iterator_tag iterator_category
Definition: otbStringUtilities.h:360
otb::operator+
std::string operator+(string_view const &lhs, string_view const &rhs)
Definition: otbStringUtilities.h:273
otb::string_view::char_iterator::operator*
const_reference operator*() const
Definition: otbStringUtilities.h:83
otb::find
string_view find(string_view const &haystack, string_view const &needle)
Definition: otbStringUtilities.h:305
otb::string_view::m_size
std::vcl_size_t m_size
Definition: otbStringUtilities.h:249
otb::string_view::char_iterator::operator++
char_iterator operator++(int)
Definition: otbStringUtilities.h:80
otb::string_view::string_view
string_view(II first, size_type size_)
Definition: otbStringUtilities.h:152
otb::string_view::char_iterator::iterator_category
std::random_access_iterator_tag iterator_category
Definition: otbStringUtilities.h:76
otb::string_view::crbegin
const_reverse_iterator crbegin() const
Definition: otbStringUtilities.h:204
otb::lstrip
OTBCommon_EXPORT string_view lstrip(string_view const &v, string_view const &c)
returns a string_view with the leading characters removed
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::string_view::char_iterator::value_type
const char value_type
Definition: otbStringUtilities.h:71
otb::string_view::m_first
const_iterator m_first
Definition: otbStringUtilities.h:250
otb::part_range::const_iterator
part_iterator< Splitter > const_iterator
Definition: otbStringUtilities.h:441
otb::string_view::string_view
string_view(II first, II last)
Definition: otbStringUtilities.h:160
otbMacro.h
otb::string_view::const_pointer
char const * const_pointer
Definition: otbStringUtilities.h:63
otb::string_view::string_view
string_view(std::string const &s)
Definition: otbStringUtilities.h:121
otb::operator==
constexpr bool operator==(extents< StaticExtentsL... > const &lhs, extents< StaticExtentsR... > const &rhs)
Definition: otbExtents.h:150
otb::starts_with
bool starts_with(string_view const &haystack, string_view const &needle)
Definition: otbStringUtilities.h:289
otb::string_view::belongs_to
bool belongs_to(char const (&array)[N]) const
Definition: otbStringUtilities.h:177
otb::string_view::build_empty
Definition: otbStringUtilities.h:245
otb::part_iterator::operator++
part_iterator & operator++()
Definition: otbStringUtilities.h:375
otb::string_view::size_type
std::vcl_size_t size_type
Definition: otbStringUtilities.h:65
otb::string_view::cend
const_iterator cend() const
Definition: otbStringUtilities.h:198
otb::details::len
std::vcl_size_t len(char)
Definition: otbStringUtilities.h:421
otb::part_iterator::part_iterator
part_iterator(string_view const &global_string, Splitter s)
Definition: otbStringUtilities.h:363
otb::string_view::const_iterator
char_iterator const_iterator
Definition: otbStringUtilities.h:114
otb::string_view::char_iterator::char_iterator
char_iterator(const_pointer p)
Definition: otbStringUtilities.h:78
otb::string_view::rbegin
const_reverse_iterator rbegin() const
Definition: otbStringUtilities.h:202
otb::to_with_default
T to_with_default(string_view const &v, T const &def=T())
Generic string to whatever conversion – failure is hidden. Tries to decode a value from a string.
Definition: otbStringUtilities.h:550
otb::string_view::belongs_to
bool belongs_to(char const *first, char const *last) const
Definition: otbStringUtilities.h:173
otb::part_range::m_last
const const_iterator m_last
Definition: otbStringUtilities.h:446
otb::string_view::pointer
char const * pointer
Definition: otbStringUtilities.h:64
otb::string_view::char_iterator::operator+
friend char_iterator operator+(char_iterator lhs, difference_type off)
Definition: otbStringUtilities.h:88
otb::string_view::cbegin
const_iterator cbegin() const
Definition: otbStringUtilities.h:197
otb::part_range::part_range
part_range(string_view const &global_string, Splitter s)
Definition: otbStringUtilities.h:437
otb::details::to_float
FloatType to_float(string_view const &v, string_view const &context)
Internal generic string to float conversion (w/ exception). Tries to convert the input string into a ...
Definition: otbStringUtilities.h:723
otb::part_iterator::const_pointer
string_view const * const_pointer
Definition: otbStringUtilities.h:359
otb::part_iterator::operator*
const_reference operator*() const
Definition: otbStringUtilities.h:391
otb::splitter_on_delim::next_start
std::vcl_size_t next_start() const
Definition: otbStringUtilities.h:463
otb::string_view::data
const_pointer data() const
Definition: otbStringUtilities.h:229
otb::rstrip
OTBCommon_EXPORT string_view rstrip(string_view const &v, string_view const &c)
returns a string_view with the ending characters removed
otb::string_view::belongs_to
bool belongs_to(String const &s) const
Definition: otbStringUtilities.h:185
otb::part_iterator::m_global
string_view m_global
Definition: otbStringUtilities.h:415
otb::details::to_integer
Int to_integer(string_view const &v, Int const def)
Internal generic string to integer conversion (w/o exception). Tries to convert the input string into...
Definition: otbStringUtilities.h:617
otb::splitter_on_delim
Definition: otbStringUtilities.h:454
otb::string_view::back
const_reference back() const
Definition: otbStringUtilities.h:224
OTB_FALLTHROUGH
#define OTB_FALLTHROUGH
Definition: otbMacro.h:216
otb::part_iterator::const_reference
string_view const & const_reference
Definition: otbStringUtilities.h:358
otb::part_iterator::theend
Definition: otbStringUtilities.h:368
otb::string_view::value_type
const char value_type
Definition: otbStringUtilities.h:60
otb::string_view::char_iterator::operator-
friend char_iterator operator-(difference_type off, char_iterator rhs)
Definition: otbStringUtilities.h:91
otb::part_iterator::m_crt
string_view m_crt
Definition: otbStringUtilities.h:417
otb::to
T to(string_view const &v, string_view const &context)
Generic string to whatever conversion – failure means exception. Tries to decode a value from a strin...
Definition: otbStringUtilities.h:519
otb::string_view::string_view
string_view(build_empty)
Definition: otbStringUtilities.h:246
otb::part_range::begin
const_iterator const & begin() const
Definition: otbStringUtilities.h:442
otb::string_view::char_iterator::pointer
char const * pointer
Definition: otbStringUtilities.h:73
otb::string_view
Definition: otbStringUtilities.h:58
otb::string_view::remove_suffix
void remove_suffix(std::vcl_size_t n)
Definition: otbStringUtilities.h:243
otb::string_view::string_view
string_view(char const (&array)[N])
Definition: otbStringUtilities.h:130
otb::part_iterator::operator++
part_iterator operator++(int)
Definition: otbStringUtilities.h:386
otb::part_range::end
const_iterator const & end() const
Definition: otbStringUtilities.h:443
otb::string_view::char_iterator::difference_type
std::ptrdiff_t difference_type
Definition: otbStringUtilities.h:75
otb::string_view::end
const_iterator end() const
Definition: otbStringUtilities.h:196
otb::operator!=
constexpr bool operator!=(extents< StaticExtentsL... > const &lhs, extents< StaticExtentsR... > const &rhs)
Definition: otbExtents.h:164
otb::part_iterator::operator==
friend bool operator==(part_iterator const &lhs, part_iterator const &rhs)
Definition: otbStringUtilities.h:398
otb::string_view::const_reference
char const & const_reference
Definition: otbStringUtilities.h:62
otb::string_view::begin
const_iterator begin() const
Definition: otbStringUtilities.h:195
otb::string_view::char_iterator::m_ptr
const_pointer m_ptr
Definition: otbStringUtilities.h:109
otb::string_view::front
const_reference front() const
Definition: otbStringUtilities.h:219
otb::ends_with
bool ends_with(string_view const &haystack, string_view const &needle)
Definition: otbStringUtilities.h:297
otb::string_view::char_iterator::operator-
friend difference_type operator-(char_iterator lhs, char_iterator rhs)
Definition: otbStringUtilities.h:93
otb::details::to_integer
Int to_integer(string_view const &v, string_view const &context)
Internal generic string to integer conversion (w/ exception). Tries to convert the input string into ...
Definition: otbStringUtilities.h:576
otb::splitter_on_delim::splitter_on_delim
splitter_on_delim(char delim)
Definition: otbStringUtilities.h:456
otb::part_range::m_first
const const_iterator m_first
Definition: otbStringUtilities.h:445
otb::string_view::empty
bool empty() const
Definition: otbStringUtilities.h:191
otb::string_view::char_iterator::operator!=
friend bool operator!=(char_iterator lhs, char_iterator rhs)
Definition: otbStringUtilities.h:98
otb::operator<<
OTBCommon_EXPORT std::ostream & operator<<(std::ostream &os, const otb::StringToHTML &str)
otb::string_view::operator[]
const_reference operator[](size_type p)
Definition: otbStringUtilities.h:210
otb::string_view::reference
char const & reference
Definition: otbStringUtilities.h:61
otb::string_view::string_view
string_view(char const *ptr)
Definition: otbStringUtilities.h:137
otb::OTB_GENERATE_CONV
OTB_GENERATE_CONV(to_integer, char)
Generic string to whatever conversion – failure means exception. Tries to decode a value from a strin...
otb::part_iterator::part_iterator
part_iterator(string_view const &global_string, Splitter s, theend)
Definition: otbStringUtilities.h:369
otb::string_view::crend
const_reverse_iterator crend() const
Definition: otbStringUtilities.h:205
otb::string_view::char_iterator
Definition: otbStringUtilities.h:69
otb::part_iterator
Definition: otbStringUtilities.h:355
otb::string_view::char_iterator::operator--
char_iterator operator--(int)
Definition: otbStringUtilities.h:82
otb::string_view::char_iterator::operator++
char_iterator & operator++()
Definition: otbStringUtilities.h:79
otb::string_view::char_iterator::operator==
friend bool operator==(char_iterator lhs, char_iterator rhs)
Definition: otbStringUtilities.h:95
otb::string_view::rend
const_reverse_iterator rend() const
Definition: otbStringUtilities.h:203
otb::details::decode_uint
unsigned int decode_uint(string_view &v)
Internal generic string to float conversion (w/ exception). Tries to convert the input string into a ...
Definition: otbStringUtilities.h:770
otb::details::to_uinteger
Int to_uinteger(string_view const &v, string_view const &context)
Internal generic string to unsigned integer conversion (w/ exception). Tries to convert the input str...
Definition: otbStringUtilities.h:655
otb::string_view::char_iterator::reference
char const & reference
Definition: otbStringUtilities.h:72
otb::splitter_on_delim::operator()
string_view operator()(string_view const &within) const
Definition: otbStringUtilities.h:457
otb::string_view::char_iterator::operator<
friend bool operator<(char_iterator lhs, char_iterator rhs)
Definition: otbStringUtilities.h:101
otb::is_same_view
bool is_same_view(string_view const &lhs, string_view const &rhs)
Definition: otbStringUtilities.h:282
otb::details::to_float
FloatType to_float(string_view const &v, FloatType const def)
Internal generic string to float conversion (w/o exception). Tries to convert the input string into a...
Definition: otbStringUtilities.h:754
otb::string_view::char_iterator::operator<=
friend bool operator<=(char_iterator lhs, char_iterator rhs)
Definition: otbStringUtilities.h:105
otb::part_iterator::operator!=
friend bool operator!=(part_iterator const &lhs, part_iterator const &rhs)
Definition: otbStringUtilities.h:403
otb::string_view::char_iterator::size_type
std::vcl_size_t size_type
Definition: otbStringUtilities.h:74
otb::contains
bool contains(string_view const &haystack, string_view const &needle)
Definition: otbStringUtilities.h:338
otb::string_view::char_iterator::operator--
char_iterator & operator--()
Definition: otbStringUtilities.h:81