DUNE: Uniform Navigational Environment  2016.05.0
DUNE::Utils::String Class Reference

Static Public Member Functions

template<typename Iterator >
static std::string join (Iterator begin, Iterator end, const std::string &separator)
 
static std::string filterDuplicates (char element, const std::string &subject)
 
static std::string ltrim (const std::string &str)
 
static std::string rtrim (const std::string &str)
 
static void rtrim (char *str)
 
static std::string trim (const std::string &str)
 
static void split (const std::string &s, const std::string &sep, std::vector< std::string > &lst)
 
template<typename Type >
static void split (const std::string &s, const std::string &sep, std::vector< Type > &lst)
 
template<typename Type >
static void splitMulti (const std::string &s, const std::string &sep0, const std::string &sep1, std::vector< std::vector< Type > > &lst)
 
static void toLowerCase (std::string &str)
 
static void toUpperCase (std::string &str)
 
static std::string toHex (const std::string &str)
 
static std::string toHex (const std::vector< char > &str)
 
static std::string toHex (int nr)
 
static std::string fromHex (const std::string &str)
 
static void assign (std::vector< char > &dst, const char *src)
 
static std::string getRemaining (const std::string &prefix, const std::string &str)
 
template<typename Type >
static std::string str (Type t)
 
static std::string str (const char *format,...)
 
static int format (char *str, size_t size, const char *format,...)
 
static void replaceWhiteSpace (std::string &str, char rep)
 
static std::string replace (const std::string &str, char rep, const std::string &pat)
 
static std::string escape (const std::string &input)
 
static std::string unescape (const std::string &input, bool unescape_all=true)
 
static bool startsWith (const std::string &str, const std::string &prefix)
 
static bool endsWith (const std::string &str, const std::string &suffix)
 

Member Function Documentation

void DUNE::Utils::String::assign ( std::vector< char > &  dst,
const char *  src 
)
static
bool DUNE::Utils::String::endsWith ( const std::string &  str,
const std::string &  suffix 
)
static

Test if string 'str' ends with a specified 'suffix'.

Parameters
[in]strstring.
[in]suffixsuffix.
Returns
true if 'str' ends with 'suffix', false otherwise.
std::string DUNE::Utils::String::escape ( const std::string &  input)
static
std::string DUNE::Utils::String::filterDuplicates ( char  element,
const std::string &  subject 
)
static

Filter duplicates of a given character in a string.

Parameters
elementelement to filter.
subjectstring to search for duplicates.
Returns
filtered string.

Referenced by DUNE::FileSystem::Path::normalize().

static int DUNE::Utils::String::format ( char *  str,
size_t  size,
const char *  format,
  ... 
)
inlinestatic
std::string DUNE::Utils::String::fromHex ( const std::string &  str)
static
std::string DUNE::Utils::String::getRemaining ( const std::string &  prefix,
const std::string &  str 
)
static

References str().

template<typename Iterator >
static std::string DUNE::Utils::String::join ( Iterator  begin,
Iterator  end,
const std::string &  separator 
)
inlinestatic
std::string DUNE::Utils::String::ltrim ( const std::string &  str)
static

Strip whitespace from the beginning of a string.

Parameters
strobject string.
Returns
string without leading whitespaces.

Referenced by trim().

std::string DUNE::Utils::String::replace ( const std::string &  str,
char  rep,
const std::string &  pat 
)
static
void DUNE::Utils::String::replaceWhiteSpace ( std::string &  str,
char  rep 
)
static
std::string DUNE::Utils::String::rtrim ( const std::string &  str)
static

Strip whitespace from the end of a string.

Parameters
strobject string.
Returns
string without trailing whitespaces.

Referenced by trim().

void DUNE::Utils::String::rtrim ( char *  str)
static

Strip whitespace from the end of a string, modifying the original string.

Parameters
strobject string.
template<typename Type >
static void DUNE::Utils::String::split ( const std::string &  s,
const std::string &  sep,
std::vector< Type > &  lst 
)
inlinestatic

Split a string into a vector of given type.

Parameters
sstring to split.
sepseparator string.
lstvector of Type.

References trim().

template<typename Type >
static void DUNE::Utils::String::splitMulti ( const std::string &  s,
const std::string &  sep0,
const std::string &  sep1,
std::vector< std::vector< Type > > &  lst 
)
inlinestatic

References split().

bool DUNE::Utils::String::startsWith ( const std::string &  str,
const std::string &  prefix 
)
static

Test if string 'str' starts with a specified 'prefix'.

Parameters
[in]strstring.
[in]prefixprefix.
Returns
true if 'str' starts with 'prefix', false otherwise.
static std::string DUNE::Utils::String::str ( const char *  format,
  ... 
)
inlinestatic
std::string DUNE::Utils::String::toHex ( const std::string &  str)
static

References format().

Referenced by DUNE::IMC::toJSON().

std::string DUNE::Utils::String::toHex ( const std::vector< char > &  str)
static

References format().

std::string DUNE::Utils::String::toHex ( int  nr)
static
void DUNE::Utils::String::toLowerCase ( std::string &  str)
static
void DUNE::Utils::String::toUpperCase ( std::string &  str)
static
std::string DUNE::Utils::String::trim ( const std::string &  str)
static

Strip whitespace from the beginning and end of a string.

Parameters
strobject string.
Returns
string without leading and trailing whitespaces.

References ltrim(), and rtrim().

Referenced by DUNE::Utils::TupleList::operator<<(), and split().

std::string DUNE::Utils::String::unescape ( const std::string &  input,
bool  unescape_all = true 
)
static
Collaboration diagram for DUNE::Utils::String:
Collaboration graph