![]() |
libfilezilla
|
String types and assorted functions. More...


Go to the source code of this file.
Namespaces | |
| namespace | fz |
The namespace used by libfilezilla. | |
Defines | |
| #define | fzT(x) L ## x |
| Macro for a string literal in system-native character type. Note: Macro definition changes depending on platform! | |
| #define | fzS(Char, s) fz::choose_string<Char>(s, L ## s) |
| Macro to get const pointer to a string of the corresponding type. | |
Typedefs | |
| typedef std::wstring | native_string |
| A string in the system's native character type and encoding. Note: This typedef changes depending on platform! | |
Functions | |
| native_string | to_native (std::string const &in) |
| Converts std::string to native_string. | |
| native_string | to_native (std::wstring const &in) |
| Convert std::wstring to native_string. | |
| int | stricmp (std::string const &a, std::string const &b) |
| Locale-sensitive stricmp. | |
| int | stricmp (std::wstring const &a, std::wstring const &b) |
| template<typename Char > | |
| Char | tolower_ascii (Char c) |
| Converts ASCII uppercase characters to lowercase as if C-locale is used. | |
| template<> | |
| std::wstring::value_type | tolower_ascii (std::wstring::value_type c) |
| template<typename Char > | |
| Char | toupper_ascii (Char c) |
| Converts ASCII lowercase characters to uppercase as if C-locale is used. | |
| template<> | |
| std::wstring::value_type | toupper_ascii (std::wstring::value_type c) |
| template<typename String > | |
| String | str_tolower_ascii (String const &s) |
| tr_tolower_ascii does for strings what tolower_ascii does for individual characters | |
| template<typename String > | |
| String | str_toupper_ascii (String const &s) |
| std::wstring | to_wstring (std::string const &in) |
| Converts from std::string in system encoding into std::wstring. | |
| std::wstring | to_wstring (std::wstring const &in) |
| Returns identity, that way to_wstring can be called with native_string. | |
| template<typename Arg > | |
| std::enable_if < std::is_arithmetic < std::decay_t< Arg > >::value, std::wstring >::type | to_wstring (Arg &&arg) |
| Converts from arithmetic type to std::wstring. | |
| std::wstring | to_wstring_from_utf8 (std::string const &in) |
| Converts from std::string in UTF-8 into std::wstring. | |
| std::string | to_string (std::wstring const &in) |
| Converts from std::wstring into std::string in system encoding. | |
| std::string | to_string (std::string const &in) |
| Returns identity, that way to_string can be called with native_string. | |
| template<typename Arg > | |
| std::enable_if < std::is_arithmetic < std::decay_t< Arg > >::value, std::string >::type | to_string (Arg &&arg) |
| Converts from arithmetic type to std::string. | |
| template<typename Char > | |
| size_t | strlen (Char const *str) |
| Returns length of 0-terminated character sequence. Works with both narrow and wide-characters. | |
| std::string | to_utf8 (std::string const &in) |
| Converts from std::string in native encoding into std::string in UTF-8. | |
| std::string | to_utf8 (std::wstring const &in) |
| Converts from std::wstring in native encoding into std::string in UTF-8. | |
| template<typename Char > | |
| int | hex_char_to_int (Char c) |
| Converts a hex digit to decimal int. | |
| template<typename String > | |
| std::vector< uint8_t > | hex_decode (String const &in) |
| template<typename Char = char, bool Lowercase = true> | |
| Char | int_to_hex_char (int d) |
| Converts an integer to the corresponding lowercase hex digit. | |
| template<typename String , typename InString , bool Lowercase = true> | |
| String | hex_encode (InString const &data) |
| template<typename String , typename Arg > | |
| auto | toString (Arg &&arg)-> typename std |
| Calls either fz::to_string or fz::to_wstring depending on the passed template argument. | |
| template<typename Char > | |
| Char const * | choose_string (char const *c, wchar_t const *w) |
| Returns the function argument of the type matching the template argument. | |
| template<> | |
| char const * | choose_string (char const *c, wchar_t const *) |
| Returns the function argument of the type matching the template argument. | |
| std::string | replaced_substrings (std::string const &in, std::string const &find, std::string const &replacement) |
Returns in with all occurrences of find in the input string replaced with replacement. | |
| std::wstring | replaced_substrings (std::wstring const &in, std::wstring const &find, std::wstring const &replacement) |
| void | replace_substrings (std::string &in, std::string const &find, std::string const &replacement) |
Modifies in, replacing all occurrences of find with replacement. | |
| void | replace_substrings (std::wstring &in, std::wstring const &find, std::wstring const &replacement) |
| template<typename String , typename Delim , typename Container = std::vector<String>> | |
| Container | strtok (String const &s, Delim const &delims) |
| Tokenizes string. Returns all non-empty substrings. | |
| std::string | base64_encode (std::string const &in) |
| Encodes raw input string to base64. | |
| std::string | base64_decode (std::string const &in) |
| Decodes base64, ignores whitespace. Returns empty string on invalid input. | |
| template<typename T , typename String > | |
| T | to_integral (String const &s, T const errorval=T()) |
| template<typename String > | |
| bool | str_is_ascii (String const &s) |
| Returns true iff the string only has characters in the 7-bit ASCII range. | |
| template<typename String > | |
| String | trimmed (String const &s) |
| Return passed string with all leading and trailing whitespace removed. | |
| template<typename String > | |
| void | trim (String &s) |
| Remove all leading and trailing whitespace from string. | |
String types and assorted functions.
Defines the fz::native_string type and offers various functions to convert between different string types.
| #define fzS | ( | Char, | |
| s | |||
| ) | fz::choose_string<Char>(s, L ## s) |
Macro to get const pointer to a string of the corresponding type.
Useful when using string literals in templates where the type of string is a template argument:
template<typename String> String append_foo(String const& s) { s += fzS(String::value_type, "foo"); }
| #define fzT | ( | x | ) | L ## x |
Macro for a string literal in system-native character type.
Note: Macro definition changes depending on platform!
Example: fzT("this string is wide on Windows and narrow elsewhere")
1.7.6.1