libfilezilla
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Namespaces | Macros | Typedefs | Functions
string.hpp File Reference

String types and assorted functions. More...

#include "libfilezilla.hpp"
#include <string>
Include dependency graph for string.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 fz
 The namespace used by libfilezilla.
 

Macros

#define fzT(x)   L ## x
 Macro for a string literal in system-native character type.
Note: Macro definition changes depending on platform! More...
 
#define fzS(Char, s)   choose_string<Char>(s, L ## s)
 Macro to get const pointer to a string of the corresponding type. More...
 

Typedefs

typedef std::wstring native_string
 A string in the system's native character type and encoding.
Note: This typedef changes depending on platform! More...
 

Functions

native_string to_native (std::string const &in)
 Converts std::string to native_string. More...
 
native_string to_native (std::wstring const &in)
 Convert std::wstring to native_string. More...
 
int stricmp (std::string const &a, std::string const &b)
 Locale-sensitive stricmp. More...
 
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. More...
 
template<>
std::wstring::value_type tolower_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
 
std::wstring to_wstring (std::string const &in)
 Converts from std::string in system encoding into std::wstring. More...
 
std::wstring to_wstring (std::wstring const &in)
 Returns identity, that way to_wstring can be called with native_string.
 
std::wstring to_wstring_from_utf8 (std::string const &in)
 Converts from std::string in UTF-8 into std::wstring. More...
 
std::string to_string (std::wstring const &in)
 Converts from std::wstring into std::string in system encoding. More...
 
std::string to_string (std::string const &in)
 Returns identity, that way to_string can be called with native_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. More...
 
std::string to_utf8 (std::wstring const &in)
 Converts from std::wstring in native encoding into std::string in UTF-8. More...
 
template<typename Char >
int hex_char_to_int (Char c)
 Converts a hex digit to decimal int. More...
 
template<typename String , typename Int >
std::enable_if< std::is_same
< String, std::string >::value,
std::string >::type 
convert (Int i)
 Convert integer to string.
 
template<typename String , typename Int >
std::enable_if< std::is_same
< String, std::wstring >
::value, std::wstring >::type 
convert (Int i)
 
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. More...
 
template<>
char const * choose_string (char const *c, wchar_t const *)
 Returns the function argument of the type matching the template argument. More...
 
template<>
wchar_t const * choose_string (char const *, wchar_t const *w)
 Returns the function argument of the type matching the template argument. More...
 

Detailed Description

String types and assorted functions.

Defines the fz::native_string type and offers various functions to convert between different string types.

Macro Definition Documentation

#define fzS (   Char,
 
)    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:

1 template<typename String>
2 String append_foo(String const& s) {
3  s += fzS(String::value_type, "foo");
4 }
#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")

Examples:
list.cpp, and process.cpp.