MRPT
2.0.4
|
Header: #include <mrpt/system/string_utils.h>
.
Library: [mrpt-system]
Functions | |
char * | mrpt::system::strtok (char *str, const char *strDelimit, char **context) noexcept |
An OS-independent method for tokenizing a string. More... | |
template<class OUT_CONTAINER > | |
void | mrpt::system::tokenize (const std::string &inString, const std::string &inDelimiters, OUT_CONTAINER &outTokens, bool skipBlankTokens=true) noexcept |
Tokenizes a string according to a set of delimiting characters. More... | |
template void | mrpt::system::tokenize< std::deque< std::string > > (const std::string &inString, const std::string &inDelimiters, std::deque< std::string > &outTokens, bool skipBlankTokens) noexcept |
template void | mrpt::system::tokenize< std::vector< std::string > > (const std::string &inString, const std::string &inDelimiters, std::vector< std::string > &outTokens, bool skipBlankTokens) 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, std::vector< uint16_t > &out_uniStr) |
Decodes a UTF-8 string into an UNICODE string. More... | |
void | mrpt::system::encodeUTF8 (const std::vector< uint16_t > &input, std::string &output) |
Encodes a 2-bytes UNICODE string into a UTF-8 string. More... | |
void | mrpt::system::encodeBase64 (const std::vector< uint8_t > &inputData, std::string &outString) |
Encode a sequence of bytes as a string in base-64. More... | |
bool | mrpt::system::decodeBase64 (const std::string &inString, std::vector< uint8_t > &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... | |
void | mrpt::system::stringListAsString (const std::vector< std::string > &lst, std::string &out, const std::string &newline="\") |
Convert a string list to one single string with new-lines. More... | |
void | mrpt::system::stringListAsString (const std::deque< std::string > &lst, std::string &out, const std::string &newline="\") |
template<typename T > | |
T | mrpt::system::str2num (std::string const &value) |
Original code snippet found in http://stackoverflow.com/a/30357710. More... | |
bool mrpt::system::decodeBase64 | ( | const std::string & | inString, |
std::vector< uint8_t > & | outData | ||
) |
Decode a base-64 string into the original sequence of bytes.
Definition at line 88 of file base64.cpp.
References alphabet, and mrpt::round().
Referenced by TEST().
void mrpt::system::decodeUTF8 | ( | const std::string & | strUTF8, |
std::vector< uint16_t > & | 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::img::CCanvas::textOut().
void mrpt::system::encodeBase64 | ( | const std::vector< uint8_t > & | inputData, |
std::string & | outString | ||
) |
Encode a sequence of bytes as a string in base-64.
Definition at line 29 of file base64.cpp.
References alphabet, and mrpt::round().
Referenced by mrpt::comms::net::http_request(), mrpt::hwdrivers::CNTRIPClient::private_ntrip_thread(), and TEST().
void mrpt::system::encodeUTF8 | ( | const std::vector< uint16_t > & | 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 64 of file string_utils.cpp.
References MASK2BYTES, MASKBITS, and MASKBYTE.
string mrpt::system::lowerCase | ( | const std::string & | str | ) |
Returns an lower-case version of a string.
Definition at line 26 of file string_utils.cpp.
Referenced by mrpt::obs::carmen_log_parse_line(), mrpt::apps::MonteCarloLocalization_Base::do_pf_localization(), mrpt::hwdrivers::CCameraSensor::initialize(), mrpt::ros1bridge::MapHdl::loadMap(), mrpt::graphslam::CWindowObserver::OnEvent(), mrpt::config::CConfigFileBase::read_bool(), and run_test_pf_localization().
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 290 of file string_utils.cpp.
Referenced by aux_format_string_multilines().
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 125 of file string_utils.h.
References mrpt::format().
Referenced by mrpt::nav::CHolonomicFullEval::TOptions::saveToConfigFile().
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 153 of file string_utils.h.
bool mrpt::system::strCmp | ( | const std::string & | s1, |
const std::string & | s2 | ||
) |
Return true if the two strings are equal (case sensitive)
Definition at line 299 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().
bool mrpt::system::strCmpI | ( | const std::string & | s1, |
const std::string & | s2 | ||
) |
Return true if the two strings are equal (case insensitive)
Definition at line 305 of file string_utils.cpp.
References mrpt::system::os::_strcmpi().
Referenced by mrpt::graphslam::CGraphSlamEngine< GRAPH_T >::_execGraphSlamStep(), mrpt::graphslam::apps::TUserOptionsChecker< GRAPH_T >::checkOptimizerExists(), mrpt::graphslam::apps::TUserOptionsChecker< GRAPH_T >::checkRegistrationDeciderExists(), mrpt::graphslam::apps::TUserOptionsChecker< GRAPH_T >::dumpRegistrarsToConsole(), mrpt::hmtslam::CMHPropertiesValuesList::getElemental(), mrpt::graphslam::CGraphSlamEngine< GRAPH_T >::initClass(), mrpt::obs::CObservation3DRangeScan::load(), mrpt::graphs::detail::graph_ops< graph_t >::load_graph_of_poses_from_text_stream(), mrpt::hwdrivers::CNationalInstrumentsDAQ::loadConfig_sensorSpecific(), mrpt::graphslam::CGraphSlamEngine< GRAPH_T >::TRGBDInfoFileParams::parseFile(), mrpt::hmtslam::CMHPropertiesValuesList::setElemental(), and mrpt::graphslam::CGraphSlamEngine< GRAPH_T >::~CGraphSlamEngine().
void mrpt::system::stringListAsString | ( | const std::vector< std::string > & | lst, |
std::string & | out, | ||
const std::string & | newline = "\r\n" |
||
) |
Convert a string list to one single string with new-lines.
Definition at line 351 of file string_utils.cpp.
References impl_stringListAsString().
Referenced by mrpt::config::CConfigFileMemory::CConfigFileMemory(), mrpt::hmtslam::CHMTSLAM::LSLAM_process_message_from_AA(), mrpt::maps::CBeaconMap::saveToMATLABScript3D(), and mrpt::config::CConfigFileMemory::setContent().
void mrpt::system::stringListAsString | ( | const std::deque< std::string > & | lst, |
std::string & | out, | ||
const std::string & | newline = "\r\n" |
||
) |
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 358 of file string_utils.cpp.
References impl_stringListAsString().
bool mrpt::system::strStarts | ( | const std::string & | s1, |
const std::string & | s2 | ||
) |
Return true if "str" starts with "subStr" (case sensitive)
Definition at line 312 of file string_utils.cpp.
References mrpt::system::os::_strncmp().
Referenced by mrpt::io::CTextFileLinesParser::getNextLine().
bool mrpt::system::strStartsI | ( | const std::string & | s1, |
const std::string & | s2 | ||
) |
Return true if "str" starts with "subStr" (case insensitive)
Definition at line 321 of file string_utils.cpp.
References mrpt::system::os::_strnicmp().
Referenced by mrpt::obs::carmen_log_parse_line().
|
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.
Definition at line 197 of file string_utils.cpp.
Referenced by mrpt::hwdrivers::CSICKTim561Eth::decodeScan(), 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().
|
noexcept |
Tokenizes a string according to a set of delimiting characters.
Example:
Will generate 3 tokens:
[in] | skipBlankTokens | If true , consecutive "delimiters" will be considered one single delimiters. If false , a blank token will be returned between each pair of delimiters. |
OUT_CONTAINER | Can be a std::vector or std::deque of std::string's. |
Referenced by mrpt::hwdrivers::CGillAnemometer::doProcess(), mrpt::hwdrivers::CGyroKVHDSP3000::doProcess(), mrpt::maps::internal::TMetricMapTypesRegistry::doRegister(), mrpt::expr::CRuntimeCompiledExpression::ExprVerbose::ExprVerbose(), get_words(), mrpt::poses::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::hwdrivers::TCaptureOptions_FlyCapture2::loadOptionsFrom(), mrpt::hwdrivers::CGPSInterface::parse_NMEA(), mrpt::graphslam::CGraphSlamEngine< GRAPH_T >::TRGBDInfoFileParams::parseFile(), mrpt::config::CConfigFileBase::read_string_first_word(), mrpt::config::CConfigFileBase::read_vector(), mrpt::graphslam::CGraphSlamEngine< GRAPH_T >::readGTFile(), mrpt::graphslam::CGraphSlamEngine< GRAPH_T >::readGTFileRGBD_TUM(), and mrpt::hwdrivers::CNTRIPClient::retrieveListOfMountpoints().
|
noexcept |
|
noexcept |
std::string mrpt::system::trim | ( | const std::string & | str | ) |
Removes leading and trailing spaces.
Definition at line 270 of file string_utils.cpp.
Referenced by add_comment(), add_obj_info(), mrpt::nav::CParameterizedTrajectoryGenerator::CreatePTG(), mrpt::expr::CRuntimeCompiledExpression::ExprVerbose::ExprVerbose(), mrpt::io::CTextFileLinesParser::getNextLine(), CGraphSlamHandler< GRAPH_T >::initOutputDir(), mrpt::hwdrivers::CNTRIPEmitter::loadConfig_sensorSpecific(), mrpt::hwdrivers::CSwissRanger3DCamera::loadConfig_sensorSpecific(), mrpt::hwdrivers::CGPSInterface::loadConfig_sensorSpecific(), mrpt::hwdrivers::CCameraSensor::loadConfig_sensorSpecific(), mrpt::hwdrivers::CGPSInterface::parse_NMEA(), mrpt::config::simpleini::MRPT_IniFileParser::parse_process_var_eval(), mrpt::graphslam::CGraphSlamEngine< GRAPH_T >::TRGBDInfoFileParams::parseFile(), mrpt::config::CConfigFileBase::read_string(), and mrpt::apps::KFSLAMApp::run().
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'.
Definition at line 136 of file string_utils.cpp.
References mrpt::format(), and val.
Referenced by mrpt::system::CTimeLogger::getStatsAsText(), and mrpt::apps::KFSLAMApp::Run_KF_SLAM().
string mrpt::system::upperCase | ( | const std::string & | str | ) |
Returns a upper-case version of a string.
Definition at line 40 of file string_utils.cpp.
Referenced by mrpt::graphslam::apps::TUserOptionsChecker< GRAPH_T >::dumpRegistrarsToConsole(), mrpt::hwdrivers::CPtuDPerception::echoModeQ(), mrpt::hwdrivers::CPtuDPerception::enableLimitsQ(), mrpt::hwdrivers::CCameraSensor::initialize(), mrpt::hwdrivers::CCameraSensor::loadConfig_sensorSpecific(), mrpt::graphslam::CGraphSlamEngine< GRAPH_T >::pauseExec(), mrpt::hwdrivers::CPtuDPerception::powerModeQ(), and mrpt::graphslam::CWindowObserver::registerKeystroke().
Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020 |