![]()  | 
  
    Fixposition SDK 0.0.0-heads/main-0-gb93ddb4
    
   Collection of c++ libraries and apps for use with Fixposition products on Linux 
   | 
 
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.   | |
| std::string | StrFormatBits (const uint64_t value, const std::size_t size=64) | 
| Format value to "bits string".   | |
| 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)   | |
| bool | StrToValue (const std::string &str, bool &value) | 
| Convert string to value (bool)   | |
| 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.   | |
| std::string | StrError (const int errnum) | 
| Stringify glibc error.   | |
| constexpr const char * | ToStr (const bool value) | 
| Stringify value (bool)   | |
| std::vector< uint8_t > | StrToBuf (const std::string &str) | 
| Convert string to buffer.   | |
| std::string | BufToStr (const std::vector< uint8_t > &buf) | 
| Convert buffer to string.   | |
| std::string | Base64Enc (const std::vector< uint8_t > &buf) | 
| Encode to base64.   | |
| std::vector< uint8_t > | Base64Dec (const std::string &str) | 
| Decode from base64.   | |
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 | 
References PRINTF_ATTR.
| 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 | 
References Vsprintf().
Referenced by Vsprintf().
| 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) | 
References Strftime().
Referenced by Strftime().
| 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) | 
References StrReplace().
Referenced by StrReplace().
| 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 | 
References StrTrimLeft().
Referenced by StrTrimLeft().
| 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 | 
References StrTrimRight().
Referenced by StrTrimRight().
| void fpsdk::common::string::StrTrim | ( | std::string & | str | ) | 
| 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 | 
References StrSplit().
Referenced by StrSplit().
| std::string fpsdk::common::string::StrJoin | ( | const std::vector< std::string > & | strs, | 
| const std::string & | sep ) | 
| std::vector< std::string > fpsdk::common::string::StrMap | ( | const std::vector< std::string > & | strs, | 
| std::function< std::string(const std::string &)> | map ) | 
| void fpsdk::common::string::MakeUnique | ( | std::vector< std::string > & | strs | ) | 
Remove duplicates.
| [in] | strs | List of strings | 
References MakeUnique().
Referenced by MakeUnique().
| std::vector< std::string > fpsdk::common::string::HexDump | ( | const std::vector< uint8_t > | 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 | 
References HexDump().
| std::string fpsdk::common::string::StrFormatBits | ( | const uint64_t | value, | 
| const std::size_t | size = 64 ) | 
Format value to "bits string".
| [in] | value | The value | 
| [in] | size | The number of bits to format (clamped to 1-64) | 
References StrFormatBits().
Referenced by StrFormatBits().
| 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 | 
References StrStartsWith().
Referenced by StrStartsWith().
| 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 | 
References StrEndsWith().
Referenced by StrEndsWith().
| 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 | 
References StrContains().
Referenced by StrContains().
| 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 | 
References StrToValue().
Referenced by StrToValue(), StrToValue(), StrToValue(), StrToValue(), StrToValue(), StrToValue(), StrToValue(), StrToValue(), StrToValue(), StrToValue(), and StrToValue().
| 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..."), bin ("0b...") or octal ("0..."), valid range: 0..UINT8_MAX | 
| [out] | value | The value | 
References StrToValue().
| 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 | 
References StrToValue().
| 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..."), bin ("0b...") or octal ("0..."), valid range: 0..UINT16_MAX | 
| [out] | value | The value | 
References StrToValue().
| 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 | 
References StrToValue().
| 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..."), bin ("0b...") or octal ("0..."), valid range: 0..UINT32_MAX | 
| [out] | value | The value | 
References StrToValue().
| 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 | 
References StrToValue().
| 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..."), bin ("0b...") or octal ("0..."), valid range: 0..(INT64_MAX-1) | 
| [out] | value | The value | 
References StrToValue().
| 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 | 
References StrToValue().
| 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 | 
References StrToValue().
| bool fpsdk::common::string::StrToValue | ( | const std::string & | str, | 
| bool & | value ) | 
Convert string to value (bool)
The following strings (case insensitive) are considered true resp. false:
| [in] | str | The string, anything f understands (but not infinite or NaN) | 
| [out] | value | The value | 
References StrToValue().
| std::string fpsdk::common::string::StrToUpper | ( | const std::string & | str | ) | 
Convert string to all upper case.
| [in] | str | The string | 
References StrToUpper().
Referenced by StrToUpper().
| std::string fpsdk::common::string::StrToLower | ( | const std::string & | str | ) | 
Convert string to all lower case.
| [in] | str | The string | 
References StrToLower().
Referenced by StrToLower().
| std::string fpsdk::common::string::StrError | ( | const int | errnum | ) | 
Stringify glibc error.
This works much like strerror(3), but is a bit more detailed adding the errnum value and name to the description. For example: StrError(EAGAIN) returns "Resource temporarily unavailable (11, EAGAIN)".
| [in] | errnum | The error number, see errno(3) | 
References StrError().
Referenced by StrError().
      
  | 
  constexpr | 
Stringify value (bool)
| [in] | value | The value | 
Definition at line 404 of file string.hpp.
References ToStr().
Referenced by ToStr().
| std::vector< uint8_t > fpsdk::common::string::StrToBuf | ( | const std::string & | str | ) | 
Convert string to buffer.
| [in] | str | The string | 
| std::string fpsdk::common::string::BufToStr | ( | const std::vector< uint8_t > & | buf | ) | 
Convert buffer to string.
| [in] | buf | The buffer | 
| std::string fpsdk::common::string::Base64Enc | ( | const std::vector< uint8_t > & | buf | ) | 
Encode to base64.
| [in] | buf | The data to encode | 
| std::vector< uint8_t > fpsdk::common::string::Base64Dec | ( | const std::string & | str | ) | 
Decode from base64.
| [in] | str | The base64 encoded data |