Main MRPT website > C++ reference for MRPT 1.9.9
Functions
String management and utilities (in #include

Detailed Description

<mrpt/system/string_utils.h>)

Collaboration diagram for String management and utilities (in #include:

Functions

char * mrpt::system::strtok (char *str, const char *strDelimit, char **context) noexcept
 An OS-independent method for tokenizing a string. More...
 
void mrpt::system::tokenize (const std::string &inString, const std::string &inDelimiters, std::deque< std::string > &outTokens, bool skipBlankTokens=true) noexcept
 Tokenizes a string according to a set of delimiting characters. More...
 
void mrpt::system::tokenize (const std::string &inString, const std::string &inDelimiters, std::vector< std::string > &outTokens, bool skipBlankTokens=true) noexcept
 
std::string mrpt::system::trim (const std::string &str)
 Removes leading and trailing spaces. More...
 
std::string mrpt::system::upperCase (const std::string &str)
 Returns a upper-case version of a string. More...
 
std::string mrpt::system::lowerCase (const std::string &str)
 Returns an lower-case version of a string. More...
 
void mrpt::system::decodeUTF8 (const std::string &strUTF8, vector_word &out_uniStr)
 Decodes a UTF-8 string into an UNICODE string. More...
 
void mrpt::system::encodeUTF8 (const vector_word &input, std::string &output)
 Encodes a 2-bytes UNICODE string into a UTF-8 string. More...
 
void mrpt::system::encodeBase64 (const vector_byte &inputData, std::string &outString)
 Encode a sequence of bytes as a string in base-64. More...
 
bool mrpt::system::decodeBase64 (const std::string &inString, vector_byte &outData)
 Decode a base-64 string into the original sequence of bytes. More...
 
std::string mrpt::system::unitsFormat (const double val, int nDecimalDigits=2, bool middle_space=true)
 This function implements formatting with the appropriate SI metric unit prefix: 1e-12->'p', 1e-9->'n', 1e-6->'u', 1e-3->'m', 1->'', 1e3->'K', 1e6->'M', 1e9->'G', 1e12->'T'. More...
 
std::string mrpt::system::rightPad (const std::string &str, const size_t total_len, bool truncate_if_larger=false)
 Enlarge the string with spaces up to the given length. More...
 
bool mrpt::system::strCmp (const std::string &s1, const std::string &s2)
 Return true if the two strings are equal (case sensitive) More...
 
bool mrpt::system::strCmpI (const std::string &s1, const std::string &s2)
 Return true if the two strings are equal (case insensitive) More...
 
bool mrpt::system::strStarts (const std::string &str, const std::string &subStr)
 Return true if "str" starts with "subStr" (case sensitive) More...
 
bool mrpt::system::strStartsI (const std::string &str, const std::string &subStr)
 Return true if "str" starts with "subStr" (case insensitive) More...
 
template<typename T >
std::string mrpt::system::sprintf_container (const char *fmt, const T &V)
 Generates a string for a container in the format [A,B,C,...], and the fmt string for each vector element. More...
 
template<typename T >
mrpt::system::str2num (std::string const &value)
 Original code snippet found in http://stackoverflow.com/a/30357710. More...
 
template<typename T >
std::string mrpt::system::num2str (T const &value)
 Convert number instance to string. More...
 

Function Documentation

◆ decodeBase64()

bool mrpt::system::decodeBase64 ( const std::string inString,
vector_byte outData 
)

Decode a base-64 string into the original sequence of bytes.

See also
encodeBase64
Returns
false on invalid base-64 string passed as input, true on success.

Definition at line 88 of file base64.cpp.

References alphabet, mrpt::format(), and mrpt::utils::round().

Referenced by TEST().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ decodeUTF8()

void mrpt::system::decodeUTF8 ( const std::string strUTF8,
vector_word out_uniStr 
)

Decodes a UTF-8 string into an UNICODE string.

See http://en.wikipedia.org/wiki/UTF-8 and http://www.codeguru.com/cpp/misc/misc/multi-lingualsupport/article.php/c10451/.

Definition at line 98 of file string_utils.cpp.

References MASK2BYTES, MASK3BYTES, MASKBITS, and MASKBYTE.

Referenced by mrpt::utils::CCanvas::textOut().

Here is the caller graph for this function:

◆ encodeBase64()

void mrpt::system::encodeBase64 ( const vector_byte inputData,
std::string outString 
)

Encode a sequence of bytes as a string in base-64.

See also
decodeBase64

Definition at line 28 of file base64.cpp.

References alphabet, and mrpt::utils::round().

Referenced by mrpt::comms::net::http_request(), mrpt::hwdrivers::CNTRIPClient::private_ntrip_thread(), and TEST().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ encodeUTF8()

void mrpt::system::encodeUTF8 ( const vector_word input,
std::string output 
)

Encodes a 2-bytes UNICODE string into a UTF-8 string.

See http://en.wikipedia.org/wiki/UTF-8 and http://www.codeguru.com/cpp/misc/misc/multi-lingualsupport/article.php/c10451/.

Definition at line 65 of file string_utils.cpp.

References MASK2BYTES, MASKBITS, and MASKBYTE.

◆ lowerCase()

string mrpt::system::lowerCase ( const std::string str)

Returns an lower-case version of a string.

See also
upperCase

Definition at line 27 of file string_utils.cpp.

Referenced by mrpt::obs::carmen_log_parse_line(), mrpt::hwdrivers::CCameraSensor::initialize(), mrpt::graphslam::CWindowObserver::OnEvent(), mrpt::utils::CConfigFileBase::read_bool(), and run_test_pf_localization().

Here is the caller graph for this function:

◆ num2str()

template<typename T >
std::string mrpt::system::num2str ( T const &  value)

Convert number instance to string.

Definition at line 147 of file string_utils.h.

Referenced by mrpt::comms::net::Ping().

Here is the caller graph for this function:

◆ rightPad()

std::string mrpt::system::rightPad ( const std::string str,
const size_t  total_len,
bool  truncate_if_larger = false 
)

Enlarge the string with spaces up to the given length.

Definition at line 295 of file string_utils.cpp.

Referenced by aux_format_string_multilines().

Here is the caller graph for this function:

◆ sprintf_container()

template<typename T >
std::string mrpt::system::sprintf_container ( const char *  fmt,
const T &  V 
)

Generates a string for a container in the format [A,B,C,...], and the fmt string for each vector element.

Definition at line 117 of file string_utils.h.

References mrpt::format().

Referenced by mrpt::nav::CHolonomicFullEval::TOptions::saveToConfigFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ str2num()

template<typename T >
T mrpt::system::str2num ( std::string const &  value)

Original code snippet found in http://stackoverflow.com/a/30357710.

Convert string instance to number

Definition at line 136 of file string_utils.h.

◆ strCmp()

bool mrpt::system::strCmp ( const std::string s1,
const std::string s2 
)

Return true if the two strings are equal (case sensitive)

See also
strCmpI
StrCmpI

Definition at line 304 of file string_utils.cpp.

References mrpt::system::os::_strcmp().

Referenced by mrpt::hwdrivers::CGPSInterface::legacy_topcon_setup_commands(), and mrpt::maps::CHeightGridMap2D::TInsertionOptions::loadFromConfigFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ strCmpI()

bool mrpt::system::strCmpI ( const std::string s1,
const std::string s2 
)

◆ strStarts()

bool mrpt::system::strStarts ( const std::string s1,
const std::string s2 
)

Return true if "str" starts with "subStr" (case sensitive)

See also
strStartsI

Definition at line 317 of file string_utils.cpp.

References mrpt::system::os::_strncmp().

Referenced by mrpt::utils::CTextFileLinesParser::getNextLine().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ strStartsI()

bool mrpt::system::strStartsI ( const std::string s1,
const std::string s2 
)

Return true if "str" starts with "subStr" (case insensitive)

See also
strStarts

Definition at line 326 of file string_utils.cpp.

References mrpt::system::os::_strnicmp().

Referenced by mrpt::obs::carmen_log_parse_line().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ strtok()

char * mrpt::system::strtok ( char *  str,
const char *  strDelimit,
char **  context 
)
noexcept

An OS-independent method for tokenizing a string.

The extra parameter "context" must be a pointer to a "char*" variable, which needs no initialization and is used to save information between calls to strtok.

See also
system::tokenize

Definition at line 196 of file string_utils.cpp.

Referenced by mrpt::hwdrivers::CLMS100Eth::decodeScan(), mrpt::hwdrivers::CImpinjRFID::getObservation(), mrpt::hwdrivers::CWirelessPower::GetPower(), mrpt::hwdrivers::CWirelessPower::ListInterfaces(), mrpt::hwdrivers::CWirelessPower::ListNetworks(), and mrpt::hwdrivers::CTuMicos::radQuerry().

Here is the caller graph for this function:

◆ tokenize() [1/2]

void mrpt::system::tokenize ( const std::string inString,
const std::string inDelimiters,
std::deque< std::string > &  outTokens,
bool  skipBlankTokens = true 
)
noexcept

Tokenizes a string according to a set of delimiting characters.

Example:

std::vector<std::string> tokens;
tokenize(" - Pepe-Er Muo"," -",tokens);

Will generate 3 tokens:

  • "Pepe"
  • "Er"
  • "Muo"
    Parameters
    [in]skipBlankTokensIf true, consecutive "delimiters" will be considered one single delimiters. If false, a blank token will be returned between each pair of delimiters.

Definition at line 258 of file string_utils.cpp.

References my_tokenize().

Referenced by mrpt::utils::CTypeSelector::CTypeSelector(), mrpt::hwdrivers::CGillAnemometer::doProcess(), mrpt::hwdrivers::CGyroKVHDSP3000::doProcess(), mrpt::maps::internal::TMetricMapTypesRegistry::doRegister(), mrpt::utils::CListOfClasses::fromString(), get_words(), mrpt::utils::internal::getPoseFromString(), mrpt::comms::net::http_request(), mrpt::hwdrivers::CNationalInstrumentsDAQ::loadConfig_sensorSpecific(), mrpt::nav::CNavigatorManualSequence::loadConfigFile(), mrpt::nav::CMultiObjectiveMotionOptimizerBase::TParamsBase::loadFromConfigFile(), mrpt::hmtslam::CHMTSLAM::TOptions::loadFromConfigFile(), mrpt::hmtslam::CHierarchicalMHMap::loadFromXMLfile(), mrpt::hwdrivers::TCaptureOptions_FlyCapture2::loadOptionsFrom(), mrpt::hwdrivers::CGPSInterface::parse_NMEA(), mrpt::graphslam::CGraphSlamEngine< GRAPH_T >::TRGBDInfoFileParams::parseFile(), mrpt::utils::CConfigFileBase::read_string_first_word(), mrpt::utils::CConfigFileBase::read_vector(), mrpt::graphslam::CGraphSlamEngine< GRAPH_T >::readGTFile(), mrpt::graphslam::CGraphSlamEngine< GRAPH_T >::readGTFileRGBD_TUM(), mrpt::hwdrivers::CNTRIPClient::retrieveListOfMountpoints(), and mrpt::utils::CStringList::setText().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tokenize() [2/2]

void mrpt::system::tokenize ( const std::string inString,
const std::string inDelimiters,
std::vector< std::string > &  outTokens,
bool  skipBlankTokens = true 
)
noexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 265 of file string_utils.cpp.

References my_tokenize().

Here is the call graph for this function:

◆ trim()

std::string mrpt::system::trim ( const std::string str)

◆ unitsFormat()

std::string mrpt::system::unitsFormat ( const double  val,
int  nDecimalDigits = 2,
bool  middle_space = true 
)

This function implements formatting with the appropriate SI metric unit prefix: 1e-12->'p', 1e-9->'n', 1e-6->'u', 1e-3->'m', 1->'', 1e3->'K', 1e6->'M', 1e9->'G', 1e12->'T'.

See also
intervalFormat

Definition at line 135 of file string_utils.cpp.

References mrpt::format(), and val.

Referenced by mrpt::utils::CTimeLogger::getStatsAsText().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ upperCase()

string mrpt::system::upperCase ( const std::string str)



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019