mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-16 04:47:18 +08:00
Merge branch 'feature/re-organize-value-types' into develop
Conflicts: .travis.yml
This commit is contained in:
commit
21f587e80d
@ -2,7 +2,7 @@
|
||||
#define TEST_SAMPLE_H
|
||||
|
||||
#include <sqlpp11/table.h>
|
||||
#include <sqlpp11/column_types.h>
|
||||
#include <sqlpp11/data_types.h>
|
||||
#include <sqlpp11/char_sequence.h>
|
||||
|
||||
// clang-format off
|
||||
|
36
include/sqlpp11/aggregate_functions.h
Normal file
36
include/sqlpp11/aggregate_functions.h
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_AGGREGATE_FUNCTIONS_H
|
||||
#define SQLPP_AGGREGATE_FUNCTIONS_H
|
||||
|
||||
#include <sqlpp11/aggregate_functions/count.h>
|
||||
#include <sqlpp11/aggregate_functions/min.h>
|
||||
#include <sqlpp11/aggregate_functions/max.h>
|
||||
#include <sqlpp11/aggregate_functions/avg.h>
|
||||
#include <sqlpp11/aggregate_functions/sum.h>
|
||||
|
||||
#endif
|
@ -60,6 +60,7 @@ namespace sqlpp
|
||||
{
|
||||
using _traits = make_traits<floating_point, tag::is_expression, tag::is_selectable>;
|
||||
using _nodes = detail::type_vector<Expr, aggregate_function>;
|
||||
using _can_be_null = std::true_type;
|
||||
using _is_aggregate_expression = std::true_type;
|
||||
|
||||
static_assert(is_noop<Flag>::value or std::is_same<distinct_t, Flag>::value,
|
@ -29,7 +29,7 @@
|
||||
|
||||
#include <sqlpp11/char_sequence.h>
|
||||
#include <sqlpp11/select_flags.h>
|
||||
#include <sqlpp11/integral.h>
|
||||
#include <sqlpp11/data_types/integral/data_type.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
@ -62,8 +62,8 @@ namespace sqlpp
|
||||
using _traits = make_traits<integral, tag::is_expression /*, tag::is_selectable*/>;
|
||||
|
||||
using _nodes = detail::type_vector<Expr, aggregate_function>;
|
||||
using _is_aggregate_expression = std::true_type;
|
||||
using _can_be_null = std::false_type;
|
||||
using _is_aggregate_expression = std::true_type;
|
||||
|
||||
static_assert(is_noop<Flag>::value or std::is_same<distinct_t, Flag>::value,
|
||||
"count() used with flag other than 'distinct'");
|
@ -59,6 +59,7 @@ namespace sqlpp
|
||||
{
|
||||
using _traits = make_traits<value_type_of<Expr>, tag::is_expression, tag::is_selectable>;
|
||||
using _nodes = detail::type_vector<Expr, aggregate_function>;
|
||||
using _can_be_null = std::true_type;
|
||||
using _is_aggregate_expression = std::true_type;
|
||||
|
||||
using _auto_alias_t = max_alias_t;
|
@ -59,6 +59,7 @@ namespace sqlpp
|
||||
{
|
||||
using _traits = make_traits<value_type_of<Expr>, tag::is_expression, tag::is_selectable>;
|
||||
using _nodes = detail::type_vector<Expr, aggregate_function>;
|
||||
using _can_be_null = std::true_type;
|
||||
using _is_aggregate_expression = std::true_type;
|
||||
|
||||
using _auto_alias_t = min_alias_t;
|
@ -60,6 +60,7 @@ namespace sqlpp
|
||||
{
|
||||
using _traits = make_traits<value_type_of<Expr>, tag::is_expression, tag::is_selectable>;
|
||||
using _nodes = detail::type_vector<Expr, aggregate_function>;
|
||||
using _can_be_null = std::true_type;
|
||||
using _is_aggregate_expression = std::true_type;
|
||||
|
||||
static_assert(is_noop<Flag>::value or std::is_same<distinct_t, Flag>::value,
|
44
include/sqlpp11/alias_operators.h
Normal file
44
include/sqlpp11/alias_operators.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_ALIAS_OPERATORS_H
|
||||
#define SQLPP_ALIAS_OPERATORS_H
|
||||
|
||||
#include <sqlpp11/alias.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
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
|
@ -27,7 +27,7 @@
|
||||
#ifndef SQLPP_ANY_H
|
||||
#define SQLPP_ANY_H
|
||||
|
||||
#include <sqlpp11/boolean.h>
|
||||
#include <sqlpp11/data_types/boolean.h>
|
||||
#include <sqlpp11/char_sequence.h>
|
||||
#include <sqlpp11/detail/type_set.h>
|
||||
|
||||
|
58
include/sqlpp11/bad_expression.h
Normal file
58
include/sqlpp11/bad_expression.h
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_BAD_EXPRESSION_H
|
||||
#define SQLPP_BAD_EXPRESSION_H
|
||||
|
||||
#include <sqlpp11/portable_static_assert.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
SQLPP_PORTABLE_STATIC_ASSERT(assert_valid_operands, "Invalid operand(s)");
|
||||
|
||||
template <typename ValueType>
|
||||
struct bad_expression
|
||||
{
|
||||
template <typename... T>
|
||||
bad_expression(T&&...)
|
||||
{
|
||||
}
|
||||
using _traits = make_traits<ValueType, tag::is_expression>;
|
||||
using _nodes = detail::type_vector<>;
|
||||
};
|
||||
|
||||
template <typename Context, typename ValueType>
|
||||
struct serializer_t<Context, bad_expression<ValueType>>
|
||||
{
|
||||
using _serialize_check = assert_valid_operands;
|
||||
using T = bad_expression<ValueType>;
|
||||
|
||||
static Context& _(const T&, Context&);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -36,7 +36,7 @@
|
||||
#include <sqlpp11/expression_fwd.h>
|
||||
#include <sqlpp11/in_fwd.h>
|
||||
#include <sqlpp11/is_null_fwd.h>
|
||||
#include <sqlpp11/wrap_operand_fwd.h>
|
||||
#include <sqlpp11/wrap_operand.h>
|
||||
#include <sqlpp11/logic.h>
|
||||
|
||||
namespace sqlpp
|
||||
@ -218,16 +218,91 @@ namespace sqlpp
|
||||
check_rhs_in_arguments_t<ValueType, wrap_operand_t<T>...>::_();
|
||||
return {*static_cast<const Expr*>(this), wrap_operand_t<T>{t}...};
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Expr>
|
||||
struct alias_operators
|
||||
template <typename Defer = void>
|
||||
auto operator not() const -> return_type_not_t<Expr, Defer>
|
||||
{
|
||||
template <typename alias_provider>
|
||||
expression_alias_t<Expr, alias_provider> as(const alias_provider&) const
|
||||
return_type_not<Expr, Defer>::check::_();
|
||||
return {*static_cast<const Expr*>(this)};
|
||||
}
|
||||
|
||||
template <typename R>
|
||||
auto operator and(const R& r) const -> return_type_and_t<Expr, R>
|
||||
{
|
||||
return_type_and<Expr, R>::check::_();
|
||||
return {*static_cast<const Expr*>(this), wrap_operand_t<R>{r}};
|
||||
}
|
||||
|
||||
template <typename R>
|
||||
auto operator&(const R& r) const -> return_type_bitwise_and_t<Expr, R>
|
||||
{
|
||||
return_type_bitwise_and<Expr, R>::check::_();
|
||||
return {*static_cast<const Expr*>(this), wrap_operand_t<R>{r}};
|
||||
}
|
||||
|
||||
template <typename R>
|
||||
auto operator|(const R& r) const -> return_type_bitwise_or_t<Expr, R>
|
||||
{
|
||||
return_type_bitwise_or<Expr, R>::check::_();
|
||||
return {*static_cast<const Expr*>(this), wrap_operand_t<R>{r}};
|
||||
}
|
||||
|
||||
template <typename R>
|
||||
auto operator or(const R& r) const -> return_type_or_t<Expr, R>
|
||||
{
|
||||
return_type_or<Expr, R>::check::_();
|
||||
return {*static_cast<const Expr*>(this), wrap_operand_t<R>{r}};
|
||||
}
|
||||
|
||||
template <typename R>
|
||||
auto operator+(const R& r) const -> return_type_plus_t<Expr, R>
|
||||
{
|
||||
return_type_plus<Expr, R>::check::_();
|
||||
return {*static_cast<const Expr*>(this), wrap_operand_t<R>{r}};
|
||||
}
|
||||
|
||||
template <typename R>
|
||||
auto operator-(const R& r) const -> return_type_minus_t<Expr, R>
|
||||
{
|
||||
return_type_minus<Expr, R>::check::_();
|
||||
return {*static_cast<const Expr*>(this), wrap_operand_t<R>{r}};
|
||||
}
|
||||
|
||||
template <typename R>
|
||||
auto operator*(const R& r) const -> return_type_multiplies_t<Expr, R>
|
||||
{
|
||||
return_type_multiplies<Expr, R>::check::_();
|
||||
return {*static_cast<const Expr*>(this), wrap_operand_t<R>{r}};
|
||||
}
|
||||
|
||||
template <typename R>
|
||||
auto operator/(const R& r) const -> return_type_divides_t<Expr, R>
|
||||
{
|
||||
return_type_divides<Expr, R>::check::_();
|
||||
return {*static_cast<const Expr*>(this), wrap_operand_t<R>{r}};
|
||||
}
|
||||
|
||||
template <typename R>
|
||||
auto operator%(const R& r) const -> return_type_modulus_t<Expr, R>
|
||||
{
|
||||
return_type_modulus<Expr, R>::check::_();
|
||||
return {*static_cast<const Expr*>(this), wrap_operand_t<R>{r}};
|
||||
}
|
||||
|
||||
template <typename Defer = void>
|
||||
auto operator+() const -> return_type_unary_plus_t<Expr, Defer>
|
||||
{
|
||||
return_type_unary_plus<Expr, Defer>::check::_();
|
||||
return {*static_cast<const Expr*>(this)};
|
||||
}
|
||||
|
||||
template <typename Defer = void>
|
||||
auto operator-() const -> return_type_unary_minus_t<Expr, Defer>
|
||||
{
|
||||
return_type_unary_minus<Expr, Defer>::check::_();
|
||||
return {*static_cast<const Expr*>(this)};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,233 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_BOOLEAN_H
|
||||
#define SQLPP_BOOLEAN_H
|
||||
|
||||
#include <cstdlib>
|
||||
#include <ostream>
|
||||
#include <sqlpp11/basic_expression_operators.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/exception.h>
|
||||
#include <sqlpp11/tvin.h>
|
||||
#include <sqlpp11/result_field.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
// boolean value type
|
||||
struct boolean
|
||||
{
|
||||
using _traits = make_traits<boolean, tag::is_value_type>;
|
||||
using _tag = tag::is_boolean;
|
||||
using _cpp_value_type = bool;
|
||||
|
||||
template <typename T>
|
||||
using _is_valid_operand = is_boolean_t<T>;
|
||||
};
|
||||
|
||||
// boolean parameter type
|
||||
template <>
|
||||
struct parameter_value_t<boolean>
|
||||
{
|
||||
using _value_type = boolean; // FIXME
|
||||
using _cpp_value_type = typename _value_type::_cpp_value_type;
|
||||
|
||||
parameter_value_t() : _value(false), _is_null(true)
|
||||
{
|
||||
}
|
||||
|
||||
parameter_value_t(const _cpp_value_type& val) : _value(val), _is_null(false)
|
||||
{
|
||||
}
|
||||
|
||||
parameter_value_t& operator=(const _cpp_value_type& val)
|
||||
{
|
||||
_value = val;
|
||||
_is_null = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
parameter_value_t& operator=(const tvin_t<wrap_operand_t<_cpp_value_type>>& t)
|
||||
{
|
||||
if (t._is_trivial())
|
||||
{
|
||||
_value = false;
|
||||
_is_null = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_value = t._value._t;
|
||||
_is_null = false;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
parameter_value_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;
|
||||
};
|
||||
|
||||
// boolean expression operators
|
||||
template <typename Base>
|
||||
struct expression_operators<Base, boolean> : public basic_expression_operators<Base, boolean>
|
||||
{
|
||||
template <typename T>
|
||||
using _is_valid_operand = is_valid_operand<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)};
|
||||
}
|
||||
};
|
||||
|
||||
// boolean column operators
|
||||
template <typename Base>
|
||||
struct column_operators<Base, boolean>
|
||||
{
|
||||
};
|
||||
|
||||
// boolean result field
|
||||
template <typename Db, typename 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>, boolean>::value, "field type mismatch");
|
||||
using _cpp_value_type = typename boolean::_cpp_value_type;
|
||||
|
||||
result_field_t() : _is_valid(false), _is_null(true), _value(false)
|
||||
{
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
bool _is_trivial() const
|
||||
{
|
||||
if (not _is_valid)
|
||||
throw exception("accessing is_null in non-existing row");
|
||||
|
||||
return value() == false;
|
||||
}
|
||||
|
||||
_cpp_value_type value() const
|
||||
{
|
||||
if (not _is_valid)
|
||||
throw exception("accessing value in non-existing row");
|
||||
|
||||
if (_is_null)
|
||||
{
|
||||
if (enforce_null_result_treatment_t<Db>::value and not null_is_trivial_value_t<FieldSpec>::value)
|
||||
{
|
||||
throw exception("accessing value of NULL field");
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return _value;
|
||||
}
|
||||
|
||||
template <typename Target>
|
||||
void _bind(Target& target, size_t i)
|
||||
{
|
||||
target._bind_boolean_result(i, &_value, &_is_null);
|
||||
}
|
||||
|
||||
private:
|
||||
bool _is_valid;
|
||||
bool _is_null;
|
||||
signed char _value;
|
||||
};
|
||||
|
||||
template <typename Db, typename FieldSpec>
|
||||
inline std::ostream& operator<<(std::ostream& os, const result_field_t<boolean, Db, FieldSpec>& e)
|
||||
{
|
||||
return serialize(e, os);
|
||||
}
|
||||
}
|
||||
#endif
|
@ -24,8 +24,8 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_DATE_FWD_H
|
||||
#define SQLPP_DATE_FWD_H
|
||||
#ifndef SQLPP_CHRONO_H
|
||||
#define SQLPP_CHRONO_H
|
||||
|
||||
#include <chrono>
|
||||
|
||||
@ -38,9 +38,6 @@ namespace sqlpp
|
||||
using day_point = std::chrono::time_point<std::chrono::system_clock, days>;
|
||||
using mus_point = std::chrono::time_point<std::chrono::system_clock, std::chrono::microseconds>;
|
||||
}
|
||||
|
||||
struct day_point;
|
||||
struct time_point;
|
||||
}
|
||||
|
||||
#endif
|
@ -60,8 +60,6 @@ namespace sqlpp
|
||||
using _table = Table;
|
||||
using _alias_t = typename _spec_t::_alias_t;
|
||||
|
||||
template <typename T>
|
||||
using _is_valid_operand = is_valid_operand<value_type_of<ColumnSpec>, T>;
|
||||
template <typename T>
|
||||
using _is_valid_assignment_operand = is_valid_assignment_operand<value_type_of<ColumnSpec>, T>;
|
||||
|
||||
|
@ -27,11 +27,6 @@
|
||||
#ifndef SQLPP_COLUMN_TYPES_H
|
||||
#define SQLPP_COLUMN_TYPES_H
|
||||
|
||||
#include <sqlpp11/boolean.h>
|
||||
#include <sqlpp11/day_point.h>
|
||||
#include <sqlpp11/time_point.h>
|
||||
#include <sqlpp11/integral.h>
|
||||
#include <sqlpp11/floating_point.h>
|
||||
#include <sqlpp11/text.h>
|
||||
#include <sqlpp11/data_types.h>
|
||||
|
||||
#endif
|
||||
|
37
include/sqlpp11/data_types.h
Normal file
37
include/sqlpp11/data_types.h
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_DATA_TYPES_H
|
||||
#define SQLPP_DATA_TYPES_H
|
||||
|
||||
#include <sqlpp11/data_types/boolean.h>
|
||||
#include <sqlpp11/data_types/integral.h>
|
||||
#include <sqlpp11/data_types/floating_point.h>
|
||||
#include <sqlpp11/data_types/text.h>
|
||||
#include <sqlpp11/data_types/day_point.h>
|
||||
#include <sqlpp11/data_types/time_point.h>
|
||||
|
||||
#endif
|
38
include/sqlpp11/data_types/boolean.h
Normal file
38
include/sqlpp11/data_types/boolean.h
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_BOOLEAN_H
|
||||
#define SQLPP_BOOLEAN_H
|
||||
|
||||
#include <sqlpp11/data_types/boolean/data_type.h>
|
||||
#include <sqlpp11/data_types/boolean/operand.h>
|
||||
#include <sqlpp11/data_types/boolean/wrap_operand.h>
|
||||
#include <sqlpp11/data_types/boolean/expression_operators.h>
|
||||
#include <sqlpp11/data_types/boolean/column_operators.h>
|
||||
#include <sqlpp11/data_types/boolean/parameter_value.h>
|
||||
#include <sqlpp11/data_types/boolean/result_field.h>
|
||||
|
||||
#endif
|
@ -24,16 +24,18 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_DETAIL_WRAP_OPERAND_FWD_H
|
||||
#define SQLPP_DETAIL_WRAP_OPERAND_FWD_H
|
||||
#ifndef SQLPP_BOOLEAN_COLUMN_OPERATORS_H
|
||||
#define SQLPP_BOOLEAN_COLUMN_OPERATORS_H
|
||||
|
||||
#include <sqlpp11/data_types/column_operators.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename T, typename Enable = void>
|
||||
struct wrap_operand;
|
||||
struct boolean;
|
||||
|
||||
template <typename T>
|
||||
using wrap_operand_t = typename wrap_operand<T>::type;
|
||||
template <typename Column>
|
||||
struct column_operators<Column, boolean>
|
||||
{
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
44
include/sqlpp11/data_types/boolean/data_type.h
Normal file
44
include/sqlpp11/data_types/boolean/data_type.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_BOOLEAN_DATA_TYPE_H
|
||||
#define SQLPP_BOOLEAN_DATA_TYPE_H
|
||||
|
||||
#include <sqlpp11/type_traits.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
struct boolean
|
||||
{
|
||||
using _traits = make_traits<boolean, tag::is_value_type>;
|
||||
using _cpp_value_type = bool;
|
||||
|
||||
template <typename T>
|
||||
using _is_valid_operand = is_boolean_t<T>;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
64
include/sqlpp11/data_types/boolean/expression_operators.h
Normal file
64
include/sqlpp11/data_types/boolean/expression_operators.h
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_BOOLEAN_EXPRESSION_OPERATORS_H
|
||||
#define SQLPP_BOOLEAN_EXPRESSION_OPERATORS_H
|
||||
|
||||
#include <sqlpp11/expression_return_types.h>
|
||||
#include <sqlpp11/operand_check.h>
|
||||
#include <sqlpp11/expression_operators.h>
|
||||
#include <sqlpp11/basic_expression_operators.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename Expression>
|
||||
struct expression_operators<Expression, boolean> : public basic_expression_operators<Expression, boolean>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename L, typename R>
|
||||
struct return_type_and<L, R, binary_operand_check_t<L, is_boolean_t, R, is_boolean_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = logical_and_t<wrap_operand_t<L>, wrap_operand_t<R>>;
|
||||
};
|
||||
|
||||
template <typename L, typename R>
|
||||
struct return_type_or<L, R, binary_operand_check_t<L, is_boolean_t, R, is_boolean_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = logical_or_t<wrap_operand_t<L>, wrap_operand_t<R>>;
|
||||
};
|
||||
|
||||
template <typename T, typename Defer>
|
||||
struct return_type_not<T, Defer, unary_operand_check_t<T, is_boolean_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = logical_not_t<wrap_operand_t<T>>;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
82
include/sqlpp11/data_types/boolean/operand.h
Normal file
82
include/sqlpp11/data_types/boolean/operand.h
Normal file
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_BOOLEAN_OPERAND_H
|
||||
#define SQLPP_BOOLEAN_OPERAND_H
|
||||
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/alias_operators.h>
|
||||
#include <sqlpp11/serializer.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
struct boolean;
|
||||
|
||||
struct boolean_operand : public alias_operators<boolean_operand>
|
||||
{
|
||||
using _traits = make_traits<boolean, tag::is_expression, tag::is_wrapped_value>;
|
||||
using _nodes = detail::type_vector<>;
|
||||
using _is_aggregate_expression = std::true_type;
|
||||
|
||||
using _value_t = bool;
|
||||
|
||||
boolean_operand() : _t{}
|
||||
{
|
||||
}
|
||||
|
||||
boolean_operand(_value_t t) : _t(t)
|
||||
{
|
||||
}
|
||||
|
||||
boolean_operand(const boolean_operand&) = default;
|
||||
boolean_operand(boolean_operand&&) = default;
|
||||
boolean_operand& operator=(const boolean_operand&) = default;
|
||||
boolean_operand& operator=(boolean_operand&&) = default;
|
||||
~boolean_operand() = default;
|
||||
|
||||
bool _is_trivial() const
|
||||
{
|
||||
return _t == false;
|
||||
}
|
||||
|
||||
_value_t _t;
|
||||
};
|
||||
|
||||
template <typename Context>
|
||||
struct serializer_t<Context, boolean_operand>
|
||||
{
|
||||
using _serialize_check = consistent_t;
|
||||
using Operand = boolean_operand;
|
||||
|
||||
static Context& _(const Operand& t, Context& context)
|
||||
{
|
||||
context << t._t;
|
||||
return context;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
52
include/sqlpp11/data_types/boolean/parameter_value.h
Normal file
52
include/sqlpp11/data_types/boolean/parameter_value.h
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_BOOLEAN_PARAMETER_VALUE_H
|
||||
#define SQLPP_BOOLEAN_PARAMETER_VALUE_H
|
||||
|
||||
#include <sqlpp11/data_types/parameter_value.h>
|
||||
#include <sqlpp11/data_types/parameter_value_base.h>
|
||||
#include <sqlpp11/data_types/boolean/data_type.h>
|
||||
#include <sqlpp11/tvin.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <>
|
||||
struct parameter_value_t<boolean> : public parameter_value_base<boolean, signed char>
|
||||
{
|
||||
using base = parameter_value_base<boolean, signed char>;
|
||||
using base::base;
|
||||
using base::operator=;
|
||||
|
||||
template <typename Target>
|
||||
void _bind(Target& target, size_t index) const
|
||||
{
|
||||
target._bind_boolean_parameter(index, &_value, _is_null);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
50
include/sqlpp11/data_types/boolean/result_field.h
Normal file
50
include/sqlpp11/data_types/boolean/result_field.h
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_BOOLEAN_RESULT_FIELD_H
|
||||
#define SQLPP_BOOLEAN_RESULT_FIELD_H
|
||||
|
||||
#include <sqlpp11/basic_expression_operators.h>
|
||||
#include <sqlpp11/result_field.h>
|
||||
#include <sqlpp11/result_field_base.h>
|
||||
#include <sqlpp11/data_types/boolean/data_type.h>
|
||||
#include <sqlpp11/field_spec.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename Db, typename NameType, bool CanBeNull, bool NullIsTrivialValue>
|
||||
struct result_field_t<Db, field_spec_t<NameType, boolean, CanBeNull, NullIsTrivialValue>>
|
||||
: public result_field_base<Db, field_spec_t<NameType, boolean, CanBeNull, NullIsTrivialValue>, signed char>
|
||||
{
|
||||
template <typename Target>
|
||||
void _bind(Target& target, size_t index)
|
||||
{
|
||||
target._bind_boolean_result(index, &this->_value, &this->_is_null);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
43
include/sqlpp11/data_types/boolean/wrap_operand.h
Normal file
43
include/sqlpp11/data_types/boolean/wrap_operand.h
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_BOOLEAN_WRAP_OPERAND_H
|
||||
#define SQLPP_BOOLEAN_WRAP_OPERAND_H
|
||||
|
||||
#include <sqlpp11/wrap_operand.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
struct boolean_operand;
|
||||
|
||||
template <>
|
||||
struct wrap_operand<bool, void>
|
||||
{
|
||||
using type = boolean_operand;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
41
include/sqlpp11/data_types/column_operators.h
Normal file
41
include/sqlpp11/data_types/column_operators.h
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_COLUMN_OPERATORS_H
|
||||
#define SQLPP_COLUMN_OPERATORS_H
|
||||
|
||||
#include <sqlpp11/wrong.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename Column, typename ValueType>
|
||||
struct column_operators
|
||||
{
|
||||
static_assert(wrong_t<column_operators>::value, "Missing column operators for ValueType");
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
38
include/sqlpp11/data_types/day_point.h
Normal file
38
include/sqlpp11/data_types/day_point.h
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_DAY_POINT_H
|
||||
#define SQLPP_DAY_POINT_H
|
||||
|
||||
#include <sqlpp11/data_types/day_point/data_type.h>
|
||||
#include <sqlpp11/data_types/day_point/operand.h>
|
||||
#include <sqlpp11/data_types/day_point/wrap_operand.h>
|
||||
#include <sqlpp11/data_types/day_point/expression_operators.h>
|
||||
#include <sqlpp11/data_types/day_point/column_operators.h>
|
||||
#include <sqlpp11/data_types/day_point/parameter_value.h>
|
||||
#include <sqlpp11/data_types/day_point/result_field.h>
|
||||
|
||||
#endif
|
44
include/sqlpp11/data_types/day_point/column_operators.h
Normal file
44
include/sqlpp11/data_types/day_point/column_operators.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_DAY_POINT_COLUMN_OPERATORS_H
|
||||
#define SQLPP_DAY_POINT_COLUMN_OPERATORS_H
|
||||
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/assignment.h>
|
||||
#include <sqlpp11/data_types/day_point/data_type.h>
|
||||
#include <sqlpp11/data_types/column_operators.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename Column>
|
||||
struct column_operators<Column, day_point>
|
||||
{
|
||||
template <typename T>
|
||||
using _is_valid_operand = is_valid_operand<day_point, T>;
|
||||
};
|
||||
}
|
||||
#endif
|
46
include/sqlpp11/data_types/day_point/data_type.h
Normal file
46
include/sqlpp11/data_types/day_point/data_type.h
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_DAY_POINT_DATA_TYPE_H
|
||||
#define SQLPP_DAY_POINT_DATA_TYPE_H
|
||||
|
||||
#include <sqlpp11/chrono.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
struct day_point
|
||||
{
|
||||
using _traits = make_traits<day_point, tag::is_value_type>;
|
||||
using _cpp_value_type = ::sqlpp::chrono::day_point;
|
||||
|
||||
template <typename T>
|
||||
using _is_valid_operand = is_day_or_time_point_t<T>;
|
||||
template <typename T>
|
||||
using _is_valid_assignment_operand = is_day_point_t<T>;
|
||||
};
|
||||
}
|
||||
#endif
|
42
include/sqlpp11/data_types/day_point/expression_operators.h
Normal file
42
include/sqlpp11/data_types/day_point/expression_operators.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_DAY_POINT_EXPRESSION_OPERATORS_H
|
||||
#define SQLPP_DAY_POINT_EXPRESSION_OPERATORS_H
|
||||
|
||||
#include <sqlpp11/expression_operators.h>
|
||||
#include <sqlpp11/basic_expression_operators.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/data_types/day_point/data_type.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename Expression>
|
||||
struct expression_operators<Expression, day_point> : public basic_expression_operators<Expression, day_point>
|
||||
{
|
||||
};
|
||||
}
|
||||
#endif
|
84
include/sqlpp11/data_types/day_point/operand.h
Normal file
84
include/sqlpp11/data_types/day_point/operand.h
Normal file
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_DAY_POINT_OPERAND_H
|
||||
#define SQLPP_DAY_POINT_OPERAND_H
|
||||
|
||||
#include <date.h>
|
||||
#include <sqlpp11/chrono.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/alias_operators.h>
|
||||
#include <sqlpp11/serializer.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
struct day_point;
|
||||
|
||||
struct day_point_operand : public alias_operators<day_point_operand>
|
||||
{
|
||||
using _traits = make_traits<day_point, tag::is_expression, tag::is_wrapped_value>;
|
||||
using _nodes = detail::type_vector<>;
|
||||
using _is_aggregate_expression = std::true_type;
|
||||
|
||||
using _value_t = ::sqlpp::chrono::day_point;
|
||||
|
||||
day_point_operand() : _t{}
|
||||
{
|
||||
}
|
||||
|
||||
day_point_operand(_value_t t) : _t(t)
|
||||
{
|
||||
}
|
||||
|
||||
day_point_operand(const day_point_operand&) = default;
|
||||
day_point_operand(day_point_operand&&) = default;
|
||||
day_point_operand& operator=(const day_point_operand&) = default;
|
||||
day_point_operand& operator=(day_point_operand&&) = default;
|
||||
~day_point_operand() = default;
|
||||
|
||||
bool _is_trivial() const
|
||||
{
|
||||
return _t == _value_t{};
|
||||
}
|
||||
|
||||
_value_t _t;
|
||||
};
|
||||
|
||||
template <typename Context>
|
||||
struct serializer_t<Context, day_point_operand>
|
||||
{
|
||||
using _serialize_check = consistent_t;
|
||||
using Operand = day_point_operand;
|
||||
|
||||
static Context& _(const Operand& t, Context& context)
|
||||
{
|
||||
const auto ymd = ::date::year_month_day{t._t};
|
||||
context << "DATE '" << ymd << "'";
|
||||
return context;
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
53
include/sqlpp11/data_types/day_point/parameter_value.h
Normal file
53
include/sqlpp11/data_types/day_point/parameter_value.h
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_DAY_POINT_PARAMETER_VALUE_H
|
||||
#define SQLPP_DAY_POINT_PARAMETER_VALUE_H
|
||||
|
||||
#include <sqlpp11/data_types/parameter_value.h>
|
||||
#include <sqlpp11/data_types/parameter_value_base.h>
|
||||
#include <sqlpp11/data_types/day_point/data_type.h>
|
||||
#include <sqlpp11/data_types/day_point/wrap_operand.h>
|
||||
#include <sqlpp11/data_types/day_point/operand.h>
|
||||
#include <sqlpp11/tvin.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <>
|
||||
struct parameter_value_t<day_point> : public parameter_value_base<day_point>
|
||||
{
|
||||
using base = parameter_value_base<day_point>;
|
||||
using base::base;
|
||||
using base::operator=;
|
||||
|
||||
template <typename Target>
|
||||
void _bind(Target& target, size_t index) const
|
||||
{
|
||||
target._bind_date_parameter(index, &_value, _is_null);
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
66
include/sqlpp11/data_types/day_point/result_field.h
Normal file
66
include/sqlpp11/data_types/day_point/result_field.h
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_DAY_POINT_RESULT_FIELD_H
|
||||
#define SQLPP_DAY_POINT_RESULT_FIELD_H
|
||||
|
||||
#include <sqlpp11/basic_expression_operators.h>
|
||||
#include <sqlpp11/result_field.h>
|
||||
#include <sqlpp11/result_field_base.h>
|
||||
#include <sqlpp11/data_types/day_point/data_type.h>
|
||||
#include <sqlpp11/field_spec.h>
|
||||
#include <ostream>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename Db, typename NameType, bool CanBeNull, bool NullIsTrivialValue>
|
||||
struct result_field_t<Db, field_spec_t<NameType, day_point, CanBeNull, NullIsTrivialValue>>
|
||||
: public result_field_base<Db, field_spec_t<NameType, day_point, CanBeNull, NullIsTrivialValue>>
|
||||
{
|
||||
template <typename Target>
|
||||
void _bind(Target& target, size_t index)
|
||||
{
|
||||
target._bind_date_result(index, &this->_value, &this->_is_null);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Db, typename NameType, bool CanBeNull, bool NullIsTrivialValue>
|
||||
inline std::ostream& operator<<(
|
||||
std::ostream& os, const result_field_t<Db, field_spec_t<NameType, day_point, CanBeNull, NullIsTrivialValue>>& e)
|
||||
{
|
||||
if (e.is_null() and not NullIsTrivialValue)
|
||||
{
|
||||
os << "NULL";
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto ymd = ::date::year_month_day{e.value()};
|
||||
os << ymd;
|
||||
}
|
||||
return os;
|
||||
}
|
||||
}
|
||||
#endif
|
45
include/sqlpp11/data_types/day_point/wrap_operand.h
Normal file
45
include/sqlpp11/data_types/day_point/wrap_operand.h
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_DAY_POINT_WRAP_OPERAND_H
|
||||
#define SQLPP_DAY_POINT_WRAP_OPERAND_H
|
||||
|
||||
#include <utility>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/chrono.h>
|
||||
#include <sqlpp11/wrap_operand.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
struct day_point_operand;
|
||||
|
||||
template <>
|
||||
struct wrap_operand<std::chrono::time_point<std::chrono::system_clock, sqlpp::chrono::days>, void>
|
||||
{
|
||||
using type = day_point_operand;
|
||||
};
|
||||
}
|
||||
#endif
|
38
include/sqlpp11/data_types/floating_point.h
Normal file
38
include/sqlpp11/data_types/floating_point.h
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_FLOATING_POINT_H
|
||||
#define SQLPP_FLOATING_POINT_H
|
||||
|
||||
#include <sqlpp11/data_types/floating_point/data_type.h>
|
||||
#include <sqlpp11/data_types/floating_point/operand.h>
|
||||
#include <sqlpp11/data_types/floating_point/wrap_operand.h>
|
||||
#include <sqlpp11/data_types/floating_point/expression_operators.h>
|
||||
#include <sqlpp11/data_types/floating_point/column_operators.h>
|
||||
#include <sqlpp11/data_types/floating_point/parameter_value.h>
|
||||
#include <sqlpp11/data_types/floating_point/result_field.h>
|
||||
|
||||
#endif
|
80
include/sqlpp11/data_types/floating_point/column_operators.h
Normal file
80
include/sqlpp11/data_types/floating_point/column_operators.h
Normal file
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_FLOATING_POINT_COLUMN_OPERATORS_H
|
||||
#define SQLPP_FLOATING_POINT_COLUMN_OPERATORS_H
|
||||
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/assignment.h>
|
||||
#include <sqlpp11/data_types/floating_point/data_type.h>
|
||||
#include <sqlpp11/data_types/column_operators.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename Column>
|
||||
struct column_operators<Column, floating_point>
|
||||
{
|
||||
template <typename T>
|
||||
using _is_valid_operand = is_valid_operand<floating_point, T>;
|
||||
|
||||
template <typename T>
|
||||
auto operator+=(T t) const -> assignment_t<Column, plus_t<Column, 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 Column*>(this), {*static_cast<const Column*>(this), rhs{t}}};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
auto operator-=(T t) const -> assignment_t<Column, minus_t<Column, 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 Column*>(this), {*static_cast<const Column*>(this), rhs{t}}};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
auto operator/=(T t) const -> assignment_t<Column, divides_t<Column, 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 Column*>(this), {*static_cast<const Column*>(this), rhs{t}}};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
auto operator*=(T t) const -> assignment_t<Column, multiplies_t<Column, 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 Column*>(this), {*static_cast<const Column*>(this), rhs{t}}};
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
43
include/sqlpp11/data_types/floating_point/data_type.h
Normal file
43
include/sqlpp11/data_types/floating_point/data_type.h
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_FLOATING_POINT_DATA_TYPE_H
|
||||
#define SQLPP_FLOATING_POINT_DATA_TYPE_H
|
||||
|
||||
#include <sqlpp11/type_traits.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
struct floating_point
|
||||
{
|
||||
using _traits = make_traits<floating_point, tag::is_value_type>;
|
||||
using _cpp_value_type = double;
|
||||
|
||||
template <typename T>
|
||||
using _is_valid_operand = is_numeric_t<T>;
|
||||
};
|
||||
}
|
||||
#endif
|
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_FLOATING_POINT_EXPRESSION_OPERATORS_H
|
||||
#define SQLPP_FLOATING_POINT_EXPRESSION_OPERATORS_H
|
||||
|
||||
#include <sqlpp11/expression_return_types.h>
|
||||
#include <sqlpp11/operand_check.h>
|
||||
#include <sqlpp11/expression_operators.h>
|
||||
#include <sqlpp11/basic_expression_operators.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/data_types/floating_point/data_type.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename Expr>
|
||||
struct expression_operators<Expr, floating_point> : public basic_expression_operators<Expr, floating_point>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename L, typename R>
|
||||
struct return_type_plus<L, R, binary_operand_check_t<L, is_floating_point_t, R, is_numeric_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = plus_t<wrap_operand_t<L>, floating_point, wrap_operand_t<R>>;
|
||||
};
|
||||
|
||||
template <typename L, typename R>
|
||||
struct return_type_minus<L, R, binary_operand_check_t<L, is_floating_point_t, R, is_numeric_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = minus_t<wrap_operand_t<L>, floating_point, wrap_operand_t<R>>;
|
||||
};
|
||||
|
||||
template <typename L, typename R>
|
||||
struct return_type_multiplies<L, R, binary_operand_check_t<L, is_floating_point_t, R, is_numeric_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = multiplies_t<wrap_operand_t<L>, floating_point, wrap_operand_t<R>>;
|
||||
};
|
||||
|
||||
template <typename L, typename R>
|
||||
struct return_type_divides<L, R, binary_operand_check_t<L, is_floating_point_t, R, is_numeric_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = divides_t<wrap_operand_t<L>, wrap_operand_t<R>>;
|
||||
};
|
||||
|
||||
template <typename T, typename Defer>
|
||||
struct return_type_unary_plus<T, Defer, unary_operand_check_t<T, is_floating_point_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = unary_plus_t<floating_point, wrap_operand_t<T>>;
|
||||
};
|
||||
|
||||
template <typename T, typename Defer>
|
||||
struct return_type_unary_minus<T, Defer, unary_operand_check_t<T, is_floating_point_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = unary_minus_t<floating_point, wrap_operand_t<T>>;
|
||||
};
|
||||
}
|
||||
#endif
|
79
include/sqlpp11/data_types/floating_point/operand.h
Normal file
79
include/sqlpp11/data_types/floating_point/operand.h
Normal file
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_FLOATING_POINT_OPERAND_H
|
||||
#define SQLPP_FLOATING_POINT_OPERAND_H
|
||||
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/alias_operators.h>
|
||||
#include <sqlpp11/serializer.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
struct floating_point_operand : public alias_operators<floating_point_operand>
|
||||
{
|
||||
using _traits = make_traits<floating_point, tag::is_expression, tag::is_wrapped_value>;
|
||||
using _nodes = detail::type_vector<>;
|
||||
using _is_aggregate_expression = std::true_type;
|
||||
|
||||
using _value_t = double;
|
||||
|
||||
floating_point_operand() : _t{}
|
||||
{
|
||||
}
|
||||
|
||||
floating_point_operand(_value_t t) : _t(t)
|
||||
{
|
||||
}
|
||||
|
||||
floating_point_operand(const floating_point_operand&) = default;
|
||||
floating_point_operand(floating_point_operand&&) = default;
|
||||
floating_point_operand& operator=(const floating_point_operand&) = default;
|
||||
floating_point_operand& operator=(floating_point_operand&&) = default;
|
||||
~floating_point_operand() = default;
|
||||
|
||||
bool _is_trivial() const
|
||||
{
|
||||
return _t == 0;
|
||||
}
|
||||
|
||||
_value_t _t;
|
||||
};
|
||||
|
||||
template <typename Context>
|
||||
struct serializer_t<Context, floating_point_operand>
|
||||
{
|
||||
using _serialize_check = consistent_t;
|
||||
using Operand = floating_point_operand;
|
||||
|
||||
static Context& _(const Operand& t, Context& context)
|
||||
{
|
||||
context << t._t;
|
||||
return context;
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
53
include/sqlpp11/data_types/floating_point/parameter_value.h
Normal file
53
include/sqlpp11/data_types/floating_point/parameter_value.h
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_FLOATING_POINT_PARAMETER_VALUE_H
|
||||
#define SQLPP_FLOATING_POINT_PARAMETER_VALUE_H
|
||||
|
||||
#include <sqlpp11/data_types/parameter_value.h>
|
||||
#include <sqlpp11/data_types/parameter_value_base.h>
|
||||
#include <sqlpp11/data_types/floating_point/data_type.h>
|
||||
#include <sqlpp11/data_types/floating_point/wrap_operand.h>
|
||||
#include <sqlpp11/data_types/floating_point/operand.h>
|
||||
#include <sqlpp11/tvin.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <>
|
||||
struct parameter_value_t<floating_point> : public parameter_value_base<floating_point>
|
||||
{
|
||||
using base = parameter_value_base<floating_point>;
|
||||
using base::base;
|
||||
using base::operator=;
|
||||
|
||||
template <typename Target>
|
||||
void _bind(Target& target, size_t index) const
|
||||
{
|
||||
target._bind_floating_point_parameter(index, &_value, _is_null);
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
51
include/sqlpp11/data_types/floating_point/result_field.h
Normal file
51
include/sqlpp11/data_types/floating_point/result_field.h
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_FLOATING_POINT_RESULT_FIELD_H
|
||||
#define SQLPP_FLOATING_POINT_RESULT_FIELD_H
|
||||
|
||||
#include <sqlpp11/basic_expression_operators.h>
|
||||
#include <sqlpp11/exception.h>
|
||||
#include <sqlpp11/result_field.h>
|
||||
#include <sqlpp11/result_field_base.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/data_types/floating_point/data_type.h>
|
||||
#include <sqlpp11/field_spec.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename Db, typename NameType, bool CanBeNull, bool NullIsTrivialValue>
|
||||
struct result_field_t<Db, field_spec_t<NameType, floating_point, CanBeNull, NullIsTrivialValue>>
|
||||
: public result_field_base<Db, field_spec_t<NameType, floating_point, CanBeNull, NullIsTrivialValue>>
|
||||
{
|
||||
template <typename Target>
|
||||
void _bind(Target& target, size_t index)
|
||||
{
|
||||
target._bind_floating_point_result(index, &this->_value, &this->_is_null);
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
43
include/sqlpp11/data_types/floating_point/wrap_operand.h
Normal file
43
include/sqlpp11/data_types/floating_point/wrap_operand.h
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_FLOATING_POINT_WRAP_OPERAND_H
|
||||
#define SQLPP_FLOATING_POINT_WRAP_OPERAND_H
|
||||
|
||||
#include <utility>
|
||||
#include <sqlpp11/wrap_operand.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
struct floating_point_operand;
|
||||
|
||||
template <typename T>
|
||||
struct wrap_operand<T, typename std::enable_if<std::is_floating_point<T>::value>::type>
|
||||
{
|
||||
using type = floating_point_operand;
|
||||
};
|
||||
}
|
||||
#endif
|
38
include/sqlpp11/data_types/integral.h
Normal file
38
include/sqlpp11/data_types/integral.h
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_INTEGRAL_H
|
||||
#define SQLPP_INTEGRAL_H
|
||||
|
||||
#include <sqlpp11/data_types/integral/data_type.h>
|
||||
#include <sqlpp11/data_types/integral/operand.h>
|
||||
#include <sqlpp11/data_types/integral/wrap_operand.h>
|
||||
#include <sqlpp11/data_types/integral/expression_operators.h>
|
||||
#include <sqlpp11/data_types/integral/column_operators.h>
|
||||
#include <sqlpp11/data_types/integral/parameter_value.h>
|
||||
#include <sqlpp11/data_types/integral/result_field.h>
|
||||
|
||||
#endif
|
82
include/sqlpp11/data_types/integral/column_operators.h
Normal file
82
include/sqlpp11/data_types/integral/column_operators.h
Normal file
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_INTEGRAL_COLUMN_OPERATORS_H
|
||||
#define SQLPP_INTEGRAL_COLUMN_OPERATORS_H
|
||||
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/assignment.h>
|
||||
#include <sqlpp11/value_type.h>
|
||||
#include <sqlpp11/data_types/integral/data_type.h>
|
||||
#include <sqlpp11/data_types/column_operators.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename Column>
|
||||
struct column_operators<Column, integral>
|
||||
{
|
||||
template <typename T>
|
||||
using _is_valid_operand = is_valid_operand<integral, T>;
|
||||
|
||||
template <typename T>
|
||||
auto operator+=(T t) const -> assignment_t<Column, plus_t<Column, 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 Column*>(this), {{*static_cast<const Column*>(this), rhs{t}}}};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
auto operator-=(T t) const -> assignment_t<Column, minus_t<Column, 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 Column*>(this), {{*static_cast<const Column*>(this), rhs{t}}}};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
auto operator/=(T t) const -> assignment_t<Column, divides_t<Column, 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 Column*>(this), {{*static_cast<const Column*>(this), rhs{t}}}};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
auto operator*=(T t) const -> assignment_t<Column, multiplies_t<Column, 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 Column*>(this), {{*static_cast<const Column*>(this), rhs{t}}}};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
48
include/sqlpp11/data_types/integral/data_type.h
Normal file
48
include/sqlpp11/data_types/integral/data_type.h
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_INTEGRAL_DATA_TYPE_H
|
||||
#define SQLPP_INTEGRAL_DATA_TYPE_H
|
||||
|
||||
#include <sqlpp11/type_traits.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
struct integral
|
||||
{
|
||||
using _traits = make_traits<integral, tag::is_value_type>;
|
||||
using _cpp_value_type = int64_t;
|
||||
|
||||
template <typename T>
|
||||
using _is_valid_operand = is_numeric_t<T>;
|
||||
};
|
||||
|
||||
using tinyint = integral;
|
||||
using smallint = integral;
|
||||
using integer = integral;
|
||||
using bigint = integral;
|
||||
}
|
||||
#endif
|
108
include/sqlpp11/data_types/integral/expression_operators.h
Normal file
108
include/sqlpp11/data_types/integral/expression_operators.h
Normal file
@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_INTEGRAL_EXPRESSION_OPERATORS_H
|
||||
#define SQLPP_INTEGRAL_EXPRESSION_OPERATORS_H
|
||||
|
||||
#include <sqlpp11/expression_return_types.h>
|
||||
#include <sqlpp11/operand_check.h>
|
||||
#include <sqlpp11/expression_operators.h>
|
||||
#include <sqlpp11/basic_expression_operators.h>
|
||||
#include <sqlpp11/value_type.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/data_types/integral/data_type.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename Expression>
|
||||
struct expression_operators<Expression, integral> : public basic_expression_operators<Expression, integral>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename L, typename R>
|
||||
struct return_type_plus<L, R, binary_operand_check_t<L, is_integral_t, R, is_numeric_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = plus_t<wrap_operand_t<L>, value_type_of<wrap_operand_t<R>>, wrap_operand_t<R>>;
|
||||
};
|
||||
|
||||
template <typename L, typename R>
|
||||
struct return_type_minus<L, R, binary_operand_check_t<L, is_integral_t, R, is_numeric_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = minus_t<wrap_operand_t<L>, value_type_of<wrap_operand_t<R>>, wrap_operand_t<R>>;
|
||||
};
|
||||
|
||||
template <typename L, typename R>
|
||||
struct return_type_multiplies<L, R, binary_operand_check_t<L, is_integral_t, R, is_numeric_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = multiplies_t<wrap_operand_t<L>, value_type_of<wrap_operand_t<R>>, wrap_operand_t<R>>;
|
||||
};
|
||||
|
||||
template <typename L, typename R>
|
||||
struct return_type_divides<L, R, binary_operand_check_t<L, is_integral_t, R, is_numeric_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = divides_t<wrap_operand_t<L>, wrap_operand_t<R>>;
|
||||
};
|
||||
|
||||
template <typename L, typename R>
|
||||
struct return_type_modulus<L, R, binary_operand_check_t<L, is_integral_t, R, is_integral_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = modulus_t<wrap_operand_t<L>, wrap_operand_t<R>>;
|
||||
};
|
||||
|
||||
template <typename T, typename Defer>
|
||||
struct return_type_unary_plus<T, Defer, unary_operand_check_t<T, is_integral_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = unary_plus_t<integral, wrap_operand_t<T>>;
|
||||
};
|
||||
|
||||
template <typename T, typename Defer>
|
||||
struct return_type_unary_minus<T, Defer, unary_operand_check_t<T, is_integral_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = unary_minus_t<integral, wrap_operand_t<T>>;
|
||||
};
|
||||
|
||||
template <typename L, typename R>
|
||||
struct return_type_bitwise_and<L, R, binary_operand_check_t<L, is_integral_t, R, is_integral_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = bitwise_and_t<wrap_operand_t<L>, integral, wrap_operand_t<R>>;
|
||||
};
|
||||
|
||||
template <typename L, typename R>
|
||||
struct return_type_bitwise_or<L, R, binary_operand_check_t<L, is_integral_t, R, is_integral_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = bitwise_or_t<wrap_operand_t<L>, integral, wrap_operand_t<R>>;
|
||||
};
|
||||
}
|
||||
#endif
|
82
include/sqlpp11/data_types/integral/operand.h
Normal file
82
include/sqlpp11/data_types/integral/operand.h
Normal file
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_INTEGRAL_OPERAND_H
|
||||
#define SQLPP_INTEGRAL_OPERAND_H
|
||||
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/alias_operators.h>
|
||||
#include <sqlpp11/serializer.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
struct integral;
|
||||
|
||||
struct integral_operand : public alias_operators<integral_operand>
|
||||
{
|
||||
using _traits = make_traits<integral, tag::is_expression, tag::is_wrapped_value>;
|
||||
using _nodes = detail::type_vector<>;
|
||||
using _is_aggregate_expression = std::true_type;
|
||||
|
||||
using _value_t = int64_t;
|
||||
|
||||
integral_operand() : _t{}
|
||||
{
|
||||
}
|
||||
|
||||
integral_operand(_value_t t) : _t(t)
|
||||
{
|
||||
}
|
||||
|
||||
integral_operand(const integral_operand&) = default;
|
||||
integral_operand(integral_operand&&) = default;
|
||||
integral_operand& operator=(const integral_operand&) = default;
|
||||
integral_operand& operator=(integral_operand&&) = default;
|
||||
~integral_operand() = default;
|
||||
|
||||
bool _is_trivial() const
|
||||
{
|
||||
return _t == 0;
|
||||
}
|
||||
|
||||
_value_t _t;
|
||||
};
|
||||
|
||||
template <typename Context>
|
||||
struct serializer_t<Context, integral_operand>
|
||||
{
|
||||
using _serialize_check = consistent_t;
|
||||
using Operand = integral_operand;
|
||||
|
||||
static Context& _(const Operand& t, Context& context)
|
||||
{
|
||||
context << t._t;
|
||||
return context;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
51
include/sqlpp11/data_types/integral/parameter_value.h
Normal file
51
include/sqlpp11/data_types/integral/parameter_value.h
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_INTEGRAL_PARAMETER_VALUE_H
|
||||
#define SQLPP_INTEGRAL_PARAMETER_VALUE_H
|
||||
|
||||
#include <sqlpp11/data_types/parameter_value.h>
|
||||
#include <sqlpp11/data_types/parameter_value_base.h>
|
||||
#include <sqlpp11/data_types/integral/data_type.h>
|
||||
#include <sqlpp11/tvin.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <>
|
||||
struct parameter_value_t<integral> : public parameter_value_base<integral>
|
||||
{
|
||||
using base = parameter_value_base<integral>;
|
||||
using base::base;
|
||||
using base::operator=;
|
||||
|
||||
template <typename Target>
|
||||
void _bind(Target& target, size_t index) const
|
||||
{
|
||||
target._bind_integral_parameter(index, &_value, _is_null);
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
49
include/sqlpp11/data_types/integral/result_field.h
Normal file
49
include/sqlpp11/data_types/integral/result_field.h
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_INTEGRAL_RESULT_FIELD_H
|
||||
#define SQLPP_INTEGRAL_RESULT_FIELD_H
|
||||
|
||||
#include <sqlpp11/basic_expression_operators.h>
|
||||
#include <sqlpp11/result_field.h>
|
||||
#include <sqlpp11/result_field_base.h>
|
||||
#include <sqlpp11/data_types/integral/data_type.h>
|
||||
#include <sqlpp11/field_spec.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename Db, typename NameType, bool CanBeNull, bool NullIsTrivialValue>
|
||||
struct result_field_t<Db, field_spec_t<NameType, integral, CanBeNull, NullIsTrivialValue>>
|
||||
: public result_field_base<Db, field_spec_t<NameType, integral, CanBeNull, NullIsTrivialValue>>
|
||||
{
|
||||
template <typename Target>
|
||||
void _bind(Target& target, size_t index)
|
||||
{
|
||||
target._bind_integral_result(index, &this->_value, &this->_is_null);
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
43
include/sqlpp11/data_types/integral/wrap_operand.h
Normal file
43
include/sqlpp11/data_types/integral/wrap_operand.h
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_INTEGRAL_WRAP_OPERAND_H
|
||||
#define SQLPP_INTEGRAL_WRAP_OPERAND_H
|
||||
|
||||
#include <utility>
|
||||
#include <sqlpp11/wrap_operand.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
struct integral_operand;
|
||||
|
||||
template <typename T>
|
||||
struct wrap_operand<T, typename std::enable_if<std::is_integral<T>::value and not std::is_same<bool, T>::value>::type>
|
||||
{
|
||||
using type = integral_operand;
|
||||
};
|
||||
}
|
||||
#endif
|
41
include/sqlpp11/data_types/parameter_value.h
Normal file
41
include/sqlpp11/data_types/parameter_value.h
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_PARAMETER_VALUE_H
|
||||
#define SQLPP_PARAMETER_VALUE_H
|
||||
|
||||
#include <sqlpp11/wrong.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename ValueType>
|
||||
struct parameter_value_t
|
||||
{
|
||||
static_assert(wrong_t<parameter_value_t>::value, "Missing parameter value type for ValueType");
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
98
include/sqlpp11/data_types/parameter_value_base.h
Normal file
98
include/sqlpp11/data_types/parameter_value_base.h
Normal file
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_PARAMETER_VALUE_BASE_H
|
||||
#define SQLPP_PARAMETER_VALUE_BASE_H
|
||||
|
||||
#include <sqlpp11/data_types/parameter_value.h>
|
||||
#include <sqlpp11/tvin.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename DataType, typename StorageType = typename DataType::_cpp_value_type>
|
||||
struct parameter_value_base
|
||||
{
|
||||
using _value_type = DataType;
|
||||
using _cpp_value_type = typename _value_type::_cpp_value_type;
|
||||
using _cpp_storage_type = StorageType;
|
||||
|
||||
parameter_value_base() : _value{}, _is_null{true}
|
||||
{
|
||||
}
|
||||
|
||||
explicit parameter_value_base(const _cpp_value_type& val) : _value(val), _is_null(false)
|
||||
{
|
||||
}
|
||||
|
||||
parameter_value_base& operator=(const _cpp_value_type& val)
|
||||
{
|
||||
_value = val;
|
||||
_is_null = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
parameter_value_base& operator=(const tvin_t<wrap_operand_t<_cpp_value_type>>& t)
|
||||
{
|
||||
if (t._is_trivial())
|
||||
{
|
||||
_value = {};
|
||||
_is_null = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_value = t._value._t;
|
||||
_is_null = false;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void set_null()
|
||||
{
|
||||
_value = {};
|
||||
_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;
|
||||
}
|
||||
|
||||
protected:
|
||||
_cpp_storage_type _value;
|
||||
bool _is_null;
|
||||
};
|
||||
}
|
||||
#endif
|
42
include/sqlpp11/data_types/text.h
Normal file
42
include/sqlpp11/data_types/text.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_TEXT_H
|
||||
#define SQLPP_TEXT_H
|
||||
|
||||
#include <sqlpp11/data_types/text/data_type.h>
|
||||
#include <sqlpp11/data_types/text/operand.h>
|
||||
#include <sqlpp11/data_types/text/wrap_operand.h>
|
||||
#include <sqlpp11/data_types/text/expression_operators.h>
|
||||
#include <sqlpp11/data_types/text/column_operators.h>
|
||||
#include <sqlpp11/data_types/text/parameter_value.h>
|
||||
#include <sqlpp11/data_types/text/result_field.h>
|
||||
|
||||
// text specific functions
|
||||
#include <sqlpp11/data_types/text/like.h>
|
||||
#include <sqlpp11/data_types/text/concat.h>
|
||||
|
||||
#endif
|
57
include/sqlpp11/data_types/text/column_operators.h
Normal file
57
include/sqlpp11/data_types/text/column_operators.h
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_TEXT_COLUMN_OPERATORS_H
|
||||
#define SQLPP_TEXT_COLUMN_OPERATORS_H
|
||||
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/assignment.h>
|
||||
#include <sqlpp11/data_types/text/data_type.h>
|
||||
#include <sqlpp11/data_types/column_operators.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename... Args>
|
||||
struct concat_t;
|
||||
|
||||
template <typename Column>
|
||||
struct column_operators<Column, text>
|
||||
{
|
||||
template <typename T>
|
||||
using _is_valid_operand = is_valid_operand<text, T>;
|
||||
|
||||
template <typename T>
|
||||
auto operator+=(T t) const -> assignment_t<Column, concat_t<Column, 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 Column*>(this),
|
||||
concat_t<Column, wrap_operand_t<T>>{*static_cast<const Column*>(this), rhs{t}}};
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
@ -30,8 +30,10 @@
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/char_sequence.h>
|
||||
#include <sqlpp11/interpret_tuple.h>
|
||||
#include <sqlpp11/basic_expression_operators.h>
|
||||
#include <sqlpp11/expression_operators.h>
|
||||
#include <sqlpp11/alias_operators.h>
|
||||
#include <sqlpp11/logic.h>
|
||||
#include <sqlpp11/wrap_operand.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
47
include/sqlpp11/data_types/text/data_type.h
Normal file
47
include/sqlpp11/data_types/text/data_type.h
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_TEXT_DATA_TYPE_H
|
||||
#define SQLPP_TEXT_DATA_TYPE_H
|
||||
|
||||
#include <sqlpp11/type_traits.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
struct text
|
||||
{
|
||||
using _traits = make_traits<text, tag::is_value_type>;
|
||||
using _cpp_value_type = std::string;
|
||||
|
||||
template <typename T>
|
||||
using _is_valid_operand = is_text_t<T>;
|
||||
};
|
||||
|
||||
using blob = text;
|
||||
using varchar = text;
|
||||
using char_ = text;
|
||||
}
|
||||
#endif
|
80
include/sqlpp11/data_types/text/expression_operators.h
Normal file
80
include/sqlpp11/data_types/text/expression_operators.h
Normal file
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_TEXT_EXPRESSION_OPERATORS_H
|
||||
#define SQLPP_TEXT_EXPRESSION_OPERATORS_H
|
||||
|
||||
#include <sqlpp11/expression_operators.h>
|
||||
#include <sqlpp11/basic_expression_operators.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/data_types/text/data_type.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename... Args>
|
||||
struct concat_t;
|
||||
|
||||
template <typename Operand, typename Pattern>
|
||||
struct like_t;
|
||||
|
||||
template <typename T, typename Defer, typename Enable = void>
|
||||
struct return_type_like
|
||||
{
|
||||
using check = assert_valid_operands;
|
||||
using type = bad_expression<boolean>;
|
||||
};
|
||||
template <typename T, typename Defer>
|
||||
using return_type_like_t = typename return_type_like<T, Defer>::type;
|
||||
|
||||
template <typename L, typename R>
|
||||
struct return_type_like<L, R, binary_operand_check_t<L, is_text_t, R, is_text_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = like_t<wrap_operand_t<L>, wrap_operand_t<R>>;
|
||||
};
|
||||
|
||||
template <typename Expression>
|
||||
struct expression_operators<Expression, text> : public basic_expression_operators<Expression, text>
|
||||
{
|
||||
template <typename T>
|
||||
using _is_valid_operand = is_valid_operand<text, T>;
|
||||
|
||||
template <typename R>
|
||||
auto like(const R& r) const -> return_type_like_t<Expression, R>
|
||||
{
|
||||
return_type_like<Expression, R>::check::_();
|
||||
return {*static_cast<const Expression*>(this), wrap_operand_t<R>{r}};
|
||||
}
|
||||
};
|
||||
|
||||
template <typename L, typename R>
|
||||
struct return_type_plus<L, R, binary_operand_check_t<L, is_text_t, R, is_text_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = concat_t<wrap_operand_t<L>, wrap_operand_t<R>>;
|
||||
};
|
||||
}
|
||||
#endif
|
@ -27,13 +27,15 @@
|
||||
#ifndef SQLPP_LIKE_H
|
||||
#define SQLPP_LIKE_H
|
||||
|
||||
#include <sqlpp11/boolean.h>
|
||||
#include <sqlpp11/expression_operators.h>
|
||||
#include <sqlpp11/alias_operators.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/char_sequence.h>
|
||||
#include <sqlpp11/detail/type_set.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
struct boolean;
|
||||
|
||||
template <typename Operand, typename Pattern>
|
||||
struct like_t : public expression_operators<like_t<Operand, Pattern>, boolean>,
|
||||
public alias_operators<like_t<Operand, Pattern>>
|
82
include/sqlpp11/data_types/text/operand.h
Normal file
82
include/sqlpp11/data_types/text/operand.h
Normal file
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_TEXT_OPERAND_H
|
||||
#define SQLPP_TEXT_OPERAND_H
|
||||
|
||||
#include <string>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/alias_operators.h>
|
||||
#include <sqlpp11/serializer.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
struct text;
|
||||
|
||||
struct text_operand : public alias_operators<text_operand>
|
||||
{
|
||||
using _traits = make_traits<text, tag::is_expression, tag::is_wrapped_value>;
|
||||
using _nodes = detail::type_vector<>;
|
||||
using _is_aggregate_expression = std::true_type;
|
||||
|
||||
using _value_t = std::string;
|
||||
|
||||
text_operand() : _t{}
|
||||
{
|
||||
}
|
||||
|
||||
text_operand(_value_t t) : _t(t)
|
||||
{
|
||||
}
|
||||
|
||||
text_operand(const text_operand&) = default;
|
||||
text_operand(text_operand&&) = default;
|
||||
text_operand& operator=(const text_operand&) = default;
|
||||
text_operand& operator=(text_operand&&) = default;
|
||||
~text_operand() = default;
|
||||
|
||||
bool _is_trivial() const
|
||||
{
|
||||
return _t.empty();
|
||||
}
|
||||
|
||||
_value_t _t;
|
||||
};
|
||||
|
||||
template <typename Context>
|
||||
struct serializer_t<Context, text_operand>
|
||||
{
|
||||
using _serialize_check = consistent_t;
|
||||
using Operand = text_operand;
|
||||
|
||||
static Context& _(const Operand& t, Context& context)
|
||||
{
|
||||
context << '\'' << context.escape(t._t) << '\'';
|
||||
return context;
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
53
include/sqlpp11/data_types/text/parameter_value.h
Normal file
53
include/sqlpp11/data_types/text/parameter_value.h
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_TEXT_PARAMETER_VALUE_H
|
||||
#define SQLPP_TEXT_PARAMETER_VALUE_H
|
||||
|
||||
#include <sqlpp11/data_types/parameter_value.h>
|
||||
#include <sqlpp11/data_types/parameter_value_base.h>
|
||||
#include <sqlpp11/data_types/text/data_type.h>
|
||||
#include <sqlpp11/data_types/text/wrap_operand.h>
|
||||
#include <sqlpp11/data_types/text/operand.h>
|
||||
#include <sqlpp11/tvin.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <>
|
||||
struct parameter_value_t<text> : public parameter_value_base<text>
|
||||
{
|
||||
using base = parameter_value_base<text>;
|
||||
using base::base;
|
||||
using base::operator=;
|
||||
|
||||
template <typename Target>
|
||||
void _bind(Target& target, size_t index) const
|
||||
{
|
||||
target._bind_text_parameter(index, &_value, _is_null);
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
68
include/sqlpp11/data_types/text/result_field.h
Normal file
68
include/sqlpp11/data_types/text/result_field.h
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_TEXT_RESULT_FIELD_H
|
||||
#define SQLPP_TEXT_RESULT_FIELD_H
|
||||
|
||||
#include <sqlpp11/basic_expression_operators.h>
|
||||
#include <sqlpp11/result_field.h>
|
||||
#include <sqlpp11/result_field_base.h>
|
||||
#include <sqlpp11/data_types/text/data_type.h>
|
||||
#include <sqlpp11/field_spec.h>
|
||||
#include <ostream>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename Db, typename NameType, bool CanBeNull, bool NullIsTrivialValue>
|
||||
struct result_field_t<Db, field_spec_t<NameType, text, CanBeNull, NullIsTrivialValue>>
|
||||
: public result_field_base<Db, field_spec_t<NameType, text, CanBeNull, NullIsTrivialValue>>
|
||||
{
|
||||
template <typename Target>
|
||||
void _bind(Target& target, size_t index)
|
||||
{
|
||||
const char* text{nullptr};
|
||||
size_t len{};
|
||||
target._bind_text_result(index, &text, &len);
|
||||
this->_value = {text, len};
|
||||
this->_is_null = (len == 0);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Db, typename NameType, bool CanBeNull, bool NullIsTrivialValue>
|
||||
inline std::ostream& operator<<(
|
||||
std::ostream& os, const result_field_t<Db, field_spec_t<NameType, text, CanBeNull, NullIsTrivialValue>>& e)
|
||||
{
|
||||
if (e.is_null() and not NullIsTrivialValue)
|
||||
{
|
||||
return os << "NULL";
|
||||
}
|
||||
else
|
||||
{
|
||||
return os << e.value();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
46
include/sqlpp11/data_types/text/wrap_operand.h
Normal file
46
include/sqlpp11/data_types/text/wrap_operand.h
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_TEXT_WRAP_OPERAND_H
|
||||
#define SQLPP_TEXT_WRAP_OPERAND_H
|
||||
|
||||
#include <utility>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/wrap_operand.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
struct text_operand;
|
||||
|
||||
template <typename T>
|
||||
struct wrap_operand<
|
||||
T,
|
||||
typename std::enable_if<std::is_convertible<T, std::string>::value and not is_result_field_t<T>::value>::type>
|
||||
{
|
||||
using type = text_operand;
|
||||
};
|
||||
}
|
||||
#endif
|
38
include/sqlpp11/data_types/time_point.h
Normal file
38
include/sqlpp11/data_types/time_point.h
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_TIME_POINT_H
|
||||
#define SQLPP_TIME_POINT_H
|
||||
|
||||
#include <sqlpp11/data_types/time_point/data_type.h>
|
||||
#include <sqlpp11/data_types/time_point/operand.h>
|
||||
#include <sqlpp11/data_types/time_point/wrap_operand.h>
|
||||
#include <sqlpp11/data_types/time_point/expression_operators.h>
|
||||
#include <sqlpp11/data_types/time_point/column_operators.h>
|
||||
#include <sqlpp11/data_types/time_point/parameter_value.h>
|
||||
#include <sqlpp11/data_types/time_point/result_field.h>
|
||||
|
||||
#endif
|
44
include/sqlpp11/data_types/time_point/column_operators.h
Normal file
44
include/sqlpp11/data_types/time_point/column_operators.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_TIME_POINT_COLUMN_OPERATOR_H
|
||||
#define SQLPP_TIME_POINT_COLUMN_OPERATOR_H
|
||||
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/assignment.h>
|
||||
#include <sqlpp11/data_types/time_point/data_type.h>
|
||||
#include <sqlpp11/data_types/column_operators.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename Column>
|
||||
struct column_operators<Column, time_point>
|
||||
{
|
||||
template <typename T>
|
||||
using _is_valid_operand = is_valid_operand<time_point, T>;
|
||||
};
|
||||
}
|
||||
#endif
|
44
include/sqlpp11/data_types/time_point/data_type.h
Normal file
44
include/sqlpp11/data_types/time_point/data_type.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_TIME_POINT_DATA_TYPE_H
|
||||
#define SQLPP_TIME_POINT_DATA_TYPE_H
|
||||
|
||||
#include <sqlpp11/chrono.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
struct time_point
|
||||
{
|
||||
using _traits = make_traits<time_point, tag::is_value_type>;
|
||||
using _cpp_value_type = ::sqlpp::chrono::mus_point;
|
||||
|
||||
template <typename T>
|
||||
using _is_valid_operand = is_day_or_time_point_t<T>;
|
||||
};
|
||||
}
|
||||
#endif
|
43
include/sqlpp11/data_types/time_point/expression_operators.h
Normal file
43
include/sqlpp11/data_types/time_point/expression_operators.h
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_TIME_POINT_EXPRESSION_OPERATORS_H
|
||||
#define SQLPP_TIME_POINT_EXPRESSION_OPERATORS_H
|
||||
|
||||
#include <sqlpp11/expression_operators.h>
|
||||
#include <sqlpp11/basic_expression_operators.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/data_types/time_point/data_type.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
// time_point expression operators
|
||||
template <typename Expression>
|
||||
struct expression_operators<Expression, time_point> : public basic_expression_operators<Expression, time_point>
|
||||
{
|
||||
};
|
||||
}
|
||||
#endif
|
87
include/sqlpp11/data_types/time_point/operand.h
Normal file
87
include/sqlpp11/data_types/time_point/operand.h
Normal file
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_TIME_POINT_OPERAND_H
|
||||
#define SQLPP_TIME_POINT_OPERAND_H
|
||||
|
||||
#include <date.h>
|
||||
#include <sqlpp11/chrono.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/alias_operators.h>
|
||||
#include <sqlpp11/serializer.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
struct time_point;
|
||||
|
||||
template <typename Period>
|
||||
struct time_point_operand : public alias_operators<time_point_operand<Period>>
|
||||
{
|
||||
using _traits = make_traits<time_point, tag::is_expression, tag::is_wrapped_value>;
|
||||
using _nodes = detail::type_vector<>;
|
||||
using _is_aggregate_expression = std::true_type;
|
||||
|
||||
using _value_t = std::chrono::time_point<std::chrono::system_clock, Period>;
|
||||
|
||||
time_point_operand() : _t{}
|
||||
{
|
||||
}
|
||||
|
||||
time_point_operand(_value_t t) : _t(t)
|
||||
{
|
||||
}
|
||||
|
||||
time_point_operand(const time_point_operand&) = default;
|
||||
time_point_operand(time_point_operand&&) = default;
|
||||
time_point_operand& operator=(const time_point_operand&) = default;
|
||||
time_point_operand& operator=(time_point_operand&&) = default;
|
||||
~time_point_operand() = default;
|
||||
|
||||
bool _is_trivial() const
|
||||
{
|
||||
return _t == _value_t{};
|
||||
}
|
||||
|
||||
_value_t _t;
|
||||
};
|
||||
|
||||
template <typename Context, typename Period>
|
||||
struct serializer_t<Context, time_point_operand<Period>>
|
||||
{
|
||||
using _serialize_check = consistent_t;
|
||||
using Operand = time_point_operand<Period>;
|
||||
|
||||
static Context& _(const Operand& t, Context& context)
|
||||
{
|
||||
const auto dp = ::date::floor<::date::days>(t._t);
|
||||
const auto time = ::date::make_time(t._t - dp);
|
||||
const auto ymd = ::date::year_month_day{dp};
|
||||
context << "TIMESTAMP '" << ymd << ' ' << time << "'";
|
||||
return context;
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
53
include/sqlpp11/data_types/time_point/parameter_value.h
Normal file
53
include/sqlpp11/data_types/time_point/parameter_value.h
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_TIME_POINT_PARAMETER_VALUE_H
|
||||
#define SQLPP_TIME_POINT_PARAMETER_VALUE_H
|
||||
|
||||
#include <sqlpp11/data_types/parameter_value.h>
|
||||
#include <sqlpp11/data_types/parameter_value_base.h>
|
||||
#include <sqlpp11/data_types/time_point/data_type.h>
|
||||
#include <sqlpp11/data_types/time_point/wrap_operand.h>
|
||||
#include <sqlpp11/data_types/time_point/operand.h>
|
||||
#include <sqlpp11/tvin.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <>
|
||||
struct parameter_value_t<time_point> : public parameter_value_base<time_point>
|
||||
{
|
||||
using base = parameter_value_base<time_point>;
|
||||
using base::base;
|
||||
using base::operator=;
|
||||
|
||||
template <typename Target>
|
||||
void _bind(Target& target, size_t index) const
|
||||
{
|
||||
target._bind_date_time_parameter(index, &_value, _is_null);
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
68
include/sqlpp11/data_types/time_point/result_field.h
Normal file
68
include/sqlpp11/data_types/time_point/result_field.h
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_TIME_POINT_RESULT_FIELD_H
|
||||
#define SQLPP_TIME_POINT_RESULT_FIELD_H
|
||||
|
||||
#include <sqlpp11/basic_expression_operators.h>
|
||||
#include <sqlpp11/result_field.h>
|
||||
#include <sqlpp11/result_field_base.h>
|
||||
#include <sqlpp11/data_types/time_point/data_type.h>
|
||||
#include <sqlpp11/field_spec.h>
|
||||
#include <ostream>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename Db, typename NameType, bool CanBeNull, bool NullIsTrivialValue>
|
||||
struct result_field_t<Db, field_spec_t<NameType, time_point, CanBeNull, NullIsTrivialValue>>
|
||||
: public result_field_base<Db, field_spec_t<NameType, time_point, CanBeNull, NullIsTrivialValue>>
|
||||
{
|
||||
template <typename Target>
|
||||
void _bind(Target& target, size_t i)
|
||||
{
|
||||
target._bind_date_time_result(i, &this->_value, &this->_is_null);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Db, typename NameType, bool CanBeNull, bool NullIsTrivialValue>
|
||||
inline std::ostream& operator<<(
|
||||
std::ostream& os, const result_field_t<Db, field_spec_t<NameType, time_point, CanBeNull, NullIsTrivialValue>>& e)
|
||||
{
|
||||
if (e.is_null() and not NullIsTrivialValue)
|
||||
{
|
||||
os << "NULL";
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto dp = ::date::floor<::date::days>(e.value());
|
||||
const auto time = ::date::make_time(e.value() - dp);
|
||||
const auto ymd = ::date::year_month_day{dp};
|
||||
os << ymd << 'T' << time;
|
||||
}
|
||||
return os;
|
||||
}
|
||||
}
|
||||
#endif
|
41
include/sqlpp11/data_types/time_point/wrap_operand.h
Normal file
41
include/sqlpp11/data_types/time_point/wrap_operand.h
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_TIME_POINT_WRAP_OPERAND_H
|
||||
#define SQLPP_TIME_POINT_WRAP_OPERAND_H
|
||||
|
||||
#include <sqlpp11/wrap_operand.h>
|
||||
#include <sqlpp11/data_types/time_point/operand.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename Period>
|
||||
struct wrap_operand<std::chrono::time_point<std::chrono::system_clock, Period>, void>
|
||||
{
|
||||
using type = time_point_operand<Period>;
|
||||
};
|
||||
}
|
||||
#endif
|
308
include/sqlpp11/data_types/wrap_operand.h
Normal file
308
include/sqlpp11/data_types/wrap_operand.h
Normal file
@ -0,0 +1,308 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_DETAIL_WRAP_OPERAND_H
|
||||
#define SQLPP_DETAIL_WRAP_OPERAND_H
|
||||
|
||||
#include <date.h>
|
||||
#include <string>
|
||||
#include <sqlpp11/date_time_fwd.h>
|
||||
#include <sqlpp11/serializer.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/basic_expression_operators.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
struct integral;
|
||||
struct floating_point;
|
||||
struct text;
|
||||
|
||||
struct day_point_operand : public alias_operators<day_point_operand>
|
||||
{
|
||||
using _traits = make_traits<day_point, tag::is_expression, tag::is_wrapped_value>;
|
||||
using _nodes = detail::type_vector<>;
|
||||
using _is_aggregate_expression = std::true_type;
|
||||
|
||||
using _value_t = ::sqlpp::chrono::day_point;
|
||||
|
||||
day_point_operand() : _t{}
|
||||
{
|
||||
}
|
||||
|
||||
day_point_operand(_value_t t) : _t(t)
|
||||
{
|
||||
}
|
||||
|
||||
day_point_operand(const day_point_operand&) = default;
|
||||
day_point_operand(day_point_operand&&) = default;
|
||||
day_point_operand& operator=(const day_point_operand&) = default;
|
||||
day_point_operand& operator=(day_point_operand&&) = default;
|
||||
~day_point_operand() = default;
|
||||
|
||||
bool _is_trivial() const
|
||||
{
|
||||
return _t == _value_t{};
|
||||
}
|
||||
|
||||
_value_t _t;
|
||||
};
|
||||
|
||||
template <typename Context>
|
||||
struct serializer_t<Context, day_point_operand>
|
||||
{
|
||||
using _serialize_check = consistent_t;
|
||||
using Operand = day_point_operand;
|
||||
|
||||
static Context& _(const Operand& t, Context& context)
|
||||
{
|
||||
const auto ymd = ::date::year_month_day{t._t};
|
||||
context << "DATE '" << ymd << "'";
|
||||
return context;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Period>
|
||||
struct time_point_operand : public alias_operators<time_point_operand<Period>>
|
||||
{
|
||||
using _traits = make_traits<time_point, tag::is_expression, tag::is_wrapped_value>;
|
||||
using _nodes = detail::type_vector<>;
|
||||
using _is_aggregate_expression = std::true_type;
|
||||
|
||||
using _value_t = std::chrono::time_point<std::chrono::system_clock, Period>;
|
||||
|
||||
time_point_operand() : _t{}
|
||||
{
|
||||
}
|
||||
|
||||
time_point_operand(_value_t t) : _t(t)
|
||||
{
|
||||
}
|
||||
|
||||
time_point_operand(const time_point_operand&) = default;
|
||||
time_point_operand(time_point_operand&&) = default;
|
||||
time_point_operand& operator=(const time_point_operand&) = default;
|
||||
time_point_operand& operator=(time_point_operand&&) = default;
|
||||
~time_point_operand() = default;
|
||||
|
||||
bool _is_trivial() const
|
||||
{
|
||||
return _t == _value_t{};
|
||||
}
|
||||
|
||||
_value_t _t;
|
||||
};
|
||||
|
||||
template <typename Context, typename Period>
|
||||
struct serializer_t<Context, time_point_operand<Period>>
|
||||
{
|
||||
using _serialize_check = consistent_t;
|
||||
using Operand = time_point_operand<Period>;
|
||||
|
||||
static Context& _(const Operand& t, Context& context)
|
||||
{
|
||||
const auto dp = ::date::floor<::date::days>(t._t);
|
||||
const auto time = ::date::make_time(t._t - dp);
|
||||
const auto ymd = ::date::year_month_day{dp};
|
||||
context << "TIMESTAMP '" << ymd << ' ' << time << "'";
|
||||
return context;
|
||||
}
|
||||
};
|
||||
|
||||
struct integral_operand : public alias_operators<integral_operand>
|
||||
{
|
||||
using _traits = make_traits<integral, tag::is_expression, tag::is_wrapped_value>;
|
||||
using _nodes = detail::type_vector<>;
|
||||
using _is_aggregate_expression = std::true_type;
|
||||
|
||||
using _value_t = int64_t;
|
||||
|
||||
integral_operand() : _t{}
|
||||
{
|
||||
}
|
||||
|
||||
integral_operand(_value_t t) : _t(t)
|
||||
{
|
||||
}
|
||||
|
||||
integral_operand(const integral_operand&) = default;
|
||||
integral_operand(integral_operand&&) = default;
|
||||
integral_operand& operator=(const integral_operand&) = default;
|
||||
integral_operand& operator=(integral_operand&&) = default;
|
||||
~integral_operand() = default;
|
||||
|
||||
bool _is_trivial() const
|
||||
{
|
||||
return _t == 0;
|
||||
}
|
||||
|
||||
_value_t _t;
|
||||
};
|
||||
|
||||
template <typename Context>
|
||||
struct serializer_t<Context, integral_operand>
|
||||
{
|
||||
using _serialize_check = consistent_t;
|
||||
using Operand = integral_operand;
|
||||
|
||||
static Context& _(const Operand& t, Context& context)
|
||||
{
|
||||
context << t._t;
|
||||
return context;
|
||||
}
|
||||
};
|
||||
|
||||
struct floating_point_operand : public alias_operators<floating_point_operand>
|
||||
{
|
||||
using _traits = make_traits<floating_point, tag::is_expression, tag::is_wrapped_value>;
|
||||
using _nodes = detail::type_vector<>;
|
||||
using _is_aggregate_expression = std::true_type;
|
||||
|
||||
using _value_t = double;
|
||||
|
||||
floating_point_operand() : _t{}
|
||||
{
|
||||
}
|
||||
|
||||
floating_point_operand(_value_t t) : _t(t)
|
||||
{
|
||||
}
|
||||
|
||||
floating_point_operand(const floating_point_operand&) = default;
|
||||
floating_point_operand(floating_point_operand&&) = default;
|
||||
floating_point_operand& operator=(const floating_point_operand&) = default;
|
||||
floating_point_operand& operator=(floating_point_operand&&) = default;
|
||||
~floating_point_operand() = default;
|
||||
|
||||
bool _is_trivial() const
|
||||
{
|
||||
return _t == 0;
|
||||
}
|
||||
|
||||
_value_t _t;
|
||||
};
|
||||
|
||||
template <typename Context>
|
||||
struct serializer_t<Context, floating_point_operand>
|
||||
{
|
||||
using _serialize_check = consistent_t;
|
||||
using Operand = floating_point_operand;
|
||||
|
||||
static Context& _(const Operand& t, Context& context)
|
||||
{
|
||||
context << t._t;
|
||||
return context;
|
||||
}
|
||||
};
|
||||
|
||||
struct text_operand : public alias_operators<text_operand>
|
||||
{
|
||||
using _traits = make_traits<text, tag::is_expression, tag::is_wrapped_value>;
|
||||
using _nodes = detail::type_vector<>;
|
||||
using _is_aggregate_expression = std::true_type;
|
||||
|
||||
using _value_t = std::string;
|
||||
|
||||
text_operand() : _t{}
|
||||
{
|
||||
}
|
||||
|
||||
text_operand(_value_t t) : _t(t)
|
||||
{
|
||||
}
|
||||
|
||||
text_operand(const text_operand&) = default;
|
||||
text_operand(text_operand&&) = default;
|
||||
text_operand& operator=(const text_operand&) = default;
|
||||
text_operand& operator=(text_operand&&) = default;
|
||||
~text_operand() = default;
|
||||
|
||||
bool _is_trivial() const
|
||||
{
|
||||
return _t.empty();
|
||||
}
|
||||
|
||||
_value_t _t;
|
||||
};
|
||||
|
||||
template <typename Context>
|
||||
struct serializer_t<Context, text_operand>
|
||||
{
|
||||
using _serialize_check = consistent_t;
|
||||
using Operand = text_operand;
|
||||
|
||||
static Context& _(const Operand& t, Context& context)
|
||||
{
|
||||
context << '\'' << context.escape(t._t) << '\'';
|
||||
return context;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename Enable = void>
|
||||
struct wrap_operand
|
||||
{
|
||||
using type = T;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct wrap_operand<bool, void>
|
||||
{
|
||||
using type = boolean_operand;
|
||||
};
|
||||
|
||||
template <typename Period>
|
||||
struct wrap_operand<std::chrono::time_point<std::chrono::system_clock, Period>, void>
|
||||
{
|
||||
using type = time_point_operand<Period>;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct wrap_operand<std::chrono::time_point<std::chrono::system_clock, sqlpp::chrono::days>, void>
|
||||
{
|
||||
using type = day_point_operand;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct wrap_operand<T, typename std::enable_if<std::is_integral<T>::value>::type>
|
||||
{
|
||||
using type = integral_operand;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct wrap_operand<T, typename std::enable_if<std::is_floating_point<T>::value>::type>
|
||||
{
|
||||
using type = floating_point_operand;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct wrap_operand<
|
||||
T,
|
||||
typename std::enable_if<std::is_convertible<T, std::string>::value and not is_result_field_t<T>::value>::type>
|
||||
{
|
||||
using type = text_operand;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -1,236 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_DAY_POINT_H
|
||||
#define SQLPP_DAY_POINT_H
|
||||
|
||||
#include <date.h>
|
||||
#include <sqlpp11/time_point.h>
|
||||
#include <sqlpp11/basic_expression_operators.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/exception.h>
|
||||
#include <sqlpp11/value_type.h>
|
||||
#include <sqlpp11/assignment.h>
|
||||
#include <sqlpp11/result_field.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
// day_point value type
|
||||
struct day_point
|
||||
{
|
||||
using _traits = make_traits<day_point, tag::is_value_type>;
|
||||
using _tag = tag::is_date;
|
||||
using _cpp_value_type = ::sqlpp::chrono::day_point;
|
||||
|
||||
template <typename T>
|
||||
using _is_valid_operand = is_time_point_t<T>;
|
||||
template <typename T>
|
||||
using _is_valid_assignment_operand = is_date_t<T>;
|
||||
};
|
||||
|
||||
// day_point parameter value
|
||||
template <>
|
||||
struct parameter_value_t<day_point>
|
||||
{
|
||||
using _value_type = day_point;
|
||||
using _cpp_value_type = typename _value_type::_cpp_value_type;
|
||||
|
||||
parameter_value_t() : _value{}, _is_null(true)
|
||||
{
|
||||
}
|
||||
|
||||
explicit parameter_value_t(const _cpp_value_type& val) : _value(val), _is_null(false)
|
||||
{
|
||||
}
|
||||
|
||||
parameter_value_t& operator=(const _cpp_value_type& val)
|
||||
{
|
||||
_value = val;
|
||||
_is_null = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
parameter_value_t& operator=(const tvin_t<wrap_operand_t<_cpp_value_type>>& t)
|
||||
{
|
||||
if (t._is_trivial())
|
||||
{
|
||||
_value = _cpp_value_type{};
|
||||
_is_null = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_value = t._value._t;
|
||||
_is_null = false;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void set_null()
|
||||
{
|
||||
_value = _cpp_value_type{};
|
||||
_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_date_parameter(index, &_value, _is_null);
|
||||
}
|
||||
|
||||
private:
|
||||
_cpp_value_type _value;
|
||||
bool _is_null;
|
||||
};
|
||||
|
||||
// day_point expression operators
|
||||
template <typename Base>
|
||||
struct expression_operators<Base, day_point> : public basic_expression_operators<Base, day_point>
|
||||
{
|
||||
template <typename T>
|
||||
using _is_valid_operand = is_valid_operand<day_point, T>;
|
||||
};
|
||||
|
||||
// day_point column operators
|
||||
template <typename Base>
|
||||
struct column_operators<Base, day_point>
|
||||
{
|
||||
template <typename T>
|
||||
using _is_valid_operand = is_valid_operand<day_point, T>;
|
||||
};
|
||||
|
||||
// day_point result field
|
||||
template <typename Db, typename FieldSpec>
|
||||
struct result_field_t<day_point, Db, FieldSpec>
|
||||
: public result_field_methods_t<result_field_t<day_point, Db, FieldSpec>>
|
||||
{
|
||||
static_assert(std::is_same<value_type_of<FieldSpec>, day_point>::value, "field type mismatch");
|
||||
using _cpp_value_type = typename sqlpp::day_point::_cpp_value_type;
|
||||
|
||||
result_field_t() : _is_valid(false), _is_null(true), _value{}
|
||||
{
|
||||
}
|
||||
|
||||
void _invalidate()
|
||||
{
|
||||
_is_valid = false;
|
||||
_is_null = true;
|
||||
_value = _cpp_value_type{};
|
||||
}
|
||||
|
||||
void _validate()
|
||||
{
|
||||
_is_valid = true;
|
||||
}
|
||||
|
||||
bool is_null() const
|
||||
{
|
||||
if (not _is_valid)
|
||||
throw exception("accessing is_null in non-existing row");
|
||||
return _is_null;
|
||||
}
|
||||
|
||||
bool _is_trivial() const
|
||||
{
|
||||
if (not _is_valid)
|
||||
throw exception("accessing is_null in non-existing row");
|
||||
|
||||
return value() == _cpp_value_type{};
|
||||
}
|
||||
|
||||
_cpp_value_type value() const
|
||||
{
|
||||
if (not _is_valid)
|
||||
throw exception("accessing value in non-existing row");
|
||||
|
||||
if (_is_null)
|
||||
{
|
||||
if (enforce_null_result_treatment_t<Db>::value and not null_is_trivial_value_t<FieldSpec>::value)
|
||||
{
|
||||
throw exception("accessing value of NULL field");
|
||||
}
|
||||
else
|
||||
{
|
||||
return _cpp_value_type{};
|
||||
}
|
||||
}
|
||||
return _value;
|
||||
}
|
||||
|
||||
template <typename Target>
|
||||
void _bind(Target& target, size_t i)
|
||||
{
|
||||
target._bind_date_result(i, &_value, &_is_null);
|
||||
}
|
||||
|
||||
private:
|
||||
bool _is_valid;
|
||||
bool _is_null;
|
||||
_cpp_value_type _value;
|
||||
};
|
||||
|
||||
template <typename Context, typename Db, typename FieldSpec>
|
||||
struct serializer_t<Context, result_field_t<day_point, Db, FieldSpec>>
|
||||
{
|
||||
using _serialize_check = consistent_t;
|
||||
using T = result_field_t<day_point, Db, FieldSpec>;
|
||||
|
||||
static Context& _(const T& t, Context& context)
|
||||
{
|
||||
if (t.is_null() and not null_is_trivial_value_t<FieldSpec>::value)
|
||||
{
|
||||
context << "NULL";
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto ymd = ::date::year_month_day{t.value()};
|
||||
context << ymd;
|
||||
}
|
||||
return context;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Db, typename FieldSpec>
|
||||
inline std::ostream& operator<<(std::ostream& os, const result_field_t<day_point, Db, FieldSpec>& e)
|
||||
{
|
||||
return serialize(e, os);
|
||||
}
|
||||
}
|
||||
#endif
|
41
include/sqlpp11/detail/enable_if.h
Normal file
41
include/sqlpp11/detail/enable_if.h
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_DETAIL_ENABLE_IF_H
|
||||
#define SQLPP_DETAIL_ENABLE_IF_H
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
template <bool B, typename T = void>
|
||||
using enable_if_t = typename std::enable_if<B, T>::type;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
45
include/sqlpp11/detail/void.h
Normal file
45
include/sqlpp11/detail/void.h
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_DETAIL_VOID_H
|
||||
#define SQLPP_DETAIL_VOID_H
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
template <typename T>
|
||||
struct void_impl
|
||||
{
|
||||
using type = void;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
using void_t = typename void_impl<T>::type;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -45,7 +45,7 @@ namespace sqlpp
|
||||
using _name_type = alias::a_t::_alias_t;
|
||||
using _value_type = value_type_of<Expr>;
|
||||
using _field_spec = field_spec_t<_name_type, _value_type, true, false>;
|
||||
using type = result_field_t<_value_type, Db, _field_spec>;
|
||||
using type = result_field_t<Db, _field_spec>;
|
||||
};
|
||||
|
||||
template <typename Db,
|
||||
|
@ -28,7 +28,7 @@
|
||||
#define SQLPP_EXISTS_H
|
||||
|
||||
#include <sqlpp11/char_sequence.h>
|
||||
#include <sqlpp11/boolean.h>
|
||||
#include <sqlpp11/data_types/boolean.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
|
@ -28,7 +28,7 @@
|
||||
#define SQLPP_EXPRESSION_H
|
||||
|
||||
#include <sqlpp11/alias.h>
|
||||
#include <sqlpp11/boolean.h>
|
||||
#include <sqlpp11/data_types/boolean.h>
|
||||
#include <sqlpp11/tvin.h>
|
||||
#include <sqlpp11/rhs_wrap.h>
|
||||
#include <sqlpp11/noop.h>
|
||||
|
41
include/sqlpp11/expression_operators.h
Normal file
41
include/sqlpp11/expression_operators.h
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_EXPRESSION_OPERATORS_H
|
||||
#define SQLPP_EXPRESSION_OPERATORS_H
|
||||
|
||||
#include <sqlpp11/wrong.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename Expr, typename ValueType>
|
||||
struct expression_operators
|
||||
{
|
||||
static_assert(wrong_t<expression_operators>::value, "Missing expression operators for ValueType");
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
143
include/sqlpp11/expression_return_types.h
Normal file
143
include/sqlpp11/expression_return_types.h
Normal file
@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_EXPRESSION_RETURN_TYPES_H
|
||||
#define SQLPP_EXPRESSION_RETURN_TYPES_H
|
||||
|
||||
#include <sqlpp11/bad_expression.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename L, typename R, typename Enable = void>
|
||||
struct return_type_and
|
||||
{
|
||||
using check = assert_valid_operands;
|
||||
using type = bad_expression<boolean>;
|
||||
};
|
||||
template <typename L, typename R>
|
||||
using return_type_and_t = typename return_type_and<L, R>::type;
|
||||
|
||||
template <typename L, typename R, typename Enable = void>
|
||||
struct return_type_bitwise_and
|
||||
{
|
||||
using check = assert_valid_operands;
|
||||
using type = bad_expression<boolean>;
|
||||
};
|
||||
template <typename L, typename R>
|
||||
using return_type_bitwise_and_t = typename return_type_bitwise_and<L, R>::type;
|
||||
|
||||
template <typename L, typename R, typename Enable = void>
|
||||
struct return_type_or
|
||||
{
|
||||
using check = assert_valid_operands;
|
||||
using type = bad_expression<boolean>;
|
||||
};
|
||||
template <typename L, typename R>
|
||||
using return_type_or_t = typename return_type_or<L, R>::type;
|
||||
|
||||
template <typename L, typename R, typename Enable = void>
|
||||
struct return_type_bitwise_or
|
||||
{
|
||||
using check = assert_valid_operands;
|
||||
using type = bad_expression<boolean>;
|
||||
};
|
||||
template <typename L, typename R>
|
||||
using return_type_bitwise_or_t = typename return_type_bitwise_or<L, R>::type;
|
||||
|
||||
template <typename T, typename Defer, typename Enable = void>
|
||||
struct return_type_not
|
||||
{
|
||||
using check = assert_valid_operands;
|
||||
using type = bad_expression<boolean>;
|
||||
};
|
||||
template <typename T, typename Defer>
|
||||
using return_type_not_t = typename return_type_not<T, Defer>::type;
|
||||
|
||||
template <typename L, typename R, typename Enable = void>
|
||||
struct return_type_plus
|
||||
{
|
||||
using check = assert_valid_operands;
|
||||
using type = bad_expression<boolean>;
|
||||
};
|
||||
template <typename L, typename R>
|
||||
using return_type_plus_t = typename return_type_plus<L, R>::type;
|
||||
|
||||
template <typename L, typename R, typename Enable = void>
|
||||
struct return_type_minus
|
||||
{
|
||||
using check = assert_valid_operands;
|
||||
using type = bad_expression<boolean>;
|
||||
};
|
||||
template <typename L, typename R>
|
||||
using return_type_minus_t = typename return_type_minus<L, R>::type;
|
||||
|
||||
template <typename L, typename R, typename Enable = void>
|
||||
struct return_type_multiplies
|
||||
{
|
||||
using check = assert_valid_operands;
|
||||
using type = bad_expression<boolean>;
|
||||
};
|
||||
template <typename L, typename R>
|
||||
using return_type_multiplies_t = typename return_type_multiplies<L, R>::type;
|
||||
|
||||
template <typename L, typename R, typename Enable = void>
|
||||
struct return_type_divides
|
||||
{
|
||||
using check = assert_valid_operands;
|
||||
using type = bad_expression<boolean>;
|
||||
};
|
||||
template <typename L, typename R>
|
||||
using return_type_divides_t = typename return_type_divides<L, R>::type;
|
||||
|
||||
template <typename L, typename R, typename Enable = void>
|
||||
struct return_type_modulus
|
||||
{
|
||||
using check = assert_valid_operands;
|
||||
using type = bad_expression<boolean>;
|
||||
};
|
||||
template <typename L, typename R>
|
||||
using return_type_modulus_t = typename return_type_modulus<L, R>::type;
|
||||
|
||||
template <typename T, typename Defer, typename Enable = void>
|
||||
struct return_type_unary_plus
|
||||
{
|
||||
using check = assert_valid_operands;
|
||||
using type = bad_expression<boolean>;
|
||||
};
|
||||
template <typename T, typename Defer>
|
||||
using return_type_unary_plus_t = typename return_type_unary_plus<T, Defer>::type;
|
||||
|
||||
template <typename T, typename Defer, typename Enable = void>
|
||||
struct return_type_unary_minus
|
||||
{
|
||||
using check = assert_valid_operands;
|
||||
using type = bad_expression<boolean>;
|
||||
};
|
||||
template <typename T, typename Defer>
|
||||
using return_type_unary_minus_t = typename return_type_unary_minus<T, Defer>::type;
|
||||
}
|
||||
|
||||
#endif
|
@ -1,290 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_FLOATING_POINT_H
|
||||
#define SQLPP_FLOATING_POINT_H
|
||||
|
||||
#include <cstdlib>
|
||||
#include <sqlpp11/basic_expression_operators.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/exception.h>
|
||||
#include <sqlpp11/result_field.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
// floating_point value type
|
||||
struct floating_point
|
||||
{
|
||||
using _traits = make_traits<floating_point, tag::is_value_type>;
|
||||
using _tag = tag::is_floating_point;
|
||||
using _cpp_value_type = double;
|
||||
|
||||
template <typename T>
|
||||
using _is_valid_operand = is_numeric_t<T>;
|
||||
};
|
||||
|
||||
// floating_point parameter type
|
||||
template <>
|
||||
struct parameter_value_t<floating_point>
|
||||
{
|
||||
using _value_type = floating_point;
|
||||
using _cpp_value_type = typename _value_type::_cpp_value_type;
|
||||
|
||||
parameter_value_t() : _value(0), _is_null(true)
|
||||
{
|
||||
}
|
||||
|
||||
parameter_value_t(const _cpp_value_type& val) : _value(val), _is_null(false)
|
||||
{
|
||||
}
|
||||
|
||||
parameter_value_t& operator=(const _cpp_value_type& val)
|
||||
{
|
||||
_value = val;
|
||||
_is_null = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
parameter_value_t& operator=(const tvin_t<wrap_operand_t<_cpp_value_type>>& t)
|
||||
{
|
||||
if (t._is_trivial())
|
||||
{
|
||||
_value = 0;
|
||||
_is_null = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_value = t._value._t;
|
||||
_is_null = false;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
parameter_value_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;
|
||||
};
|
||||
|
||||
// floating_point expression operators
|
||||
template <typename Expr>
|
||||
struct expression_operators<Expr, floating_point> : public basic_expression_operators<Expr, floating_point>
|
||||
{
|
||||
template <typename T>
|
||||
using _is_valid_operand = is_valid_operand<floating_point, T>;
|
||||
|
||||
template <typename T>
|
||||
plus_t<Expr, 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 Expr*>(this), rhs{t}};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
minus_t<Expr, 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 Expr*>(this), rhs{t}};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
multiplies_t<Expr, floating_point, wrap_operand_t<T>> operator*(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
|
||||
return {*static_cast<const Expr*>(this), rhs{t}};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
divides_t<Expr, wrap_operand_t<T>> operator/(T t) const
|
||||
{
|
||||
using rhs = wrap_operand_t<T>;
|
||||
|
||||
return {*static_cast<const Expr*>(this), rhs{t}};
|
||||
}
|
||||
|
||||
unary_plus_t<floating_point, Expr> operator+() const
|
||||
{
|
||||
return {*static_cast<const Expr*>(this)};
|
||||
}
|
||||
|
||||
unary_minus_t<floating_point, Expr> operator-() const
|
||||
{
|
||||
return {*static_cast<const Expr*>(this)};
|
||||
}
|
||||
};
|
||||
|
||||
// floating_point column operators
|
||||
template <typename Column>
|
||||
struct column_operators<Column, floating_point>
|
||||
{
|
||||
template <typename T>
|
||||
using _is_valid_operand = is_valid_operand<floating_point, T>;
|
||||
|
||||
template <typename T>
|
||||
auto operator+=(T t) const -> assignment_t<Column, plus_t<Column, 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 Column*>(this), {*static_cast<const Column*>(this), rhs{t}}};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
auto operator-=(T t) const -> assignment_t<Column, minus_t<Column, 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 Column*>(this), {*static_cast<const Column*>(this), rhs{t}}};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
auto operator/=(T t) const -> assignment_t<Column, divides_t<Column, 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 Column*>(this), {*static_cast<const Column*>(this), rhs{t}}};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
auto operator*=(T t) const -> assignment_t<Column, multiplies_t<Column, 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 Column*>(this), {*static_cast<const Column*>(this), rhs{t}}};
|
||||
}
|
||||
};
|
||||
// floating_point result field
|
||||
template <typename Db, typename FieldSpec>
|
||||
struct result_field_t<floating_point, Db, FieldSpec>
|
||||
: public result_field_methods_t<result_field_t<floating_point, Db, FieldSpec>>
|
||||
{
|
||||
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;
|
||||
|
||||
result_field_t() : _is_valid(false), _is_null(true), _value(0)
|
||||
{
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
bool _is_trivial() const
|
||||
{
|
||||
if (not _is_valid)
|
||||
throw exception("accessing is_null in non-existing row");
|
||||
|
||||
return value() == 0;
|
||||
}
|
||||
|
||||
_cpp_value_type value() const
|
||||
{
|
||||
if (not _is_valid)
|
||||
throw exception("accessing value in non-existing row");
|
||||
|
||||
if (_is_null)
|
||||
{
|
||||
if (enforce_null_result_treatment_t<Db>::value and not null_is_trivial_value_t<FieldSpec>::value)
|
||||
{
|
||||
throw exception("accessing value of NULL field");
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return _value;
|
||||
}
|
||||
|
||||
template <typename Target>
|
||||
void _bind(Target& target, size_t i)
|
||||
{
|
||||
target._bind_floating_point_result(i, &_value, &_is_null);
|
||||
}
|
||||
|
||||
private:
|
||||
bool _is_valid;
|
||||
bool _is_null;
|
||||
_cpp_value_type _value;
|
||||
};
|
||||
|
||||
template <typename Db, typename FieldSpec>
|
||||
inline std::ostream& operator<<(std::ostream& os, const result_field_t<floating_point, Db, FieldSpec>& e)
|
||||
{
|
||||
return serialize(e, os);
|
||||
}
|
||||
}
|
||||
#endif
|
@ -29,20 +29,15 @@
|
||||
|
||||
#include <sqlpp11/parameter.h>
|
||||
#include <sqlpp11/parameter_list.h>
|
||||
#include <sqlpp11/column_types.h>
|
||||
#include <sqlpp11/data_types.h>
|
||||
#include <sqlpp11/aggregate_functions.h>
|
||||
#include <sqlpp11/in.h>
|
||||
#include <sqlpp11/not_in.h>
|
||||
#include <sqlpp11/is_null.h>
|
||||
#include <sqlpp11/is_not_null.h>
|
||||
#include <sqlpp11/exists.h>
|
||||
#include <sqlpp11/any.h>
|
||||
#include <sqlpp11/concat.h>
|
||||
#include <sqlpp11/some.h>
|
||||
#include <sqlpp11/count.h>
|
||||
#include <sqlpp11/min.h>
|
||||
#include <sqlpp11/max.h>
|
||||
#include <sqlpp11/avg.h>
|
||||
#include <sqlpp11/sum.h>
|
||||
#include <sqlpp11/value_type.h>
|
||||
#include <sqlpp11/verbatim.h> // Csaba Csoma suggests: unsafe_sql instead of verbatim
|
||||
#include <sqlpp11/verbatim_table.h>
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/char_sequence.h>
|
||||
#include <sqlpp11/boolean.h>
|
||||
#include <sqlpp11/data_types/boolean.h>
|
||||
#include <sqlpp11/in_fwd.h>
|
||||
#include <sqlpp11/detail/type_set.h>
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <sqlpp11/portable_static_assert.h>
|
||||
#include <sqlpp11/logic.h>
|
||||
#include <sqlpp11/column_fwd.h>
|
||||
#include <sqlpp11/expression_fwd.h>
|
||||
#include <sqlpp11/assignment.h>
|
||||
#include <sqlpp11/interpretable_list.h>
|
||||
#include <sqlpp11/interpret_tuple.h>
|
||||
|
@ -1,327 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_INTEGRAL_H
|
||||
#define SQLPP_INTEGRAL_H
|
||||
|
||||
#include <cstdlib>
|
||||
#include <sqlpp11/basic_expression_operators.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/exception.h>
|
||||
#include <sqlpp11/value_type.h>
|
||||
#include <sqlpp11/assignment.h>
|
||||
#include <sqlpp11/result_field.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
// integral value type
|
||||
struct integral
|
||||
{
|
||||
using _traits = make_traits<integral, tag::is_value_type>;
|
||||
using _tag = tag::is_integral;
|
||||
using _cpp_value_type = int64_t;
|
||||
|
||||
template <typename T>
|
||||
using _is_valid_operand = is_numeric_t<T>;
|
||||
};
|
||||
|
||||
// integral parameter value
|
||||
template <>
|
||||
struct parameter_value_t<integral>
|
||||
{
|
||||
using _value_type = integral;
|
||||
using _cpp_value_type = typename _value_type::_cpp_value_type;
|
||||
|
||||
parameter_value_t() : _value(0), _is_null(true)
|
||||
{
|
||||
}
|
||||
|
||||
explicit parameter_value_t(const _cpp_value_type& val) : _value(val), _is_null(false)
|
||||
{
|
||||
}
|
||||
|
||||
parameter_value_t& operator=(const _cpp_value_type& val)
|
||||
{
|
||||
_value = val;
|
||||
_is_null = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
parameter_value_t& operator=(const tvin_t<wrap_operand_t<_cpp_value_type>>& t)
|
||||
{
|
||||
if (t._is_trivial())
|
||||
{
|
||||
_value = 0;
|
||||
_is_null = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_value = t._value._t;
|
||||
_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;
|
||||
};
|
||||
|
||||
// integral expression operators
|
||||
template <typename Base>
|
||||
struct expression_operators<Base, integral> : public basic_expression_operators<Base, integral>
|
||||
{
|
||||
template <typename T>
|
||||
using _is_valid_operand = is_valid_operand<integral, 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 T>
|
||||
bitwise_and_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>
|
||||
bitwise_or_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}};
|
||||
}
|
||||
};
|
||||
|
||||
// integral column operators
|
||||
template <typename Base>
|
||||
struct column_operators<Base, integral>
|
||||
{
|
||||
template <typename T>
|
||||
using _is_valid_operand = is_valid_operand<integral, T>;
|
||||
|
||||
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}}}};
|
||||
}
|
||||
};
|
||||
|
||||
// integral result field
|
||||
template <typename Db, typename 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>, integral>::value, "field type mismatch");
|
||||
using _cpp_value_type = typename integral::_cpp_value_type;
|
||||
|
||||
result_field_t() : _is_valid(false), _is_null(true), _value(0)
|
||||
{
|
||||
}
|
||||
|
||||
void _invalidate()
|
||||
{
|
||||
_is_valid = false;
|
||||
_is_null = true;
|
||||
_value = 0;
|
||||
}
|
||||
|
||||
void _validate()
|
||||
{
|
||||
_is_valid = true;
|
||||
}
|
||||
|
||||
bool is_null() const
|
||||
{
|
||||
if (not _is_valid)
|
||||
throw exception("accessing is_null in non-existing row");
|
||||
return _is_null;
|
||||
}
|
||||
|
||||
bool _is_trivial() const
|
||||
{
|
||||
if (not _is_valid)
|
||||
throw exception("accessing is_null in non-existing row");
|
||||
|
||||
return value() == 0;
|
||||
}
|
||||
|
||||
_cpp_value_type value() const
|
||||
{
|
||||
if (not _is_valid)
|
||||
throw exception("accessing value in non-existing row");
|
||||
|
||||
if (_is_null)
|
||||
{
|
||||
if (enforce_null_result_treatment_t<Db>::value and not null_is_trivial_value_t<FieldSpec>::value)
|
||||
{
|
||||
throw exception("accessing value of NULL field");
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return _value;
|
||||
}
|
||||
|
||||
template <typename Target>
|
||||
void _bind(Target& target, size_t i)
|
||||
{
|
||||
target._bind_integral_result(i, &_value, &_is_null);
|
||||
}
|
||||
|
||||
private:
|
||||
bool _is_valid;
|
||||
bool _is_null;
|
||||
_cpp_value_type _value;
|
||||
};
|
||||
|
||||
// ostream operator for integral result field
|
||||
template <typename Db, typename FieldSpec>
|
||||
inline std::ostream& operator<<(std::ostream& os, const result_field_t<integral, Db, FieldSpec>& e)
|
||||
{
|
||||
return serialize(e, os);
|
||||
}
|
||||
|
||||
using tinyint = integral;
|
||||
using smallint = integral;
|
||||
using integer = integral;
|
||||
using bigint = integral;
|
||||
}
|
||||
#endif
|
@ -27,7 +27,7 @@
|
||||
#ifndef SQLPP_IS_NOT_NULL_H
|
||||
#define SQLPP_IS_NOT_NULL_H
|
||||
|
||||
#include <sqlpp11/boolean.h>
|
||||
#include <sqlpp11/data_types/boolean.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/char_sequence.h>
|
||||
#include <sqlpp11/detail/type_set.h>
|
||||
|
@ -27,7 +27,7 @@
|
||||
#ifndef SQLPP_IS_NULL_H
|
||||
#define SQLPP_IS_NULL_H
|
||||
|
||||
#include <sqlpp11/boolean.h>
|
||||
#include <sqlpp11/data_types/boolean.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/char_sequence.h>
|
||||
#include <sqlpp11/detail/type_set.h>
|
||||
|
36
include/sqlpp11/no_name.h
Normal file
36
include/sqlpp11/no_name.h
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_NO_NAME_H
|
||||
#define SQLPP_NO_NAME_H
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
struct no_name_t
|
||||
{
|
||||
};
|
||||
}
|
||||
#endif
|
@ -28,13 +28,14 @@
|
||||
#define SQLPP_NO_VALUE_H
|
||||
|
||||
#include <type_traits>
|
||||
#include <sqlpp11/value_type_fwd.h>
|
||||
#include <sqlpp11/expression_operators.h>
|
||||
#include <sqlpp11/data_types/column_operators.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
struct no_value_t
|
||||
{
|
||||
using _tag = void;
|
||||
using _traits = make_traits<void>;
|
||||
};
|
||||
|
||||
template <typename Base>
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/char_sequence.h>
|
||||
#include <sqlpp11/boolean.h>
|
||||
#include <sqlpp11/data_types/boolean.h>
|
||||
#include <sqlpp11/in_fwd.h>
|
||||
#include <sqlpp11/detail/type_set.h>
|
||||
|
||||
|
72
include/sqlpp11/operand_check.h
Normal file
72
include/sqlpp11/operand_check.h
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_OPERAND_CHECK_H
|
||||
#define SQLPP_OPERAND_CHECK_H
|
||||
|
||||
#include <sqlpp11/wrap_operand.h>
|
||||
#include <sqlpp11/detail/enable_if.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename T, template <typename> class Pred, typename Enable = void>
|
||||
struct unary_operand_check
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T, template <typename> class Pred>
|
||||
struct unary_operand_check<T, Pred, detail::enable_if_t<Pred<wrap_operand_t<T>>::value>>
|
||||
{
|
||||
using type = void;
|
||||
};
|
||||
|
||||
template <typename T, template <typename> class Pred>
|
||||
using unary_operand_check_t = typename unary_operand_check<T, Pred>::type;
|
||||
|
||||
template <typename L,
|
||||
template <typename> class LPred,
|
||||
typename R,
|
||||
template <typename> class RPred,
|
||||
typename Enable = void>
|
||||
struct binary_operand_check
|
||||
{
|
||||
};
|
||||
|
||||
template <typename L, template <typename> class LPred, typename R, template <typename> class RPred>
|
||||
struct binary_operand_check<L,
|
||||
LPred,
|
||||
R,
|
||||
RPred,
|
||||
detail::enable_if_t<LPred<wrap_operand_t<L>>::value and RPred<wrap_operand_t<R>>::value>>
|
||||
{
|
||||
using type = void;
|
||||
};
|
||||
|
||||
template <typename L, template <typename> class LPred, typename R, template <typename> class RPred>
|
||||
using binary_operand_check_t = typename binary_operand_check<L, LPred, R, RPred>::type;
|
||||
}
|
||||
|
||||
#endif
|
55
include/sqlpp11/operators.h
Normal file
55
include/sqlpp11/operators.h
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_OPERATORS_H
|
||||
#define SQLPP_OPERATORS_H
|
||||
|
||||
#include <sqlpp11/wrap_operand.h>
|
||||
#include <sqlpp11/expression_return_types.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename L, typename R>
|
||||
auto operator and(const L& l, const R& r) -> return_type_and_t<L, R>
|
||||
{
|
||||
return_type_and<L, R>::check::_();
|
||||
return {wrap_operand_t<L>{l}, wrap_operand_t<R>{r}};
|
||||
}
|
||||
template <typename L, typename R>
|
||||
auto operator or(const L& l, const R& r) -> return_type_or_t<L, R>
|
||||
{
|
||||
return_type_or<L, R>::check::_();
|
||||
return {wrap_operand_t<L>{l}, wrap_operand_t<R>{r}};
|
||||
}
|
||||
template <typename T>
|
||||
auto operator not(const T& t) -> return_type_not_t<T>
|
||||
{
|
||||
return_type_not<T>::check::_();
|
||||
return {wrap_operand_t<T>{t}};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -27,22 +27,25 @@
|
||||
#ifndef SQLPP_RESULT_FIELD_H
|
||||
#define SQLPP_RESULT_FIELD_H
|
||||
|
||||
#include <ostream>
|
||||
#include <sqlpp11/wrong.h>
|
||||
#include <sqlpp11/result_field_methods.h>
|
||||
#include <sqlpp11/wrap_operand.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename ValueType, typename Db, typename FieldSpec>
|
||||
template <typename Db, typename FieldSpec>
|
||||
struct result_field_t
|
||||
{
|
||||
using X = typename FieldSpec::incorrect;
|
||||
static_assert(wrong_t<result_field_t>::value, "Missing specialization for result_field_t");
|
||||
};
|
||||
|
||||
template <typename Context, typename ValueType, typename Db, typename FieldSpec>
|
||||
struct serializer_t<Context, result_field_t<ValueType, Db, FieldSpec>>
|
||||
template <typename Context, typename Db, typename FieldSpec>
|
||||
struct serializer_t<Context, result_field_t<Db, FieldSpec>>
|
||||
{
|
||||
using _serialize_check = consistent_t;
|
||||
using T = result_field_t<ValueType, Db, FieldSpec>;
|
||||
using T = result_field_t<Db, FieldSpec>;
|
||||
|
||||
static Context& _(const T& t, Context& context)
|
||||
{
|
||||
@ -52,10 +55,16 @@ namespace sqlpp
|
||||
}
|
||||
else
|
||||
{
|
||||
context << t.value();
|
||||
serialize(wrap_operand_t<cpp_value_type_of<FieldSpec>>(t.value()), context);
|
||||
}
|
||||
return context;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Db, typename FieldSpec>
|
||||
inline std::ostream& operator<<(std::ostream& os, const result_field_t<Db, FieldSpec>& rf)
|
||||
{
|
||||
return serialize(rf, os);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
128
include/sqlpp11/result_field_base.h
Normal file
128
include/sqlpp11/result_field_base.h
Normal file
@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_RESULT_FIELD_BASE_H
|
||||
#define SQLPP_RESULT_FIELD_BASE_H
|
||||
|
||||
#include <utility>
|
||||
#include <sqlpp11/basic_expression_operators.h>
|
||||
#include <sqlpp11/alias_operators.h>
|
||||
#include <sqlpp11/result_field.h>
|
||||
#include <sqlpp11/exception.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename Db, typename FieldSpec, typename StorageType = typename value_type_of<FieldSpec>::_cpp_value_type>
|
||||
struct result_field_base
|
||||
{
|
||||
using _db_t = Db;
|
||||
using _field_spec_t = FieldSpec;
|
||||
using _cpp_value_type = typename value_type_of<FieldSpec>::_cpp_value_type;
|
||||
using _cpp_storage_type = StorageType;
|
||||
|
||||
static constexpr bool _null_is_trivial =
|
||||
column_spec_can_be_null_t<_field_spec_t>::value and
|
||||
(null_is_trivial_value_t<_field_spec_t>::value or not enforce_null_result_treatment_t<_db_t>::value);
|
||||
using _traits = make_traits<value_type_of<_field_spec_t>,
|
||||
tag::is_result_field,
|
||||
tag::is_expression,
|
||||
tag_if<tag::null_is_trivial_value, _null_is_trivial>>;
|
||||
|
||||
using _nodes = detail::type_vector<>;
|
||||
using _can_be_null = column_spec_can_be_null_t<_field_spec_t>;
|
||||
|
||||
result_field_base() : _is_valid{false}, _is_null{true}, _value{}
|
||||
{
|
||||
}
|
||||
|
||||
bool operator==(const _cpp_value_type& rhs) const
|
||||
{
|
||||
return value() == rhs;
|
||||
}
|
||||
|
||||
bool operator!=(const _cpp_value_type& rhs) const
|
||||
{
|
||||
return not operator==(rhs);
|
||||
}
|
||||
|
||||
void _validate()
|
||||
{
|
||||
_is_valid = true;
|
||||
}
|
||||
|
||||
void _invalidate()
|
||||
{
|
||||
_is_valid = false;
|
||||
_is_null = true;
|
||||
_value = {};
|
||||
}
|
||||
|
||||
bool is_null() const
|
||||
{
|
||||
if (not _is_valid)
|
||||
throw exception("accessing is_null in non-existing row");
|
||||
return _is_null;
|
||||
}
|
||||
|
||||
bool _is_trivial() const
|
||||
{
|
||||
if (not _is_valid)
|
||||
throw exception("accessing is_null in non-existing row");
|
||||
|
||||
return value() == _cpp_storage_type{};
|
||||
}
|
||||
|
||||
_cpp_value_type value() const
|
||||
{
|
||||
if (not _is_valid)
|
||||
throw exception("accessing value in non-existing row");
|
||||
|
||||
if (_is_null)
|
||||
{
|
||||
if (not _null_is_trivial)
|
||||
{
|
||||
throw exception("accessing value of NULL field");
|
||||
}
|
||||
else
|
||||
{
|
||||
return {};
|
||||
}
|
||||
}
|
||||
return _value;
|
||||
}
|
||||
|
||||
operator _cpp_value_type() const
|
||||
{
|
||||
return value();
|
||||
}
|
||||
|
||||
bool _is_valid;
|
||||
bool _is_null;
|
||||
_cpp_storage_type _value;
|
||||
};
|
||||
}
|
||||
#endif
|
@ -1,89 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_RESULT_FIELD_METHODS_H
|
||||
#define SQLPP_RESULT_FIELD_METHODS_H
|
||||
|
||||
#include <utility>
|
||||
#include <sqlpp11/basic_expression_operators.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
template <typename Field>
|
||||
struct get_field_spec_impl
|
||||
{
|
||||
static_assert(wrong_t<get_field_spec_impl>::value, "Invalid argument for get_field_spec");
|
||||
};
|
||||
|
||||
template <template <typename, typename, typename> class Field, typename ValueType, typename Db, typename FieldSpec>
|
||||
struct get_field_spec_impl<Field<ValueType, Db, FieldSpec>>
|
||||
{
|
||||
using type = FieldSpec;
|
||||
};
|
||||
|
||||
template <typename Field>
|
||||
using get_field_spec_t = typename get_field_spec_impl<Field>::type;
|
||||
}
|
||||
|
||||
template <typename Field, typename Enable = void>
|
||||
struct result_field_methods_base_t
|
||||
{
|
||||
using _field_spec_t = detail::get_field_spec_t<Field>;
|
||||
static constexpr bool _null_is_trivial = true;
|
||||
operator cpp_value_type_of<_field_spec_t>() const
|
||||
{
|
||||
return static_cast<const Field&>(*this).value();
|
||||
}
|
||||
};
|
||||
|
||||
template <template <typename, typename, typename> class Field, typename ValueType, typename Db, typename FieldSpec>
|
||||
struct result_field_methods_base_t<Field<ValueType, Db, FieldSpec>,
|
||||
typename std::enable_if<enforce_null_result_treatment_t<Db>::value and
|
||||
column_spec_can_be_null_t<FieldSpec>::value and
|
||||
not null_is_trivial_value_t<FieldSpec>::value>::type>
|
||||
{
|
||||
using _field_spec_t = FieldSpec;
|
||||
static constexpr bool _null_is_trivial = false;
|
||||
};
|
||||
|
||||
template <typename Field>
|
||||
struct result_field_methods_t : public result_field_methods_base_t<Field>, public alias_operators<Field>
|
||||
{
|
||||
using _base_t = result_field_methods_base_t<Field>;
|
||||
using _field_spec_t = typename _base_t::_field_spec_t;
|
||||
|
||||
using _traits = make_traits<value_type_of<_field_spec_t>,
|
||||
tag::is_result_field,
|
||||
tag::is_expression,
|
||||
tag_if<tag::null_is_trivial_value, _base_t::_null_is_trivial>>;
|
||||
|
||||
using _nodes = detail::type_vector<>;
|
||||
using _can_be_null = column_spec_can_be_null_t<_field_spec_t>;
|
||||
};
|
||||
}
|
||||
#endif
|
@ -30,7 +30,8 @@
|
||||
#include <map>
|
||||
#include <sqlpp11/result_row_fwd.h>
|
||||
#include <sqlpp11/field_spec.h>
|
||||
#include <sqlpp11/text.h>
|
||||
#include <sqlpp11/no_name.h>
|
||||
#include <sqlpp11/data_types/text.h>
|
||||
#include <sqlpp11/detail/field_index_sequence.h>
|
||||
|
||||
namespace sqlpp
|
||||
@ -41,9 +42,9 @@ namespace sqlpp
|
||||
struct result_row_impl;
|
||||
|
||||
template <typename Db, std::size_t index, typename FieldSpec>
|
||||
struct result_field : public member_t<FieldSpec, result_field_t<value_type_of<FieldSpec>, Db, FieldSpec>>
|
||||
struct result_field : public member_t<FieldSpec, result_field_t<Db, FieldSpec>>
|
||||
{
|
||||
using _field = member_t<FieldSpec, result_field_t<value_type_of<FieldSpec>, Db, FieldSpec>>;
|
||||
using _field = member_t<FieldSpec, result_field_t<Db, FieldSpec>>;
|
||||
|
||||
result_field() = default;
|
||||
|
||||
@ -182,16 +183,7 @@ namespace sqlpp
|
||||
{
|
||||
using _field_index_sequence = detail::make_field_index_sequence<0, FieldSpecs...>;
|
||||
using _impl = detail::result_row_impl<Db, _field_index_sequence, FieldSpecs...>;
|
||||
struct _field_spec_t
|
||||
{
|
||||
using _traits = make_traits<text, tag::is_noop, tag::can_be_null, tag::null_is_trivial_value>;
|
||||
using _nodes = detail::type_vector<>;
|
||||
|
||||
struct _alias_t
|
||||
{
|
||||
};
|
||||
};
|
||||
using _field_type = result_field_t<text, Db, _field_spec_t>;
|
||||
using _field_type = result_field_t<Db, field_spec_t<no_name_t, text, true, true>>;
|
||||
|
||||
bool _is_valid;
|
||||
std::vector<std::string> _dynamic_field_names;
|
||||
|
@ -27,7 +27,7 @@
|
||||
#ifndef SQLPP_SOME_H
|
||||
#define SQLPP_SOME_H
|
||||
|
||||
#include <sqlpp11/boolean.h>
|
||||
#include <sqlpp11/data_types/boolean.h>
|
||||
#include <sqlpp11/detail/type_set.h>
|
||||
#include <sqlpp11/char_sequence.h>
|
||||
|
||||
|
@ -28,10 +28,11 @@
|
||||
#define SQLPP_SORT_ORDER_H
|
||||
|
||||
#include <sqlpp11/detail/type_set.h>
|
||||
#include <sqlpp11/no_value.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
struct no_value_t;
|
||||
|
||||
enum class sort_type
|
||||
{
|
||||
asc,
|
||||
|
@ -28,7 +28,7 @@
|
||||
#define SQLPP_H
|
||||
|
||||
#include <sqlpp11/alias_provider.h>
|
||||
#include <sqlpp11/column_types.h>
|
||||
#include <sqlpp11/data_types.h>
|
||||
#include <sqlpp11/insert.h>
|
||||
#include <sqlpp11/remove.h>
|
||||
#include <sqlpp11/update.h>
|
||||
|
@ -1,282 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_TEXT_H
|
||||
#define SQLPP_TEXT_H
|
||||
|
||||
#include <sqlpp11/assignment.h>
|
||||
#include <sqlpp11/basic_expression_operators.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/exception.h>
|
||||
#include <sqlpp11/like.h>
|
||||
#include <sqlpp11/result_field.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename... Args>
|
||||
struct concat_t;
|
||||
|
||||
// text value type
|
||||
struct text
|
||||
{
|
||||
using _traits = make_traits<text, tag::is_value_type>;
|
||||
using _tag = tag::is_text;
|
||||
using _cpp_value_type = std::string;
|
||||
|
||||
template <typename T>
|
||||
using _is_valid_operand = is_text_t<T>;
|
||||
};
|
||||
|
||||
// text parameter type
|
||||
template <>
|
||||
struct parameter_value_t<text>
|
||||
{
|
||||
using _value_type = text;
|
||||
using _cpp_value_type = typename _value_type::_cpp_value_type;
|
||||
|
||||
parameter_value_t() : _value(""), _is_null(true)
|
||||
{
|
||||
}
|
||||
|
||||
parameter_value_t(const _cpp_value_type& val) : _value(val), _is_null(false)
|
||||
{
|
||||
}
|
||||
|
||||
parameter_value_t& operator=(const _cpp_value_type& val)
|
||||
{
|
||||
_value = val;
|
||||
_is_null = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
parameter_value_t& operator=(const tvin_t<wrap_operand_t<_cpp_value_type>>& t)
|
||||
{
|
||||
if (t._is_trivial())
|
||||
{
|
||||
_value = "";
|
||||
_is_null = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_value = t._value._t;
|
||||
_is_null = false;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
parameter_value_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;
|
||||
};
|
||||
|
||||
// text expression operators
|
||||
template <typename Base>
|
||||
struct expression_operators<Base, text> : public basic_expression_operators<Base, text>
|
||||
{
|
||||
template <typename T>
|
||||
using _is_valid_operand = is_valid_operand<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}};
|
||||
}
|
||||
};
|
||||
|
||||
// text column operators
|
||||
template <typename Base>
|
||||
struct column_operators<Base, text>
|
||||
{
|
||||
template <typename T>
|
||||
using _is_valid_operand = is_valid_operand<text, T>;
|
||||
|
||||
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),
|
||||
concat_t<Base, wrap_operand_t<T>>{*static_cast<const Base*>(this), rhs{t}}};
|
||||
}
|
||||
};
|
||||
|
||||
// text result field
|
||||
template <typename Db, typename 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>, text>::value, "field type mismatch");
|
||||
using _cpp_value_type = typename text::_cpp_value_type;
|
||||
|
||||
result_field_t() : _is_valid(false), _value_ptr(nullptr), _len(0)
|
||||
{
|
||||
}
|
||||
|
||||
void _validate()
|
||||
{
|
||||
_is_valid = true;
|
||||
}
|
||||
|
||||
void _invalidate()
|
||||
{
|
||||
_is_valid = false;
|
||||
_value_ptr = nullptr;
|
||||
_len = 0;
|
||||
}
|
||||
|
||||
bool operator==(const _cpp_value_type& rhs) const
|
||||
{
|
||||
return value() == rhs;
|
||||
}
|
||||
bool operator!=(const _cpp_value_type& rhs) const
|
||||
{
|
||||
return not operator==(rhs);
|
||||
}
|
||||
|
||||
bool is_null() const
|
||||
{
|
||||
if (not _is_valid)
|
||||
throw exception("accessing is_null in non-existing row");
|
||||
return _value_ptr == nullptr;
|
||||
}
|
||||
|
||||
bool _is_trivial() const
|
||||
{
|
||||
if (not _is_valid)
|
||||
throw exception("accessing is_null in non-existing row");
|
||||
|
||||
return value() == "";
|
||||
}
|
||||
|
||||
_cpp_value_type value() const
|
||||
{
|
||||
if (not _is_valid)
|
||||
throw exception("accessing value in non-existing row");
|
||||
|
||||
if (not _value_ptr)
|
||||
{
|
||||
if (enforce_null_result_treatment_t<Db>::value and not null_is_trivial_value_t<FieldSpec>::value)
|
||||
{
|
||||
throw exception("accessing value of NULL field");
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
return std::string(_value_ptr, _value_ptr + _len);
|
||||
}
|
||||
|
||||
template <typename Target>
|
||||
void _bind(Target& target, size_t i)
|
||||
{
|
||||
target._bind_text_result(i, &_value_ptr, &_len);
|
||||
}
|
||||
|
||||
private:
|
||||
bool _is_valid;
|
||||
const char* _value_ptr;
|
||||
size_t _len;
|
||||
};
|
||||
|
||||
template <typename Context, typename Db, typename FieldSpec>
|
||||
struct serializer_t<Context, result_field_t<text, Db, FieldSpec>>
|
||||
{
|
||||
using _serialize_check = consistent_t;
|
||||
using T = result_field_t<text, Db, FieldSpec>;
|
||||
|
||||
static Context& _(const T& t, Context& context)
|
||||
{
|
||||
if (t.is_null() and not null_is_trivial_value_t<T>::value)
|
||||
{
|
||||
context << "NULL";
|
||||
}
|
||||
else
|
||||
{
|
||||
context << '\'' << context.escape(t.value()) << '\'';
|
||||
}
|
||||
return context;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Db, typename FieldSpec>
|
||||
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)
|
||||
{
|
||||
return os << "NULL";
|
||||
}
|
||||
else
|
||||
{
|
||||
return os << e.value();
|
||||
}
|
||||
}
|
||||
|
||||
using blob = text;
|
||||
using varchar = text;
|
||||
using char_ = text;
|
||||
}
|
||||
#endif
|
@ -1,235 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_TIME_POINT_H
|
||||
#define SQLPP_TIME_POINT_H
|
||||
|
||||
#include <sqlpp11/date_time_fwd.h>
|
||||
#include <sqlpp11/basic_expression_operators.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/exception.h>
|
||||
#include <sqlpp11/value_type.h>
|
||||
#include <sqlpp11/assignment.h>
|
||||
#include <sqlpp11/result_field.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
// time_point value type
|
||||
struct time_point
|
||||
{
|
||||
using _traits = make_traits<time_point, tag::is_value_type>;
|
||||
using _tag = tag::is_date_time;
|
||||
using _cpp_value_type = ::sqlpp::chrono::mus_point;
|
||||
|
||||
template <typename T>
|
||||
using _is_valid_operand = is_time_point_t<T>;
|
||||
};
|
||||
|
||||
// time_point parameter value
|
||||
template <>
|
||||
struct parameter_value_t<time_point>
|
||||
{
|
||||
using _value_type = time_point;
|
||||
using _cpp_value_type = typename _value_type::_cpp_value_type;
|
||||
|
||||
parameter_value_t() : _value{}, _is_null(true)
|
||||
{
|
||||
}
|
||||
|
||||
explicit parameter_value_t(const _cpp_value_type& val) : _value(val), _is_null(false)
|
||||
{
|
||||
}
|
||||
|
||||
parameter_value_t& operator=(const _cpp_value_type& val)
|
||||
{
|
||||
_value = val;
|
||||
_is_null = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
parameter_value_t& operator=(const tvin_t<wrap_operand_t<_cpp_value_type>>& t)
|
||||
{
|
||||
if (t._is_trivial())
|
||||
{
|
||||
_value = _cpp_value_type{};
|
||||
_is_null = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_value = t._value._t;
|
||||
_is_null = false;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void set_null()
|
||||
{
|
||||
_value = _cpp_value_type{};
|
||||
_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_date_time_parameter(index, &_value, _is_null);
|
||||
}
|
||||
|
||||
private:
|
||||
_cpp_value_type _value;
|
||||
bool _is_null;
|
||||
};
|
||||
|
||||
// time_point expression operators
|
||||
template <typename Base>
|
||||
struct expression_operators<Base, time_point> : public basic_expression_operators<Base, time_point>
|
||||
{
|
||||
template <typename T>
|
||||
using _is_valid_operand = is_valid_operand<time_point, T>;
|
||||
};
|
||||
|
||||
// time_point column operators
|
||||
template <typename Base>
|
||||
struct column_operators<Base, time_point>
|
||||
{
|
||||
template <typename T>
|
||||
using _is_valid_operand = is_valid_operand<time_point, T>;
|
||||
};
|
||||
|
||||
// time_point result field
|
||||
template <typename Db, typename FieldSpec>
|
||||
struct result_field_t<time_point, Db, FieldSpec>
|
||||
: public result_field_methods_t<result_field_t<time_point, Db, FieldSpec>>
|
||||
{
|
||||
static_assert(std::is_same<value_type_of<FieldSpec>, time_point>::value, "field type mismatch");
|
||||
using _cpp_value_type = typename time_point::_cpp_value_type;
|
||||
|
||||
result_field_t() : _is_valid(false), _is_null(true), _value{}
|
||||
{
|
||||
}
|
||||
|
||||
void _invalidate()
|
||||
{
|
||||
_is_valid = false;
|
||||
_is_null = true;
|
||||
_value = _cpp_value_type{};
|
||||
}
|
||||
|
||||
void _validate()
|
||||
{
|
||||
_is_valid = true;
|
||||
}
|
||||
|
||||
bool is_null() const
|
||||
{
|
||||
if (not _is_valid)
|
||||
throw exception("accessing is_null in non-existing row");
|
||||
return _is_null;
|
||||
}
|
||||
|
||||
bool _is_trivial() const
|
||||
{
|
||||
if (not _is_valid)
|
||||
throw exception("accessing is_null in non-existing row");
|
||||
|
||||
return value() == _cpp_value_type{};
|
||||
}
|
||||
|
||||
_cpp_value_type value() const
|
||||
{
|
||||
if (not _is_valid)
|
||||
throw exception("accessing value in non-existing row");
|
||||
|
||||
if (_is_null)
|
||||
{
|
||||
if (enforce_null_result_treatment_t<Db>::value and not null_is_trivial_value_t<FieldSpec>::value)
|
||||
{
|
||||
throw exception("accessing value of NULL field");
|
||||
}
|
||||
else
|
||||
{
|
||||
return _cpp_value_type{};
|
||||
}
|
||||
}
|
||||
return _value;
|
||||
}
|
||||
|
||||
template <typename Target>
|
||||
void _bind(Target& target, size_t i)
|
||||
{
|
||||
target._bind_date_time_result(i, &_value, &_is_null);
|
||||
}
|
||||
|
||||
private:
|
||||
bool _is_valid;
|
||||
bool _is_null;
|
||||
_cpp_value_type _value;
|
||||
};
|
||||
|
||||
template <typename Context, typename Db, typename FieldSpec>
|
||||
struct serializer_t<Context, result_field_t<time_point, Db, FieldSpec>>
|
||||
{
|
||||
using _serialize_check = consistent_t;
|
||||
using T = result_field_t<time_point, Db, FieldSpec>;
|
||||
|
||||
static Context& _(const T& t, Context& context)
|
||||
{
|
||||
if (t.is_null() and not null_is_trivial_value_t<FieldSpec>::value)
|
||||
{
|
||||
context << "NULL";
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto dp = ::date::floor<::date::days>(t.value());
|
||||
const auto time = ::date::make_time(t.value() - dp);
|
||||
const auto ymd = ::date::year_month_day{dp};
|
||||
context << ymd << ' ' << time;
|
||||
}
|
||||
return context;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Db, typename FieldSpec>
|
||||
inline std::ostream& operator<<(std::ostream& os, const result_field_t<time_point, Db, FieldSpec>& e)
|
||||
{
|
||||
return serialize(e, os);
|
||||
}
|
||||
}
|
||||
#endif
|
@ -33,10 +33,60 @@
|
||||
#include <sqlpp11/serializer.h>
|
||||
#include <sqlpp11/detail/type_vector.h>
|
||||
#include <sqlpp11/detail/type_set.h>
|
||||
#include <sqlpp11/detail/void.h>
|
||||
#include <sqlpp11/detail/get_first.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
template <typename T, typename Enable = void>
|
||||
struct value_type_of_impl
|
||||
{
|
||||
static_assert(wrong_t<value_type_of_impl>::value, "Attempting to obtain value type from type without value_type");
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct value_type_of_impl<T, detail::void_t<typename T::_traits::_value_type>>
|
||||
{
|
||||
using type = typename T::_traits::_value_type;
|
||||
};
|
||||
}
|
||||
template <typename T>
|
||||
using value_type_of = typename detail::value_type_of_impl<T>::type;
|
||||
|
||||
// data types
|
||||
struct boolean;
|
||||
template <typename T>
|
||||
using is_boolean_t = std::is_same<value_type_of<T>, boolean>;
|
||||
|
||||
struct day_point;
|
||||
template <typename T>
|
||||
using is_day_point_t = std::is_same<value_type_of<T>, day_point>;
|
||||
|
||||
struct floating_point;
|
||||
template <typename T>
|
||||
using is_floating_point_t = std::is_same<value_type_of<T>, floating_point>;
|
||||
|
||||
struct integral;
|
||||
template <typename T>
|
||||
using is_integral_t = std::is_same<value_type_of<T>, integral>;
|
||||
|
||||
struct text;
|
||||
template <typename T>
|
||||
using is_text_t = std::is_same<value_type_of<T>, text>;
|
||||
|
||||
struct time_point;
|
||||
template <typename T>
|
||||
using is_time_point_t = std::is_same<value_type_of<T>, time_point>;
|
||||
|
||||
// joined data type
|
||||
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>;
|
||||
|
||||
namespace tag
|
||||
{
|
||||
struct can_be_null
|
||||
@ -65,9 +115,7 @@ namespace sqlpp
|
||||
#define SQLPP_VALUE_TRAIT_GENERATOR(name) \
|
||||
namespace tag \
|
||||
{ \
|
||||
struct name \
|
||||
{ \
|
||||
}; \
|
||||
struct name; \
|
||||
} \
|
||||
namespace detail \
|
||||
{ \
|
||||
@ -87,22 +135,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)
|
||||
@ -168,9 +202,6 @@ namespace sqlpp
|
||||
using is_database =
|
||||
typename std::conditional<std::is_same<Database, void>::value, std::false_type, std::true_type>::type;
|
||||
|
||||
template <typename T>
|
||||
using value_type_of = typename T::_traits::_value_type;
|
||||
|
||||
template <typename T>
|
||||
using cpp_value_type_of = typename value_type_of<T>::_cpp_value_type;
|
||||
|
||||
@ -229,6 +260,15 @@ namespace sqlpp
|
||||
SQLPP_RECURSIVE_TRAIT_GENERATOR(can_be_null)
|
||||
SQLPP_RECURSIVE_TRAIT_GENERATOR(contains_aggregate_function)
|
||||
|
||||
template <typename ValueType, typename T>
|
||||
struct is_valid_operand
|
||||
{
|
||||
static constexpr bool value =
|
||||
is_expression_t<T>::value // expressions are OK
|
||||
and ValueType::template _is_valid_operand<T>::value // the correct value type is required, of course
|
||||
;
|
||||
};
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <typename KnownAggregates, typename T, typename Leaf = void>
|
||||
@ -292,7 +332,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
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user