0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-15 20:31:16 +08:00

Removed the slightly annoying _tag from data_types

This commit is contained in:
rbock 2015-11-01 19:26:49 +01:00
parent 929a543d8c
commit a452438cad
8 changed files with 45 additions and 32 deletions

View File

@ -33,8 +33,7 @@ namespace sqlpp
{
struct boolean
{
using _traits = make_traits<boolean, tag::is_value_type>;
using _tag = tag::is_boolean;
using _traits = make_traits<void, tag::is_value_type>;
using _cpp_value_type = bool;
template <typename T>

View File

@ -34,14 +34,13 @@ namespace sqlpp
{
struct day_point
{
using _traits = make_traits<day_point, tag::is_value_type>;
using _tag = tag::is_date;
using _traits = make_traits<void, tag::is_value_type>;
using _cpp_value_type = ::sqlpp::chrono::day_point;
template <typename T>
using _is_valid_operand = is_time_point_t<T>;
using _is_valid_operand = is_day_or_time_point_t<T>;
template <typename T>
using _is_valid_assignment_operand = is_date_t<T>;
using _is_valid_assignment_operand = is_day_point_t<T>;
};
}
#endif

View File

@ -33,8 +33,7 @@ namespace sqlpp
{
struct floating_point
{
using _traits = make_traits<floating_point, tag::is_value_type>;
using _tag = tag::is_floating_point;
using _traits = make_traits<void, tag::is_value_type>;
using _cpp_value_type = double;
template <typename T>

View File

@ -33,8 +33,7 @@ namespace sqlpp
{
struct integral
{
using _traits = make_traits<integral, tag::is_value_type>;
using _tag = tag::is_integral;
using _traits = make_traits<void, tag::is_value_type>;
using _cpp_value_type = int64_t;
template <typename T>

View File

@ -33,8 +33,7 @@ namespace sqlpp
{
struct text
{
using _traits = make_traits<text, tag::is_value_type>;
using _tag = tag::is_text;
using _traits = make_traits<void, tag::is_value_type>;
using _cpp_value_type = std::string;
template <typename T>

View File

@ -34,12 +34,11 @@ namespace sqlpp
{
struct time_point
{
using _traits = make_traits<time_point, tag::is_value_type>;
using _tag = tag::is_date_time;
using _traits = make_traits<void, tag::is_value_type>;
using _cpp_value_type = ::sqlpp::chrono::mus_point;
template <typename T>
using _is_valid_operand = is_time_point_t<T>;
using _is_valid_operand = is_day_or_time_point_t<T>;
};
}
#endif

View File

@ -35,7 +35,7 @@ namespace sqlpp
{
struct no_value_t
{
using _tag = void;
using _traits = make_traits<void>;
};
template <typename Base>

View File

@ -62,6 +62,39 @@ namespace sqlpp
template <typename T>
using column_spec_can_be_null_t = typename detail::column_spec_can_be_null_impl<T>::type;
#define SQLPP_VALUE_TYPE_GENERATOR(name) \
struct name; \
namespace detail \
{ \
template <typename T, typename Enable = void> \
struct is_##name##_impl \
{ \
using type = std::false_type; \
}; \
template <typename T> \
struct is_##name##_impl< \
T, \
typename std::enable_if<std::is_same<name, typename T::_traits::_value_type>::value>::type> \
{ \
using type = std::true_type; \
}; \
} \
template <typename T> \
using is_##name##_t = typename detail::is_##name##_impl<T>::type;
SQLPP_VALUE_TYPE_GENERATOR(boolean)
SQLPP_VALUE_TYPE_GENERATOR(day_point)
SQLPP_VALUE_TYPE_GENERATOR(time_point)
SQLPP_VALUE_TYPE_GENERATOR(integral)
SQLPP_VALUE_TYPE_GENERATOR(floating_point)
template <typename T>
using is_numeric_t = logic::any_t<is_integral_t<T>::value, is_floating_point_t<T>::value>;
template <typename T>
using is_day_or_time_point_t = logic::any_t<is_day_point_t<T>::value, is_time_point_t<T>::value>;
SQLPP_VALUE_TYPE_GENERATOR(text)
#define SQLPP_VALUE_TRAIT_GENERATOR(name) \
namespace tag \
{ \
@ -87,22 +120,8 @@ namespace sqlpp
template <typename T> \
using name##_t = typename detail::name##_impl<T>::type;
SQLPP_VALUE_TRAIT_GENERATOR(is_value_type)
SQLPP_VALUE_TRAIT_GENERATOR(is_sql_null)
SQLPP_VALUE_TRAIT_GENERATOR(is_boolean)
SQLPP_VALUE_TRAIT_GENERATOR(is_date)
SQLPP_VALUE_TRAIT_GENERATOR(is_date_time)
SQLPP_VALUE_TRAIT_GENERATOR(is_integral)
SQLPP_VALUE_TRAIT_GENERATOR(is_floating_point)
template <typename T>
using is_numeric_t = logic::any_t<detail::is_element_of<tag::is_integral, typename T::_traits::_tags>::value,
detail::is_element_of<tag::is_floating_point, typename T::_traits::_tags>::value>;
template <typename T>
using is_time_point_t = logic::any_t<detail::is_element_of<tag::is_date, typename T::_traits::_tags>::value,
detail::is_element_of<tag::is_date_time, typename T::_traits::_tags>::value>;
SQLPP_VALUE_TRAIT_GENERATOR(is_text)
SQLPP_VALUE_TRAIT_GENERATOR(is_value_type)
SQLPP_VALUE_TRAIT_GENERATOR(is_wrapped_value)
SQLPP_VALUE_TRAIT_GENERATOR(is_selectable)
SQLPP_VALUE_TRAIT_GENERATOR(is_expression)
@ -301,7 +320,7 @@ namespace sqlpp
struct make_traits
{
using _value_type = ValueType;
using _tags = detail::make_type_set_t<typename ValueType::_tag, Tags...>;
using _tags = detail::make_type_set_t<Tags...>;
};
struct aggregate_function