libfilezilla
Loading...
Searching...
No Matches
wx.hpp
Go to the documentation of this file.
1#ifndef LIBFILEZILLA_GLUE_WX_HEADER
2#define LIBFILEZILLA_GLUE_WX_HEADER
3
7
8
9#include "../private/defs.hpp"
10#if FZ_WINDOWS
11#include "windows.hpp"
12#endif
13
14#include <wx/string.h>
15
16#include "../format.hpp"
17#include "../string.hpp"
18
19namespace fz {
20template<typename T, typename std::enable_if_t<std::is_same_v<wxString, typename std::decay_t<T>>, int> = 0>
21inline std::wstring to_wstring(T const& s) {
22 return s.ToStdWstring();
23}
24
25template<typename T, typename std::enable_if_t<std::is_same_v<wxString, typename std::decay_t<T>>, int> = 0>
26inline native_string to_native(T const& in)
27{
28 return to_native(in.ToStdWstring());
29}
30
31template<typename T, typename std::enable_if_t<std::is_same_v<wxString, typename std::decay_t<T>>, int> = 0>
32inline std::string to_utf8(T const& s)
33{
34 return to_utf8(s.ToStdWstring());
35}
36
37template<typename T, typename std::enable_if_t<std::is_same_v<wxString, typename std::decay_t<T>>, int> = 0, typename... Args>
38std::wstring sprintf(T const& fmt, Args&&... args)
39{
40 return sprintf(fmt.ToStdWstring(), std::forward<Args>(args)...);
41}
42
43}
44
45#endif
Header for the sprintf string formatting function.
The namespace used by libfilezilla.
Definition apply.hpp:17
std::wstring native_string
A string in the system's native character type and encoding. Note: This typedef changes depending on...
Definition string.hpp:36
std::string to_utf8(std::string_view const &in)
Converts from std::string in native encoding into std::string in UTF-8.
std::wstring to_wstring(std::string_view const &in)
Converts from std::string in system encoding into std::wstring.
std::string sprintf(std::string_view const &fmt, Args &&... args)
A simple type-safe sprintf replacement.
Definition format.hpp:456
native_string to_native(std::string_view const &in)
Converts std::string to native_string.
String types and assorted functions.