44 static std::string
prune(
const std::string& str);
47 static std::string
pruneZeros(
const std::string& str,
int max);
62 static std::string
replace(std::string str,
const std::string& what,
const std::string& by);
65 static std::string
substituteEnvironment(
const std::string& str,
const std::chrono::time_point<std::chrono::system_clock>*
const timeRef =
nullptr);
68 static std::string
isoTimeString(
const std::chrono::time_point<std::chrono::system_clock>*
const timeRef =
nullptr);
71 static bool startsWith(
const std::string& str,
const std::string prefix);
74 static bool endsWith(
const std::string& str,
const std::string suffix);
77 static std::string
padFront(
const std::string& str,
int length,
char padding);
88 static std::string
escapeXML(
const std::string& orig,
const bool maskDoubleHyphen =
false);
93 static std::string
escapeShell(
const std::string& orig);
99 static std::string
urlEncode(
const std::string& url,
const std::string encodeWhich =
"");
102 static std::string
urlDecode(
const std::string& encoded);
105 static std::string
charToHex(
unsigned char c);
108 static unsigned char hexToChar(
const std::string& str);
114 static int toInt(
const std::string& sData);
117 static bool isInt(
const std::string& sData);
121 static int toIntSecure(
const std::string& sData,
int def);
127 static long long int toLong(
const std::string& sData);
130 static bool isLong(
const std::string& sData);
136 static int hexToInt(
const std::string& sData);
139 static bool isHex(std::string sData);
145 static double toDouble(
const std::string& sData);
148 static bool isDouble(
const std::string& sData);
152 static double toDoubleSecure(
const std::string& sData,
const double def);
160 static bool toBool(
const std::string& sData);
163 static bool isBool(
const std::string& sData);
169 static double parseDist(
const std::string& sData);
172 static double parseSpeed(
const std::string& sData,
const bool defaultKmph =
true);
175 static std::string
trim_left(
const std::string s,
const std::string& t =
" \t\n");
178 static std::string
trim_right(
const std::string s,
const std::string& t =
" \t\n");
181 static std::string
trim(
const std::string s,
const std::string& t =
" \t\n");
184 static std::string
wrapText(
const std::string s,
int width);
191 template<
typename T,
typename... Targs>
192 static const std::string
format(
const std::string&
format, T value, Targs... Fargs) {
193 std::ostringstream os;
194 os << std::fixed << std::setprecision(
gPrecision);
206 template<
typename T,
typename... Targs>
207 static void _format(
const char*
format, std::ostringstream& os, T value, Targs... Fargs) {
int gPrecision
the precision for floating point outputs
std::pair< int, double > MMVersion
(M)ajor/(M)inor version for written networks and default version for loading
Some static methods for string processing.
static std::string pruneZeros(const std::string &str, int max)
Removes trailing zeros (at most 'max')
static std::string urlEncode(const std::string &url, const std::string encodeWhich="")
encode url (stem from http://bogomip.net/blog/cpp-url-encoding-and-decoding/)
static bool isDouble(const std::string &sData)
check if the given sData can be conveted to double
static MMVersion toVersion(const std::string &sData)
parse a (network) version string
static bool isBool(const std::string &sData)
check if the given value can be converted to bool
static std::string to_upper_case(const std::string &str)
Transfers the content to upper case.
static std::string charToHex(unsigned char c)
char to hexadecimal
static std::string urlDecode(const std::string &encoded)
decode url (stem from http://bogomip.net/blog/cpp-url-encoding-and-decoding/)
static long long int toLong(const std::string &sData)
converts a string into the long value described by it by calling the char-type converter,...
static double toDoubleSecure(const std::string &sData, const double def)
converts a string into the integer value described by it
static std::string trim(const std::string s, const std::string &t=" \t\n")
remove leading and trailing whitespace
static std::string to_lower_case(const std::string &str)
Transfers the content to lower case.
static void _format(const char *format, std::ostringstream &os, T value, Targs... Fargs)
adds a new formatted message
static std::string trim_right(const std::string s, const std::string &t=" \t\n")
remove trailing whitespace from string
static void _format(const char *format, std::ostringstream &os)
static std::string trim_left(const std::string s, const std::string &t=" \t\n")
remove leading whitespace from string
static std::string escapeShell(const std::string &orig)
Escape special characters with backslash.
static std::string replace(std::string str, const std::string &what, const std::string &by)
Replaces all occurrences of the second string by the third string within the first string.
static int hexToInt(const std::string &sData)
converts a string with a hex value into the integer value described by it by calling the char-type co...
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
static std::string escapeXML(const std::string &orig, const bool maskDoubleHyphen=false)
Replaces the standard escapes by their XML entities.
static bool isHex(std::string sData)
check if the given string can be converted to hex
static std::string latin1_to_utf8(std::string str)
Transfers from Latin 1 (ISO-8859-1) to UTF-8.
static std::string prune(const std::string &str)
Removes trailing and leading whitechars.
static std::string padFront(const std::string &str, int length, char padding)
static std::string convertUmlaute(std::string str)
Converts german "Umlaute" to their latin-version.
static double parseDist(const std::string &sData)
parse a distance, length or width value with a unit
static std::string adjustDecimalValue(double value, int precision)
write with maximum precision if needed but remove trailing zeros
static unsigned char hexToChar(const std::string &str)
hexadecimal to char
static const std::string format(const std::string &format, T value, Targs... Fargs)
adds a new formatted message
static bool startsWith(const std::string &str, const std::string prefix)
Checks whether a given string starts with the prefix.
static std::string wrapText(const std::string s, int width)
remove leading and trailing whitespace
static double parseSpeed(const std::string &sData, const bool defaultKmph=true)
parse a speed value with a unit
static std::string emptyString
An empty string.
static bool endsWith(const std::string &str, const std::string suffix)
Checks whether a given string ends with the suffix.
static std::string substituteEnvironment(const std::string &str, const std::chrono::time_point< std::chrono::system_clock > *const timeRef=nullptr)
Replaces an environment variable with its value (similar to bash); syntax for a variable is ${NAME}.
static bool isLong(const std::string &sData)
Check if the given sData can be converted to long.
static int toIntSecure(const std::string &sData, int def)
converts a string into the integer value described by it
static std::string isoTimeString(const std::chrono::time_point< std::chrono::system_clock > *const timeRef=nullptr)
Returns an ISO8601 formatted time string with microsecond precision.
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter,...
static bool isInt(const std::string &sData)
check if the given sData can be converted to int
static bool toBool(const std::string &sData)
converts a string into the bool value described by it by calling the char-type converter