DUNE: Uniform Navigational Environment  2019.02.1
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 void resize (char *str, int size)
 
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

Referenced by splitMulti().

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.

Referenced by format().

std::string DUNE::Utils::String::escape ( const std::string &  input)
static

Referenced by format(), and DUNE::IMC::toJSON().

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 join(), and DUNE::FileSystem::Path::normalize().

std::string DUNE::Utils::String::fromHex ( const std::string &  str)
static

Referenced by splitMulti().

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

References str().

Referenced by splitMulti().

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 join(), and trim().

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

Referenced by format(), and DUNE::IMC::toJSON().

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

Referenced by format().

void DUNE::Utils::String::resize ( char *  str,
int  size 
)
static

Resize string by replacing any extra characters with '\0'.

If size is greater than current size, the string is untouched. If size is lower than 0, the resulting size is [strlen(str) + size].

Parameters
strobject string
sizenew size

Referenced by join().

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 join(), and 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
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.

Referenced by format().

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 splitMulti(), and 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 join(), DUNE::Utils::TupleList::operator<<(), DUNE::Hardware::BasicModem::readRaw(), and split().

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

Referenced by format().

Collaboration diagram for DUNE::Utils::String:
Collaboration graph