|
UTILLib 2.0
Common C++ library with utilities.
|
The string namespace is used for string manipulation functions. More...
Classes | |
| class | IgnoreCase |
| class | StringParser |
| Helper class that splits a string. More... | |
| class | UnitHelper |
| Support class that wrap useful Unit functions. More... | |
| struct | UnitQuantity |
| Unit - quantity -physical dimension relation. More... | |
Typedefs | |
| using | UnitQuantityList = std::vector<UnitQuantity> |
| List of unit quantity physical dimension relation. | |
Functions | |
| bool | IEquals (const std::string &s1, const std::string &s2, size_t nChar=0) |
| Compare strings by ignoring case. | |
| bool | IEquals (const std::wstring &s1, const std::wstring &s2, size_t nChar=0) |
| Compare wide strings by ignoring case. | |
| void | Trim (std::string &text) |
| Remove white space from string. | |
| std::string | Trim (const std::string &text) |
| Remove white space from string. | |
| std::string | FormatDouble (double value, uint8_t decimals, bool fixed=false, const std::string &unit={}) |
| Converts a float to a string. | |
| bool | WildcardMatch (const std::string &text, const std::string &wildcard, bool ignore_case) |
| std::string | FloatToString (float value) |
| Converts a float to string without loosing precision. | |
| std::string | DoubleToString (double value) |
| Converts a double to string without loosing precision. | |
The string namespace is used for string manipulation functions.
|
nodiscard |
Converts a double value to a string without loosing any precision.
| value | Double value to convert |
|
nodiscard |
Converts a float value to a string without loosing any precision.
| value | Float value to convert |
| std::string util::string::FormatDouble | ( | double | value, |
| uint8_t | decimals, | ||
| bool | fixed = false, | ||
| const std::string & | unit = {} ) |
Converts a floating point value to a string using number of decimals.
It also fix rounding and returning a fixed decimals. Presenting fixed number of decimals means that it fills up the string with '0' characters.
Example: Value: 1.23 and decimals 3,String: (Fixed = false) "1.23" (Fixed = true) "1.230"
Optional it can append a unit to the string (Example: "1.23 m/s").
| [in] | value | The floating point value. |
| [in] | decimals | Max number of decimals. |
| [in] | fixed | If it should show fixed number of decimals. |
| [in] | unit | Appends a unit string to the output. |
| bool util::string::IEquals | ( | const std::string & | s1, |
| const std::string & | s2, | ||
| size_t | nChar = 0 ) |
Compare two strings by ignoring case characters.
| s1 | String 1 |
| s2 | String 2 |
| nChar | 0 = Compare all whole string otherwise compare nChar characters. |
| bool util::string::IEquals | ( | const std::wstring & | s1, |
| const std::wstring & | s2, | ||
| size_t | nChar = 0 ) |
Compare two strings by ignoring case characters.
| s1 | String 1 |
| s2 | String 2 |
| nChar | 0 = Compare all whole string otherwise compare nChar characters. |
|
nodiscard |
Remove white space from the begin and end of the string but keep original string.
| text | Input string |
| void util::string::Trim | ( | std::string & | text | ) |
Removes white spaces from the begin and end of the string
| text | String to trim |
| bool util::string::WildcardMatch | ( | const std::string & | text, |
| const std::string & | wildcard, | ||
| bool | ignore_case ) |
Compare a string against a simple * or ? wildcard string
| text | The text to match |
| wildcard | The wildcard string |
| ignore_case | True if the algorithm should ignore case |