mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-15 20:31:16 +08:00
Moved value types out of detail namespace
This commit is contained in:
parent
c88a1097c2
commit
88d28d6830
@ -36,116 +36,111 @@
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
// boolean operators
|
||||
namespace detail
|
||||
// boolean value type
|
||||
struct boolean
|
||||
{
|
||||
// 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;
|
||||
|
||||
struct _parameter_t
|
||||
{
|
||||
using _traits = make_traits<boolean, ::sqlpp::tag::is_boolean, ::sqlpp::tag::is_expression>;
|
||||
using _tag = ::sqlpp::tag::is_boolean;
|
||||
using _cpp_value_type = bool;
|
||||
using _value_type = boolean; // FIXME
|
||||
|
||||
struct _parameter_t
|
||||
_parameter_t():
|
||||
_value(false),
|
||||
_is_null(true)
|
||||
{}
|
||||
|
||||
_parameter_t(const _cpp_value_type& value):
|
||||
_value(value),
|
||||
_is_null(false)
|
||||
{}
|
||||
|
||||
_parameter_t& operator=(const _cpp_value_type& value)
|
||||
{
|
||||
using _value_type = boolean; // FIXME
|
||||
_value = value;
|
||||
_is_null = (false);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_parameter_t():
|
||||
_value(false),
|
||||
_is_null(true)
|
||||
{}
|
||||
|
||||
_parameter_t(const _cpp_value_type& value):
|
||||
_value(value),
|
||||
_is_null(false)
|
||||
{}
|
||||
|
||||
_parameter_t& operator=(const _cpp_value_type& value)
|
||||
{
|
||||
_value = value;
|
||||
_is_null = (false);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_parameter_t& operator=(const std::nullptr_t&)
|
||||
{
|
||||
_value = false;
|
||||
_is_null = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool is_null() const
|
||||
{
|
||||
return _is_null;
|
||||
}
|
||||
|
||||
_cpp_value_type value() const
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
operator _cpp_value_type() const { return value(); }
|
||||
|
||||
template<typename Target>
|
||||
void _bind(Target& target, size_t index) const
|
||||
{
|
||||
target._bind_boolean_parameter(index, &_value, _is_null);
|
||||
}
|
||||
|
||||
private:
|
||||
signed char _value;
|
||||
bool _is_null;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct _is_valid_operand
|
||||
{
|
||||
static constexpr bool value =
|
||||
is_expression_t<T>::value // expressions are OK
|
||||
and is_boolean_t<T>::value // the correct value type is required, of course
|
||||
;
|
||||
};
|
||||
|
||||
template<typename Base>
|
||||
struct expression_operators: public basic_expression_operators<Base, is_boolean_t>
|
||||
_parameter_t& operator=(const std::nullptr_t&)
|
||||
{
|
||||
template<typename T>
|
||||
logical_and_t<Base, wrap_operand_t<T>> operator and(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs operand");
|
||||
_value = false;
|
||||
_is_null = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
return { *static_cast<const Base*>(this), rhs{t} };
|
||||
}
|
||||
bool is_null() const
|
||||
{
|
||||
return _is_null;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
logical_or_t<Base, wrap_operand_t<T>> operator or(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs operand");
|
||||
_cpp_value_type value() const
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
return { *static_cast<const Base*>(this), rhs{t} };
|
||||
}
|
||||
operator _cpp_value_type() const { return value(); }
|
||||
|
||||
logical_not_t<Base> operator not() const
|
||||
template<typename Target>
|
||||
void _bind(Target& target, size_t index) const
|
||||
{
|
||||
return { *static_cast<const Base*>(this) };
|
||||
target._bind_boolean_parameter(index, &_value, _is_null);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Base>
|
||||
struct column_operators
|
||||
{
|
||||
};
|
||||
private:
|
||||
signed char _value;
|
||||
bool _is_null;
|
||||
};
|
||||
|
||||
}
|
||||
template<typename T>
|
||||
struct _is_valid_operand
|
||||
{
|
||||
static constexpr bool value =
|
||||
is_expression_t<T>::value // expressions are OK
|
||||
and is_boolean_t<T>::value // the correct value type is required, of course
|
||||
;
|
||||
};
|
||||
|
||||
template<typename Base>
|
||||
struct expression_operators: public basic_expression_operators<Base, is_boolean_t>
|
||||
{
|
||||
template<typename T>
|
||||
logical_and_t<Base, wrap_operand_t<T>> operator and(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs operand");
|
||||
|
||||
return { *static_cast<const Base*>(this), rhs{t} };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
logical_or_t<Base, wrap_operand_t<T>> operator or(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs operand");
|
||||
|
||||
return { *static_cast<const Base*>(this), rhs{t} };
|
||||
}
|
||||
|
||||
logical_not_t<Base> operator not() const
|
||||
{
|
||||
return { *static_cast<const Base*>(this) };
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Base>
|
||||
struct column_operators
|
||||
{
|
||||
};
|
||||
};
|
||||
|
||||
template<typename Db, typename FieldSpec>
|
||||
struct result_field_t<detail::boolean, Db, FieldSpec>: public result_field_methods_t<result_field_t<detail::boolean, Db, FieldSpec>>
|
||||
struct result_field_t<boolean, Db, FieldSpec>: public result_field_methods_t<result_field_t<boolean, Db, FieldSpec>>
|
||||
{
|
||||
static_assert(std::is_same<value_type_of<FieldSpec>, detail::boolean>::value, "field type mismatch");
|
||||
using _cpp_value_type = typename detail::boolean::_cpp_value_type;
|
||||
static_assert(std::is_same<value_type_of<FieldSpec>, boolean>::value, "field type mismatch");
|
||||
using _cpp_value_type = typename boolean::_cpp_value_type;
|
||||
|
||||
result_field_t():
|
||||
_is_valid(false),
|
||||
@ -212,12 +207,10 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template<typename Db, typename FieldSpec>
|
||||
inline std::ostream& operator<<(std::ostream& os, const result_field_t<detail::boolean, Db, FieldSpec>& e)
|
||||
inline std::ostream& operator<<(std::ostream& os, const result_field_t<boolean, Db, FieldSpec>& e)
|
||||
{
|
||||
return serialize(e, os);
|
||||
}
|
||||
|
||||
using boolean = detail::boolean;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
@ -33,10 +33,10 @@
|
||||
namespace sqlpp
|
||||
{
|
||||
template<typename Flag, typename Expr>
|
||||
struct count_t: public sqlpp::detail::integral::template expression_operators<count_t<Flag, Expr>>,
|
||||
struct count_t: public sqlpp::integral::template expression_operators<count_t<Flag, Expr>>,
|
||||
public alias_operators<count_t<Flag, Expr>>
|
||||
{
|
||||
using _traits = make_traits<::sqlpp::detail::integral, ::sqlpp::tag::is_expression, ::sqlpp::tag::is_named_expression>;
|
||||
using _traits = make_traits<::sqlpp::integral, ::sqlpp::tag::is_expression, ::sqlpp::tag::is_named_expression>;
|
||||
using _recursive_traits = make_recursive_traits<Expr>;
|
||||
|
||||
static_assert(is_noop<Flag>::value or std::is_same<sqlpp::distinct_t, Flag>::value, "count() used with flag other than 'distinct'");
|
||||
|
@ -40,7 +40,7 @@
|
||||
namespace sqlpp
|
||||
{
|
||||
template<typename Lhs, typename Rhs>
|
||||
struct binary_expression_t<Lhs, op::equal_to, Rhs>: public ::sqlpp::detail::boolean::template expression_operators<binary_expression_t<Lhs, op::equal_to, Rhs>>,
|
||||
struct binary_expression_t<Lhs, op::equal_to, Rhs>: public ::sqlpp::boolean::template expression_operators<binary_expression_t<Lhs, op::equal_to, Rhs>>,
|
||||
public alias_operators<binary_expression_t<Lhs, op::equal_to, Rhs>>
|
||||
{
|
||||
using _traits = make_traits<boolean, sqlpp::tag::is_expression>;
|
||||
@ -88,7 +88,7 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template<typename Lhs, typename Rhs>
|
||||
struct binary_expression_t<Lhs, op::not_equal_to, Rhs>: public ::sqlpp::detail::boolean::template expression_operators<binary_expression_t<Lhs, op::not_equal_to, Rhs>>,
|
||||
struct binary_expression_t<Lhs, op::not_equal_to, Rhs>: public ::sqlpp::boolean::template expression_operators<binary_expression_t<Lhs, op::not_equal_to, Rhs>>,
|
||||
public alias_operators<binary_expression_t<Lhs, op::not_equal_to, Rhs>>
|
||||
{
|
||||
using _traits = make_traits<boolean, sqlpp::tag::is_expression>;
|
||||
@ -136,7 +136,7 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template<typename Rhs>
|
||||
struct unary_expression_t<op::logical_not, Rhs>: public ::sqlpp::detail::boolean::template expression_operators<unary_expression_t<op::logical_not, Rhs>>,
|
||||
struct unary_expression_t<op::logical_not, Rhs>: public ::sqlpp::boolean::template expression_operators<unary_expression_t<op::logical_not, Rhs>>,
|
||||
public alias_operators<unary_expression_t<op::logical_not, Rhs>>
|
||||
{
|
||||
using _traits = make_traits<boolean, sqlpp::tag::is_expression>;
|
||||
|
@ -29,64 +29,61 @@
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
struct boolean;
|
||||
struct integral;
|
||||
struct floating_point;
|
||||
}
|
||||
struct boolean;
|
||||
struct integral;
|
||||
struct floating_point;
|
||||
|
||||
namespace op
|
||||
{
|
||||
struct less
|
||||
{
|
||||
using _traits = make_traits<::sqlpp::detail::boolean>;
|
||||
using _traits = make_traits<::sqlpp::boolean>;
|
||||
static constexpr const char* _name = "<";
|
||||
};
|
||||
|
||||
struct less_equal
|
||||
{
|
||||
using _traits = make_traits<::sqlpp::detail::boolean>;
|
||||
using _traits = make_traits<::sqlpp::boolean>;
|
||||
static constexpr const char* _name = "<=";
|
||||
};
|
||||
|
||||
struct equal_to
|
||||
{
|
||||
using _traits = make_traits<::sqlpp::detail::boolean>;
|
||||
using _traits = make_traits<::sqlpp::boolean>;
|
||||
};
|
||||
|
||||
struct not_equal_to
|
||||
{
|
||||
using _traits = make_traits<::sqlpp::detail::boolean>;
|
||||
using _traits = make_traits<::sqlpp::boolean>;
|
||||
};
|
||||
|
||||
struct greater_equal
|
||||
{
|
||||
using _traits = make_traits<::sqlpp::detail::boolean>;
|
||||
using _traits = make_traits<::sqlpp::boolean>;
|
||||
static constexpr const char* _name = ">=";
|
||||
};
|
||||
|
||||
struct greater
|
||||
{
|
||||
using _traits = make_traits<::sqlpp::detail::boolean>;
|
||||
using _traits = make_traits<::sqlpp::boolean>;
|
||||
static constexpr const char* _name = ">";
|
||||
};
|
||||
|
||||
struct logical_or
|
||||
{
|
||||
using _traits = make_traits<::sqlpp::detail::boolean>;
|
||||
using _traits = make_traits<::sqlpp::boolean>;
|
||||
static constexpr const char* _name = " OR ";
|
||||
};
|
||||
|
||||
struct logical_and
|
||||
{
|
||||
using _traits = make_traits<::sqlpp::detail::boolean>;
|
||||
using _traits = make_traits<::sqlpp::boolean>;
|
||||
static constexpr const char* _name = " AND ";
|
||||
};
|
||||
|
||||
struct logical_not
|
||||
{
|
||||
using _traits = make_traits<::sqlpp::detail::boolean>;
|
||||
using _traits = make_traits<::sqlpp::boolean>;
|
||||
};
|
||||
|
||||
template<typename ValueType>
|
||||
@ -112,13 +109,13 @@ namespace sqlpp
|
||||
|
||||
struct divides
|
||||
{
|
||||
using _traits = make_traits<::sqlpp::detail::floating_point>;
|
||||
using _traits = make_traits<::sqlpp::floating_point>;
|
||||
static constexpr const char* _name = "/";
|
||||
};
|
||||
|
||||
struct modulus
|
||||
{
|
||||
using _traits = make_traits<::sqlpp::detail::integral>;
|
||||
using _traits = make_traits<::sqlpp::integral>;
|
||||
static constexpr const char* _name = "%";
|
||||
};
|
||||
|
||||
|
@ -35,195 +35,190 @@
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
namespace detail
|
||||
// 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;
|
||||
|
||||
// floating_point value type
|
||||
struct floating_point
|
||||
struct _parameter_t
|
||||
{
|
||||
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;
|
||||
using _value_type = floating_point;
|
||||
|
||||
struct _parameter_t
|
||||
_parameter_t():
|
||||
_value(0),
|
||||
_is_null(true)
|
||||
{}
|
||||
|
||||
_parameter_t(const _cpp_value_type& value):
|
||||
_value(value),
|
||||
_is_null(false)
|
||||
{}
|
||||
|
||||
_parameter_t& operator=(const _cpp_value_type& value)
|
||||
{
|
||||
using _value_type = floating_point;
|
||||
_value = value;
|
||||
_is_null = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
_parameter_t():
|
||||
_value(0),
|
||||
_is_null(true)
|
||||
{}
|
||||
|
||||
_parameter_t(const _cpp_value_type& value):
|
||||
_value(value),
|
||||
_is_null(false)
|
||||
{}
|
||||
|
||||
_parameter_t& operator=(const _cpp_value_type& value)
|
||||
{
|
||||
_value = value;
|
||||
_is_null = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
_parameter_t& operator=(const std::nullptr_t&)
|
||||
{
|
||||
_value = 0;
|
||||
_is_null = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool is_null() const
|
||||
{
|
||||
return _is_null;
|
||||
}
|
||||
|
||||
const _cpp_value_type& value() const
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
operator _cpp_value_type() const { return _value; }
|
||||
|
||||
template<typename Target>
|
||||
void _bind(Target& target, size_t index) const
|
||||
{
|
||||
target._bind_floating_point_parameter(index, &_value, _is_null);
|
||||
}
|
||||
|
||||
private:
|
||||
_cpp_value_type _value;
|
||||
bool _is_null;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct _is_valid_operand
|
||||
{
|
||||
static constexpr bool value =
|
||||
is_expression_t<T>::value // expressions are OK
|
||||
and is_numeric_t<T>::value // the correct value type is required, of course
|
||||
;
|
||||
};
|
||||
|
||||
template<typename Base>
|
||||
struct expression_operators: public basic_expression_operators<Base, is_numeric_t>
|
||||
_parameter_t& operator=(const std::nullptr_t&)
|
||||
{
|
||||
template<typename T>
|
||||
plus_t<Base, floating_point, wrap_operand_t<T>> operator +(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs operand");
|
||||
_value = 0;
|
||||
_is_null = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
return { *static_cast<const Base*>(this), rhs{t} };
|
||||
}
|
||||
bool is_null() const
|
||||
{
|
||||
return _is_null;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
minus_t<Base, floating_point, wrap_operand_t<T>> operator -(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs operand");
|
||||
const _cpp_value_type& value() const
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
return { *static_cast<const Base*>(this), rhs{t} };
|
||||
}
|
||||
operator _cpp_value_type() const { return _value; }
|
||||
|
||||
template<typename T>
|
||||
multiplies_t<Base, floating_point, wrap_operand_t<T>> operator *(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
|
||||
return { *static_cast<const Base*>(this), rhs{t} };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
divides_t<Base, wrap_operand_t<T>> operator /(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
|
||||
return { *static_cast<const Base*>(this), rhs{t} };
|
||||
}
|
||||
|
||||
unary_plus_t<floating_point, Base> operator +() const
|
||||
template<typename Target>
|
||||
void _bind(Target& target, size_t index) const
|
||||
{
|
||||
return { *static_cast<const Base*>(this) };
|
||||
target._bind_floating_point_parameter(index, &_value, _is_null);
|
||||
}
|
||||
|
||||
unary_minus_t<floating_point, Base> operator -() const
|
||||
{
|
||||
return { *static_cast<const Base*>(this) };
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Base>
|
||||
struct column_operators
|
||||
{
|
||||
template<typename T>
|
||||
auto operator +=(T t) const -> assignment_t<Base, plus_t<Base, floating_point, wrap_operand_t<T>>>
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs assignment operand");
|
||||
|
||||
return { *static_cast<const Base*>(this), { *static_cast<const Base*>(this), rhs{t} } };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto operator -=(T t) const -> assignment_t<Base, minus_t<Base, floating_point, wrap_operand_t<T>>>
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs assignment operand");
|
||||
|
||||
return { *static_cast<const Base*>(this), { *static_cast<const Base*>(this), rhs{t} } };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto operator /=(T t) const -> assignment_t<Base, divides_t<Base, wrap_operand_t<T>>>
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs assignment operand");
|
||||
|
||||
return { *static_cast<const Base*>(this), { *static_cast<const Base*>(this), rhs{t} } };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto operator *=(T t) const -> assignment_t<Base, multiplies_t<Base, floating_point, wrap_operand_t<T>>>
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs assignment operand");
|
||||
|
||||
return { *static_cast<const Base*>(this), { *static_cast<const Base*>(this), rhs{t} } };
|
||||
}
|
||||
};
|
||||
private:
|
||||
_cpp_value_type _value;
|
||||
bool _is_null;
|
||||
};
|
||||
|
||||
}
|
||||
template<typename T>
|
||||
struct _is_valid_operand
|
||||
{
|
||||
static constexpr bool value =
|
||||
is_expression_t<T>::value // expressions are OK
|
||||
and is_numeric_t<T>::value // the correct value type is required, of course
|
||||
;
|
||||
};
|
||||
|
||||
template<typename Base>
|
||||
struct expression_operators: public basic_expression_operators<Base, is_numeric_t>
|
||||
{
|
||||
template<typename T>
|
||||
plus_t<Base, floating_point, wrap_operand_t<T>> operator +(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs operand");
|
||||
|
||||
return { *static_cast<const Base*>(this), rhs{t} };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
minus_t<Base, floating_point, wrap_operand_t<T>> operator -(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs operand");
|
||||
|
||||
return { *static_cast<const Base*>(this), rhs{t} };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
multiplies_t<Base, floating_point, wrap_operand_t<T>> operator *(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
|
||||
return { *static_cast<const Base*>(this), rhs{t} };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
divides_t<Base, wrap_operand_t<T>> operator /(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
|
||||
return { *static_cast<const Base*>(this), rhs{t} };
|
||||
}
|
||||
|
||||
unary_plus_t<floating_point, Base> operator +() const
|
||||
{
|
||||
return { *static_cast<const Base*>(this) };
|
||||
}
|
||||
|
||||
unary_minus_t<floating_point, Base> operator -() const
|
||||
{
|
||||
return { *static_cast<const Base*>(this) };
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Base>
|
||||
struct column_operators
|
||||
{
|
||||
template<typename T>
|
||||
auto operator +=(T t) const -> assignment_t<Base, plus_t<Base, floating_point, wrap_operand_t<T>>>
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs assignment operand");
|
||||
|
||||
return { *static_cast<const Base*>(this), { *static_cast<const Base*>(this), rhs{t} } };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto operator -=(T t) const -> assignment_t<Base, minus_t<Base, floating_point, wrap_operand_t<T>>>
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs assignment operand");
|
||||
|
||||
return { *static_cast<const Base*>(this), { *static_cast<const Base*>(this), rhs{t} } };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto operator /=(T t) const -> assignment_t<Base, divides_t<Base, wrap_operand_t<T>>>
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs assignment operand");
|
||||
|
||||
return { *static_cast<const Base*>(this), { *static_cast<const Base*>(this), rhs{t} } };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto operator *=(T t) const -> assignment_t<Base, multiplies_t<Base, floating_point, wrap_operand_t<T>>>
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs assignment operand");
|
||||
|
||||
return { *static_cast<const Base*>(this), { *static_cast<const Base*>(this), rhs{t} } };
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template<typename Db, typename FieldSpec>
|
||||
struct result_field_t<detail::floating_point, Db, FieldSpec>: public result_field_methods_t<result_field_t<detail::floating_point, Db, FieldSpec>>
|
||||
{
|
||||
static_assert(std::is_same<value_type_of<FieldSpec>, detail::floating_point>::value, "field type mismatch");
|
||||
using _cpp_value_type = typename detail::floating_point::_cpp_value_type;
|
||||
|
||||
result_field_t():
|
||||
_is_valid(false),
|
||||
_is_null(true),
|
||||
_value(0)
|
||||
{}
|
||||
|
||||
void _validate()
|
||||
struct result_field_t<floating_point, Db, FieldSpec>: public result_field_methods_t<result_field_t<floating_point, Db, FieldSpec>>
|
||||
{
|
||||
_is_valid = true;
|
||||
}
|
||||
static_assert(std::is_same<value_type_of<FieldSpec>, floating_point>::value, "field type mismatch");
|
||||
using _cpp_value_type = typename floating_point::_cpp_value_type;
|
||||
|
||||
void _invalidate()
|
||||
{
|
||||
_is_valid = false;
|
||||
_is_null = true;
|
||||
_value = 0;
|
||||
}
|
||||
result_field_t():
|
||||
_is_valid(false),
|
||||
_is_null(true),
|
||||
_value(0)
|
||||
{}
|
||||
|
||||
bool is_null() const
|
||||
{
|
||||
if (not _is_valid)
|
||||
throw exception("accessing is_null in non-existing row");
|
||||
void _validate()
|
||||
{
|
||||
_is_valid = true;
|
||||
}
|
||||
|
||||
void _invalidate()
|
||||
{
|
||||
_is_valid = false;
|
||||
_is_null = true;
|
||||
_value = 0;
|
||||
}
|
||||
|
||||
bool is_null() const
|
||||
{
|
||||
if (not _is_valid)
|
||||
throw exception("accessing is_null in non-existing row");
|
||||
return _is_null;
|
||||
}
|
||||
|
||||
@ -267,13 +262,10 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template<typename Db, typename FieldSpec>
|
||||
inline std::ostream& operator<<(std::ostream& os, const result_field_t<detail::floating_point, Db, FieldSpec>& e)
|
||||
inline std::ostream& operator<<(std::ostream& os, const result_field_t<floating_point, Db, FieldSpec>& e)
|
||||
{
|
||||
return serialize(e, os);
|
||||
}
|
||||
|
||||
|
||||
using floating_point = detail::floating_point;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
@ -37,182 +37,178 @@
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
namespace detail
|
||||
// integral value type
|
||||
struct integral
|
||||
{
|
||||
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;
|
||||
|
||||
// integral value type
|
||||
struct integral
|
||||
struct _parameter_t
|
||||
{
|
||||
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;
|
||||
using _value_type = integral;
|
||||
|
||||
struct _parameter_t
|
||||
_parameter_t():
|
||||
_value(0),
|
||||
_is_null(true)
|
||||
{}
|
||||
|
||||
explicit _parameter_t(const _cpp_value_type& value):
|
||||
_value(value),
|
||||
_is_null(false)
|
||||
{}
|
||||
|
||||
_parameter_t& operator=(const _cpp_value_type& value)
|
||||
{
|
||||
using _value_type = integral;
|
||||
_value = value;
|
||||
_is_null = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
_parameter_t():
|
||||
_value(0),
|
||||
_is_null(true)
|
||||
{}
|
||||
|
||||
explicit _parameter_t(const _cpp_value_type& value):
|
||||
_value(value),
|
||||
_is_null(false)
|
||||
{}
|
||||
|
||||
_parameter_t& operator=(const _cpp_value_type& value)
|
||||
{
|
||||
_value = value;
|
||||
_is_null = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void set_null()
|
||||
{
|
||||
_value = 0;
|
||||
_is_null = true;
|
||||
}
|
||||
|
||||
bool is_null() const
|
||||
{
|
||||
return _is_null;
|
||||
}
|
||||
|
||||
const _cpp_value_type& value() const
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
operator _cpp_value_type() const { return _value; }
|
||||
|
||||
template<typename Target>
|
||||
void _bind(Target& target, size_t index) const
|
||||
{
|
||||
target._bind_integral_parameter(index, &_value, _is_null);
|
||||
}
|
||||
|
||||
private:
|
||||
_cpp_value_type _value;
|
||||
bool _is_null;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct _is_valid_operand
|
||||
{
|
||||
static constexpr bool value =
|
||||
is_expression_t<T>::value // expressions are OK
|
||||
and is_numeric_t<T>::value // the correct value type is required, of course
|
||||
;
|
||||
};
|
||||
|
||||
template<typename Base>
|
||||
struct expression_operators: public basic_expression_operators<Base, is_numeric_t>
|
||||
void set_null()
|
||||
{
|
||||
template<typename T>
|
||||
plus_t<Base, value_type_t<T>, wrap_operand_t<T>> operator +(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs operand");
|
||||
_value = 0;
|
||||
_is_null = true;
|
||||
}
|
||||
|
||||
return { *static_cast<const Base*>(this), {t} };
|
||||
}
|
||||
bool is_null() const
|
||||
{
|
||||
return _is_null;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
minus_t<Base, value_type_t<T>, wrap_operand_t<T>> operator -(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs operand");
|
||||
const _cpp_value_type& value() const
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
return { *static_cast<const Base*>(this), {t} };
|
||||
}
|
||||
operator _cpp_value_type() const { return _value; }
|
||||
|
||||
template<typename T>
|
||||
multiplies_t<Base, value_type_t<T>, wrap_operand_t<T>> operator *(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs operand");
|
||||
|
||||
return { *static_cast<const Base*>(this), {t} };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
divides_t<Base, wrap_operand_t<T>> operator /(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs operand");
|
||||
|
||||
return { *static_cast<const Base*>(this), {t} };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
modulus_t<Base, wrap_operand_t<T>> operator %(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs operand");
|
||||
|
||||
return { *static_cast<const Base*>(this), {t} };
|
||||
}
|
||||
|
||||
unary_plus_t<integral, Base> operator +() const
|
||||
template<typename Target>
|
||||
void _bind(Target& target, size_t index) const
|
||||
{
|
||||
return { *static_cast<const Base*>(this) };
|
||||
target._bind_integral_parameter(index, &_value, _is_null);
|
||||
}
|
||||
|
||||
unary_minus_t<integral, Base> operator -() const
|
||||
{
|
||||
return { *static_cast<const Base*>(this) };
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Base>
|
||||
struct column_operators
|
||||
{
|
||||
template<typename T>
|
||||
auto operator +=(T t) const -> assignment_t<Base, plus_t<Base, value_type_t<T>, wrap_operand_t<T>>>
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs assignment operand");
|
||||
|
||||
return { *static_cast<const Base*>(this), { *static_cast<const Base*>(this), rhs{t} } };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto operator -=(T t) const -> assignment_t<Base, minus_t<Base, value_type_t<T>, wrap_operand_t<T>>>
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs assignment operand");
|
||||
|
||||
return { *static_cast<const Base*>(this), { *static_cast<const Base*>(this), rhs{t} } };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto operator /=(T t) const -> assignment_t<Base, divides_t<Base, wrap_operand_t<T>>>
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs assignment operand");
|
||||
|
||||
return { *static_cast<const Base*>(this), { *static_cast<const Base*>(this), rhs{t} } };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto operator *=(T t) const -> assignment_t<Base, multiplies_t<Base, value_type_t<T>, wrap_operand_t<T>>>
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs assignment operand");
|
||||
|
||||
return { *static_cast<const Base*>(this), { *static_cast<const Base*>(this), rhs{t} } };
|
||||
}
|
||||
};
|
||||
private:
|
||||
_cpp_value_type _value;
|
||||
bool _is_null;
|
||||
};
|
||||
|
||||
}
|
||||
template<typename T>
|
||||
struct _is_valid_operand
|
||||
{
|
||||
static constexpr bool value =
|
||||
is_expression_t<T>::value // expressions are OK
|
||||
and is_numeric_t<T>::value // the correct value type is required, of course
|
||||
;
|
||||
};
|
||||
|
||||
template<typename Base>
|
||||
struct expression_operators: public basic_expression_operators<Base, is_numeric_t>
|
||||
{
|
||||
template<typename T>
|
||||
plus_t<Base, value_type_t<T>, wrap_operand_t<T>> operator +(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs operand");
|
||||
|
||||
return { *static_cast<const Base*>(this), {t} };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
minus_t<Base, value_type_t<T>, wrap_operand_t<T>> operator -(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs operand");
|
||||
|
||||
return { *static_cast<const Base*>(this), {t} };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
multiplies_t<Base, value_type_t<T>, wrap_operand_t<T>> operator *(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs operand");
|
||||
|
||||
return { *static_cast<const Base*>(this), {t} };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
divides_t<Base, wrap_operand_t<T>> operator /(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs operand");
|
||||
|
||||
return { *static_cast<const Base*>(this), {t} };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
modulus_t<Base, wrap_operand_t<T>> operator %(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs operand");
|
||||
|
||||
return { *static_cast<const Base*>(this), {t} };
|
||||
}
|
||||
|
||||
unary_plus_t<integral, Base> operator +() const
|
||||
{
|
||||
return { *static_cast<const Base*>(this) };
|
||||
}
|
||||
|
||||
unary_minus_t<integral, Base> operator -() const
|
||||
{
|
||||
return { *static_cast<const Base*>(this) };
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Base>
|
||||
struct column_operators
|
||||
{
|
||||
template<typename T>
|
||||
auto operator +=(T t) const -> assignment_t<Base, plus_t<Base, value_type_t<T>, wrap_operand_t<T>>>
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs assignment operand");
|
||||
|
||||
return { *static_cast<const Base*>(this), { *static_cast<const Base*>(this), rhs{t} } };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto operator -=(T t) const -> assignment_t<Base, minus_t<Base, value_type_t<T>, wrap_operand_t<T>>>
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs assignment operand");
|
||||
|
||||
return { *static_cast<const Base*>(this), { *static_cast<const Base*>(this), rhs{t} } };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto operator /=(T t) const -> assignment_t<Base, divides_t<Base, wrap_operand_t<T>>>
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs assignment operand");
|
||||
|
||||
return { *static_cast<const Base*>(this), { *static_cast<const Base*>(this), rhs{t} } };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto operator *=(T t) const -> assignment_t<Base, multiplies_t<Base, value_type_t<T>, wrap_operand_t<T>>>
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs assignment operand");
|
||||
|
||||
return { *static_cast<const Base*>(this), { *static_cast<const Base*>(this), rhs{t} } };
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template<typename Db, typename FieldSpec>
|
||||
struct result_field_t<detail::integral, Db, FieldSpec>: public result_field_methods_t<result_field_t<detail::integral, Db, FieldSpec>>
|
||||
struct result_field_t<integral, Db, FieldSpec>: public result_field_methods_t<result_field_t<integral, Db, FieldSpec>>
|
||||
{
|
||||
static_assert(std::is_same<value_type_of<FieldSpec>, detail::integral>::value, "field type mismatch");
|
||||
using _cpp_value_type = typename detail::integral::_cpp_value_type;
|
||||
static_assert(std::is_same<value_type_of<FieldSpec>, integral>::value, "field type mismatch");
|
||||
using _cpp_value_type = typename integral::_cpp_value_type;
|
||||
|
||||
result_field_t():
|
||||
_is_valid(false),
|
||||
@ -279,15 +275,15 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template<typename Db, typename FieldSpec>
|
||||
inline std::ostream& operator<<(std::ostream& os, const result_field_t<detail::integral, Db, FieldSpec>& e)
|
||||
inline std::ostream& operator<<(std::ostream& os, const result_field_t<integral, Db, FieldSpec>& e)
|
||||
{
|
||||
return serialize(e, os);
|
||||
}
|
||||
|
||||
using tinyint = detail::integral;
|
||||
using smallint = detail::integral;
|
||||
using integer = detail::integral;
|
||||
using bigint = detail::integral;
|
||||
using tinyint = integral;
|
||||
using smallint = integral;
|
||||
using integer = integral;
|
||||
using bigint = integral;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
@ -184,12 +184,12 @@ namespace sqlpp
|
||||
using _impl = detail::result_row_impl<Db, detail::make_column_index_sequence<0, FieldSpecs...>, FieldSpecs...>;
|
||||
struct _field_spec_t
|
||||
{
|
||||
using _traits = make_traits<detail::text, tag::is_noop, tag::can_be_null, tag::null_is_trivial_value>;
|
||||
using _traits = make_traits<text, tag::is_noop, tag::can_be_null, tag::null_is_trivial_value>;
|
||||
using _recursive_traits = make_recursive_traits<>;
|
||||
|
||||
struct _name_t {};
|
||||
};
|
||||
using _field_type = result_field_t<detail::text, Db, _field_spec_t>;
|
||||
using _field_type = result_field_t<text, Db, _field_spec_t>;
|
||||
static constexpr size_t _last_static_index = _impl::_last_index;
|
||||
|
||||
bool _is_valid;
|
||||
|
@ -36,119 +36,115 @@
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
namespace detail
|
||||
// text value type
|
||||
struct text
|
||||
{
|
||||
// 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;
|
||||
|
||||
struct _parameter_t
|
||||
{
|
||||
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;
|
||||
using _value_type = text;
|
||||
|
||||
struct _parameter_t
|
||||
_parameter_t():
|
||||
_value(""),
|
||||
_is_null(true)
|
||||
{}
|
||||
|
||||
_parameter_t(const _cpp_value_type& value):
|
||||
_value(value),
|
||||
_is_null(false)
|
||||
{}
|
||||
|
||||
_parameter_t& operator=(const _cpp_value_type& value)
|
||||
{
|
||||
using _value_type = text;
|
||||
_value = value;
|
||||
_is_null = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
_parameter_t():
|
||||
_value(""),
|
||||
_is_null(true)
|
||||
{}
|
||||
|
||||
_parameter_t(const _cpp_value_type& value):
|
||||
_value(value),
|
||||
_is_null(false)
|
||||
{}
|
||||
|
||||
_parameter_t& operator=(const _cpp_value_type& value)
|
||||
{
|
||||
_value = value;
|
||||
_is_null = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
_parameter_t& operator=(const std::nullptr_t&)
|
||||
{
|
||||
_value = "";
|
||||
_is_null = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool is_null() const
|
||||
{
|
||||
return _is_null;
|
||||
}
|
||||
|
||||
_cpp_value_type value() const
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
operator _cpp_value_type() const { return value(); }
|
||||
|
||||
template<typename Target>
|
||||
void _bind(Target& target, size_t index) const
|
||||
{
|
||||
target._bind_text_parameter(index, &_value, _is_null);
|
||||
}
|
||||
|
||||
private:
|
||||
_cpp_value_type _value;
|
||||
bool _is_null;
|
||||
};
|
||||
|
||||
|
||||
template<typename T>
|
||||
struct _is_valid_operand
|
||||
{
|
||||
static constexpr bool value =
|
||||
is_expression_t<T>::value // expressions are OK
|
||||
and is_text_t<T>::value // the correct value type is required, of course
|
||||
;
|
||||
};
|
||||
|
||||
template<typename Base>
|
||||
struct expression_operators: public basic_expression_operators<Base, is_text_t>
|
||||
_parameter_t& operator=(const std::nullptr_t&)
|
||||
{
|
||||
template<typename T>
|
||||
concat_t<Base, wrap_operand_t<T>> operator+(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs operand");
|
||||
_value = "";
|
||||
_is_null = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
return { *static_cast<const Base*>(this), {t} };
|
||||
}
|
||||
bool is_null() const
|
||||
{
|
||||
return _is_null;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
like_t<Base, wrap_operand_t<T>> like(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid argument for like()");
|
||||
_cpp_value_type value() const
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
return { *static_cast<const Base*>(this), {t} };
|
||||
}
|
||||
};
|
||||
operator _cpp_value_type() const { return value(); }
|
||||
|
||||
template<typename Base>
|
||||
struct column_operators
|
||||
template<typename Target>
|
||||
void _bind(Target& target, size_t index) const
|
||||
{
|
||||
template<typename T>
|
||||
auto operator +=(T t) const -> assignment_t<Base, concat_t<Base, wrap_operand_t<T>>>
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs assignment operand");
|
||||
target._bind_text_parameter(index, &_value, _is_null);
|
||||
}
|
||||
|
||||
return { *static_cast<const Base*>(this), { *static_cast<const Base*>(this), rhs{t} } };
|
||||
}
|
||||
};
|
||||
private:
|
||||
_cpp_value_type _value;
|
||||
bool _is_null;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
struct _is_valid_operand
|
||||
{
|
||||
static constexpr bool value =
|
||||
is_expression_t<T>::value // expressions are OK
|
||||
and is_text_t<T>::value // the correct value type is required, of course
|
||||
;
|
||||
};
|
||||
|
||||
template<typename Base>
|
||||
struct expression_operators: public basic_expression_operators<Base, is_text_t>
|
||||
{
|
||||
template<typename T>
|
||||
concat_t<Base, wrap_operand_t<T>> operator+(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs operand");
|
||||
|
||||
return { *static_cast<const Base*>(this), {t} };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
like_t<Base, wrap_operand_t<T>> like(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid argument for like()");
|
||||
|
||||
return { *static_cast<const Base*>(this), {t} };
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Base>
|
||||
struct column_operators
|
||||
{
|
||||
template<typename T>
|
||||
auto operator +=(T t) const -> assignment_t<Base, concat_t<Base, wrap_operand_t<T>>>
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs assignment operand");
|
||||
|
||||
return { *static_cast<const Base*>(this), { *static_cast<const Base*>(this), rhs{t} } };
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template<typename Db, typename FieldSpec>
|
||||
struct result_field_t<detail::text, Db, FieldSpec>: public result_field_methods_t<result_field_t<detail::text, Db, FieldSpec>>
|
||||
struct result_field_t<text, Db, FieldSpec>: public result_field_methods_t<result_field_t<text, Db, FieldSpec>>
|
||||
{
|
||||
static_assert(std::is_same<value_type_of<FieldSpec>, detail::text>::value, "field type mismatch");
|
||||
using _cpp_value_type = typename detail::text::_cpp_value_type;
|
||||
static_assert(std::is_same<value_type_of<FieldSpec>, text>::value, "field type mismatch");
|
||||
using _cpp_value_type = typename text::_cpp_value_type;
|
||||
|
||||
result_field_t():
|
||||
_is_valid(false),
|
||||
@ -218,9 +214,9 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template<typename Context, typename Db, typename FieldSpec>
|
||||
struct serializer_t<Context, result_field_t<detail::text, Db, FieldSpec>>
|
||||
struct serializer_t<Context, result_field_t<text, Db, FieldSpec>>
|
||||
{
|
||||
using T = result_field_t<detail::text, Db, FieldSpec>;
|
||||
using T = result_field_t<text, Db, FieldSpec>;
|
||||
|
||||
static Context& _(const T& t, Context& context)
|
||||
{
|
||||
@ -237,7 +233,7 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template<typename Db, typename FieldSpec>
|
||||
inline std::ostream& operator<<(std::ostream& os, const result_field_t<detail::text, Db, FieldSpec>& e)
|
||||
inline std::ostream& operator<<(std::ostream& os, const result_field_t<text, Db, FieldSpec>& e)
|
||||
{
|
||||
if (e.is_null() and not null_is_trivial_value_t<FieldSpec>::value)
|
||||
{
|
||||
@ -250,10 +246,9 @@ namespace sqlpp
|
||||
return serialize(e, os);
|
||||
}
|
||||
|
||||
using text = detail::text;
|
||||
using blob = detail::text;
|
||||
using varchar = detail::text;
|
||||
using char_ = detail::text;
|
||||
using blob = text;
|
||||
using varchar = text;
|
||||
using char_ = text;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
@ -33,17 +33,14 @@
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
struct boolean;
|
||||
struct integral;
|
||||
struct floating_point;
|
||||
struct text;
|
||||
}
|
||||
struct boolean;
|
||||
struct integral;
|
||||
struct floating_point;
|
||||
struct text;
|
||||
|
||||
struct boolean_operand
|
||||
{
|
||||
using _traits = make_traits<::sqlpp::detail::boolean, ::sqlpp::tag::is_expression, ::sqlpp::tag::is_wrapped_value>;
|
||||
using _traits = make_traits<::sqlpp::boolean, ::sqlpp::tag::is_expression, ::sqlpp::tag::is_wrapped_value>;
|
||||
using _recursive_traits = make_recursive_traits<>;
|
||||
|
||||
using _value_t = bool;
|
||||
@ -81,7 +78,7 @@ namespace sqlpp
|
||||
|
||||
struct integral_operand
|
||||
{
|
||||
using _traits = make_traits<::sqlpp::detail::integral, ::sqlpp::tag::is_expression, ::sqlpp::tag::is_wrapped_value>;
|
||||
using _traits = make_traits<::sqlpp::integral, ::sqlpp::tag::is_expression, ::sqlpp::tag::is_wrapped_value>;
|
||||
using _recursive_traits = make_recursive_traits<>;
|
||||
|
||||
using _value_t = int64_t;
|
||||
@ -120,7 +117,7 @@ namespace sqlpp
|
||||
|
||||
struct floating_point_operand
|
||||
{
|
||||
using _traits = make_traits<::sqlpp::detail::floating_point, ::sqlpp::tag::is_expression, ::sqlpp::tag::is_wrapped_value>;
|
||||
using _traits = make_traits<::sqlpp::floating_point, ::sqlpp::tag::is_expression, ::sqlpp::tag::is_wrapped_value>;
|
||||
using _recursive_traits = make_recursive_traits<>;
|
||||
|
||||
using _value_t = double;
|
||||
@ -158,7 +155,7 @@ namespace sqlpp
|
||||
|
||||
struct text_operand
|
||||
{
|
||||
using _traits = make_traits<::sqlpp::detail::text, ::sqlpp::tag::is_expression, ::sqlpp::tag::is_wrapped_value>;
|
||||
using _traits = make_traits<::sqlpp::text, ::sqlpp::tag::is_expression, ::sqlpp::tag::is_wrapped_value>;
|
||||
using _recursive_traits = make_recursive_traits<>;
|
||||
|
||||
using _value_t = std::string;
|
||||
|
@ -101,7 +101,7 @@ int main()
|
||||
|
||||
// functions
|
||||
serialize(sqlpp::value(7), printer).str();
|
||||
serialize(sqlpp::verbatim<sqlpp::detail::integral>("irgendwas integrales"), printer).str();
|
||||
serialize(sqlpp::verbatim<sqlpp::integral>("irgendwas integrales"), printer).str();
|
||||
serialize(sqlpp::value_list(std::vector<int>({1,2,3,4,5,6,8})), printer).str();
|
||||
serialize(exists(select(t.alpha).from(t)), printer).str();
|
||||
serialize(any(select(t.alpha).from(t)), printer).str();
|
||||
|
Loading…
Reference in New Issue
Block a user