mirror of
https://github.com/rbock/sqlpp11.git
synced 2026-01-10 07:02:11 -06:00
Reformatted using clang-format
Please use clang-format before submitting code, e.g via the pre-commit supplied in the repo (thanks AndiDog)
This commit is contained in:
@@ -38,119 +38,122 @@
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
// basic operators
|
||||
template<typename Expr, typename ValueType>
|
||||
struct basic_expression_operators
|
||||
{
|
||||
template<typename T>
|
||||
struct _is_valid_comparison_operand
|
||||
{
|
||||
static constexpr bool value =
|
||||
(is_expression_t<T>::value // expressions are OK
|
||||
or is_multi_expression_t<T>::value) // multi-expressions like ANY are OK for comparisons, too
|
||||
and ValueType::template _is_valid_operand<T>::value // the correct value type is required, of course
|
||||
;
|
||||
};
|
||||
// basic operators
|
||||
template <typename Expr, typename ValueType>
|
||||
struct basic_expression_operators
|
||||
{
|
||||
template <typename T>
|
||||
struct _is_valid_comparison_operand
|
||||
{
|
||||
static constexpr bool value =
|
||||
(is_expression_t<T>::value // expressions are OK
|
||||
or
|
||||
is_multi_expression_t<T>::value) // multi-expressions like ANY are OK for comparisons, too
|
||||
and
|
||||
ValueType::template _is_valid_operand<T>::value // the correct value type is required, of course
|
||||
;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
equal_to_t<Expr, wrap_operand_t<T>> operator==(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_comparison_operand<rhs>::value, "invalid rhs operand in comparison");
|
||||
template <typename T>
|
||||
equal_to_t<Expr, wrap_operand_t<T>> operator==(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_comparison_operand<rhs>::value, "invalid rhs operand in comparison");
|
||||
|
||||
return { *static_cast<const Expr*>(this), {rhs{t}} };
|
||||
}
|
||||
return {*static_cast<const Expr*>(this), {rhs{t}}};
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
not_equal_to_t<Expr, wrap_operand_t<T>> operator!=(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_comparison_operand<rhs>::value, "invalid rhs operand in comparison");
|
||||
template <typename T>
|
||||
not_equal_to_t<Expr, wrap_operand_t<T>> operator!=(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_comparison_operand<rhs>::value, "invalid rhs operand in comparison");
|
||||
|
||||
return { *static_cast<const Expr*>(this), {rhs{t}} };
|
||||
}
|
||||
return {*static_cast<const Expr*>(this), {rhs{t}}};
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
less_than_t<Expr, wrap_operand_t<T>> operator<(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_comparison_operand<rhs>::value, "invalid rhs operand in comparison");
|
||||
template <typename T>
|
||||
less_than_t<Expr, wrap_operand_t<T>> operator<(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_comparison_operand<rhs>::value, "invalid rhs operand in comparison");
|
||||
|
||||
return { *static_cast<const Expr*>(this), rhs{t} };
|
||||
}
|
||||
return {*static_cast<const Expr*>(this), rhs{t}};
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
less_equal_t<Expr, wrap_operand_t<T>> operator<=(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_comparison_operand<rhs>::value, "invalid rhs operand in comparison");
|
||||
template <typename T>
|
||||
less_equal_t<Expr, wrap_operand_t<T>> operator<=(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_comparison_operand<rhs>::value, "invalid rhs operand in comparison");
|
||||
|
||||
return { *static_cast<const Expr*>(this), rhs{t} };
|
||||
}
|
||||
return {*static_cast<const Expr*>(this), rhs{t}};
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
greater_than_t<Expr, wrap_operand_t<T>> operator>(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_comparison_operand<rhs>::value, "invalid rhs operand in comparison");
|
||||
template <typename T>
|
||||
greater_than_t<Expr, wrap_operand_t<T>> operator>(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_comparison_operand<rhs>::value, "invalid rhs operand in comparison");
|
||||
|
||||
return { *static_cast<const Expr*>(this), rhs{t} };
|
||||
}
|
||||
return {*static_cast<const Expr*>(this), rhs{t}};
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
greater_equal_t<Expr, wrap_operand_t<T>> operator>=(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_comparison_operand<rhs>::value, "invalid rhs operand in comparison");
|
||||
template <typename T>
|
||||
greater_equal_t<Expr, wrap_operand_t<T>> operator>=(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_comparison_operand<rhs>::value, "invalid rhs operand in comparison");
|
||||
|
||||
return { *static_cast<const Expr*>(this), rhs{t} };
|
||||
}
|
||||
return {*static_cast<const Expr*>(this), rhs{t}};
|
||||
}
|
||||
|
||||
is_null_t<Expr> is_null() const
|
||||
{
|
||||
return { *static_cast<const Expr*>(this) };
|
||||
}
|
||||
is_null_t<Expr> is_null() const
|
||||
{
|
||||
return {*static_cast<const Expr*>(this)};
|
||||
}
|
||||
|
||||
is_not_null_t<Expr> is_not_null() const
|
||||
{
|
||||
return { *static_cast<const Expr*>(this) };
|
||||
}
|
||||
is_not_null_t<Expr> is_not_null() const
|
||||
{
|
||||
return {*static_cast<const Expr*>(this)};
|
||||
}
|
||||
|
||||
sort_order_t<Expr, sort_type::asc> asc() const
|
||||
{
|
||||
return { *static_cast<const Expr*>(this) };
|
||||
}
|
||||
sort_order_t<Expr, sort_type::asc> asc() const
|
||||
{
|
||||
return {*static_cast<const Expr*>(this)};
|
||||
}
|
||||
|
||||
sort_order_t<Expr, sort_type::desc> desc() const
|
||||
{
|
||||
return { *static_cast<const Expr*>(this) };
|
||||
}
|
||||
sort_order_t<Expr, sort_type::desc> desc() const
|
||||
{
|
||||
return {*static_cast<const Expr*>(this)};
|
||||
}
|
||||
|
||||
// Hint: use value_list wrapper for containers...
|
||||
template<typename... T>
|
||||
in_t<Expr, wrap_operand_t<T>...> in(T... t) const
|
||||
{
|
||||
static_assert(logic::all_t<_is_valid_comparison_operand<wrap_operand_t<T>>::value...>::value, "at least one operand of in() is not valid");
|
||||
return { *static_cast<const Expr*>(this), wrap_operand_t<T>{t}... };
|
||||
}
|
||||
// Hint: use value_list wrapper for containers...
|
||||
template <typename... T>
|
||||
in_t<Expr, wrap_operand_t<T>...> in(T... t) const
|
||||
{
|
||||
static_assert(logic::all_t<_is_valid_comparison_operand<wrap_operand_t<T>>::value...>::value,
|
||||
"at least one operand of in() is not valid");
|
||||
return {*static_cast<const Expr*>(this), wrap_operand_t<T>{t}...};
|
||||
}
|
||||
|
||||
template<typename... T>
|
||||
not_in_t<Expr, wrap_operand_t<T>...> not_in(T... t) const
|
||||
{
|
||||
static_assert(logic::all_t<_is_valid_comparison_operand<wrap_operand_t<T>>::value...>::value, "at least one operand of in() is not valid");
|
||||
return { *static_cast<const Expr*>(this), wrap_operand_t<T>{t}... };
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Expr>
|
||||
struct alias_operators
|
||||
{
|
||||
template<typename alias_provider>
|
||||
expression_alias_t<Expr, alias_provider> as(const alias_provider&) const
|
||||
{
|
||||
return { *static_cast<const Expr*>(this) };
|
||||
}
|
||||
};
|
||||
template <typename... T>
|
||||
not_in_t<Expr, wrap_operand_t<T>...> not_in(T... t) const
|
||||
{
|
||||
static_assert(logic::all_t<_is_valid_comparison_operand<wrap_operand_t<T>>::value...>::value,
|
||||
"at least one operand of in() is not valid");
|
||||
return {*static_cast<const Expr*>(this), wrap_operand_t<T>{t}...};
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Expr>
|
||||
struct alias_operators
|
||||
{
|
||||
template <typename alias_provider>
|
||||
expression_alias_t<Expr, alias_provider> as(const alias_provider&) const
|
||||
{
|
||||
return {*static_cast<const Expr*>(this)};
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user