OTB  9.0.0
Orfeo Toolbox
Classes | Namespaces | Functions
otbStringUtilities.h File Reference
#include <algorithm>
#include <iterator>
#include <cassert>
#include <cstring>
#include <ostream>
#include <sstream>
#include <typeinfo>
#include <stdexcept>
#include <cctype>
#include <cstdarg>
#include <cmath>
#include <string>
#include "OTBCommonExport.h"
#include "otbMacro.h"
+ Include dependency graph for otbStringUtilities.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  otb::string_view::build_empty
 
struct  otb::string_view::char_iterator
 
struct  otb::part_iterator< Splitter >
 
struct  otb::part_range< Splitter >
 
struct  otb::splitter_on_delim
 
struct  otb::string_view
 
struct  otb::part_iterator< Splitter >::theend
 

Namespaces

 otb
 
 otb::details
 

Functions

template<std::vcl_size_t N>
std::vcl_size_t otb::details::len (char const (&)[N])
 
std::vcl_size_t otb::details::len (char const *ptr)
 
std::vcl_size_t otb::details::len (char)
 
template<typename String >
std::vcl_size_t otb::details::len (String const &s)
 
template<typename Int >
Int otb::details::to_integer (string_view const &v, Int const def)
 
template<typename Int >
Int otb::details::to_integer (string_view const &v, string_view const &context)
 
template<typename Int >
Int otb::details::to_uinteger (string_view const &v, Int const def)
 
template<typename Int >
Int otb::details::to_uinteger (string_view const &v, string_view const &context)
 
String view + functions
bool otb::contains (string_view const &haystack, string_view const &needle)
 
bool otb::ends_with (string_view const &haystack, string_view const &needle)
 
string_view otb::find (string_view const &haystack, string_view const &needle)
 
bool otb::is_same_view (string_view const &lhs, string_view const &rhs)
 
bool otb::operator!= (string_view const &lhs, string_view const &rhs)
 
std::string otb::operator+ (string_view const &lhs, string_view const &rhs)
 
std::ostream & otb::operator<< (std::ostream &os, const string_view &v)
 
bool otb::operator== (string_view const &lhs, string_view const &rhs)
 
bool otb::starts_with (string_view const &haystack, string_view const &needle)
 
Splitting functions
template<typename String >
part_range< splitter_on_delim > otb::split_on (String const &str, char delim)
 
unsigned int otb::details::decode_uint (string_view &v)
 
template<typename FloatType >
FloatType otb::details::to_float (string_view const &v, FloatType const def)
 
template<typename FloatType >
FloatType otb::details::to_float (string_view const &v, string_view const &context)
 
String view + functions
bool otb::operator== (string_view const &lhs, string_view const &rhs)
 
bool otb::operator!= (string_view const &lhs, string_view const &rhs)
 
std::ostream & otb::operator<< (std::ostream &os, const string_view &v)
 
std::string otb::operator+ (string_view const &lhs, string_view const &rhs)
 
bool otb::is_same_view (string_view const &lhs, string_view const &rhs)
 
bool otb::starts_with (string_view const &haystack, string_view const &needle)
 
bool otb::ends_with (string_view const &haystack, string_view const &needle)
 
string_view otb::find (string_view const &haystack, string_view const &needle)
 
bool otb::contains (string_view const &haystack, string_view const &needle)
 
Splitting functions
template<typename String >
part_range< splitter_on_delim > otb::split_on (String const &str, char delim)
 
string to number conversion
template<typename T >
otb::to (string_view const &v, string_view const &context)
 
template<typename T >
otb::to_with_default (string_view const &v, T const &def=T())
 
 otb::OTB_GENERATE_CONV (to_integer, char)
 
 otb::OTB_GENERATE_CONV (to_uinteger, unsigned char)
 
 otb::OTB_GENERATE_CONV (to_integer, signed char)
 
 otb::OTB_GENERATE_CONV (to_uinteger, unsigned short)
 
 otb::OTB_GENERATE_CONV (to_integer, short)
 
 otb::OTB_GENERATE_CONV (to_integer, int)
 
 otb::OTB_GENERATE_CONV (to_uinteger, unsigned int)
 
 otb::OTB_GENERATE_CONV (to_integer, long)
 
 otb::OTB_GENERATE_CONV (to_uinteger, unsigned long)
 
 otb::OTB_GENERATE_CONV (to_float, float)
 
 otb::OTB_GENERATE_CONV (to_float, double)
 
 otb::OTB_GENERATE_CONV (to_float, long double)
 
template<>
std::string otb::to< std::string > (string_view const &v, string_view const &)
 
template<typename T >
T const & otb::to (T const &v, string_view const &)
 
template<typename T >
T const & otb::to_with_default (T const &v, T const &)
 
OTBCommon_EXPORT string_view otb::lstrip (string_view const &v, string_view const &c)
 
OTBCommon_EXPORT string_view otb::rstrip (string_view const &v, string_view const &c)
 
template<typename FloatType >
FloatType otb::details::to_float (string_view const &v, string_view const &context)
 
template<typename FloatType >
FloatType otb::details::to_float (string_view const &v, FloatType const def)
 
unsigned int otb::details::decode_uint (string_view &v)
 

string to number conversion

OTBCommon_EXPORT string_view otb::lstrip (string_view const &v, string_view const &c)
 
#define OTB_GENERATE_CONV(internal_to, type)
 
 otb::OTB_GENERATE_CONV (to_float, double)
 
 otb::OTB_GENERATE_CONV (to_float, float)
 
 otb::OTB_GENERATE_CONV (to_float, long double)
 
 otb::OTB_GENERATE_CONV (to_integer, char)
 
 otb::OTB_GENERATE_CONV (to_integer, int)
 
 otb::OTB_GENERATE_CONV (to_integer, long)
 
 otb::OTB_GENERATE_CONV (to_integer, short)
 
 otb::OTB_GENERATE_CONV (to_integer, signed char)
 
 otb::OTB_GENERATE_CONV (to_uinteger, unsigned char)
 
 otb::OTB_GENERATE_CONV (to_uinteger, unsigned int)
 
 otb::OTB_GENERATE_CONV (to_uinteger, unsigned long)
 
 otb::OTB_GENERATE_CONV (to_uinteger, unsigned short)
 
OTBCommon_EXPORT string_view otb::rstrip (string_view const &v, string_view const &c)
 
template<typename T >
otb::to (string_view const &v, string_view const &context)
 
template<typename T >
T const & otb::to (T const &v, string_view const &)
 
template<>
std::string otb::to< std::string > (string_view const &v, string_view const &)
 
template<typename T >
otb::to_with_default (string_view const &v, T const &def=T())
 
template<typename T >
T const & otb::to_with_default (T const &v, T const &)
 

Macro Definition Documentation

◆ OTB_GENERATE_CONV

#define OTB_GENERATE_CONV (   internal_to,
  type 
)
Value:
template <> inline type to<type>(string_view const& v, string_view const& context) \
{ return details::internal_to<type>(v, context); } \
template <> inline type to_with_default<type>(string_view const& v, type const& def) \
{ return details::internal_to<type>(v, def); }

Generic string to whatever conversion – failure means exception. Tries to decode a value from a string.

Template Parameters
TType of the value decoded from the input string
Parameters
[in]vinput string to convert
[in]contextcontext message for the exception thrown
Returns
The value decoded
Exceptions
std::runtime_errorif a value of type T cannot be decoded from the string.
Note
For efficiency reasons, the function has been specialized for integral floating point, and string types.
That alternative to ossimString::toXxxx() function has been defined to support generic programming in get() and add() helper functions for keyword list.
See also
to_with_default() for the version that never fails, but returns a default value otherwise (being T() by default).

Definition at line 784 of file otbStringUtilities.h.