![]() |
libfilezilla
|
The namespace used by libfilezilla. More...
Classes | |
class | condition |
Waitable condition variable. More... | |
class | datetime |
Represents a point of time in wallclock, tracking the timestamps accuracy/precision. More... | |
class | duration |
The duration class represents a time interval in milliseconds. More... | |
class | event_base |
Common base class for all events. More... | |
class | event_handler |
Simple handler for asynchronous event processing. More... | |
class | event_loop |
A threaded event loop that supports sending events and timers. More... | |
class | file |
Lean class for file access. More... | |
class | local_filesys |
This class can be used to enumerate the contents of local directories and to query the metadata of files. More... | |
class | monotonic_clock |
A monotonic clock (aka steady clock) is independent from walltime. More... | |
class | mutex |
Lean replacement for std::(recursive_)mutex. More... | |
class | process |
The process class manages an asynchronous process with redirected IO. More... | |
class | recursive_remove |
Recursively deletes directories. More... | |
class | scoped_lock |
A simple scoped lock. More... | |
class | shared_optional |
shared_optional is like std::shared_ptr but with relational operators acting like C++17's std::optional More... | |
class | simple_event |
This is the recommended event class. More... | |
class | sparse_optional |
Similar to C++17's std::optional, but stores the data in dynamic memory. More... | |
class | thread |
Spawns and represents a new thread of execution. More... | |
Typedefs | |
typedef unsigned long long | timer_id |
typedef simple_event < timer_event_type, timer_id > | timer_event |
All timer events have this type. More... | |
template<typename T > | |
using | shared_value = shared_optional< T, true > |
like shared_optional but can never be empty More... | |
typedef std::wstring | native_string |
A string in the system's native character type and encoding. Note: This typedef changes depending on platform! More... | |
Enumerations | |
enum | address_type { unknown, ipv4, ipv6 } |
Functions | |
template<typename F , typename Tuple , typename Seq = typename std::make_index_sequence<std::tuple_size<typename std::remove_reference<Tuple>::type>::value>> | |
auto | apply (F &&f, Tuple &&args) -> decltype(apply_(std::forward< F >(f), std::forward< Tuple >(args), Seq())) |
Apply tuple to ordinary functor. More... | |
template<typename Obj , typename F , typename Tuple , typename Seq = typename std::make_index_sequence<std::tuple_size<typename std::remove_reference<Tuple>::type>::value>> | |
auto | apply (Obj &&obj, F &&f, Tuple &&args) -> decltype(apply_(std::forward< Obj >(obj), std::forward< F >(f), std::forward< Tuple >(args), Seq())) |
Apply tuple to pointer to member. More... | |
template<typename T > | |
bool | same_type (event_base const &ev) |
template<typename T , typename F > | |
bool | dispatch (event_base const &ev, F &&f) |
Dispatch for simple_event<> based events to simple functors. More... | |
template<typename T , typename H , typename F > | |
bool | dispatch (event_base const &ev, H *h, F &&f) |
Dispatch for simple_event<> based events to pointer to member. More... | |
template<typename T , typename... Ts, typename H , typename F , typename... Fs> | |
bool | dispatch (event_base const &ev, H *h, F &&f, Fs &&...fs) |
Compound dispatch for simple_event<> based events. More... | |
std::string | get_ipv6_long_form (std::string const &short_address) |
Given a shortened IPv6 address, returns the full, unshortened address. More... | |
std::wstring | get_ipv6_long_form (std::wstring const &short_address) |
bool | is_routable_address (std::string const &address) |
Tests whether the passed IP address is routable on the public Internet. More... | |
bool | is_routable_address (std::wstring const &address) |
address_type | get_address_type (std::string const &address) |
Gets the type of the passed IP address. | |
address_type | get_address_type (std::wstring const &address) |
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... | |
duration | operator- (duration const &a, duration const &b) |
duration | operator- (datetime const &a, datetime const &b) |
Gets the difference between two timestamps as duration. More... | |
duration | operator- (monotonic_clock const &a, monotonic_clock const &b) |
void | sleep (duration const &d) |
Sleep current thread for the specified duration. More... | |
int64_t | random_number (int64_t min, int64_t max) |
Get a secure random integer uniformly distributed in the closed interval [min, max]. | |
std::string | get_version_string () |
Get version string of libfilezilla. | |
std::tuple< int, int, int, int, std::string > | get_version () |
Get version of libfilezilla broken down into components major, minor, micro, nano and suffix. | |
The namespace used by libfilezilla.
All declarations in any libfilezilla header are in this namespace.
typedef std::string native_string |
A string in the system's native character type and encoding.
Note: This typedef changes depending on platform!
On Windows, the system's native encoding is UTF-16, so native_string is typedef'ed to std::wstring.
On all other platform, native_string is a typedef for std::string.
Always using native_string has the benefit that no conversion needs to be performed which is especially useful if dealing with filenames.
using shared_value = shared_optional<T, true> |
like shared_optional but can never be empty
All operations that would result in an empty shared_optional instead result in a default-constructed value.
As such, operator* and operator-> are always well-defined.
typedef simple_event<timer_event_type, timer_id> timer_event |
All timer events have this type.
All timer events have one arguments of type timer_id
which is the id of the timer that triggered.
auto fz::apply | ( | F && | f, |
Tuple && | args | ||
) | -> decltype(apply_(std::forward<F>(f), std::forward<Tuple>(args), Seq())) |
Apply tuple to ordinary functor.
Example:
auto fz::apply | ( | Obj && | obj, |
F && | f, | ||
Tuple && | args | ||
) | -> decltype(apply_(std::forward<Obj>(obj), std::forward<F>(f), std::forward<Tuple>(args), Seq())) |
Apply tuple to pointer to member.
Example:
|
inline |
Returns the function argument of the type matching the template argument.
|
inline |
Returns the function argument of the type matching the template argument.
|
inline |
Returns the function argument of the type matching the template argument.
bool fz::dispatch | ( | event_base const & | ev, |
F && | f | ||
) |
Dispatch for simple_event<> based events to simple functors.
T | the event type, a simple_event<> instantiation |
ev | the received event |
f | functor that should be called if the event matches the passed type. |
If the passed event is of the type passed as template argument, the passed function is called with the contents of the event unpacked as arguments.
bool fz::dispatch | ( | event_base const & | ev, |
H * | h, | ||
F && | f | ||
) |
Dispatch for simple_event<> based events to pointer to member.
T | the event type, a simple_event<> instantiation |
ev | the received event. |
h | object whose member gets called if the event matches the passed type. |
f | pointer to member of h that should be called if the event matches the passed type. |
If the passed event is of the type passed as template argument, the passed function is called with the contents of the event unpacked as arguments.
bool fz::dispatch | ( | event_base const & | ev, |
H * | h, | ||
F && | f, | ||
Fs &&... | fs | ||
) |
Compound dispatch for simple_event<> based events.
Calls the simple dispatch for each passed type and tries the next one if it didn't match.
Order the passed types in decreasing usage frequency for maximum performance.
T | the event type, a simple_event<> instantiation |
Ts | additional event types |
ev | the received event. |
h | object whose member gets called if the event matches the passed type. |
f | pointer to member of h that should be called if the event matches the passed type. |
fs | additional pairs of objects and pointers to members. |
std::string fz::get_ipv6_long_form | ( | std::string const & | short_address | ) |
Given a shortened IPv6 address, returns the full, unshortened address.
If passed address is encloded in square brackes, they are stripped.
Returns an empty string if the passed string isn't a valid IPv6 address.
int fz::hex_char_to_int | ( | Char | c | ) |
Converts a hex digit to decimal int.
Example: '9' becomes 9, 'b' becomes 11, 'D' becomes 13
Undefined output if input is not a valid hex digit.
bool fz::is_routable_address | ( | std::string const & | address | ) |
Tests whether the passed IP address is routable on the public Internet.
Unroutable addresss are:
All other addresses are assumed routable.
duration operator- | ( | datetime const & | a, |
datetime const & | b | ||
) |
Gets the difference between two timestamps as duration.
This function ignores accuracy, it treats both timestamps as if they had millisecond-accuracy.
|
inline |
Gets the difference between two clocks as duration
bool fz::same_type | ( | event_base const & | ev | ) |
Used as lightweight RTTI alternative during dispatch
void fz::sleep | ( | duration const & | d | ) |
Sleep current thread for the specified duration.
Alternative to std::this_thread::sleep_for
which unfortunately isn't implemented on MinGW.
int fz::stricmp | ( | std::string const & | a, |
std::string const & | b | ||
) |
Locale-sensitive stricmp.
Like std::string::strcmp but case-insensitive, respectinge locale.
native_string fz::to_native | ( | std::string const & | in | ) |
Converts std::string to native_string.
native_string fz::to_native | ( | std::wstring const & | in | ) |
Convert std::wstring to native_string.
std::string fz::to_string | ( | std::wstring const & | in | ) |
Converts from std::wstring into std::string in system encoding.
std::string fz::to_utf8 | ( | std::string const & | in | ) |
Converts from std::string in native encoding into std::string in UTF-8.
std::string fz::to_utf8 | ( | std::wstring const & | in | ) |
Converts from std::wstring in native encoding into std::string in UTF-8.
std::wstring fz::to_wstring | ( | std::string const & | in | ) |
Converts from std::string in system encoding into std::wstring.
std::wstring fz::to_wstring_from_utf8 | ( | std::string const & | in | ) |
Converts from std::string in UTF-8 into std::wstring.
Char fz::tolower_ascii | ( | Char | c | ) |
Converts ASCII uppercase characters to lowercase as if C-locale is used.
Under some locales there is a different case-relationship between the letters a-z and A-Z as one expects from ASCII under the C locale. In Turkish for example there are different variations of the letter i, namely dotted and dotless. What we see as 'i' is the lowercase dotted i and 'I' is the uppercase dotless i. Since std::tolower is locale-aware, I would become the dotless lowercase i.
This is not always what we want. FTP commands for example are case-insensitive ASCII strings, LIST and list are the same.
tolower_ascii instead converts all types of 'i's to the ASCII i as well.