![]() |
appkit
1.5.1
RoadNarrows Robotics Application Kit
|
String. More...
Typedefs | |
| typedef std::vector< std::string > | StringVec |
| Useful types. More... | |
Functions | |
| std::string | okstr (bool b) |
| Convert boolean to "ok" or "not-ok". More... | |
| std::string | space (unsigned n) |
| Create space string. More... | |
| size_t | split (const std::string &str, const char delim, StringVec &elems) |
| Split string. More... | |
| StringVec | split (const std::string &str, const char delim) |
| Split string. More... | |
| std::string & | ltrim (std::string &str) |
| Trim string in-place of leading whitespace. More... | |
| std::string | ltrim (const char *s) |
| Trim copy of string of leading whitespace. More... | |
| std::string & | rtrim (std::string &str) |
| Trim string in-place of trailing whitespace. More... | |
| std::string | rtrim (const char *s) |
| Trim copy of string of trailing whitespace. More... | |
| std::string & | trim (std::string &str) |
| Trim string in-place of leading and trailing whitespace. More... | |
| std::string | trim (const char *s) |
| Trim copy of string of leading and trailing whitespace. More... | |
| std::string & | replace (const std::string &what, const std::string &with, std::string &str) |
| In-place replace all whats in string with with. More... | |
| std::string | replace (const std::string &what, const std::string &with, const char *s) |
| Copy replace all whats in string with with. More... | |
| std::string | lowercase (const std::string &str) |
| Convert in-place string to lower case. More... | |
| std::string | lowercase (const char *s) |
| Convert copy of string to lower case. More... | |
| std::string | uppercase (const std::string &str) |
| Convert string to upper case. More... | |
| std::string | uppercase (const char *s) |
| Convert copy of string to upper case. More... | |
| size_t | gcss (const std::string &str1, const std::string &str2, const size_t pos=0) |
| Find the length of the Greatest Common SubString. More... | |
| int | tobool (const std::string &str, bool &val) |
| Convert string to boolean. More... | |
| int | tolong (const std::string &str, long &val) |
| Convert string to a long integer. More... | |
| int | todouble (const std::string &str, double &val) |
| Convert string to a double-precision floating-point number. More... | |
| std::string | prettify (const std::string &str) |
| Prettify string. More... | |
| std::string | c14n (const std::string &str) |
| Simple canonicalization of a string. More... | |
| std::string | c14n (const str::StringVec &tokens) |
| Canonicalization of a list of tokens into a string. More... | |
| size_t | split (const string &str, const char delim, StringVec &elems) |
| StringVec | split (const string &str, const char delim) |
| string & | replace (const string &what, const string &with, string &str) |
| string | lowercase (const string &str) |
| string | uppercase (const string &str) |
| size_t | gcss (const string &str1, const string &str2, const size_t pos) |
| int | tobool (const string &str, bool &val) |
| int | tolong (const string &str, long &val) |
| int | todouble (const string &str, double &val) |
| string | prettify (const string &str) |
| string | c14n (const string &str) |
Variables | |
| const char * | FalseHood [] |
| Falsehood and truthhood strings. Each list termintate with a NULL. More... | |
| const char * | TruthHood [] |
| strings that equate to true More... | |
String.
| typedef std::vector<std::string> rnr::str::StringVec |
| std::string rnr::str::c14n | ( | const std::string & | str | ) |
Simple canonicalization of a string.
The string is canonical when:
| str | String to canonicalize. |
Referenced by rnr::cmd::CommandLine::addToHistory(), c14n(), rnr::cmd::CommandLine::end(), and uppercase().
| string rnr::str::c14n | ( | const str::StringVec & | tokens | ) |
Canonicalization of a list of tokens into a string.
| tokens | String tokens to canonicalize. |
Definition at line 296 of file StringTheory.cxx.
References c14n(), and prettify().
| size_t rnr::str::gcss | ( | const std::string & | str1, |
| const std::string & | str2, | ||
| const size_t | pos = 0 |
||
| ) |
Find the length of the Greatest Common SubString.
Examples:
| string 1 | string 2 | length |
|---|---|---|
| "abcd" | "x" | 0 |
| "abcd" | "bc" | 2 |
| "abcd" | "bcx" | 2 |
| "abcd" | "bcdef" | 3 |
| str1 | String 1. |
| str2 | String 2. |
| pos | Starting position in str1. |
Referenced by rnr::cmd::CommandLine::rlTabList(), and uppercase().
| std::string rnr::str::lowercase | ( | const std::string & | str | ) |
Convert in-place string to lower case.
| [in,out] | str | String to convert. |
Referenced by rnr::cmd::CmdArgDef::convert(), lowercase(), rnr::cmd::CmdArgDef::match(), rnr::cmd::CmdArgDef::matchLiteral(), replace(), and rnr::cmd::CommandLine::rlPartialMatch().
|
inline |
Convert copy of string to lower case.
| [in] | s | Null-terminated character string. Cannot be NULL. |
Definition at line 265 of file StringTheory.h.
References lowercase(), and uppercase().
|
inline |
Trim string in-place of leading whitespace.
| [in,out] | str | String to trim. |
Definition at line 143 of file StringTheory.h.
|
inline |
Trim copy of string of leading whitespace.
| [in] | s | Null-terminated character string. Cannot be NULL. |
Definition at line 157 of file StringTheory.h.
References ltrim().
|
inline |
Convert boolean to "ok" or "not-ok".
| b | Boolean value. |
Definition at line 98 of file StringTheory.h.
Referenced by rnr::cmd::CommandLine::parseArg(), rnr::cmd::CommandLine::parseArgv0(), rnr::cmd::CommandLine::parseIdentifier(), rnr::cmd::CommandLine::parseLiteralArg(), rnr::cmd::CommandLine::parseLiteralValue(), rnr::cmd::CommandLine::parseOptionalArgList(), rnr::cmd::CommandLine::parseRequiredArgList(), rnr::cmd::CommandLine::parseSyntax(), rnr::cmd::CommandLine::parseVariableArg(), rnr::cmd::CommandLine::parseVarMod(), rnr::cmd::CommandLine::parseVarRangeExpr(), rnr::cmd::CommandLine::parseVarRegExpr(), rnr::cmd::CommandLine::parseVarType(), rnr::cmd::CommandLine::parseXorList(), rnr::cmd::CommandLine::parseXorListArg(), rnr::cmd::CommandLine::tokEq(), and rnr::cmd::CommandLine::tokIdentifier().
| std::string rnr::str::prettify | ( | const std::string & | str | ) |
Prettify string.
Binary characters are converted to ascii escape hex sequences. Control characters are converted to standard ascii escape sequences. If required, the string is double quoted ('"') to conform to sh(1) strings.
| str | String to make pretty. |
Referenced by c14n(), rnr::cmd::CommandLine::c14n(), rnr::cmd::Token::printAnnotated(), and uppercase().
| std::string& rnr::str::replace | ( | const std::string & | what, |
| const std::string & | with, | ||
| std::string & | str | ||
| ) |
In-place replace all whats in string with with.
| what | What substrings to replace. | |
| with | With this substring. | |
| [in,out] | str | String before and after. |
Referenced by rnr::cmd::addons::execBtEnable(), rnr::cmd::addons::execQuit(), rnr::cmd::addons::printCmdHelp(), replace(), and trim().
|
inline |
Copy replace all whats in string with with.
| what | What substrings to replace. | |
| with | With this substring. | |
| [in] | s | Null-terminated character string. Cannot be NULL. |
Definition at line 241 of file StringTheory.h.
References lowercase(), and replace().
|
inline |
Trim string in-place of trailing whitespace.
| [in,out] | str | String to trim. |
Definition at line 170 of file StringTheory.h.
Referenced by rnr::chronos::Time::operator>(), rtrim(), and trim().
|
inline |
Trim copy of string of trailing whitespace.
| [in] | s | Null-terminated character string. Cannot be NULL. |
Definition at line 184 of file StringTheory.h.
References rtrim().
|
inline |
Create space string.
| n | Number of spaces. |
Definition at line 110 of file StringTheory.h.
References split().
| size_t rnr::str::split | ( | const std::string & | str, |
| const char | delim, | ||
| StringVec & | elems | ||
| ) |
Split string.
| [in] | str | String to split. |
| [in] | delim | Character delimiter. |
| [in,out] | elems | Vector of split strings. |
Referenced by rnr::cmd::CommandLine::addCommand(), rnr::cmd::CommandLine::parseVarRangeExpr(), rnr::cmd::addons::printCmdHelp(), and space().
| StringVec rnr::str::split | ( | const std::string & | str, |
| const char | delim | ||
| ) |
Split string.
| [in] | str | String to split. |
| [in] | delim | Character delimiter. |
| int rnr::str::tobool | ( | const std::string & | str, |
| bool & | val | ||
| ) |
Convert string to boolean.
false: "0" "false" "f" "off" "low" "disable" "open" true: "1" "true" "t" "on" "high" "enable" "close"
| [in] | str | String in hex, decimal, or octal format. |
| [out] | val | Converted boolean value. |
Referenced by rnr::cmd::CmdArgDef::convert(), rnr::cmd::CmdArgDef::match(), and uppercase().
| int rnr::str::todouble | ( | const std::string & | str, |
| double & | val | ||
| ) |
Convert string to a double-precision floating-point number.
| [in] | str | String in hex, decimal, or octal format. |
| [out] | val | Converted double value. |
Referenced by rnr::cmd::CmdArgDef::convert(), rnr::cmd::CmdArgDef::match(), rnr::cmd::CommandLine::parseVarRangeExpr(), and uppercase().
| int rnr::str::tolong | ( | const std::string & | str, |
| long & | val | ||
| ) |
Convert string to a long integer.
| [in] | str | String in hex, decimal, or octal format. |
| [out] | val | Converted long value. |
Referenced by rnr::cmd::CmdArgDef::convert(), rnr::cmd::CmdArgDef::match(), and uppercase().
|
inline |
Trim string in-place of leading and trailing whitespace.
| [in,out] | str | String to trim. |
Definition at line 197 of file StringTheory.h.
References ltrim(), and rtrim().
Referenced by rnr::cmd::ReadLine::freadLine(), rnr::cmd::ReadLine::generatorWrapper(), and trim().
|
inline |
Trim copy of string of leading and trailing whitespace.
| [in] | s | Null-terminated character string. Cannot be NULL. |
Definition at line 209 of file StringTheory.h.
References replace(), and trim().
| std::string rnr::str::uppercase | ( | const std::string & | str | ) |
Convert string to upper case.
| [in,out] | str | String to convert. |
Referenced by lowercase(), and uppercase().
|
inline |
Convert copy of string to upper case.
| [in] | s | Null-terminated character string. Cannot be NULL. |
Definition at line 287 of file StringTheory.h.
References c14n(), gcss(), prettify(), tobool(), todouble(), tolong(), and uppercase().
| const char * rnr::str::FalseHood |
Falsehood and truthhood strings. Each list termintate with a NULL.
strings that equate to false
Definition at line 77 of file StringTheory.cxx.
Referenced by rnr::cmd::CommandLine::rlTabList().
| const char * rnr::str::TruthHood |
strings that equate to true
Definition at line 82 of file StringTheory.cxx.
Referenced by rnr::cmd::CommandLine::rlTabList().