Cleaned up traits a bit more

This commit is contained in:
rbock
2014-07-28 07:41:59 +02:00
parent dd33b8096e
commit 42179cbc87
11 changed files with 26 additions and 33 deletions

View File

@@ -41,6 +41,7 @@ namespace sqlpp
// boolean value type
struct boolean
{
using _traits = make_traits<boolean, ::sqlpp::tag::is_boolean, ::sqlpp::tag::is_expression>;
using _tag = ::sqlpp::tag::is_boolean;
using _cpp_value_type = bool;
@@ -122,7 +123,7 @@ namespace sqlpp
using _field_methods_t = field_methods_t<_result_field_t<Db, FieldSpec>>;
using _traits = make_traits<integral,
typename std::conditional<_field_methods_t::_null_is_trivial, ::sqlpp::tag::null_is_trivial_value, void>::type>;
tag_if<tag::null_is_trivial_value, _field_methods_t::_null_is_trivial>>;
struct _recursive_traits
{

View File

@@ -35,9 +35,9 @@ namespace sqlpp
struct field_spec_t
{
using _traits = make_traits<ValueType, tag::is_noop,
typename std::conditional<CanBeNull, tag::can_be_null, void>::type,
typename std::conditional<NullIsTrivialValue, tag::null_is_trivial_value, void>::type
>;
tag_if<tag::can_be_null, CanBeNull>,
tag_if<tag::null_is_trivial_value, NullIsTrivialValue>
>;
using _recursive_traits = make_recursive_traits<>;
using _name_t = NameType;

View File

@@ -40,6 +40,7 @@ namespace sqlpp
// floating_point value type
struct floating_point
{
using _traits = make_traits<floating_point, ::sqlpp::tag::is_floating_point, ::sqlpp::tag::is_expression>;
using _tag = ::sqlpp::tag::is_floating_point;
using _cpp_value_type = double;
@@ -121,7 +122,7 @@ namespace sqlpp
using _field_methods_t = field_methods_t<_result_field_t<Db, FieldSpec>>;
using _traits = make_traits<integral,
typename std::conditional<_field_methods_t::_null_is_trivial, ::sqlpp::tag::null_is_trivial_value, void>::type>;
tag_if<tag::null_is_trivial_value, _field_methods_t::_null_is_trivial>>;
struct _recursive_traits
{

View File

@@ -42,7 +42,7 @@ namespace sqlpp
// integral value type
struct integral
{
using _traits = make_traits<integral, ::sqlpp::tag::is_expression>;
using _traits = make_traits<integral, ::sqlpp::tag::is_integral, ::sqlpp::tag::is_expression>;
using _tag = ::sqlpp::tag::is_integral;
using _cpp_value_type = int64_t;
@@ -123,7 +123,7 @@ namespace sqlpp
using _field_methods_t = field_methods_t<_result_field_t<Db, FieldSpec>>;
using _traits = make_traits<integral,
typename std::conditional<_field_methods_t::_null_is_trivial, ::sqlpp::tag::null_is_trivial_value, void>::type>;
tag_if<tag::null_is_trivial_value, _field_methods_t::_null_is_trivial>>;
struct _recursive_traits
{

View File

@@ -43,7 +43,7 @@ namespace sqlpp
using _traits = make_traits<value_type_of<NamedExpr>,
tag::must_not_insert,
tag::must_not_update,
typename std::conditional<_can_be_null or _depends_on_outer_table, tag::can_be_null, void>::type
tag_if<tag::can_be_null, _can_be_null or _depends_on_outer_table>
>;
};

View File

@@ -98,12 +98,7 @@ namespace sqlpp
no_value_t // if a required statement part is missing (e.g. columns in a select), then the statement cannot be used as a value
>::type;
using _is_expression = typename std::conditional<
std::is_same<_value_type, no_value_t>::value,
std::false_type,
std::true_type>::type;
using _traits = make_traits<_value_type>;
using _traits = make_traits<_value_type, tag_if<tag::is_expression, not std::is_same<_value_type, no_value_t>::value>>;
struct _recursive_traits
{
@@ -135,8 +130,8 @@ namespace sqlpp
using _traits = make_traits<value_type_of<_policies_t>,
::sqlpp::tag::is_select,
tag::is_expression_if<typename _policies_t::_is_expression>,
tag::is_named_expression_if<typename _policies_t::_is_expression>,
tag_if<tag::is_expression, is_expression_t<_policies_t>::value>,
tag_if<tag::is_named_expression, is_expression_t<_policies_t>::value>,
tag::requires_braces>;
using _recursive_traits = typename _policies_t::_recursive_traits;
using _used_outer_tables = typename _policies_t::_all_provided_outer_tables;

View File

@@ -39,7 +39,7 @@ namespace sqlpp
struct table_alias_t: public ColumnSpec::_name_t::template _member_t<column_t<AliasProvider, ColumnSpec>>...
{
//FIXME: Need to add join functionality
using _traits = make_traits<value_type_of<Table>, tag::is_table, tag::is_alias, tag::is_named_expression_if<is_expression_t<Table>>>;
using _traits = make_traits<value_type_of<Table>, tag::is_table, tag::is_alias, tag_if<tag::is_named_expression, is_expression_t<Table>::value>>;
struct _recursive_traits
{

View File

@@ -40,6 +40,7 @@ namespace sqlpp
// text value type
struct text
{
using _traits = make_traits<text, ::sqlpp::tag::is_text, ::sqlpp::tag::is_expression>;
using _tag = ::sqlpp::tag::is_text;
using _cpp_value_type = std::string;
@@ -121,7 +122,7 @@ namespace sqlpp
using _field_methods_t = field_methods_t<_result_field_t<Db, FieldSpec>>;
using _traits = make_traits<integral,
typename std::conditional<_field_methods_t::_null_is_trivial, ::sqlpp::tag::null_is_trivial_value, void>::type>;
tag_if<tag::null_is_trivial_value, _field_methods_t::_null_is_trivial>>;
struct _recursive_traits
{

View File

@@ -82,16 +82,6 @@ namespace sqlpp
SQLPP_VALUE_TRAIT_GENERATOR(is_wrapped_value);
SQLPP_VALUE_TRAIT_GENERATOR(is_expression);
SQLPP_VALUE_TRAIT_GENERATOR(is_named_expression);
namespace tag
{
template<typename C>
using is_named_expression_if = typename std::conditional<C::value, tag::is_named_expression, void>::type;
}
namespace tag
{
template<typename C>
using is_expression_if = typename std::conditional<C::value, tag::is_expression, void>::type;
}
SQLPP_VALUE_TRAIT_GENERATOR(is_multi_expression);
SQLPP_VALUE_TRAIT_GENERATOR(is_alias);
SQLPP_VALUE_TRAIT_GENERATOR(is_select_flag);
@@ -139,12 +129,12 @@ namespace sqlpp
SQLPP_VALUE_TRAIT_GENERATOR(enforce_null_result_treatment);
template<typename Tag, bool Condition>
using tag_if = typename std::conditional<Condition, Tag, void>::type;
template<typename Database>
using is_database = typename std::conditional<std::is_same<Database, void>::value, std::false_type, std::true_type>::type;
template<typename T, template<typename> class IsTag>
using copy_type_trait = typename std::conditional<IsTag<T>::value, std::true_type, std::false_type>::type;
namespace detail
{
template<typename T>