mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-15 20:31:16 +08:00
reset to master, added unsigned_integral, removed time_of_day
This commit is contained in:
parent
8b38df125b
commit
a8fa0ddba0
@ -44,6 +44,14 @@ namespace sqlpp
|
||||
#else
|
||||
using ::date::floor;
|
||||
#endif
|
||||
|
||||
|
||||
template<typename T>
|
||||
std::chrono::microseconds time_of_day(T t)
|
||||
{
|
||||
const auto dp = floor<days>(t);
|
||||
return std::chrono::duration_cast<std::chrono::microseconds>(::date::make_time(t - dp).to_duration());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
#include <sqlpp11/data_types/boolean.h>
|
||||
#include <sqlpp11/data_types/integral.h>
|
||||
#include <sqlpp11/data_types/unsigned_integral.h>
|
||||
#include <sqlpp11/data_types/floating_point.h>
|
||||
#include <sqlpp11/data_types/text.h>
|
||||
#include <sqlpp11/data_types/day_point.h>
|
||||
|
@ -35,7 +35,7 @@ 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>
|
||||
struct wrap_operand<T, typename std::enable_if<std::is_integral<T>::value and not std::is_same<bool, T>::value and not std::is_unsigned<T>::value>::type>
|
||||
{
|
||||
using type = integral_operand;
|
||||
};
|
||||
|
38
include/sqlpp11/data_types/unsigned_integral.h
Normal file
38
include/sqlpp11/data_types/unsigned_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_UNSIGNED_INTEGRAL_H
|
||||
#define SQLPP_UNSIGNED_INTEGRAL_H
|
||||
|
||||
#include <sqlpp11/data_types/unsigned_integral/data_type.h>
|
||||
#include <sqlpp11/data_types/unsigned_integral/operand.h>
|
||||
#include <sqlpp11/data_types/unsigned_integral/wrap_operand.h>
|
||||
#include <sqlpp11/data_types/unsigned_integral/expression_operators.h>
|
||||
#include <sqlpp11/data_types/unsigned_integral/column_operators.h>
|
||||
#include <sqlpp11/data_types/unsigned_integral/parameter_value.h>
|
||||
#include <sqlpp11/data_types/unsigned_integral/result_field.h>
|
||||
|
||||
#endif
|
@ -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_UNSIGNED_INTEGRAL_COLUMN_OPERATORS_H
|
||||
#define SQLPP_UNSIGNED_INTEGRAL_COLUMN_OPERATORS_H
|
||||
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/assignment.h>
|
||||
#include <sqlpp11/value_type.h>
|
||||
#include <sqlpp11/data_types/unsigned_integral/data_type.h>
|
||||
#include <sqlpp11/data_types/column_operators.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename Column>
|
||||
struct column_operators<Column, unsigned_integral>
|
||||
{
|
||||
template <typename T>
|
||||
using _is_valid_operand = is_valid_operand<unsigned_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/unsigned_integral/data_type.h
Normal file
48
include/sqlpp11/data_types/unsigned_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_UNSIGNED_INTEGRAL_DATA_TYPE_H
|
||||
#define SQLPP_UNSIGNED_INTEGRAL_DATA_TYPE_H
|
||||
|
||||
#include <sqlpp11/type_traits.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
struct unsigned_integral
|
||||
{
|
||||
using _traits = make_traits<unsigned_integral, tag::is_value_type>;
|
||||
using _cpp_value_type = uint64_t;
|
||||
|
||||
template <typename T>
|
||||
using _is_valid_operand = is_numeric_t<T>;
|
||||
};
|
||||
|
||||
using tinyint_unsigned = unsigned_integral;
|
||||
using smallint_unsigned = unsigned_integral;
|
||||
using integer_unsigned = unsigned_integral;
|
||||
using bigint_unsigned = unsigned_integral;
|
||||
}
|
||||
#endif
|
@ -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_UNSIGNED_INTEGRAL_EXPRESSION_OPERATORS_H
|
||||
#define SQLPP_UNSIGNED_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/unsigned_integral/data_type.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename Expression>
|
||||
struct expression_operators<Expression, unsigned_integral> : public basic_expression_operators<Expression>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename L, typename R>
|
||||
struct return_type_plus<L, R, binary_operand_check_t<L, is_unsigned_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_unsigned_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_unsigned_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_unsigned_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_unsigned_integral_t, R, is_unsigned_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_unsigned_integral_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = unary_plus_t<unsigned_integral, wrap_operand_t<T>>;
|
||||
};
|
||||
|
||||
template <typename T, typename Defer>
|
||||
struct return_type_unary_minus<T, Defer, unary_operand_check_t<T, is_unsigned_integral_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = unary_minus_t<unsigned_integral, wrap_operand_t<T>>;
|
||||
};
|
||||
|
||||
template <typename L, typename R>
|
||||
struct return_type_bitwise_and<L, R, binary_operand_check_t<L, is_unsigned_integral_t, R, is_unsigned_integral_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = bitwise_and_t<wrap_operand_t<L>, unsigned_integral, wrap_operand_t<R>>;
|
||||
};
|
||||
|
||||
template <typename L, typename R>
|
||||
struct return_type_bitwise_or<L, R, binary_operand_check_t<L, is_unsigned_integral_t, R, is_unsigned_integral_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = bitwise_or_t<wrap_operand_t<L>, unsigned_integral, wrap_operand_t<R>>;
|
||||
};
|
||||
}
|
||||
#endif
|
82
include/sqlpp11/data_types/unsigned_integral/operand.h
Normal file
82
include/sqlpp11/data_types/unsigned_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_UNSIGNED_INTEGRAL_OPERAND_H
|
||||
#define SQLPP_UNSIGNED_INTEGRAL_OPERAND_H
|
||||
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/alias_operators.h>
|
||||
#include <sqlpp11/serializer.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
struct unsigned_integral;
|
||||
|
||||
struct unsigned_integral_operand : public alias_operators<unsigned_integral_operand>
|
||||
{
|
||||
using _traits = make_traits<unsigned_integral, tag::is_expression, tag::is_wrapped_value>;
|
||||
using _nodes = detail::type_vector<>;
|
||||
using _is_aggregate_expression = std::true_type;
|
||||
|
||||
using _value_t = uint64_t;
|
||||
|
||||
unsigned_integral_operand() : _t{}
|
||||
{
|
||||
}
|
||||
|
||||
unsigned_integral_operand(_value_t t) : _t(t)
|
||||
{
|
||||
}
|
||||
|
||||
unsigned_integral_operand(const unsigned_integral_operand&) = default;
|
||||
unsigned_integral_operand(unsigned_integral_operand&&) = default;
|
||||
unsigned_integral_operand& operator=(const unsigned_integral_operand&) = default;
|
||||
unsigned_integral_operand& operator=(unsigned_integral_operand&&) = default;
|
||||
~unsigned_integral_operand() = default;
|
||||
|
||||
bool _is_trivial() const
|
||||
{
|
||||
return _t == 0;
|
||||
}
|
||||
|
||||
_value_t _t;
|
||||
};
|
||||
|
||||
template <typename Context>
|
||||
struct serializer_t<Context, unsigned_integral_operand>
|
||||
{
|
||||
using _serialize_check = consistent_t;
|
||||
using Operand = unsigned_integral_operand;
|
||||
|
||||
static Context& _(const Operand& t, Context& context)
|
||||
{
|
||||
context << t._t;
|
||||
return context;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -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_UNSIGNED_INTEGRAL_PARAMETER_VALUE_H
|
||||
#define SQLPP_UNSIGNED_INTEGRAL_PARAMETER_VALUE_H
|
||||
|
||||
#include <sqlpp11/data_types/parameter_value.h>
|
||||
#include <sqlpp11/data_types/parameter_value_base.h>
|
||||
#include <sqlpp11/data_types/unsigned_integral/data_type.h>
|
||||
#include <sqlpp11/tvin.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <>
|
||||
struct parameter_value_t<unsigned_integral> : public parameter_value_base<unsigned_integral>
|
||||
{
|
||||
using base = parameter_value_base<unsigned_integral>;
|
||||
using base::base;
|
||||
using base::operator=;
|
||||
|
||||
template <typename Target>
|
||||
void _bind(Target& target, size_t index) const
|
||||
{
|
||||
target._bind_unsigned_integral_parameter(index, &_value, _is_null);
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
55
include/sqlpp11/data_types/unsigned_integral/result_field.h
Normal file
55
include/sqlpp11/data_types/unsigned_integral/result_field.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_UNSIGNED_INTEGRAL_RESULT_FIELD_H
|
||||
#define SQLPP_UNSIGNED_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/unsigned_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, unsigned_integral, CanBeNull, NullIsTrivialValue>>
|
||||
: public result_field_base<Db, field_spec_t<NameType, unsigned_integral, CanBeNull, NullIsTrivialValue>>
|
||||
{
|
||||
template <typename Target>
|
||||
void _bind(Target& target, size_t index)
|
||||
{
|
||||
target._bind_unsigned_integral_result(index, &this->_value, &this->_is_null);
|
||||
}
|
||||
|
||||
template <typename Target>
|
||||
void _post_bind(Target& target, size_t index)
|
||||
{
|
||||
target._post_bind_unsigned_integral_result(index, &this->_value, &this->_is_null);
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
43
include/sqlpp11/data_types/unsigned_integral/wrap_operand.h
Normal file
43
include/sqlpp11/data_types/unsigned_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_UNSIGNED_INTEGRAL_WRAP_OPERAND_H
|
||||
#define SQLPP_UNSIGNED_INTEGRAL_WRAP_OPERAND_H
|
||||
|
||||
#include <utility>
|
||||
#include <sqlpp11/wrap_operand.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
struct unsigned_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 and std::is_unsigned<T>::value>::type>
|
||||
{
|
||||
using type = unsigned_integral_operand;
|
||||
};
|
||||
}
|
||||
#endif
|
@ -79,6 +79,10 @@ namespace sqlpp
|
||||
template <typename T>
|
||||
using is_integral_t = std::is_same<value_type_of<T>, integral>;
|
||||
|
||||
struct unsigned_integral;
|
||||
template <typename T>
|
||||
using is_unsigned_integral_t = std::is_same<value_type_of<T>, unsigned_integral>;
|
||||
|
||||
struct text;
|
||||
template <typename T>
|
||||
using is_text_t = std::is_same<value_type_of<T>, text>;
|
||||
@ -89,7 +93,7 @@ namespace sqlpp
|
||||
|
||||
// joined data type
|
||||
template <typename T>
|
||||
using is_numeric_t = logic::any_t<is_integral_t<T>::value, is_floating_point_t<T>::value>;
|
||||
using is_numeric_t = logic::any_t<is_integral_t<T>::value, is_unsigned_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>;
|
||||
|
@ -75,9 +75,31 @@ namespace test
|
||||
};
|
||||
using _traits = sqlpp::make_traits<sqlpp::floating_point, sqlpp::tag::can_be_null>;
|
||||
};
|
||||
struct Psi
|
||||
{
|
||||
struct _alias_t
|
||||
{
|
||||
static constexpr const char _literal[] = "psi";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template <typename T>
|
||||
struct _member_t
|
||||
{
|
||||
T psi;
|
||||
T& operator()()
|
||||
{
|
||||
return psi;
|
||||
}
|
||||
const T& operator()() const
|
||||
{
|
||||
return psi;
|
||||
}
|
||||
};
|
||||
};
|
||||
using _traits = sqlpp::make_traits<sqlpp::bigint_unsigned, sqlpp::tag::can_be_null>;
|
||||
};
|
||||
}
|
||||
|
||||
struct TabFoo : sqlpp::table_t<TabFoo, TabFoo_::Delta, TabFoo_::Epsilon, TabFoo_::Omega>
|
||||
struct TabFoo : sqlpp::table_t<TabFoo, TabFoo_::Delta, TabFoo_::Epsilon, TabFoo_::Omega, TabFoo_::Psi>
|
||||
{
|
||||
struct _alias_t
|
||||
{
|
||||
|
@ -108,6 +108,7 @@ int SelectType(int, char* [])
|
||||
using T = decltype(t.alpha);
|
||||
static_assert(sqlpp::is_numeric_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_unsigned_integral_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_floating_point_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_expression_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<T>::value, "type requirement");
|
||||
@ -121,6 +122,23 @@ int SelectType(int, char* [])
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
|
||||
// Test an unsigned integral table column
|
||||
{
|
||||
using T = decltype(f.psi);
|
||||
static_assert(sqlpp::is_numeric_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_integral_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_unsigned_integral_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_floating_point_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_expression_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_alias_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_table_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
|
||||
// Test a floating point table column
|
||||
{
|
||||
using T = decltype(f.omega);
|
||||
|
@ -28,7 +28,8 @@ CREATE TABLE tab_foo
|
||||
(
|
||||
delta varchar(255),
|
||||
epsilon bigint,
|
||||
omega double
|
||||
omega double,
|
||||
psi bigint UNSIGNED
|
||||
);
|
||||
|
||||
CREATE TABLE tab_bar
|
||||
|
Loading…
Reference in New Issue
Block a user