mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-12-16 03:08:52 +08:00
Merge branch 'master' into v3
This commit is contained in:
@@ -54,17 +54,17 @@ set(toml11_config_version ${toml11_config_dir}/toml11ConfigVersion.cm
|
|||||||
|
|
||||||
add_library(toml11 INTERFACE)
|
add_library(toml11 INTERFACE)
|
||||||
target_include_directories(toml11 INTERFACE
|
target_include_directories(toml11 INTERFACE
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||||
$<INSTALL_INTERFACE:${toml11_install_include_dir}>
|
$<INSTALL_INTERFACE:${toml11_install_include_dir}>
|
||||||
)
|
)
|
||||||
add_library(toml11::toml11 ALIAS toml11)
|
add_library(toml11::toml11 ALIAS toml11)
|
||||||
|
|
||||||
# Write config and version config files
|
# Write config and version config files
|
||||||
include(CMakePackageConfigHelpers)
|
include(CMakePackageConfigHelpers)
|
||||||
write_basic_package_version_file(
|
write_basic_package_version_file(
|
||||||
${toml11_config_version}
|
${toml11_config_version}
|
||||||
VERSION ${toml11_VERSION}
|
VERSION ${toml11_VERSION}
|
||||||
COMPATIBILITY SameMajorVersion
|
COMPATIBILITY SameMajorVersion
|
||||||
)
|
)
|
||||||
|
|
||||||
configure_package_config_file(
|
configure_package_config_file(
|
||||||
@@ -76,30 +76,30 @@ configure_package_config_file(
|
|||||||
|
|
||||||
# Install config files
|
# Install config files
|
||||||
install(FILES ${toml11_config} ${toml11_config_version}
|
install(FILES ${toml11_config} ${toml11_config_version}
|
||||||
DESTINATION ${toml11_install_cmake_dir}
|
DESTINATION ${toml11_install_cmake_dir}
|
||||||
)
|
)
|
||||||
|
|
||||||
# Install header files
|
# Install header files
|
||||||
install(
|
install(
|
||||||
FILES toml.hpp
|
FILES toml.hpp
|
||||||
DESTINATION "${toml11_install_include_dir}"
|
DESTINATION "${toml11_install_include_dir}"
|
||||||
)
|
)
|
||||||
install(
|
install(
|
||||||
DIRECTORY "toml"
|
DIRECTORY "toml"
|
||||||
DESTINATION "${toml11_install_include_dir}"
|
DESTINATION "${toml11_install_include_dir}"
|
||||||
FILES_MATCHING PATTERN "*.hpp"
|
FILES_MATCHING PATTERN "*.hpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Export targets and install them
|
# Export targets and install them
|
||||||
install(TARGETS toml11
|
install(TARGETS toml11
|
||||||
EXPORT toml11Targets
|
EXPORT toml11Targets
|
||||||
)
|
)
|
||||||
install(EXPORT toml11Targets
|
install(EXPORT toml11Targets
|
||||||
FILE toml11Targets.cmake
|
FILE toml11Targets.cmake
|
||||||
DESTINATION ${toml11_install_cmake_dir}
|
DESTINATION ${toml11_install_cmake_dir}
|
||||||
NAMESPACE toml11::
|
NAMESPACE toml11::
|
||||||
)
|
)
|
||||||
|
|
||||||
if (toml11_BUILD_TEST)
|
if (toml11_BUILD_TEST)
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
endif ()
|
endif ()
|
||||||
|
|||||||
19
toml/get.hpp
19
toml/get.hpp
@@ -702,10 +702,13 @@ get_or(const basic_value<C, M, V>& v, T&& opt)
|
|||||||
template<typename T, typename C,
|
template<typename T, typename C,
|
||||||
template<typename ...> class M, template<typename ...> class V>
|
template<typename ...> class M, template<typename ...> class V>
|
||||||
detail::enable_if_t<detail::conjunction<
|
detail::enable_if_t<detail::conjunction<
|
||||||
detail::negation<detail::is_exact_toml_type<T, basic_value<C, M, V>>>,
|
detail::negation<detail::is_exact_toml_type<
|
||||||
|
typename std::remove_cv<typename std::remove_reference<T>::type>::type,
|
||||||
|
basic_value<C, M, V>>>,
|
||||||
detail::negation<std::is_same<std::string,
|
detail::negation<std::is_same<std::string,
|
||||||
typename std::remove_cv<typename std::remove_reference<T>::type>::type>>,
|
typename std::remove_cv<typename std::remove_reference<T>::type>::type>>,
|
||||||
detail::negation<detail::is_string_literal<typename std::remove_reference<T>::type>>
|
detail::negation<detail::is_string_literal<
|
||||||
|
typename std::remove_reference<T>::type>>
|
||||||
>::value, typename std::remove_reference<T>::type>
|
>::value, typename std::remove_reference<T>::type>
|
||||||
get_or(const basic_value<C, M, V>& v, T&& opt)
|
get_or(const basic_value<C, M, V>& v, T&& opt)
|
||||||
{
|
{
|
||||||
@@ -790,7 +793,7 @@ detail::enable_if_t<std::is_same<T, std::string>::value, std::string>
|
|||||||
find_or(basic_value<C, M, V>&& v, const toml::key& ky, T&& opt)
|
find_or(basic_value<C, M, V>&& v, const toml::key& ky, T&& opt)
|
||||||
{
|
{
|
||||||
if(!v.is_table()) {return std::forward<T>(opt);}
|
if(!v.is_table()) {return std::forward<T>(opt);}
|
||||||
auto tab = toml::get<toml::table>(std::move(v));
|
auto tab = std::move(v).as_table();
|
||||||
if(tab.count(ky) == 0) {return std::forward<T>(opt);}
|
if(tab.count(ky) == 0) {return std::forward<T>(opt);}
|
||||||
return get_or(std::move(tab.at(ky)), std::forward<T>(opt));
|
return get_or(std::move(tab.at(ky)), std::forward<T>(opt));
|
||||||
}
|
}
|
||||||
@@ -815,9 +818,13 @@ find_or(const basic_value<C, M, V>& v, const toml::key& ky, T&& opt)
|
|||||||
template<typename T, typename C,
|
template<typename T, typename C,
|
||||||
template<typename ...> class M, template<typename ...> class V>
|
template<typename ...> class M, template<typename ...> class V>
|
||||||
detail::enable_if_t<detail::conjunction<
|
detail::enable_if_t<detail::conjunction<
|
||||||
detail::negation<detail::is_exact_toml_type<T, basic_value<C, M, V>>>,
|
detail::negation<detail::is_exact_toml_type<
|
||||||
detail::negation<std::is_same<T, std::string>>,
|
typename std::remove_cv<typename std::remove_reference<T>::type>::type,
|
||||||
detail::negation<detail::is_string_literal<typename std::remove_reference<T>::type>>
|
basic_value<C, M, V>>>,
|
||||||
|
detail::negation<std::is_same<std::string,
|
||||||
|
typename std::remove_cv<typename std::remove_reference<T>::type>::type>>,
|
||||||
|
detail::negation<detail::is_string_literal<
|
||||||
|
typename std::remove_reference<T>::type>>
|
||||||
>::value, T>
|
>::value, T>
|
||||||
find_or(const basic_value<C, M, V>& v, const toml::key& ky, T&& opt)
|
find_or(const basic_value<C, M, V>& v, const toml::key& ky, T&& opt)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -50,6 +50,12 @@ struct has_resize_method_impl
|
|||||||
template<typename T> static std::false_type check(...);
|
template<typename T> static std::false_type check(...);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct is_comparable_impl
|
||||||
|
{
|
||||||
|
template<typename T> static std::true_type check(decltype(std::declval<T>() < std::declval<T>())*);
|
||||||
|
template<typename T> static std::false_type check(...);
|
||||||
|
};
|
||||||
|
|
||||||
struct has_from_toml_method_impl
|
struct has_from_toml_method_impl
|
||||||
{
|
{
|
||||||
template<typename T, typename C,
|
template<typename T, typename C,
|
||||||
@@ -86,6 +92,8 @@ template<typename T>
|
|||||||
struct has_mapped_type : decltype(has_mapped_type_impl::check<T>(nullptr)){};
|
struct has_mapped_type : decltype(has_mapped_type_impl::check<T>(nullptr)){};
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct has_resize_method : decltype(has_resize_method_impl::check<T>(nullptr)){};
|
struct has_resize_method : decltype(has_resize_method_impl::check<T>(nullptr)){};
|
||||||
|
template<typename T>
|
||||||
|
struct is_comparable : decltype(is_comparable_impl::check<T>(nullptr)){};
|
||||||
|
|
||||||
template<typename T, typename C,
|
template<typename T, typename C,
|
||||||
template<typename ...> class Tb, template<typename ...> class A>
|
template<typename ...> class Tb, template<typename ...> class A>
|
||||||
|
|||||||
@@ -1375,7 +1375,6 @@ operator==(const basic_value<C, T, A>& lhs, const basic_value<C, T, A>& rhs)
|
|||||||
{
|
{
|
||||||
if(lhs.type() != rhs.type()) {return false;}
|
if(lhs.type() != rhs.type()) {return false;}
|
||||||
if(lhs.comments() != rhs.comments()) {return false;}
|
if(lhs.comments() != rhs.comments()) {return false;}
|
||||||
|
|
||||||
switch(lhs.type())
|
switch(lhs.type())
|
||||||
{
|
{
|
||||||
case value_t::boolean :
|
case value_t::boolean :
|
||||||
@@ -1422,8 +1421,26 @@ operator==(const basic_value<C, T, A>& lhs, const basic_value<C, T, A>& rhs)
|
|||||||
default: {return false;}
|
default: {return false;}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename C, template<typename ...> class T, template<typename ...> class A>
|
template<typename C, template<typename ...> class T, template<typename ...> class A>
|
||||||
inline bool
|
inline bool operator!=(const basic_value<C, T, A>& lhs, const basic_value<C, T, A>& rhs)
|
||||||
|
{
|
||||||
|
return !(lhs == rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename C, template<typename ...> class T, template<typename ...> class A>
|
||||||
|
typename std::enable_if<detail::conjunction<
|
||||||
|
detail::is_comparable<typename basic_value<C, T, A>::boolean_type >,
|
||||||
|
detail::is_comparable<typename basic_value<C, T, A>::integer_type >,
|
||||||
|
detail::is_comparable<typename basic_value<C, T, A>::floating_type >,
|
||||||
|
detail::is_comparable<typename basic_value<C, T, A>::string_type >,
|
||||||
|
detail::is_comparable<typename basic_value<C, T, A>::local_time_type >,
|
||||||
|
detail::is_comparable<typename basic_value<C, T, A>::local_date_type >,
|
||||||
|
detail::is_comparable<typename basic_value<C, T, A>::local_datetime_type >,
|
||||||
|
detail::is_comparable<typename basic_value<C, T, A>::offset_datetime_type >,
|
||||||
|
detail::is_comparable<typename basic_value<C, T, A>::array_type >,
|
||||||
|
detail::is_comparable<typename basic_value<C, T, A>::table_type >
|
||||||
|
>::value, bool>::type
|
||||||
operator<(const basic_value<C, T, A>& lhs, const basic_value<C, T, A>& rhs)
|
operator<(const basic_value<C, T, A>& lhs, const basic_value<C, T, A>& rhs)
|
||||||
{
|
{
|
||||||
if(lhs.type() != rhs.type()){return (lhs.type() < rhs.type());}
|
if(lhs.type() != rhs.type()){return (lhs.type() < rhs.type());}
|
||||||
@@ -1501,22 +1518,53 @@ operator<(const basic_value<C, T, A>& lhs, const basic_value<C, T, A>& rhs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename C, template<typename ...> class T, template<typename ...> class A>
|
template<typename C, template<typename ...> class T, template<typename ...> class A>
|
||||||
inline bool operator!=(const basic_value<C, T, A>& lhs, const basic_value<C, T, A>& rhs)
|
typename std::enable_if<detail::conjunction<
|
||||||
{
|
detail::is_comparable<typename basic_value<C, T, A>::boolean_type >,
|
||||||
return !(lhs == rhs);
|
detail::is_comparable<typename basic_value<C, T, A>::integer_type >,
|
||||||
}
|
detail::is_comparable<typename basic_value<C, T, A>::floating_type >,
|
||||||
template<typename C, template<typename ...> class T, template<typename ...> class A>
|
detail::is_comparable<typename basic_value<C, T, A>::string_type >,
|
||||||
inline bool operator<=(const basic_value<C, T, A>& lhs, const basic_value<C, T, A>& rhs)
|
detail::is_comparable<typename basic_value<C, T, A>::local_time_type >,
|
||||||
|
detail::is_comparable<typename basic_value<C, T, A>::local_date_type >,
|
||||||
|
detail::is_comparable<typename basic_value<C, T, A>::local_datetime_type >,
|
||||||
|
detail::is_comparable<typename basic_value<C, T, A>::offset_datetime_type >,
|
||||||
|
detail::is_comparable<typename basic_value<C, T, A>::array_type >,
|
||||||
|
detail::is_comparable<typename basic_value<C, T, A>::table_type >
|
||||||
|
>::value, bool>::type
|
||||||
|
operator<=(const basic_value<C, T, A>& lhs, const basic_value<C, T, A>& rhs)
|
||||||
{
|
{
|
||||||
return (lhs < rhs) || (lhs == rhs);
|
return (lhs < rhs) || (lhs == rhs);
|
||||||
}
|
}
|
||||||
template<typename C, template<typename ...> class T, template<typename ...> class A>
|
template<typename C, template<typename ...> class T, template<typename ...> class A>
|
||||||
inline bool operator>(const basic_value<C, T, A>& lhs, const basic_value<C, T, A>& rhs)
|
typename std::enable_if<detail::conjunction<
|
||||||
|
detail::is_comparable<typename basic_value<C, T, A>::boolean_type >,
|
||||||
|
detail::is_comparable<typename basic_value<C, T, A>::integer_type >,
|
||||||
|
detail::is_comparable<typename basic_value<C, T, A>::floating_type >,
|
||||||
|
detail::is_comparable<typename basic_value<C, T, A>::string_type >,
|
||||||
|
detail::is_comparable<typename basic_value<C, T, A>::local_time_type >,
|
||||||
|
detail::is_comparable<typename basic_value<C, T, A>::local_date_type >,
|
||||||
|
detail::is_comparable<typename basic_value<C, T, A>::local_datetime_type >,
|
||||||
|
detail::is_comparable<typename basic_value<C, T, A>::offset_datetime_type >,
|
||||||
|
detail::is_comparable<typename basic_value<C, T, A>::array_type >,
|
||||||
|
detail::is_comparable<typename basic_value<C, T, A>::table_type >
|
||||||
|
>::value, bool>::type
|
||||||
|
operator>(const basic_value<C, T, A>& lhs, const basic_value<C, T, A>& rhs)
|
||||||
{
|
{
|
||||||
return !(lhs <= rhs);
|
return !(lhs <= rhs);
|
||||||
}
|
}
|
||||||
template<typename C, template<typename ...> class T, template<typename ...> class A>
|
template<typename C, template<typename ...> class T, template<typename ...> class A>
|
||||||
inline bool operator>=(const basic_value<C, T, A>& lhs, const basic_value<C, T, A>& rhs)
|
typename std::enable_if<detail::conjunction<
|
||||||
|
detail::is_comparable<typename basic_value<C, T, A>::boolean_type >,
|
||||||
|
detail::is_comparable<typename basic_value<C, T, A>::integer_type >,
|
||||||
|
detail::is_comparable<typename basic_value<C, T, A>::floating_type >,
|
||||||
|
detail::is_comparable<typename basic_value<C, T, A>::string_type >,
|
||||||
|
detail::is_comparable<typename basic_value<C, T, A>::local_time_type >,
|
||||||
|
detail::is_comparable<typename basic_value<C, T, A>::local_date_type >,
|
||||||
|
detail::is_comparable<typename basic_value<C, T, A>::local_datetime_type >,
|
||||||
|
detail::is_comparable<typename basic_value<C, T, A>::offset_datetime_type >,
|
||||||
|
detail::is_comparable<typename basic_value<C, T, A>::array_type >,
|
||||||
|
detail::is_comparable<typename basic_value<C, T, A>::table_type >
|
||||||
|
>::value, bool>::type
|
||||||
|
operator>=(const basic_value<C, T, A>& lhs, const basic_value<C, T, A>& rhs)
|
||||||
{
|
{
|
||||||
return !(lhs < rhs);
|
return !(lhs < rhs);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user