9 #ifndef BOOST_GIL_IO_PATH_SPEC_HPP
10 #define BOOST_GIL_IO_PATH_SPEC_HPP
12 #include <boost/gil/io/detail/filesystem.hpp>
17 #include <type_traits>
19 namespace boost {
namespace gil {
namespace detail {
21 template<
typename P>
struct is_supported_path_spec : std::false_type {};
22 template<>
struct is_supported_path_spec< std::string > : std::true_type {};
23 template<>
struct is_supported_path_spec< const std::string > : std::true_type {};
24 template<>
struct is_supported_path_spec< std::wstring > : std::true_type {};
25 template<>
struct is_supported_path_spec< const std::wstring > : std::true_type {};
26 template<>
struct is_supported_path_spec< char const* > : std::true_type {};
27 template<>
struct is_supported_path_spec< char* > : std::true_type {};
28 template<>
struct is_supported_path_spec< const wchar_t* > : std::true_type {};
29 template<>
struct is_supported_path_spec< wchar_t* > : std::true_type {};
31 template<
int i>
struct is_supported_path_spec<const char [i]> : std::true_type {};
32 template<
int i>
struct is_supported_path_spec<char [i]> : std::true_type {};
33 template<
int i>
struct is_supported_path_spec<const wchar_t [i]> : std::true_type {};
34 template<
int i>
struct is_supported_path_spec<wchar_t [i]> : std::true_type {};
36 template<>
struct is_supported_path_spec<filesystem::path> : std::true_type {};
37 template<>
struct is_supported_path_spec<filesystem::path const> : std::true_type {};
39 inline std::string convert_to_string( std::string
const& obj)
44 inline std::string convert_to_string( std::wstring
const& s )
46 std::mbstate_t state = std::mbstate_t();
47 const wchar_t* str = s.c_str();
48 const std::size_t len = std::wcsrtombs(
nullptr, &str, 0, &state);
49 std::string result(len,
'\0');
50 std::wcstombs( &result[0], s.c_str(), len );
55 inline std::string convert_to_string(
char const* str )
57 return std::string( str );
60 inline std::string convert_to_string(
char* str )
62 return std::string( str );
65 inline std::string convert_to_string(filesystem::path
const& path)
67 return convert_to_string(path.string());
70 inline char const* convert_to_native_string(
char* str )
75 inline char const* convert_to_native_string(
char const* str )
80 inline char const* convert_to_native_string(
const std::string& str )
85 inline char const* convert_to_native_string(
const wchar_t* str )
87 std::mbstate_t state = std::mbstate_t();
88 const std::size_t len = std::wcsrtombs(
nullptr, &str, 0, &state) + 1;
89 char* c =
new char[len];
90 std::wcstombs( c, str, len );
95 inline char const* convert_to_native_string( std::wstring
const& str )
97 std::mbstate_t state = std::mbstate_t();
98 const wchar_t* wstr = str.c_str();
99 const std::size_t len = std::wcsrtombs(
nullptr, &wstr, 0, &state) + 1;
100 char* c =
new char[len];
101 std::wcstombs( c, str.c_str(), len );
defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
Definition: algorithm.hpp:36