Fixposition SDK 0.0.0-heads/main-0-g7b59b93
Collection of c++ libraries and apps for use with Fixposition products
|
String utilities. More...
Functions | |
std::string | Sprintf (const char *const fmt,...) PRINTF_ATTR(1) |
Format string. | |
std::string | Vsprintf (const char *fmt, va_list args) |
Format string. | |
std::string | Strftime (const char *const fmt, const int64_t ts=0, const bool utc=false) |
Format time. | |
int | StrReplace (std::string &str, const std::string &search, const std::string &replace, const int max=0) |
Search and replace. | |
void | StrTrimLeft (std::string &str) |
Trim string left. | |
void | StrTrimRight (std::string &str) |
Trim string right. | |
void | StrTrim (std::string &str) |
Trim string left and right. | |
std::vector< std::string > | StrSplit (const std::string &str, const std::string &sep, const int maxNum=0) |
Split string. | |
std::string | StrJoin (const std::vector< std::string > &strs, const std::string &sep) |
Join strings. | |
std::vector< std::string > | StrMap (const std::vector< std::string > &strs, std::function< std::string(const std::string &)> map) |
Map strings. | |
void | MakeUnique (std::vector< std::string > &strs) |
Remove duplicates. | |
std::vector< std::string > | HexDump (const std::vector< uint8_t > data) |
Format hexdump of data. | |
std::vector< std::string > | HexDump (const uint8_t *data, const std::size_t size) |
Format hexdump of data. | |
bool | StrStartsWith (const std::string &str, const std::string &prefix) |
Check if one string starts with another string. | |
bool | StrEndsWith (const std::string &str, const std::string &suffix) |
Check if one string ends with another string. | |
bool | StrContains (const std::string &str, const std::string &sub) |
Check if one string is contained within another string string. | |
bool | StrToValue (const std::string &str, int8_t &value) |
Convert string to value (int8_t) | |
bool | StrToValue (const std::string &str, uint8_t &value) |
Convert string to value (uint8_t) | |
bool | StrToValue (const std::string &str, int16_t &value) |
Convert string to value (int16_t) | |
bool | StrToValue (const std::string &str, uint16_t &value) |
Convert string to value (uint16_t) | |
bool | StrToValue (const std::string &str, int32_t &value) |
Convert string to value (int32_t) | |
bool | StrToValue (const std::string &str, uint32_t &value) |
Convert string to value (uint32_t) | |
bool | StrToValue (const std::string &str, int64_t &value) |
Convert string to value (int64_t, long) | |
bool | StrToValue (const std::string &str, uint64_t &value) |
Convert string to value (uint64_t, unsigned long) | |
bool | StrToValue (const std::string &str, float &value) |
Convert string to value (float) | |
bool | StrToValue (const std::string &str, double &value) |
Convert string to value (double) | |
std::string | StrToUpper (const std::string &str) |
Convert string to all upper case. | |
std::string | StrToLower (const std::string &str) |
Convert string to all lower case. | |
String utilities.
std::string fpsdk::common::string::Sprintf | ( | const char *const | fmt, |
... ) |
Format string.
[in] | fmt | printf() style format string |
[in] | ... | Arguments to the format string |
std::string fpsdk::common::string::Vsprintf | ( | const char * | fmt, |
va_list | args ) |
Format string.
[in] | fmt | printf() style format string |
[in] | args | Arguments list to the format string |
std::string fpsdk::common::string::Strftime | ( | const char *const | fmt, |
const int64_t | ts = 0, | ||
const bool | utc = false ) |
Format time.
[in] | fmt | Format, see strftime(3), can be NULL for a default "yyyy-mm-dd hh:mm:ss" format |
[in] | ts | Posix timestamp [s] (time_t), or 0 for "now" |
[in] | utc | Format as UTC (true) or localtime (false, default) |
int fpsdk::common::string::StrReplace | ( | std::string & | str, |
const std::string & | search, | ||
const std::string & | replace, | ||
const int | max = 0 ) |
Search and replace.
[in,out] | str | The string to search and replace in |
[in] | search | The search term |
[in] | replace | The replacement |
[in] | max | Maximum number of replacements to do (or <= 0 for unlimited) |
void fpsdk::common::string::StrTrimLeft | ( | std::string & | str | ) |
Trim string left.
[in,out] | str | The string with all whitespace (" ", \t, \r, \n) removed on the left |
void fpsdk::common::string::StrTrimRight | ( | std::string & | str | ) |
Trim string right.
[in,out] | str | The string with all whitespace (" ", \t, \r, \n) removed on the right |
void fpsdk::common::string::StrTrim | ( | std::string & | str | ) |
Trim string left and right.
[in,out] | str | The string with all whitespace (" ", \t, \r, \n) removed on the left and the right |
std::vector< std::string > fpsdk::common::string::StrSplit | ( | const std::string & | str, |
const std::string & | sep, | ||
const int | maxNum = 0 ) |
Split string.
Splits a string using a separator string. All parts, including empty ones, are returned. An empty separator leads to only one part, that is equal to the input string.
Examples: "foo,bar,baz" separated by "," --> [ "foo", "bar", "baz" ] "foo,bar,baz" separated by "," (max=2) --> [ "foo", "bar,baz" ] "foo,,baz,,," separated by "," --> [ "foo", "", "baz", "", "", "" ]
[in] | str | The string |
[in] | sep | The separator, empty string is allowed |
[in] | maxNum | The maximum number of parts, or 0 (default) for as many as necessary |
std::string fpsdk::common::string::StrJoin | ( | const std::vector< std::string > & | strs, |
const std::string & | sep ) |
Join strings.
[in] | strs | List of strings to join |
[in] | sep | Separator |
std::vector< std::string > fpsdk::common::string::StrMap | ( | const std::vector< std::string > & | strs, |
std::function< std::string(const std::string &)> | map ) |
Map strings.
[in] | strs | List of strings to map |
[in] | map | Map function |
void fpsdk::common::string::MakeUnique | ( | std::vector< std::string > & | strs | ) |
Remove duplicates.
[in] | strs | List of strings |
std::vector< std::string > fpsdk::common::string::HexDump | ( | const std::vector< uint8_t > | data | ) |
Format hexdump of data.
[in] | data | The data |
std::vector< std::string > fpsdk::common::string::HexDump | ( | const uint8_t * | data, |
const std::size_t | size ) |
Format hexdump of data.
[in] | data | The data |
[in] | size | The size of the data |
bool fpsdk::common::string::StrStartsWith | ( | const std::string & | str, |
const std::string & | prefix ) |
Check if one string starts with another string.
[in] | str | String to check |
[in] | prefix | Prefix to check, length must be >= length of str |
bool fpsdk::common::string::StrEndsWith | ( | const std::string & | str, |
const std::string & | suffix ) |
Check if one string ends with another string.
[in] | str | String to check |
[in] | suffix | Prefix to check, length must be >= length of str |
bool fpsdk::common::string::StrContains | ( | const std::string & | str, |
const std::string & | sub ) |
Check if one string is contained within another string string.
[in] | str | String to check |
[in] | sub | String to find |
bool fpsdk::common::string::StrToValue | ( | const std::string & | str, |
int8_t & | value ) |
Convert string to value (int8_t)
[in] | str | The string, decimal, hex ("0x...") or octal ("0..."), valid range: INT8_MIN..INT8_MAX |
[out] | value | The value |
Referenced by fpsdk::apps::fpltool::FplToolOptions::HandleOption().
bool fpsdk::common::string::StrToValue | ( | const std::string & | str, |
uint8_t & | value ) |
Convert string to value (uint8_t)
[in] | str | The string, decimal, hex ("0x...") or octal ("0..."), valid range: 0..UINT8_MAX |
[out] | value | The value |
bool fpsdk::common::string::StrToValue | ( | const std::string & | str, |
int16_t & | value ) |
Convert string to value (int16_t)
[in] | str | The string, decimal, hex ("0x...") or octal ("0..."), valid range: INT16_MIN..INT16_MAX |
[out] | value | The value |
bool fpsdk::common::string::StrToValue | ( | const std::string & | str, |
uint16_t & | value ) |
Convert string to value (uint16_t)
[in] | str | The string, decimal, hex ("0x...") or octal ("0..."), valid range: 0..UINT16_MAX |
[out] | value | The value |
bool fpsdk::common::string::StrToValue | ( | const std::string & | str, |
int32_t & | value ) |
Convert string to value (int32_t)
[in] | str | The string, decimal, hex ("0x...") or octal ("0..."), valid range: INT32_MIN..INT32_MAX |
[out] | value | The value |
bool fpsdk::common::string::StrToValue | ( | const std::string & | str, |
uint32_t & | value ) |
Convert string to value (uint32_t)
[in] | str | The string, decimal, hex ("0x...") or octal ("0..."), valid range: 0..UINT32_MAX |
[out] | value | The value |
bool fpsdk::common::string::StrToValue | ( | const std::string & | str, |
int64_t & | value ) |
Convert string to value (int64_t, long)
[in] | str | The string, decimal, hex ("0x...") or octal ("0..."), valid range: (INT64_MIN+1)..(INT64_MAX-1) |
[out] | value | The value |
bool fpsdk::common::string::StrToValue | ( | const std::string & | str, |
uint64_t & | value ) |
Convert string to value (uint64_t, unsigned long)
[in] | str | The string, decimal, hex ("0x...") or octal ("0..."), valid range: 0..(INT64_MAX-1) |
[out] | value | The value |
bool fpsdk::common::string::StrToValue | ( | const std::string & | str, |
float & | value ) |
Convert string to value (float)
[in] | str | The string, anything f understands (but not infinite or NaN) |
[out] | value | The value |
bool fpsdk::common::string::StrToValue | ( | const std::string & | str, |
double & | value ) |
Convert string to value (double)
[in] | str | The string, anything f understands (but not infinite or NaN) |
[out] | value | The value |
std::string fpsdk::common::string::StrToUpper | ( | const std::string & | str | ) |
Convert string to all upper case.
[in] | str | The string |
std::string fpsdk::common::string::StrToLower | ( | const std::string & | str | ) |
Convert string to all lower case.
[in] | str | The string |