整理
This commit is contained in:
24
include/boost/nowide/detail/convert.hpp
Normal file
24
include/boost/nowide/detail/convert.hpp
Normal file
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// Copyright (c) 2020 Alexander Grund
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#ifndef BOOST_NOWIDE_DETAIL_CONVERT_HPP_INCLUDED
|
||||
#define BOOST_NOWIDE_DETAIL_CONVERT_HPP_INCLUDED
|
||||
|
||||
#include <boost/nowide/utf/convert.hpp>
|
||||
|
||||
// Legacy compatibility header only. Include <boost/nowide/utf/convert.hpp> instead
|
||||
|
||||
namespace boost {
|
||||
namespace nowide {
|
||||
namespace detail {
|
||||
using boost::nowide::utf::convert_buffer;
|
||||
using boost::nowide::utf::convert_string;
|
||||
using boost::nowide::utf::strlen;
|
||||
} // namespace detail
|
||||
} // namespace nowide
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
38
include/boost/nowide/detail/is_path.hpp
Normal file
38
include/boost/nowide/detail/is_path.hpp
Normal file
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// Copyright (c) 2020 Alexander Grund
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#ifndef BOOST_NOWIDE_DETAIL_IS_PATH_HPP_INCLUDED
|
||||
#define BOOST_NOWIDE_DETAIL_IS_PATH_HPP_INCLUDED
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost {
|
||||
namespace nowide {
|
||||
namespace detail {
|
||||
|
||||
/// Trait to heuristically check for a *\::filesystem::path
|
||||
/// Done by checking for make_preferred and filename member functions with correct signature
|
||||
template<typename T>
|
||||
struct is_path
|
||||
{
|
||||
template<typename U, U& (U::*)(), U (U::*)() const>
|
||||
struct Check;
|
||||
template<typename U>
|
||||
static std::true_type test(Check<U, &U::make_preferred, &U::filename>*);
|
||||
template<typename U>
|
||||
static std::false_type test(...);
|
||||
|
||||
static constexpr bool value = decltype(test<T>(0))::value;
|
||||
};
|
||||
/// SFINAE trait/alias which resolves to Result if the Path is a *\::filesystem::path
|
||||
template<typename Path, typename Result>
|
||||
using enable_if_path_t = typename std::enable_if<is_path<Path>::value, Result>::type;
|
||||
|
||||
} // namespace detail
|
||||
} // namespace nowide
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
95
include/boost/nowide/detail/is_string_container.hpp
Normal file
95
include/boost/nowide/detail/is_string_container.hpp
Normal file
@@ -0,0 +1,95 @@
|
||||
//
|
||||
// Copyright (c) 2020 Alexander Grund
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#ifndef BOOST_NOWIDE_DETAIL_IS_STRING_CONTAINER_HPP_INCLUDED
|
||||
#define BOOST_NOWIDE_DETAIL_IS_STRING_CONTAINER_HPP_INCLUDED
|
||||
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost {
|
||||
namespace nowide {
|
||||
namespace detail {
|
||||
template<class...>
|
||||
struct make_void
|
||||
{
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template<class... Ts>
|
||||
using void_t = typename make_void<Ts...>::type;
|
||||
|
||||
template<typename T>
|
||||
struct is_char_type : std::false_type
|
||||
{};
|
||||
template<>
|
||||
struct is_char_type<char> : std::true_type
|
||||
{};
|
||||
template<>
|
||||
struct is_char_type<wchar_t> : std::true_type
|
||||
{};
|
||||
template<>
|
||||
struct is_char_type<char16_t> : std::true_type
|
||||
{};
|
||||
template<>
|
||||
struct is_char_type<char32_t> : std::true_type
|
||||
{};
|
||||
#ifdef __cpp_char8_t
|
||||
template<>
|
||||
struct is_char_type<char8_t> : std::true_type
|
||||
{};
|
||||
#endif
|
||||
|
||||
template<typename T>
|
||||
struct is_c_string : std::false_type
|
||||
{};
|
||||
template<typename T>
|
||||
struct is_c_string<const T*> : is_char_type<T>
|
||||
{};
|
||||
|
||||
template<typename T>
|
||||
using const_data_result = decltype(std::declval<const T>().data());
|
||||
/// Return the size of the char type returned by the data() member function
|
||||
template<typename T>
|
||||
using get_data_width =
|
||||
std::integral_constant<std::size_t, sizeof(typename std::remove_pointer<const_data_result<T>>::type)>;
|
||||
template<typename T>
|
||||
using size_result = decltype(std::declval<T>().size());
|
||||
/// Return true if the data() member function returns a pointer to a type of size 1
|
||||
template<typename T>
|
||||
using has_narrow_data = std::integral_constant<bool, (get_data_width<T>::value == 1)>;
|
||||
|
||||
/// Return true if T is a string container, e.g. std::basic_string, std::basic_string_view
|
||||
/// Requires a static value `npos`, a member function `size()` returning an integral,
|
||||
/// and a member function `data()` returning a C string
|
||||
template<typename T, bool isNarrow, typename = void>
|
||||
struct is_string_container : std::false_type
|
||||
{};
|
||||
// clang-format off
|
||||
template<typename T, bool isNarrow>
|
||||
struct is_string_container<T, isNarrow, void_t<decltype(T::npos), size_result<T>, const_data_result<T>>>
|
||||
: std::integral_constant<bool,
|
||||
std::is_integral<decltype(T::npos)>::value
|
||||
&& std::is_integral<size_result<T>>::value
|
||||
&& is_c_string<const_data_result<T>>::value
|
||||
&& isNarrow == has_narrow_data<T>::value>
|
||||
{};
|
||||
// clang-format on
|
||||
template<typename T>
|
||||
using requires_narrow_string_container = typename std::enable_if<is_string_container<T, true>::value>::type;
|
||||
template<typename T>
|
||||
using requires_wide_string_container = typename std::enable_if<is_string_container<T, false>::value>::type;
|
||||
|
||||
template<typename T>
|
||||
using requires_narrow_char = typename std::enable_if<sizeof(T) == 1 && is_char_type<T>::value>::type;
|
||||
template<typename T>
|
||||
using requires_wide_char = typename std::enable_if<(sizeof(T) > 1) && is_char_type<T>::value>::type;
|
||||
|
||||
} // namespace detail
|
||||
} // namespace nowide
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
22
include/boost/nowide/detail/utf.hpp
Normal file
22
include/boost/nowide/detail/utf.hpp
Normal file
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// Copyright (c) 2020 Alexander Grund
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#ifndef BOOST_NOWIDE_DETAIL_UTF_HPP_INCLUDED
|
||||
#define BOOST_NOWIDE_DETAIL_UTF_HPP_INCLUDED
|
||||
|
||||
#include <boost/nowide/utf/utf.hpp>
|
||||
|
||||
// Legacy compatibility header only. Include <boost/nowide/utf/utf.hpp> instead
|
||||
|
||||
namespace boost {
|
||||
namespace nowide {
|
||||
namespace detail {
|
||||
namespace utf = boost::nowide::utf;
|
||||
} // namespace detail
|
||||
} // namespace nowide
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user