1 #ifndef LIBFILEZILLA_STRING_HEADER 2 #define LIBFILEZILLA_STRING_HEADER 32 #if defined(FZ_UNIX) || defined(FZ_MAC) 40 native_string FZ_PUBLIC_SYMBOL
to_native(std::string
const& in);
46 native_string FZ_PUBLIC_SYMBOL
to_native(std::wstring
const& in);
54 int FZ_PUBLIC_SYMBOL
stricmp(std::string
const& a, std::string
const& b);
55 int FZ_PUBLIC_SYMBOL
stricmp(std::wstring
const& a, std::wstring
const& b);
74 template<
typename Char>
76 if (c >=
'A' && c <=
'Z') {
77 return c + (
'a' -
'A');
83 std::wstring::value_type FZ_PUBLIC_SYMBOL
tolower_ascii(std::wstring::value_type c);
88 template<
typename String>
104 std::wstring FZ_PUBLIC_SYMBOL
to_wstring(std::string
const& in);
107 inline std::wstring FZ_PUBLIC_SYMBOL
to_wstring(std::wstring
const& in) {
return in; }
121 std::string FZ_PUBLIC_SYMBOL
to_string(std::wstring
const& in);
124 inline std::string FZ_PUBLIC_SYMBOL
to_string(std::string
const& in) {
return in; }
127 template<
typename Char>
129 return std::char_traits<Char>::length(str);
139 std::string FZ_PUBLIC_SYMBOL
to_utf8(std::string
const& in);
147 std::string FZ_PUBLIC_SYMBOL
to_utf8(std::wstring
const& in);
156 template<
typename Char>
173 template<
typename Char =
char>
185 template<
typename String,
typename Int>
186 inline typename std::enable_if<std::is_same<String, std::string>::value, std::string>::type
189 template<
typename String,
typename Int>
190 inline typename std::enable_if<std::is_same<String, std::wstring>::value, std::wstring>::type
193 #if !defined(fzT) || defined(DOXYGEN) 199 #define fzT(x) L ## x 210 template<
typename Char>
213 template<>
inline char const*
choose_string(
char const* c,
wchar_t const*) {
return c; }
214 template<>
inline wchar_t const*
choose_string(
char const*,
wchar_t const* w) {
return w; }
216 #if !defined(fzS) || defined(DOXYGEN) 228 #define fzS(Char, s) choose_string<Char>(s, L ## s) 232 std::string FZ_PUBLIC_SYMBOL
replace_substrings(std::string
const& in, std::string
const& find, std::string
const& replacement);
233 std::wstring FZ_PUBLIC_SYMBOL
replace_substrings(std::wstring
const& in, std::wstring
const& find, std::wstring
const& replacement);
236 void FZ_PUBLIC_SYMBOL
replace_substrings(std::string& in, std::string
const& find, std::string
const& replacement);
237 void FZ_PUBLIC_SYMBOL
replace_substrings(std::wstring& in, std::wstring
const& find, std::wstring
const& replacement);
std::wstring to_wstring_from_utf8(std::string const &in)
Converts from std::string in UTF-8 into std::wstring.
Char int_to_hex_char(int d)
Converts an integer to the corresponding lowercase hex digit.
Definition: string.hpp:174
int hex_char_to_int(Char c)
Converts a hex digit to decimal int.
Definition: string.hpp:157
std::string to_string(std::string const &in)
Returns identity, that way to_string can be called with native_string.
Definition: string.hpp:124
std::wstring to_wstring(std::wstring const &in)
Returns identity, that way to_wstring can be called with native_string.
Definition: string.hpp:107
int stricmp(std::string const &a, std::string const &b)
Locale-sensitive stricmp.
Char tolower_ascii(Char c)
Converts ASCII uppercase characters to lowercase as if C-locale is used.
Definition: string.hpp:75
std::enable_if< std::is_same< String, std::string >::value, std::string >::type convert(Int i)
Convert integer to string.
Definition: string.hpp:187
std::string to_utf8(std::string const &in)
Converts from std::string in native encoding into std::string in UTF-8.
size_t strlen(Char const *str)
Returns length of 0-terminated character sequence. Works with both narrow and wide-characters.
Definition: string.hpp:128
std::string replace_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 native_string
A string in the system's native character type and encoding. Note: This typedef changes depending on...
Definition: string.hpp:30
std::string to_string(std::wstring const &in)
Converts from std::wstring into std::string in system encoding.
The namespace used by libfilezilla.
Definition: apply.hpp:16
Char const * choose_string(char const *c, wchar_t const *w)
Returns the function argument of the type matching the template argument.
Definition: string.hpp:213
String str_tolower_ascii(String const &s)
tr_tolower_ascii does for strings what tolower_ascii does for individual characters ...
Definition: string.hpp:89
Sets some global macros and further includes string.hpp.
native_string to_native(std::string const &in)
Converts std::string to native_string.
std::wstring to_wstring(std::string const &in)
Converts from std::string in system encoding into std::wstring.