OpenDaVINCI  4.15.3
odcore::strings::StringToolbox Class Reference

#include <StringToolbox.h>

Public Member Functions

virtual ~StringToolbox ()
 

Static Public Member Functions

static void trim (string &s)
 
static string replaceAll (const string &s, const char &FROM, const char &TO)
 
static bool equalsIgnoreCase (const string &s1, const string &s2)
 
static vector< string > split (const string &s, const char &delimiter)
 

Detailed Description

This class can be used to perform some useful operations on strings (i.e. remove leading and trailing blanks for example).

Constructor & Destructor Documentation

virtual odcore::strings::StringToolbox::~StringToolbox ( )
inlinevirtual

Member Function Documentation

bool odcore::strings::StringToolbox::equalsIgnoreCase ( const string &  s1,
const string &  s2 
)
static

This method compares two strings while ignoring case.

Parameters
s1String 1
s2String 2
Returns
true if s1 equals s2
string odcore::strings::StringToolbox::replaceAll ( const string &  s,
const char &  FROM,
const char &  TO 
)
static

This method replaces all occurrences of character FROM to character TO.

Parameters
FROMreplace any occurrence of this character
TOby this character.
vector< string > odcore::strings::StringToolbox::split ( const string &  s,
const char &  delimiter 
)
static

This method splits a string using the delimiter according to the following semantics:

split("tokenA", ';').size() == 1. split("tokenA;", ';').size() == 2, second token is "". split(";tokenA", ';').size() == 2, first token is "". split(";tokenA;", ';').size() == 3, first and last tokens are "". split(";tokenA;;", ';').size() == 4, first, third, and fourth tokens are "".

Parameters
sString to split.
delimiter
Returns
Vector of tokens.
void odcore::strings::StringToolbox::trim ( string &  s)
static

This method removes leading and trailing blanks.

Parameters
sString to be trimmed.

Referenced by odcore::io::URLProtocol::getProtocol(), and odcore::base::KeyValueConfiguration::readFrom().