Merge branch 'release/0.35'

Conflicts:
	README.md
This commit is contained in:
rbock
2015-12-29 11:03:17 +01:00
300 changed files with 19927 additions and 13729 deletions

View 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

View 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_AVG_H
#define SQLPP_AVG_H
#include <sqlpp11/type_traits.h>
#include <sqlpp11/char_sequence.h>
namespace sqlpp
{
struct avg_alias_t
{
struct _alias_t
{
static constexpr const char _literal[] = "avg_";
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
template <typename T>
struct _member_t
{
T avg;
T& operator()()
{
return avg;
}
const T& operator()() const
{
return avg;
}
};
};
};
template <typename Flag, typename Expr>
struct avg_t : public expression_operators<avg_t<Flag, Expr>, floating_point>,
public alias_operators<avg_t<Flag, Expr>>
{
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,
"avg() used with flag other than 'distinct'");
static_assert(is_numeric_t<Expr>::value, "avg() requires a value expression as argument");
using _auto_alias_t = avg_alias_t;
avg_t(Expr expr) : _expr(expr)
{
}
avg_t(const avg_t&) = default;
avg_t(avg_t&&) = default;
avg_t& operator=(const avg_t&) = default;
avg_t& operator=(avg_t&&) = default;
~avg_t() = default;
Expr _expr;
};
template <typename Context, typename Flag, typename Expr>
struct serializer_t<Context, avg_t<Flag, Expr>>
{
using _serialize_check = serialize_check_of<Context, Flag, Expr>;
using T = avg_t<Flag, Expr>;
static Context& _(const T& t, Context& context)
{
context << "AVG(";
if (std::is_same<distinct_t, Flag>::value)
{
serialize(Flag(), context);
context << ' ';
serialize_operand(t._expr, context);
}
else
{
serialize(t._expr, context);
}
context << ")";
return context;
}
};
template <typename T>
auto avg(T t) -> avg_t<noop, wrap_operand_t<T>>
{
static_assert(not contains_aggregate_function_t<wrap_operand_t<T>>::value,
"avg() cannot be used on an aggregate function");
static_assert(is_numeric_t<wrap_operand_t<T>>::value, "avg() requires a value expression as argument");
return {t};
}
template <typename T>
auto avg(const distinct_t&, T t) -> avg_t<distinct_t, wrap_operand_t<T>>
{
static_assert(not contains_aggregate_function_t<wrap_operand_t<T>>::value,
"avg() cannot be used on an aggregate function");
static_assert(is_numeric_t<wrap_operand_t<T>>::value, "avg() requires a value expression as argument");
return {t};
}
}
#endif

View File

@@ -0,0 +1,129 @@
/*
* 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_COUNT_H
#define SQLPP_COUNT_H
#include <sqlpp11/char_sequence.h>
#include <sqlpp11/select_flags.h>
#include <sqlpp11/data_types/integral/data_type.h>
namespace sqlpp
{
struct count_alias_t
{
struct _alias_t
{
static constexpr const char _literal[] = "count_";
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
template <typename T>
struct _member_t
{
T count;
T& operator()()
{
return count;
}
const T& operator()() const
{
return count;
}
};
};
};
template <typename Flag, typename Expr>
struct count_t : public expression_operators<count_t<Flag, Expr>, integral>,
public alias_operators<count_t<Flag, Expr>>
{
using _traits = make_traits<integral, tag::is_expression /*, tag::is_selectable*/>;
using _nodes = detail::type_vector<Expr, aggregate_function>;
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'");
using _auto_alias_t = count_alias_t;
count_t(const Expr expr) : _expr(expr)
{
}
count_t(const count_t&) = default;
count_t(count_t&&) = default;
count_t& operator=(const count_t&) = default;
count_t& operator=(count_t&&) = default;
~count_t() = default;
Expr _expr;
};
template <typename Context, typename Flag, typename Expr>
struct serializer_t<Context, count_t<Flag, Expr>>
{
using _serialize_check = serialize_check_of<Context, Flag, Expr>;
using T = count_t<Flag, Expr>;
static Context& _(const T& t, Context& context)
{
context << "COUNT(";
if (std::is_same<distinct_t, Flag>::value)
{
serialize(Flag(), context);
context << ' ';
serialize_operand(t._expr, context);
}
else
{
serialize(t._expr, context);
}
context << ")";
return context;
}
};
template <typename T>
auto count(T t) -> count_t<noop, wrap_operand_t<T>>
{
static_assert(not contains_aggregate_function_t<wrap_operand_t<T>>::value,
"count() cannot be used on an aggregate function");
static_assert(is_expression_t<wrap_operand_t<T>>::value, "count() requires an expression as argument");
return {t};
}
template <typename T>
auto count(const distinct_t&, T t) -> count_t<distinct_t, wrap_operand_t<T>>
{
static_assert(not contains_aggregate_function_t<wrap_operand_t<T>>::value,
"count() cannot be used on an aggregate function");
static_assert(is_expression_t<wrap_operand_t<T>>::value, "count() requires an expression as argument");
return {t};
}
}
#endif

View File

@@ -0,0 +1,105 @@
/*
* 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_MAX_H
#define SQLPP_MAX_H
#include <sqlpp11/type_traits.h>
#include <sqlpp11/char_sequence.h>
namespace sqlpp
{
struct max_alias_t
{
struct _alias_t
{
static constexpr const char _literal[] = "max_";
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
template <typename T>
struct _member_t
{
T max;
T& operator()()
{
return max;
}
const T& operator()() const
{
return max;
}
};
};
};
template <typename Expr>
struct max_t : public expression_operators<max_t<Expr>, value_type_of<Expr>>, public alias_operators<max_t<Expr>>
{
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;
max_t(Expr expr) : _expr(expr)
{
}
max_t(const max_t&) = default;
max_t(max_t&&) = default;
max_t& operator=(const max_t&) = default;
max_t& operator=(max_t&&) = default;
~max_t() = default;
Expr _expr;
};
template <typename Context, typename Expr>
struct serializer_t<Context, max_t<Expr>>
{
using _serialize_check = serialize_check_of<Context, Expr>;
using T = max_t<Expr>;
static Context& _(const T& t, Context& context)
{
context << "MAX(";
serialize(t._expr, context);
context << ")";
return context;
}
};
template <typename T>
auto max(T t) -> max_t<wrap_operand_t<T>>
{
static_assert(not contains_aggregate_function_t<wrap_operand_t<T>>::value,
"max() cannot be used on an aggregate function");
static_assert(is_expression_t<wrap_operand_t<T>>::value, "max() requires an expression as argument");
return {t};
}
}
#endif

View File

@@ -0,0 +1,105 @@
/*
* 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_MIN_H
#define SQLPP_MIN_H
#include <sqlpp11/type_traits.h>
#include <sqlpp11/char_sequence.h>
namespace sqlpp
{
struct min_alias_t
{
struct _alias_t
{
static constexpr const char _literal[] = "min_";
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
template <typename T>
struct _member_t
{
T min;
T& operator()()
{
return min;
}
const T& operator()() const
{
return min;
}
};
};
};
template <typename Expr>
struct min_t : public expression_operators<min_t<Expr>, value_type_of<Expr>>, public alias_operators<min_t<Expr>>
{
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;
min_t(Expr expr) : _expr(expr)
{
}
min_t(const min_t&) = default;
min_t(min_t&&) = default;
min_t& operator=(const min_t&) = default;
min_t& operator=(min_t&&) = default;
~min_t() = default;
Expr _expr;
};
template <typename Context, typename Expr>
struct serializer_t<Context, min_t<Expr>>
{
using _serialize_check = serialize_check_of<Context, Expr>;
using T = min_t<Expr>;
static Context& _(const T& t, Context& context)
{
context << "MIN(";
serialize(t._expr, context);
context << ")";
return context;
}
};
template <typename T>
auto min(T t) -> min_t<wrap_operand_t<T>>
{
static_assert(not contains_aggregate_function_t<wrap_operand_t<T>>::value,
"min() cannot be used on an aggregate function");
static_assert(is_expression_t<wrap_operand_t<T>>::value, "min() requires an expression as argument");
return {t};
}
}
#endif

View File

@@ -0,0 +1,127 @@
/*
* 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_SUM_H
#define SQLPP_SUM_H
#include <sqlpp11/type_traits.h>
#include <sqlpp11/char_sequence.h>
namespace sqlpp
{
struct sum_alias_t
{
struct _alias_t
{
static constexpr const char _literal[] = "sum_";
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
template <typename T>
struct _member_t
{
T sum;
T& operator()()
{
return sum;
}
const T& operator()() const
{
return sum;
}
};
};
};
template <typename Flag, typename Expr>
struct sum_t : public expression_operators<sum_t<Flag, Expr>, value_type_of<Expr>>,
public alias_operators<sum_t<Flag, Expr>>
{
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,
"sum() used with flag other than 'distinct'");
static_assert(is_numeric_t<Expr>::value, "sum() requires a numeric expression as argument");
using _auto_alias_t = sum_alias_t;
sum_t(Expr expr) : _expr(expr)
{
}
sum_t(const sum_t&) = default;
sum_t(sum_t&&) = default;
sum_t& operator=(const sum_t&) = default;
sum_t& operator=(sum_t&&) = default;
~sum_t() = default;
Expr _expr;
};
template <typename Context, typename Flag, typename Expr>
struct serializer_t<Context, sum_t<Flag, Expr>>
{
using _serialize_check = serialize_check_of<Context, Flag, Expr>;
using T = sum_t<Flag, Expr>;
static Context& _(const T& t, Context& context)
{
context << "SUM(";
if (std::is_same<distinct_t, Flag>::value)
{
serialize(Flag(), context);
context << ' ';
serialize_operand(t._expr, context);
}
else
serialize(t._expr, context);
context << ")";
return context;
}
};
template <typename T>
auto sum(T t) -> sum_t<noop, wrap_operand_t<T>>
{
static_assert(not contains_aggregate_function_t<wrap_operand_t<T>>::value,
"sum() cannot be used on an aggregate function");
static_assert(is_numeric_t<wrap_operand_t<T>>::value, "sum() requires a numeric expression as argument");
return {t};
}
template <typename T>
auto sum(const distinct_t&, T t) -> sum_t<distinct_t, wrap_operand_t<T>>
{
static_assert(not contains_aggregate_function_t<wrap_operand_t<T>>::value,
"sum() cannot be used on an aggregate function");
static_assert(is_numeric_t<wrap_operand_t<T>>::value, "sum() requires a numeric expression as argument");
return {t};
}
}
#endif

View File

@@ -1,17 +1,17 @@
/*
* 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
@@ -32,35 +32,44 @@
namespace sqlpp
{
template<typename Expression, typename AliasProvider>
struct expression_alias_t
{
using _traits = make_traits<value_type_of<Expression>, tag::is_selectable, tag::is_alias>;
using _nodes = detail::type_vector<Expression>;
template <typename Expression, typename AliasProvider>
struct expression_alias_t
{
using _traits = make_traits<value_type_of<Expression>, tag::is_selectable, tag::is_alias>;
using _nodes = detail::type_vector<Expression>;
static_assert(is_expression_t<Expression>::value, "invalid argument for an expression alias");
static_assert(not is_alias_t<Expression>::value, "cannot create an alias of an alias");
static_assert(is_expression_t<Expression>::value, "invalid argument for an expression alias");
static_assert(not is_alias_t<Expression>::value, "cannot create an alias of an alias");
using _alias_t = typename AliasProvider::_alias_t;
using _alias_t = typename AliasProvider::_alias_t;
Expression _expression;
};
expression_alias_t(Expression expression) : _expression(expression)
{
}
template<typename Context, typename Expression, typename AliasProvider>
struct serializer_t<Context, expression_alias_t<Expression, AliasProvider>>
{
using _serialize_check = serialize_check_of<Context, Expression>;
using T = expression_alias_t<Expression, AliasProvider>;
expression_alias_t(const expression_alias_t&) = default;
expression_alias_t(expression_alias_t&&) = default;
expression_alias_t& operator=(const expression_alias_t&) = default;
expression_alias_t& operator=(expression_alias_t&&) = default;
~expression_alias_t() = default;
static Context& _(const T& t, Context& context)
{
serialize_operand(t._expression, context);
context << " AS ";
context << name_of<T>::char_ptr();
return context;
}
};
Expression _expression;
};
template <typename Context, typename Expression, typename AliasProvider>
struct serializer_t<Context, expression_alias_t<Expression, AliasProvider>>
{
using _serialize_check = serialize_check_of<Context, Expression>;
using T = expression_alias_t<Expression, AliasProvider>;
static Context& _(const T& t, Context& context)
{
serialize_operand(t._expression, context);
context << " AS ";
context << name_of<T>::char_ptr();
return context;
}
};
}
#endif

View 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

View File

@@ -1,17 +1,17 @@
/*
* 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
@@ -30,69 +30,76 @@
#include <type_traits>
#include <sqlpp11/char_sequence.h>
#define SQLPP_ALIAS_PROVIDER(name) \
struct name##_t\
{\
struct _alias_t\
{\
static constexpr const char _literal[] = #name;\
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;\
template<typename T>\
struct _member_t\
{\
T name;\
T& operator()() { return name; }\
const T& operator()() const { return name; }\
};\
};\
};\
constexpr name##_t name = {};
#define SQLPP_ALIAS_PROVIDER(name) \
struct name##_t \
{ \
struct _alias_t \
{ \
static constexpr const char _literal[] = #name; \
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>; \
template <typename T> \
struct _member_t \
{ \
T name; \
T& operator()() \
{ \
return name; \
} \
const T& operator()() const \
{ \
return name; \
} \
}; \
}; \
}; \
constexpr name##_t name = {};
namespace sqlpp
{
template<typename T, typename Enable = void>
struct is_alias_provider_t
{
static constexpr bool value = false;
};
template <typename T, typename Enable = void>
struct is_alias_provider_t
{
static constexpr bool value = false;
};
template<typename T>
struct is_alias_provider_t<T, typename std::enable_if<std::is_class<typename T::_alias_t::template _member_t<int>>::value, void>::type>
{
static constexpr bool value = true;
};
template <typename T>
struct is_alias_provider_t<
T,
typename std::enable_if<std::is_class<typename T::_alias_t::template _member_t<int>>::value, void>::type>
{
static constexpr bool value = true;
};
namespace alias
{
SQLPP_ALIAS_PROVIDER(a)
SQLPP_ALIAS_PROVIDER(b)
SQLPP_ALIAS_PROVIDER(c)
SQLPP_ALIAS_PROVIDER(d)
SQLPP_ALIAS_PROVIDER(e)
SQLPP_ALIAS_PROVIDER(f)
SQLPP_ALIAS_PROVIDER(g)
SQLPP_ALIAS_PROVIDER(h)
SQLPP_ALIAS_PROVIDER(i)
SQLPP_ALIAS_PROVIDER(j)
SQLPP_ALIAS_PROVIDER(k)
SQLPP_ALIAS_PROVIDER(l)
SQLPP_ALIAS_PROVIDER(m)
SQLPP_ALIAS_PROVIDER(n)
SQLPP_ALIAS_PROVIDER(o)
SQLPP_ALIAS_PROVIDER(p)
SQLPP_ALIAS_PROVIDER(q)
SQLPP_ALIAS_PROVIDER(s)
SQLPP_ALIAS_PROVIDER(t)
SQLPP_ALIAS_PROVIDER(u)
SQLPP_ALIAS_PROVIDER(v)
SQLPP_ALIAS_PROVIDER(w)
SQLPP_ALIAS_PROVIDER(x)
SQLPP_ALIAS_PROVIDER(y)
SQLPP_ALIAS_PROVIDER(z)
SQLPP_ALIAS_PROVIDER(left)
SQLPP_ALIAS_PROVIDER(right)
}
namespace alias
{
SQLPP_ALIAS_PROVIDER(a)
SQLPP_ALIAS_PROVIDER(b)
SQLPP_ALIAS_PROVIDER(c)
SQLPP_ALIAS_PROVIDER(d)
SQLPP_ALIAS_PROVIDER(e)
SQLPP_ALIAS_PROVIDER(f)
SQLPP_ALIAS_PROVIDER(g)
SQLPP_ALIAS_PROVIDER(h)
SQLPP_ALIAS_PROVIDER(i)
SQLPP_ALIAS_PROVIDER(j)
SQLPP_ALIAS_PROVIDER(k)
SQLPP_ALIAS_PROVIDER(l)
SQLPP_ALIAS_PROVIDER(m)
SQLPP_ALIAS_PROVIDER(n)
SQLPP_ALIAS_PROVIDER(o)
SQLPP_ALIAS_PROVIDER(p)
SQLPP_ALIAS_PROVIDER(q)
SQLPP_ALIAS_PROVIDER(s)
SQLPP_ALIAS_PROVIDER(t)
SQLPP_ALIAS_PROVIDER(u)
SQLPP_ALIAS_PROVIDER(v)
SQLPP_ALIAS_PROVIDER(w)
SQLPP_ALIAS_PROVIDER(x)
SQLPP_ALIAS_PROVIDER(y)
SQLPP_ALIAS_PROVIDER(z)
SQLPP_ALIAS_PROVIDER(left)
SQLPP_ALIAS_PROVIDER(right)
}
}
#endif

View File

@@ -1,17 +1,17 @@
/*
* 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
@@ -30,51 +30,41 @@
#include <sqlpp11/interpret.h>
#include <sqlpp11/alias.h>
#include <sqlpp11/multi_column.h>
#include <sqlpp11/portable_static_assert.h>
namespace sqlpp
{
template<typename Table>
struct all_of_t
{
using _column_tuple_t = typename Table::_column_tuple_t;
template <typename Table>
struct all_of_t
{
using _column_tuple_t = typename Table::_column_tuple_t;
template<typename AliasProvider>
detail::copy_tuple_args_t<multi_column_alias_t, AliasProvider, _column_tuple_t> as(const AliasProvider& alias)
{
return multi_column(_column_tuple_t{}).as(alias);
}
};
template <typename AliasProvider>
detail::copy_tuple_args_t<multi_column_alias_t, AliasProvider, _column_tuple_t> as(const AliasProvider& alias)
{
return multi_column(_column_tuple_t{}).as(alias);
}
};
template<typename Table>
auto all_of(Table t) -> all_of_t<Table>
{
return {};
}
template <typename Table>
auto all_of(Table) -> all_of_t<Table>
{
return {};
}
struct assert_no_stand_alone_all_of_t
{
using type = std::false_type;
SQLPP_PORTABLE_STATIC_ASSERT(assert_no_stand_alone_all_of_t, "all_of(table) seems to be used outside of select");
template<typename T = void>
static void _()
{
static_assert(wrong_t<T>::value, "all_of(table) seems to be used outside of select");
}
};
template<typename Context, typename Table>
struct serializer_t<Context, all_of_t<Table>>
{
using _serialize_check = assert_no_stand_alone_all_of_t;
using T = all_of_t<Table>;
static Context& _(const T& t, const Context&)
{
_serialize_check::_();
}
};
template <typename Context, typename Table>
struct serializer_t<Context, all_of_t<Table>>
{
using _serialize_check = assert_no_stand_alone_all_of_t;
using T = all_of_t<Table>;
static Context& _(const T&, const Context&)
{
_serialize_check::_();
}
};
}
#endif

View File

@@ -1,17 +1,17 @@
/*
* 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
@@ -27,68 +27,55 @@
#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>
namespace sqlpp
{
template<typename Select>
struct any_t
{
using _traits = make_traits<value_type_of<Select>, tag::is_multi_expression>;
using _nodes = detail::type_vector<Select>;
template <typename Select>
struct any_t
{
using _traits = make_traits<value_type_of<Select>, tag::is_multi_expression>;
using _nodes = detail::type_vector<Select>;
struct _alias_t
{
static constexpr const char _literal[] = "any_";
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
template<typename T>
struct _member_t
{
T any;
T& operator()() { return any; }
const T& operator()() const { return any; }
};
};
any_t(Select select) : _select(select)
{
}
any_t(Select select):
_select(select)
{}
any_t(const any_t&) = default;
any_t(any_t&&) = default;
any_t& operator=(const any_t&) = default;
any_t& operator=(any_t&&) = default;
~any_t() = default;
any_t(const any_t&) = default;
any_t(any_t&&) = default;
any_t& operator=(const any_t&) = default;
any_t& operator=(any_t&&) = default;
~any_t() = default;
Select _select;
};
Select _select;
};
template <typename Context, typename Select>
struct serializer_t<Context, any_t<Select>>
{
using _serialize_check = serialize_check_of<Context, Select>;
using T = any_t<Select>;
template<typename Context, typename Select>
struct serializer_t<Context, any_t<Select>>
{
using _serialize_check = serialize_check_of<Context, Select>;
using T = any_t<Select>;
static Context& _(const T& t, Context& context)
{
context << "ANY(";
serialize(t._select, context);
context << ")";
return context;
}
};
template<typename T>
auto any(T t) -> any_t<wrap_operand_t<T>>
{
static_assert(is_select_t<wrap_operand_t<T>>::value, "any() requires a select expression as argument");
static_assert(is_expression_t<wrap_operand_t<T>>::value, "any() requires a single column select expression as argument");
// FIXME: can we accept non-values like NULL here?
return { t };
}
static Context& _(const T& t, Context& context)
{
context << "ANY(";
serialize(t._select, context);
context << ")";
return context;
}
};
template <typename T>
auto any(T t) -> any_t<wrap_operand_t<T>>
{
static_assert(is_select_t<wrap_operand_t<T>>::value, "any() requires a select expression as argument");
static_assert(is_expression_t<wrap_operand_t<T>>::value,
"any() requires a single column select expression as argument");
// FIXME: can we accept non-values like NULL here?
return {t};
}
}
#endif

View File

@@ -1,17 +1,17 @@
/*
* 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
@@ -37,46 +37,46 @@
namespace sqlpp
{
template<typename Lhs, typename Rhs>
struct assignment_t
{
using _traits = make_traits<no_value_t, tag::is_assignment>;
using _lhs_t = Lhs;
using _rhs_t = rhs_wrap_t<allow_tvin_t<Rhs>, trivial_value_is_null_t<_lhs_t>::value>;
using _nodes = detail::type_vector<_lhs_t, _rhs_t>;
template <typename Lhs, typename Rhs>
struct assignment_t
{
using _traits = make_traits<no_value_t, tag::is_assignment>;
using _lhs_t = Lhs;
using _rhs_t = rhs_wrap_t<allow_tvin_t<Rhs>, trivial_value_is_null_t<_lhs_t>::value>;
using _nodes = detail::type_vector<_lhs_t, _rhs_t>;
static_assert(can_be_null_t<_lhs_t>::value ? true : not (std::is_same<_rhs_t, null_t>::value or is_tvin_t<_rhs_t>::value), "column must not be null");
static_assert(can_be_null_t<_lhs_t>::value ? true
: not(std::is_same<_rhs_t, null_t>::value or is_tvin_t<_rhs_t>::value),
"column must not be null");
assignment_t(_lhs_t lhs, _rhs_t rhs):
_lhs(lhs),
_rhs(rhs)
{}
assignment_t(_lhs_t lhs, _rhs_t rhs) : _lhs(lhs), _rhs(rhs)
{
}
assignment_t(const assignment_t&) = default;
assignment_t(assignment_t&&) = default;
assignment_t& operator=(const assignment_t&) = default;
assignment_t& operator=(assignment_t&&) = default;
~assignment_t() = default;
assignment_t(const assignment_t&) = default;
assignment_t(assignment_t&&) = default;
assignment_t& operator=(const assignment_t&) = default;
assignment_t& operator=(assignment_t&&) = default;
~assignment_t() = default;
_lhs_t _lhs;
_rhs_t _rhs;
};
_lhs_t _lhs;
_rhs_t _rhs;
};
template<typename Context, typename Lhs, typename Rhs>
struct serializer_t<Context, assignment_t<Lhs, Rhs>>
{
using T = assignment_t<Lhs, Rhs>;
using _serialize_check = serialize_check_of<Context, typename T::_lhs_t, typename T::_rhs_t>;
static Context& _(const T& t, Context& context)
{
serialize(simple_column(t._lhs), context);
context << "=";
serialize_operand(t._rhs, context);
return context;
}
};
template <typename Context, typename Lhs, typename Rhs>
struct serializer_t<Context, assignment_t<Lhs, Rhs>>
{
using T = assignment_t<Lhs, Rhs>;
using _serialize_check = serialize_check_of<Context, typename T::_lhs_t, typename T::_rhs_t>;
static Context& _(const T& t, Context& context)
{
serialize(simple_column(t._lhs), context);
context << "=";
serialize_operand(t._rhs, context);
return context;
}
};
}
#endif

View File

@@ -0,0 +1,65 @@
/*
* 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_AUTO_ALIAS_H
#define SQLPP_AUTO_ALIAS_H
#include <sqlpp11/alias.h>
namespace sqlpp
{
template <typename T, typename Enable = void>
struct has_auto_alias_t
{
static constexpr bool value = false;
};
template <typename T>
struct has_auto_alias_t<T, typename std::enable_if<not wrong_t<typename T::_auto_alias_t>::value>::type>
{
static constexpr bool value = true;
};
namespace detail
{
template <typename T, typename Enable = void>
struct auto_alias_impl
{
using type = T;
};
template <typename T>
struct auto_alias_impl<T, typename std::enable_if<has_auto_alias_t<T>::value>::type>
{
using type = expression_alias_t<T, typename T::_auto_alias_t>;
};
}
template <typename T>
using auto_alias_t = typename detail::auto_alias_impl<T>::type;
}
#endif

View File

@@ -1,114 +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_AVG_H
#define SQLPP_AVG_H
#include <sqlpp11/type_traits.h>
#include <sqlpp11/char_sequence.h>
namespace sqlpp
{
template<typename Flag, typename Expr>
struct avg_t:
public expression_operators<avg_t<Flag, Expr>, floating_point>,
public alias_operators<avg_t<Flag, Expr>>
{
using _traits = make_traits<floating_point, tag::is_expression, tag::is_selectable>;
using _nodes = detail::type_vector<Expr, aggregate_function>;
static_assert(is_noop<Flag>::value or std::is_same<distinct_t, Flag>::value, "avg() used with flag other than 'distinct'");
static_assert(is_numeric_t<Expr>::value, "avg() requires a value expression as argument");
struct _alias_t
{
static constexpr const char _literal[] = "avg_";
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
template<typename T>
struct _member_t
{
T avg;
T& operator()() { return avg; }
const T& operator()() const { return avg; }
};
};
avg_t(Expr expr):
_expr(expr)
{}
avg_t(const avg_t&) = default;
avg_t(avg_t&&) = default;
avg_t& operator=(const avg_t&) = default;
avg_t& operator=(avg_t&&) = default;
~avg_t() = default;
Expr _expr;
};
template<typename Context, typename Flag, typename Expr>
struct serializer_t<Context, avg_t<Flag, Expr>>
{
using _serialize_check = serialize_check_of<Context, Flag, Expr>;
using T = avg_t<Flag, Expr>;
static Context& _(const T& t, Context& context)
{
context << "AVG(";
if (std::is_same<distinct_t, Flag>::value)
{
serialize(Flag(), context);
context << ' ';
serialize_operand(t._expr, context);
}
else
{
serialize(t._expr, context);
}
context << ")";
return context;
}
};
template<typename T>
auto avg(T t) -> avg_t<noop, wrap_operand_t<T>>
{
static_assert(not contains_aggregate_function_t<wrap_operand_t<T>>::value, "avg() cannot be used on an aggregate function");
static_assert(is_numeric_t<wrap_operand_t<T>>::value, "avg() requires a value expression as argument");
return { t };
}
template<typename T>
auto avg(const distinct_t&, T t) -> avg_t<distinct_t, wrap_operand_t<T>>
{
static_assert(not contains_aggregate_function_t<wrap_operand_t<T>>::value, "avg() cannot be used on an aggregate function");
static_assert(is_numeric_t<wrap_operand_t<T>>::value, "avg() requires a value expression as argument");
return { t };
}
}
#endif

View 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

View File

@@ -1,17 +1,17 @@
/*
* 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
@@ -29,13 +29,13 @@
namespace sqlpp
{
struct bad_statement
{
template<typename... T>
bad_statement(T&&...) {}
};
struct bad_statement
{
template <typename... T>
bad_statement(T&&...)
{
}
};
}
#endif

View File

@@ -1,17 +1,17 @@
/*
* 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
@@ -28,129 +28,306 @@
#define SQLPP_DETAIL_BASIC_EXPRESSION_OPERATORS_H
#include <sqlpp11/value_type_fwd.h>
#include <sqlpp11/bad_statement.h>
#include <sqlpp11/portable_static_assert.h>
#include <sqlpp11/consistent.h>
#include <sqlpp11/alias.h>
#include <sqlpp11/sort_order.h>
#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
{
// basic operators
template<typename Expr, typename ValueType>
struct basic_expression_operators
{
template<typename T>
struct _is_valid_comparison_operand
{
static constexpr bool value =
(is_expression_t<T>::value // expressions are OK
or is_multi_expression_t<T>::value) // multi-expressions like ANY are OK for comparisons, too
and ValueType::template _is_valid_operand<T>::value // the correct value type is required, of course
;
};
SQLPP_PORTABLE_STATIC_ASSERT(assert_valid_rhs_comparison_operand_t, "invalid rhs operand in comparison");
template<typename T>
equal_to_t<Expr, wrap_operand_t<T>> operator==(T t) const
{
using rhs = wrap_operand_t<T>;
static_assert(_is_valid_comparison_operand<rhs>::value, "invalid rhs operand in comparison");
template <typename LhsValueType, typename RhsType>
using check_rhs_comparison_operand_t =
static_check_t<(is_expression_t<sqlpp::wrap_operand_t<RhsType>>::value // expressions are OK
or
is_multi_expression_t<sqlpp::wrap_operand_t<RhsType>>::value) // multi-expressions like ANY are
// OK for comparisons, too
and
LhsValueType::template _is_valid_operand<
sqlpp::wrap_operand_t<RhsType>>::value, // the correct value type is required, of course
assert_valid_rhs_comparison_operand_t>;
return { *static_cast<const Expr*>(this), {rhs{t}} };
}
SQLPP_PORTABLE_STATIC_ASSERT(assert_valid_in_arguments_t, "at least one operand of in() is not valid");
template<typename T>
not_equal_to_t<Expr, wrap_operand_t<T>> operator!=(T t) const
{
using rhs = wrap_operand_t<T>;
static_assert(_is_valid_comparison_operand<rhs>::value, "invalid rhs operand in comparison");
template <typename LhsValueType, typename... InTypes>
using check_rhs_in_arguments_t =
static_check_t<logic::all_t<check_rhs_comparison_operand_t<LhsValueType, InTypes>::value...>::value,
assert_valid_in_arguments_t>;
return { *static_cast<const Expr*>(this), {rhs{t}} };
}
namespace detail
{
template <bool Enable, template <typename Lhs> class Expr, typename Lhs>
struct new_unary_expression_impl
{
using type = bad_statement;
};
template<typename T>
less_than_t<Expr, wrap_operand_t<T>> operator<(T t) const
{
using rhs = wrap_operand_t<T>;
static_assert(_is_valid_comparison_operand<rhs>::value, "invalid rhs operand in comparison");
template <template <typename Lhs> class Expr, typename Lhs>
struct new_unary_expression_impl<true, Expr, Lhs>
{
using type = Expr<Lhs>;
};
}
template <typename Check, template <typename Lhs> class Expr, typename Lhs>
using new_unary_expression_t = typename detail::new_unary_expression_impl<Check::value, Expr, Lhs>::type;
return { *static_cast<const Expr*>(this), rhs{t} };
}
namespace detail
{
template <bool Enable, template <typename Lhs, typename Rhs> class Expr, typename Lhs, typename Rhs>
struct new_binary_expression_impl
{
using type = bad_statement;
};
template<typename T>
less_equal_t<Expr, wrap_operand_t<T>> operator<=(T t) const
{
using rhs = wrap_operand_t<T>;
static_assert(_is_valid_comparison_operand<rhs>::value, "invalid rhs operand in comparison");
template <template <typename Lhs, typename Rhs> class Expr, typename Lhs, typename Rhs>
struct new_binary_expression_impl<true, Expr, Lhs, Rhs>
{
using type = Expr<Lhs, Rhs>;
};
}
template <typename Check, template <typename Lhs, typename Rhs> class Expr, typename Lhs, typename Rhs>
using new_binary_expression_t = typename detail::new_binary_expression_impl<Check::value, Expr, Lhs, Rhs>::type;
return { *static_cast<const Expr*>(this), rhs{t} };
}
namespace detail
{
template <bool Enable, template <typename Lhs, typename... Rhs> class Expr, typename Lhs, typename... Rhs>
struct new_nary_expression_impl
{
using type = bad_statement;
};
template<typename T>
greater_than_t<Expr, wrap_operand_t<T>> operator>(T t) const
{
using rhs = wrap_operand_t<T>;
static_assert(_is_valid_comparison_operand<rhs>::value, "invalid rhs operand in comparison");
template <template <typename Lhs, typename... Rhs> class Expr, typename Lhs, typename... Rhs>
struct new_nary_expression_impl<true, Expr, Lhs, Rhs...>
{
using type = Expr<Lhs, Rhs...>;
};
}
template <typename Check, template <typename Lhs, typename... Rhs> class Expr, typename Lhs, typename... Rhs>
using new_nary_expression_t = typename detail::new_nary_expression_impl<Check::value, Expr, Lhs, Rhs...>::type;
return { *static_cast<const Expr*>(this), rhs{t} };
}
// basic operators
template <typename Expr, typename ValueType>
struct basic_expression_operators
{
template <template <typename Lhs, typename Rhs> class NewExpr, typename T>
using _new_binary_expression_t =
new_binary_expression_t<check_rhs_comparison_operand_t<ValueType, wrap_operand_t<T>>,
NewExpr,
Expr,
wrap_operand_t<T>>;
template<typename T>
greater_equal_t<Expr, wrap_operand_t<T>> operator>=(T t) const
{
using rhs = wrap_operand_t<T>;
static_assert(_is_valid_comparison_operand<rhs>::value, "invalid rhs operand in comparison");
// workaround for msvs bug
// template <template <typename Lhs, typename... Rhs> class NewExpr, typename... T>
// using _new_nary_expression_t =
// new_nary_expression_t<logic::all_t<check_rhs_comparison_operand_t<ValueType,
// wrap_operand_t<T>>::value...>,
// NewExpr,
// Expr,
// wrap_operand_t<T>...>;
template <template <typename Lhs, typename... Rhs> class NewExpr, typename... T>
struct _new_nary_expression
{
using type =
new_nary_expression_t<logic::all_t<check_rhs_comparison_operand_t<ValueType, wrap_operand_t<T>>::value...>,
NewExpr,
Expr,
wrap_operand_t<T>...>;
};
return { *static_cast<const Expr*>(this), rhs{t} };
}
template <typename T>
_new_binary_expression_t<equal_to_t, T> operator==(T t) const
{
using rhs = wrap_operand_t<T>;
check_rhs_comparison_operand_t<ValueType, rhs>::_();
is_null_t<Expr> is_null() const
{
return { *static_cast<const Expr*>(this) };
}
return {*static_cast<const Expr*>(this), {rhs{t}}};
}
is_not_null_t<Expr> is_not_null() const
{
return { *static_cast<const Expr*>(this) };
}
template <typename T>
_new_binary_expression_t<not_equal_to_t, T> operator!=(T t) const
{
using rhs = wrap_operand_t<T>;
check_rhs_comparison_operand_t<ValueType, rhs>::_();
sort_order_t<Expr, sort_type::asc> asc() const
{
return { *static_cast<const Expr*>(this) };
}
return {*static_cast<const Expr*>(this), {rhs{t}}};
}
sort_order_t<Expr, sort_type::desc> desc() const
{
return { *static_cast<const Expr*>(this) };
}
template <typename T>
_new_binary_expression_t<less_than_t, T> operator<(T t) const
{
using rhs = wrap_operand_t<T>;
check_rhs_comparison_operand_t<ValueType, rhs>::_();
// Hint: use value_list wrapper for containers...
template<typename... T>
in_t<Expr, wrap_operand_t<T>...> in(T... t) const
{
static_assert(logic::all_t<_is_valid_comparison_operand<wrap_operand_t<T>>::value...>::value, "at least one operand of in() is not valid");
return { *static_cast<const Expr*>(this), wrap_operand_t<T>{t}... };
}
return {*static_cast<const Expr*>(this), rhs{t}};
}
template<typename... T>
not_in_t<Expr, wrap_operand_t<T>...> not_in(T... t) const
{
static_assert(logic::all_t<_is_valid_comparison_operand<wrap_operand_t<T>>::value...>::value, "at least one operand of in() is not valid");
return { *static_cast<const Expr*>(this), wrap_operand_t<T>{t}... };
}
};
template <typename T>
_new_binary_expression_t<less_equal_t, T> operator<=(T t) const
{
using rhs = wrap_operand_t<T>;
check_rhs_comparison_operand_t<ValueType, rhs>::_();
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) };
}
};
return {*static_cast<const Expr*>(this), rhs{t}};
}
template <typename T>
_new_binary_expression_t<greater_than_t, T> operator>(T t) const
{
using rhs = wrap_operand_t<T>;
check_rhs_comparison_operand_t<ValueType, rhs>::_();
return {*static_cast<const Expr*>(this), rhs{t}};
}
template <typename T>
_new_binary_expression_t<greater_equal_t, T> operator>=(T t) const
{
using rhs = wrap_operand_t<T>;
check_rhs_comparison_operand_t<ValueType, rhs>::_();
return {*static_cast<const Expr*>(this), rhs{t}};
}
is_null_t<Expr> is_null() const
{
return {*static_cast<const Expr*>(this)};
}
is_not_null_t<Expr> is_not_null() const
{
return {*static_cast<const Expr*>(this)};
}
sort_order_t<Expr, sort_type::asc> asc() const
{
return {*static_cast<const Expr*>(this)};
}
sort_order_t<Expr, sort_type::desc> desc() const
{
return {*static_cast<const Expr*>(this)};
}
// Hint: use value_list wrapper for containers...
// workaround for msvs bug
// template <typename... T>
// _new_nary_expression_t<in_t, T...> in(T... t) const
// {
// check_rhs_in_arguments_t<ValueType, wrap_operand_t<T>...>::_();
// return {*static_cast<const Expr*>(this), wrap_operand_t<T>{t}...};
// }
template <typename... T>
typename _new_nary_expression<in_t, T...>::type in(T... t) const
{
check_rhs_in_arguments_t<ValueType, wrap_operand_t<T>...>::_();
return {*static_cast<const Expr*>(this), typename wrap_operand<T>::type{t}...};
}
// workaround for msvs bug
// template <typename... T>
// _new_nary_expression_t<not_in_t, T...> not_in(T... t) const
// {
// check_rhs_in_arguments_t<ValueType, wrap_operand_t<T>...>::_();
// return {*static_cast<const Expr*>(this), wrap_operand_t<T>{t}...};
// }
template <typename... T>
typename _new_nary_expression<not_in_t, T...>::type not_in(T... t) const
{
check_rhs_in_arguments_t<ValueType, wrap_operand_t<T>...>::_();
return {*static_cast<const Expr*>(this), typename wrap_operand<T>::type{t}...};
}
template <typename Defer = void>
auto operator not() const -> return_type_not_t<Expr, Defer>
{
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

View File

@@ -1,235 +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

View File

@@ -1,17 +1,17 @@
/*
* 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
@@ -32,54 +32,53 @@
namespace sqlpp
{
template<typename Database>
struct boolean_expression_t: public expression_operators<boolean_expression_t<Database>, boolean>
{
using _traits = make_traits<boolean, tag::is_expression>;
using _nodes = detail::type_vector<>;
template <typename Database>
struct boolean_expression_t : public expression_operators<boolean_expression_t<Database>, boolean>
{
using _traits = make_traits<boolean, tag::is_expression>;
using _nodes = detail::type_vector<>;
template<typename Expr>
boolean_expression_t(Expr expr):
_expr(expr)
{
static_assert(is_expression_t<Expr>::value, "boolean_expression requires a boolean expression argument");
static_assert(is_boolean_t<Expr>::value, "boolean_expression requires a boolean expression argument");
}
template <typename Expr>
boolean_expression_t(Expr expr)
: _expr(expr)
{
static_assert(is_expression_t<Expr>::value, "boolean_expression requires a boolean expression argument");
static_assert(is_boolean_t<Expr>::value, "boolean_expression requires a boolean expression argument");
}
boolean_expression_t(const boolean_expression_t&) = default;
boolean_expression_t(boolean_expression_t&&) = default;
boolean_expression_t& operator=(const boolean_expression_t&) = default;
boolean_expression_t& operator=(boolean_expression_t&&) = default;
~boolean_expression_t() = default;
boolean_expression_t(const boolean_expression_t&) = default;
boolean_expression_t(boolean_expression_t&&) = default;
boolean_expression_t& operator=(const boolean_expression_t&) = default;
boolean_expression_t& operator=(boolean_expression_t&&) = default;
~boolean_expression_t() = default;
interpretable_t<Database> _expr;
};
interpretable_t<Database> _expr;
};
template<typename Database, typename T>
boolean_expression_t<Database> boolean_expression(T t)
{
using Expr = wrap_operand_t<T>;
return {Expr{t}};
}
template <typename Database, typename T>
boolean_expression_t<Database> boolean_expression(T t)
{
using Expr = wrap_operand_t<T>;
return {Expr{t}};
}
template<typename Database, typename T>
boolean_expression_t<Database> boolean_expression(const Database&, T t)
{
return boolean_expression<Database>(t);
}
template <typename Database, typename T>
boolean_expression_t<Database> boolean_expression(const Database&, T t)
{
return boolean_expression<Database>(t);
}
template<typename Context, typename Database>
struct serializer_t<Context, boolean_expression_t<Database>>
{
using _serialize_check = consistent_t;
using T = boolean_expression_t<Database>;
static Context& _(const T& t, Context& context)
{
return serialize(t._expr, context);
}
};
template <typename Context, typename Database>
struct serializer_t<Context, boolean_expression_t<Database>>
{
using _serialize_check = consistent_t;
using T = boolean_expression_t<Database>;
static Context& _(const T& t, Context& context)
{
return serialize(t._expr, context);
}
};
}
#endif

195
include/sqlpp11/case.h Normal file
View File

@@ -0,0 +1,195 @@
/*
* 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_CASE_H
#define SQLPP_CASE_H
#include <sqlpp11/type_traits.h>
#include <sqlpp11/char_sequence.h>
#include <sqlpp11/data_types/boolean.h>
#include <sqlpp11/detail/type_set.h>
namespace sqlpp
{
SQLPP_PORTABLE_STATIC_ASSERT(assert_case_else_expression_t, "argument is not a value expression in else()");
SQLPP_PORTABLE_STATIC_ASSERT(assert_case_then_else_same_type_t,
"argument of then() and else() are not of the same type");
template <typename Then, typename Else>
using check_case_else_t = static_combined_check_t<
static_check_t<is_expression_t<wrap_operand_t<Else>>::value, assert_case_else_expression_t>,
static_check_t<logic::any_t<is_sql_null_t<Then>::value,
is_sql_null_t<wrap_operand_t<Else>>::value,
std::is_same<value_type_of<Then>, value_type_of<wrap_operand_t<Else>>>::value>::value,
assert_case_then_else_same_type_t>>;
SQLPP_PORTABLE_STATIC_ASSERT(assert_case_then_expression_t, "argument is not a value expression in then()");
template <typename Then>
using check_case_then_t =
static_check_t<logic::all_t<is_expression_t<wrap_operand_t<Then>>::value>::value, assert_case_then_expression_t>;
SQLPP_PORTABLE_STATIC_ASSERT(assert_case_when_boolean_expression_t,
"argument is not a boolean expression in case_when()");
template <typename When>
using check_case_when_t = static_check_t<
logic::all_t<is_boolean_t<wrap_operand_t<When>>::value, is_expression_t<wrap_operand_t<When>>::value>::value,
assert_case_when_boolean_expression_t>;
template <typename When, typename Then, typename Else>
struct case_t
: public expression_operators<
case_t<When, Then, Else>,
typename std::conditional<is_sql_null_t<Then>::value, value_type_of<Else>, value_type_of<Then>>::type>,
public alias_operators<case_t<When, Then, Else>>
{
using _traits = make_traits<value_type_of<Then>, tag::is_expression>;
using _nodes = detail::type_vector<When, Then, Else>;
case_t(When when, Then then, Else else_) : _when(when), _then(then), _else(else_)
{
}
case_t(const case_t&) = default;
case_t(case_t&&) = default;
case_t& operator=(const case_t&) = default;
case_t& operator=(case_t&&) = default;
~case_t() = default;
When _when;
Then _then;
Else _else;
};
template <typename When, typename Then>
class case_then_t
{
template <typename Else>
auto _else_impl(const std::true_type&, Else else_) -> case_t<When, Then, Else>
{
return {_when, _then, else_};
}
template <typename Else>
auto _else_impl(const std::false_type&, Else else_) -> void;
public:
case_then_t(When when, Then then) : _when(when), _then(then)
{
}
case_then_t(const case_then_t&) = default;
case_then_t(case_then_t&&) = default;
case_then_t& operator=(const case_then_t&) = default;
case_then_t& operator=(case_then_t&&) = default;
~case_then_t() = default;
template <typename Else>
auto else_(Else else_) -> decltype(this->_else_impl(check_case_else_t<Then, Else>{}, else_))
{
check_case_else_t<Then, Else>::_();
return _else_impl(check_case_else_t<Then, Else>{}, else_);
}
private:
When _when;
Then _then;
};
template <typename When>
class case_when_t
{
template <typename Then>
auto _then_impl(const std::true_type&, Then t) -> case_then_t<When, wrap_operand_t<Then>>
{
return {_when, t};
}
template <typename Then>
auto _then_impl(const std::false_type&, Then t) -> void;
public:
case_when_t(When when) : _when(when)
{
}
case_when_t(const case_when_t&) = default;
case_when_t(case_when_t&&) = default;
case_when_t& operator=(const case_when_t&) = default;
case_when_t& operator=(case_when_t&&) = default;
~case_when_t() = default;
template <typename Then>
auto then(Then t) -> decltype(this->_then_impl(check_case_then_t<Then>{}, t))
{
check_case_then_t<Then>::_();
return _then_impl(check_case_then_t<Then>{}, t);
}
private:
When _when;
};
template <typename Context, typename When, typename Then, typename Else>
struct serializer_t<Context, case_t<When, Then, Else>>
{
using _serialize_check = serialize_check_of<When, Then, Else>;
using T = case_t<When, Then, Else>;
static Context& _(const T& t, Context& context)
{
context << "(CASE WHEN ";
serialize(t._when, context);
context << " THEN ";
serialize(t._then, context);
context << " ELSE ";
serialize(t._else, context);
context << " END)";
return context;
}
};
namespace detail
{
template <typename When>
auto case_when_impl(const std::true_type&, When when) -> case_when_t<wrap_operand_t<When>>
{
return {when};
}
template <typename When>
auto case_when_impl(const std::false_type&, When when) -> void;
}
template <typename When>
auto case_when(When when) -> decltype(detail::case_when_impl(check_case_when_t<When>{}, when))
{
check_case_when_t<When>::_();
return detail::case_when_impl(typename check_case_when_t<When>::type{}, when);
}
}
#endif

View File

@@ -1,17 +1,17 @@
/*
* 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
@@ -31,26 +31,28 @@
namespace sqlpp
{
template<char... Cs> struct char_sequence
{
static const char* char_ptr()
{
static char s[] = {Cs...};
return s;
};
};
template <char... Cs>
struct char_sequence
{
static const char* char_ptr()
{
static char s[] = {Cs...};
return s;
};
};
template<std::size_t N, const char (&s) [N], typename T>
struct make_char_sequence_impl;
template <std::size_t N, const char(&s)[N], typename T>
struct make_char_sequence_impl;
template<std::size_t N, const char (&s) [N], std::size_t... i>
struct make_char_sequence_impl<N, s, sqlpp::detail::index_sequence<i...>>
{
using type = char_sequence<s[i]...>;
};
template <std::size_t N, const char(&s)[N], std::size_t... i>
struct make_char_sequence_impl<N, s, sqlpp::detail::index_sequence<i...>>
{
using type = char_sequence<s[i]...>;
};
template<std::size_t N, const char (&Input) [N]>
using make_char_sequence = typename make_char_sequence_impl<sizeof(Input), Input, sqlpp::detail::make_index_sequence<sizeof(Input)>>::type;
template <std::size_t N, const char(&Input)[N]>
using make_char_sequence =
typename make_char_sequence_impl<sizeof(Input), Input, sqlpp::detail::make_index_sequence<sizeof(Input)>>::type;
}
#endif

43
include/sqlpp11/chrono.h Normal file
View 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_CHRONO_H
#define SQLPP_CHRONO_H
#include <chrono>
namespace sqlpp
{
namespace chrono
{
using days = std::chrono::duration<int, std::ratio_multiply<std::ratio<24>, std::chrono::hours::period>>;
using day_point = std::chrono::time_point<std::chrono::system_clock, days>;
using microsecond_point = std::chrono::time_point<std::chrono::system_clock, std::chrono::microseconds>;
}
}
#endif

View File

@@ -1,17 +1,17 @@
/*
* 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
@@ -41,84 +41,94 @@
namespace sqlpp
{
template<typename Table, typename ColumnSpec>
struct column_t:
public expression_operators<column_t<Table, ColumnSpec>, value_type_of<ColumnSpec>>,
public column_operators<column_t<Table, ColumnSpec>, value_type_of<ColumnSpec>>
{
struct _traits
{
using _value_type = value_type_of<ColumnSpec>;
using _tags = detail::make_joined_set_t<detail::type_set<tag::is_column, tag::is_expression, tag::is_selectable>, typename ColumnSpec::_traits::_tags>;
};
template <typename Table, typename ColumnSpec>
struct column_t : public expression_operators<column_t<Table, ColumnSpec>, value_type_of<ColumnSpec>>,
public column_operators<column_t<Table, ColumnSpec>, value_type_of<ColumnSpec>>
{
struct _traits
{
using _value_type = value_type_of<ColumnSpec>;
using _tags = detail::make_joined_set_t<detail::type_set<tag::is_column, tag::is_expression, tag::is_selectable>,
typename ColumnSpec::_traits::_tags>;
};
using _nodes = detail::type_vector<>;
using _required_tables = detail::type_set<Table>;
using _can_be_null = column_spec_can_be_null_t<ColumnSpec>;
using _nodes = detail::type_vector<>;
using _required_tables = detail::type_set<Table>;
using _can_be_null = column_spec_can_be_null_t<ColumnSpec>;
using _spec_t = ColumnSpec;
using _table = Table;
using _alias_t = typename _spec_t::_alias_t;
using _spec_t = ColumnSpec;
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>;
column_t() = default;
column_t(const column_t&) = default;
column_t(column_t&&) = default;
column_t& operator=(const column_t&) = default;
column_t& operator=(column_t&&) = default;
~column_t() = default;
column_t() = default;
column_t(const column_t&) = default;
column_t(column_t&&) = default;
column_t& operator=(const column_t&) = default;
column_t& operator=(column_t&&) = default;
~column_t() = default;
template<typename T = _table>
auto table() const -> _table
{
static_assert(is_table_t<T>::value, "cannot call get_table for columns of a sub-selects or cte");
return _table{};
}
template <typename T = _table>
auto table() const -> _table
{
static_assert(is_table_t<T>::value, "cannot call get_table for columns of a sub-selects or cte");
return _table{};
}
template<typename alias_provider>
expression_alias_t<column_t, alias_provider> as(const alias_provider&) const
{
return { *this };
}
template <typename alias_provider>
expression_alias_t<column_t, alias_provider> as(const alias_provider&) const
{
return {*this};
}
template<typename T>
auto operator =(T t) const -> assignment_t<column_t, wrap_operand_t<T>>
{
using rhs = wrap_operand_t<T>;
static_assert(_is_valid_operand<rhs>::value, "invalid rhs assignment operand");
template <typename T>
auto operator=(T t) const -> assignment_t<column_t, wrap_operand_t<T>>
{
using rhs = wrap_operand_t<T>;
static_assert(_is_valid_assignment_operand<rhs>::value, "invalid rhs assignment operand");
return { *this, {rhs{t}} };
}
return {*this, {rhs{t}}};
}
auto operator =(null_t) const
->assignment_t<column_t, null_t>
{
static_assert(can_be_null_t<column_t>::value, "column cannot be null");
return { *this, null_t{} };
}
auto operator=(null_t) const -> assignment_t<column_t, null_t>
{
static_assert(can_be_null_t<column_t>::value, "column cannot be null");
return {*this, null_t{}};
}
auto operator =(default_value_t) const
->assignment_t<column_t, default_value_t>
{
return { *this, default_value_t{} };
}
};
auto operator=(default_value_t) const -> assignment_t<column_t, default_value_t>
{
return {*this, default_value_t{}};
}
};
template<typename Context, typename... Args>
struct serializer_t<Context, column_t<Args...>>
{
using _serialize_check = consistent_t;
using T = column_t<Args...>;
static Context& _(const T& t, Context& context)
{
context << name_of<typename T::_table>::char_ptr() << '.' << name_of<T>::char_ptr();
return context;
}
};
// workaround for msvs bug https://connect.microsoft.com/VisualStudio/feedback/details/2173053
// template <typename Context, typename... Args>
// struct serializer_t<Context, column_t<Args...>>
// {
// using _serialize_check = consistent_t;
// using T = column_t<Args...>;
//
// static Context& _(const T&, Context& context)
// {
// context << name_of<typename T::_table>::char_ptr() << '.' << name_of<T>::char_ptr();
// return context;
// }
// };
template <typename Context, typename Args1, typename Args2>
struct serializer_t<Context, column_t<Args1, Args2>>
{
using _serialize_check = consistent_t;
using T = column_t<Args1, Args2>;
static Context& _(const T&, Context& context)
{
context << name_of<typename T::_table>::char_ptr() << '.' << name_of<T>::char_ptr();
return context;
}
};
}
#endif

View File

@@ -24,14 +24,13 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SQLPP_COLUMN_FWD_H
#define SQLPP_COLUMN_FWD_H
namespace sqlpp
{
template<typename Table, typename ColumnSpec>
struct column_t;
template <typename Table, typename ColumnSpec>
struct column_t;
}
#endif

View File

@@ -1,17 +1,17 @@
/*
* 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
@@ -27,9 +27,6 @@
#ifndef SQLPP_COLUMN_TYPES_H
#define SQLPP_COLUMN_TYPES_H
#include <sqlpp11/boolean.h>
#include <sqlpp11/integral.h>
#include <sqlpp11/floating_point.h>
#include <sqlpp11/text.h>
#include <sqlpp11/data_types.h>
#endif

View File

@@ -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_CONCAT_H
#define SQLPP_CONCAT_H
#include <sqlpp11/type_traits.h>
#include <sqlpp11/char_sequence.h>
#include <sqlpp11/interpret_tuple.h>
#include <sqlpp11/basic_expression_operators.h>
#include <sqlpp11/logic.h>
namespace sqlpp
{
// FIXME: Remove First, inherit from text_t
template<typename First, typename... Args>
struct concat_t:
public expression_operators<concat_t<First, Args...>, value_type_of<First>>,
public alias_operators<concat_t<First, Args...>>
{
using _traits = make_traits<value_type_of<First>, tag::is_expression, tag::is_selectable>;
using _nodes = detail::type_vector<First, Args...>;
static_assert(sizeof...(Args) > 0, "concat requires two arguments at least");
static_assert(logic::all_t<is_text_t<First>::value, is_text_t<Args>::value...>::value, "at least one non-text argument detected in concat()");
struct _alias_t
{
static constexpr const char _literal[] = "concat_";
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
template<typename T>
struct _member_t
{
T concat;
};
};
concat_t(First first, Args... args):
_args(first, args...)
{}
concat_t(const concat_t&) = default;
concat_t(concat_t&&) = default;
concat_t& operator=(const concat_t&) = default;
concat_t& operator=(concat_t&&) = default;
~concat_t() = default;
std::tuple<First, Args...> _args;
};
template<typename Context, typename First, typename... Args>
struct serializer_t<Context, concat_t<First, Args...>>
{
using _serialize_check = serialize_check_of<Context, First, Args...>;
using T = concat_t<First, Args...>;
static Context& _(const T& t, Context& context)
{
context << "(";
interpret_tuple(t._args, "||", context);
context << ")";
return context;
}
};
}
#endif

View File

@@ -1,17 +1,17 @@
/*
* 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
@@ -29,8 +29,9 @@
namespace sqlpp
{
struct connection {};
struct connection
{
};
}
#endif

View File

@@ -0,0 +1,40 @@
/*
* 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_CONSISTENT_H
#define SQLPP_CONSISTENT_H
#include <type_traits>
namespace sqlpp
{
struct consistent_t : std::true_type
{
static void _(){};
};
}
#endif

View File

@@ -1,116 +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_COUNT_H
#define SQLPP_COUNT_H
#include <sqlpp11/char_sequence.h>
#include <sqlpp11/select_flags.h>
#include <sqlpp11/integral.h>
namespace sqlpp
{
template<typename Flag, typename Expr>
struct count_t:
public expression_operators<count_t<Flag, Expr>, integral>,
public alias_operators<count_t<Flag, Expr>>
{
using _traits = make_traits<integral, tag::is_expression, tag::is_selectable>;
using _nodes = detail::type_vector<Expr, aggregate_function>;
using _can_be_null = std::false_type;
static_assert(is_noop<Flag>::value or std::is_same<distinct_t, Flag>::value, "count() used with flag other than 'distinct'");
struct _alias_t
{
static constexpr const char _literal[] = "count_";
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
template<typename T>
struct _member_t
{
T count;
T& operator()() { return count; }
const T& operator()() const { return count; }
};
};
count_t(const Expr expr):
_expr(expr)
{}
count_t(const count_t&) = default;
count_t(count_t&&) = default;
count_t& operator=(const count_t&) = default;
count_t& operator=(count_t&&) = default;
~count_t() = default;
Expr _expr;
};
template<typename Context, typename Flag, typename Expr>
struct serializer_t<Context, count_t<Flag, Expr>>
{
using _serialize_check = serialize_check_of<Context, Flag, Expr>;
using T = count_t<Flag, Expr>;
static Context& _(const T& t, Context& context)
{
context << "COUNT(";
if (std::is_same<distinct_t, Flag>::value)
{
serialize(Flag(), context);
context << ' ';
serialize_operand(t._expr, context);
}
else
{
serialize(t._expr, context);
}
context << ")";
return context;
}
};
template<typename T>
auto count(T t) -> count_t<noop, wrap_operand_t<T>>
{
static_assert(not contains_aggregate_function_t<wrap_operand_t<T>>::value, "count() cannot be used on an aggregate function");
static_assert(is_expression_t<wrap_operand_t<T>>::value, "count() requires an expression as argument");
return { t };
}
template<typename T>
auto count(const distinct_t&, T t) -> count_t<distinct_t, wrap_operand_t<T>>
{
static_assert(not contains_aggregate_function_t<wrap_operand_t<T>>::value, "count() cannot be used on an aggregate function");
static_assert(is_expression_t<wrap_operand_t<T>>::value, "count() requires an expression as argument");
return { t };
}
}
#endif

View File

@@ -1,17 +1,17 @@
/*
* 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
@@ -40,222 +40,240 @@
namespace sqlpp
{
template<typename Flag, typename Lhs, typename Rhs>
struct cte_union_t
{
using _nodes = detail::type_vector<>;
using _required_ctes = detail::make_joined_set_t<required_ctes_of<Lhs>, required_ctes_of<Rhs>>;
using _parameters = detail::type_vector_cat_t<parameters_of<Lhs>, parameters_of<Rhs>>;
template <typename Flag, typename Lhs, typename Rhs>
struct cte_union_t
{
using _nodes = detail::type_vector<>;
using _required_ctes = detail::make_joined_set_t<required_ctes_of<Lhs>, required_ctes_of<Rhs>>;
using _parameters = detail::type_vector_cat_t<parameters_of<Lhs>, parameters_of<Rhs>>;
cte_union_t(Lhs lhs, Rhs rhs):
_lhs(lhs),
_rhs(rhs)
{}
cte_union_t(Lhs lhs, Rhs rhs) : _lhs(lhs), _rhs(rhs)
{
}
cte_union_t(const cte_union_t&) = default;
cte_union_t(cte_union_t&&) = default;
cte_union_t& operator=(const cte_union_t&) = default;
cte_union_t& operator=(cte_union_t&&) = default;
~cte_union_t() = default;
cte_union_t(const cte_union_t&) = default;
cte_union_t(cte_union_t&&) = default;
cte_union_t& operator=(const cte_union_t&) = default;
cte_union_t& operator=(cte_union_t&&) = default;
~cte_union_t() = default;
Lhs _lhs;
Rhs _rhs;
};
Lhs _lhs;
Rhs _rhs;
};
// Interpreters
template<typename Context, typename Flag, typename Lhs, typename Rhs>
struct serializer_t<Context, cte_union_t<Flag, Lhs, Rhs>>
{
using _serialize_check = serialize_check_of<Context, Lhs, Rhs>;
using T = cte_union_t<Flag, Lhs, Rhs>;
// Interpreters
template <typename Context, typename Flag, typename Lhs, typename Rhs>
struct serializer_t<Context, cte_union_t<Flag, Lhs, Rhs>>
{
using _serialize_check = serialize_check_of<Context, Lhs, Rhs>;
using T = cte_union_t<Flag, Lhs, Rhs>;
static Context& _(const T& t, Context& context)
{
serialize(t._lhs, context);
context << " UNION ";
serialize(Flag{}, context);
context << " ";
serialize(t._rhs, context);
return context;
}
};
static Context& _(const T& t, Context& context)
{
serialize(t._lhs, context);
context << " UNION ";
serialize(Flag{}, context);
context << " ";
serialize(t._rhs, context);
return context;
}
};
template<typename AliasProvider, typename Statement, typename... FieldSpecs>
struct cte_t;
template <typename AliasProvider, typename Statement, typename... FieldSpecs>
struct cte_t;
template<typename AliasProvider>
struct cte_ref_t;
template <typename AliasProvider>
struct cte_ref_t;
template<typename AliasProvider, typename Statement, typename... FieldSpecs>
auto from_table(cte_t<AliasProvider, Statement, FieldSpecs...> t) -> cte_ref_t<AliasProvider>
{
return cte_ref_t<AliasProvider>{};
}
template <typename AliasProvider, typename Statement, typename... FieldSpecs>
auto from_table(cte_t<AliasProvider, Statement, FieldSpecs...>) -> cte_ref_t<AliasProvider>
{
return cte_ref_t<AliasProvider>{};
}
template<typename AliasProvider, typename Statement, typename... FieldSpecs>
struct from_table_impl<cte_t<AliasProvider, Statement, FieldSpecs...>>
{
using type = cte_ref_t<AliasProvider>;
};
template <typename AliasProvider, typename Statement, typename... FieldSpecs>
struct from_table_impl<cte_t<AliasProvider, Statement, FieldSpecs...>>
{
using type = cte_ref_t<AliasProvider>;
};
template <typename FieldSpec>
struct cte_column_spec_t
{
using _alias_t = typename FieldSpec::_alias_t;
template<typename FieldSpec>
struct cte_column_spec_t
{
using _alias_t = typename FieldSpec::_alias_t;
using _traits = make_traits<value_type_of<FieldSpec>,
tag::must_not_insert,
tag::must_not_update,
tag_if<tag::can_be_null, column_spec_can_be_null_t<FieldSpec>::value>>;
};
using _traits = make_traits<value_type_of<FieldSpec>,
tag::must_not_insert,
tag::must_not_update,
tag_if<tag::can_be_null, column_spec_can_be_null_t<FieldSpec>::value>
>;
};
template <typename AliasProvider, typename Statement, typename ResultRow>
struct make_cte_impl
{
using type = void;
};
template<typename AliasProvider, typename Statement, typename ResultRow>
struct make_cte_impl
{
using type = void;
};
template <typename AliasProvider, typename Statement, typename... FieldSpecs>
struct make_cte_impl<AliasProvider, Statement, result_row_t<void, FieldSpecs...>>
{
using type = cte_t<AliasProvider, Statement, FieldSpecs...>;
};
template<typename AliasProvider, typename Statement, typename... FieldSpecs>
struct make_cte_impl<AliasProvider, Statement, result_row_t<void, FieldSpecs...>>
{
using type = cte_t<AliasProvider, Statement, FieldSpecs...>;
};
template <typename AliasProvider, typename Statement>
using make_cte_t = typename make_cte_impl<AliasProvider, Statement, get_result_row_t<Statement>>::type;
template<typename AliasProvider, typename Statement>
using make_cte_t = typename make_cte_impl<AliasProvider, Statement, get_result_row_t<Statement>>::type;
// workaround for msvc unknown internal error
// template <typename AliasProvider, typename Statement, typename... FieldSpecs>
// struct cte_t
// : public member_t<cte_column_spec_t<FieldSpecs>, column_t<AliasProvider, cte_column_spec_t<FieldSpecs>>>...
template <typename AliasProvider, typename FieldSpec>
struct cte_base
{
using type = member_t<cte_column_spec_t<FieldSpec>, column_t<AliasProvider, cte_column_spec_t<FieldSpec>>>;
};
template<typename AliasProvider, typename Statement, typename... FieldSpecs>
struct cte_t: public member_t<cte_column_spec_t<FieldSpecs>, column_t<AliasProvider, cte_column_spec_t<FieldSpecs>>>...
{
using _traits = make_traits<no_value_t, tag::is_cte, tag::is_table>; // FIXME: is table? really?
using _nodes = detail::type_vector<>;
using _required_ctes = detail::make_joined_set_t<required_ctes_of<Statement>, detail::type_set<AliasProvider>>;
using _parameters = parameters_of<Statement>;
template <typename AliasProvider, typename Statement, typename... FieldSpecs>
struct cte_t : public cte_base<AliasProvider, FieldSpecs>::type...
{
using _traits = make_traits<no_value_t, tag::is_cte, tag::is_table>; // FIXME: is table? really?
using _nodes = detail::type_vector<>;
using _required_ctes = detail::make_joined_set_t<required_ctes_of<Statement>, detail::type_set<AliasProvider>>;
using _parameters = parameters_of<Statement>;
using _alias_t = typename AliasProvider::_alias_t;
constexpr static bool _is_recursive = detail::is_element_of<AliasProvider, required_ctes_of<Statement>>::value;
using _alias_t = typename AliasProvider::_alias_t;
constexpr static bool _is_recursive = detail::is_element_of<AliasProvider, required_ctes_of<Statement>>::value;
using _column_tuple_t = std::tuple<column_t<AliasProvider, cte_column_spec_t<FieldSpecs>>...>;
using _column_tuple_t = std::tuple<column_t<AliasProvider, cte_column_spec_t<FieldSpecs>>...>;
template<typename... T>
using _check = logic::all_t<is_statement_t<T>::value...>;
// workaround for msvc bug https://connect.microsoft.com/VisualStudio/Feedback/Details/2086629
// template <typename... T>
// using _check = logic::all_t<is_statement_t<T>::value...>;
template <typename... T>
struct _check : logic::all_t<is_statement_t<T>::value...>
{
};
using _result_row_t = result_row_t<void, FieldSpecs...>;
using _result_row_t = result_row_t<void, FieldSpecs...>;
template<typename Rhs>
auto union_distinct(Rhs rhs) const
-> typename std::conditional<_check<Rhs>::value, cte_t<AliasProvider, cte_union_t<distinct_t, Statement, Rhs>, FieldSpecs...>, bad_statement>::type
{
static_assert(is_statement_t<Rhs>::value, "argument of union call has to be a statement");
static_assert(has_policy_t<Rhs, is_select_t>::value, "argument of union call has to be a select");
static_assert(has_result_row_t<Rhs>::value, "argument of a union has to be a (complete) select statement");
template <typename Rhs>
auto union_distinct(Rhs rhs) const ->
typename std::conditional<_check<Rhs>::value,
cte_t<AliasProvider, cte_union_t<distinct_t, Statement, Rhs>, FieldSpecs...>,
bad_statement>::type
{
static_assert(is_statement_t<Rhs>::value, "argument of union call has to be a statement");
static_assert(has_policy_t<Rhs, is_select_t>::value, "argument of union call has to be a select");
static_assert(has_result_row_t<Rhs>::value, "argument of a union has to be a (complete) select statement");
static_assert(std::is_same<_result_row_t, get_result_row_t<Rhs>>::value, "both select statements in a union have to have the same result columns (type and name)");
static_assert(std::is_same<_result_row_t, get_result_row_t<Rhs>>::value,
"both select statements in a union have to have the same result columns (type and name)");
return _union_impl<void, distinct_t>(_check<Rhs>{}, rhs);
}
return _union_impl<void, distinct_t>(_check<Rhs>{}, rhs);
}
template<typename Rhs>
auto union_all(Rhs rhs) const
-> typename std::conditional<_check<Rhs>::value, cte_t<AliasProvider, cte_union_t<all_t, Statement, Rhs>, FieldSpecs...>, bad_statement>::type
{
static_assert(is_statement_t<Rhs>::value, "argument of union call has to be a statement");
static_assert(has_policy_t<Rhs, is_select_t>::value, "argument of union call has to be a select");
static_assert(has_result_row_t<Rhs>::value, "argument of a union has to be a (complete) select statement");
template <typename Rhs>
auto union_all(Rhs rhs) const ->
typename std::conditional<_check<Rhs>::value,
cte_t<AliasProvider, cte_union_t<all_t, Statement, Rhs>, FieldSpecs...>,
bad_statement>::type
{
static_assert(is_statement_t<Rhs>::value, "argument of union call has to be a statement");
static_assert(has_policy_t<Rhs, is_select_t>::value, "argument of union call has to be a select");
static_assert(has_result_row_t<Rhs>::value, "argument of a union has to be a (complete) select statement");
static_assert(std::is_same<_result_row_t, get_result_row_t<Rhs>>::value, "both select statements in a union have to have the same result columns (type and name)");
static_assert(std::is_same<_result_row_t, get_result_row_t<Rhs>>::value,
"both select statements in a union have to have the same result columns (type and name)");
return _union_impl<all_t>(_check<Rhs>{}, rhs);
}
return _union_impl<all_t>(_check<Rhs>{}, rhs);
}
private:
template<typename Flag, typename Rhs>
auto _union_impl(const std::false_type&, Rhs rhs) const
-> bad_statement;
private:
template <typename Flag, typename Rhs>
auto _union_impl(const std::false_type&, Rhs rhs) const -> bad_statement;
template<typename Flag, typename Rhs>
auto _union_impl(const std::true_type&, Rhs rhs) const
-> cte_t<AliasProvider, cte_union_t<Flag, Statement, Rhs>, FieldSpecs...>
{
return cte_union_t<Flag, Statement, Rhs>{_statement, rhs};
}
template <typename Flag, typename Rhs>
auto _union_impl(const std::true_type&, Rhs rhs) const
-> cte_t<AliasProvider, cte_union_t<Flag, Statement, Rhs>, FieldSpecs...>
{
return cte_union_t<Flag, Statement, Rhs>{_statement, rhs};
}
public:
public:
cte_t(Statement statement) : _statement(statement)
{
}
cte_t(const cte_t&) = default;
cte_t(cte_t&&) = default;
cte_t& operator=(const cte_t&) = default;
cte_t& operator=(cte_t&&) = default;
~cte_t() = default;
cte_t(Statement statement): _statement(statement){}
cte_t(const cte_t&) = default;
cte_t(cte_t&&) = default;
cte_t& operator=(const cte_t&) = default;
cte_t& operator=(cte_t&&) = default;
~cte_t() = default;
Statement _statement;
};
Statement _statement;
};
template <typename Context, typename AliasProvider, typename Statement, typename... ColumnSpecs>
struct serializer_t<Context, cte_t<AliasProvider, Statement, ColumnSpecs...>>
{
using _serialize_check = serialize_check_of<Context, Statement>;
using T = cte_t<AliasProvider, Statement, ColumnSpecs...>;
template<typename Context, typename AliasProvider, typename Statement, typename... ColumnSpecs>
struct serializer_t<Context, cte_t<AliasProvider, Statement, ColumnSpecs...>>
{
using _serialize_check = serialize_check_of<Context, Statement>;
using T = cte_t<AliasProvider, Statement, ColumnSpecs...>;
static Context& _(const T& t, Context& context)
{
context << name_of<T>::char_ptr() << " AS (";
serialize(t._statement, context);
context << ")";
return context;
}
};
static Context& _(const T& t, Context& context)
{
context << name_of<T>::char_ptr() << " AS (";
serialize(t._statement, context);
context << ")";
return context;
}
};
// The cte_t is displayed as AliasProviderName except within the with:
// - the with needs the
// AliasProviderName AS (ColumnNames) (select/union)
// The result row of the select should not have dynamic parts
template <typename AliasProvider>
struct cte_ref_t
{
using _traits = make_traits<no_value_t, tag::is_alias, tag::is_cte, tag::is_table>; // FIXME: is table? really?
using _nodes = detail::type_vector<>;
using _required_ctes = detail::make_type_set_t<AliasProvider>;
using _provided_tables = detail::type_set<AliasProvider>;
using _alias_t = typename AliasProvider::_alias_t;
// The cte_t is displayed as AliasProviderName except within the with:
// - the with needs the
// AliasProviderName AS (ColumnNames) (select/union)
// The result row of the select should not have dynamic parts
template<typename AliasProvider>
struct cte_ref_t
{
using _traits = make_traits<no_value_t, tag::is_alias, tag::is_cte, tag::is_table>; // FIXME: is table? really?
using _nodes = detail::type_vector<>;
using _required_ctes = detail::make_type_set_t<AliasProvider>;
using _provided_tables = detail::type_set<AliasProvider>;
template <typename Statement>
auto as(Statement statement) -> make_cte_t<AliasProvider, Statement>
{
static_assert(required_tables_of<Statement>::size::value == 0,
"common table expression must not use unknown tables");
static_assert(not detail::is_element_of<AliasProvider, required_ctes_of<Statement>>::value,
"common table expression must not self-reference in the first part, use union_all/union_distinct "
"for recursion");
static_assert(is_static_result_row_t<get_result_row_t<Statement>>::value,
"ctes must not have dynamically added columns");
using _alias_t = typename AliasProvider::_alias_t;
return {statement};
}
};
template<typename Statement>
auto as(Statement statement)
-> make_cte_t<AliasProvider, Statement>
{
static_assert(required_tables_of<Statement>::size::value == 0, "common table expression must not use unknown tables");
static_assert(not detail::is_element_of<AliasProvider, required_ctes_of<Statement>>::value, "common table expression must not self-reference in the first part, use union_all/union_distinct for recursion");
static_assert(is_static_result_row_t<get_result_row_t<Statement>>::value, "ctes must not have dynamically added columns");
template <typename Context, typename AliasProvider>
struct serializer_t<Context, cte_ref_t<AliasProvider>>
{
using _serialize_check = consistent_t;
using T = cte_ref_t<AliasProvider>;
return { statement };
}
};
template<typename Context, typename AliasProvider>
struct serializer_t<Context, cte_ref_t<AliasProvider>>
{
using _serialize_check = consistent_t;
using T = cte_ref_t<AliasProvider>;
static Context& _(const T& t, Context& context)
{
context << name_of<T>::char_ptr();
return context;
}
};
template<typename AliasProvider>
auto cte(const AliasProvider&)
-> cte_ref_t<AliasProvider>
{
return {};
}
static Context& _(const T&, Context& context)
{
context << name_of<T>::char_ptr();
return context;
}
};
template <typename AliasProvider>
auto cte(const AliasProvider&) -> cte_ref_t<AliasProvider>
{
return {};
}
}
#endif

View File

@@ -1,17 +1,17 @@
/*
* 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
@@ -34,111 +34,108 @@
namespace sqlpp
{
template<typename Database, typename... Parts>
struct custom_query_t;
template <typename Database, typename... Parts>
struct custom_query_t;
namespace detail
{
template<typename Db, typename... Parts>
struct custom_parts_t
{
using _custom_query_t = custom_query_t<Db, Parts...>;
using _result_type_provider = detail::get_first_if<is_return_value_t, noop, Parts...>;
using _result_methods_t = typename _result_type_provider::template _result_methods_t<_result_type_provider>;
};
}
namespace detail
{
template <typename Db, typename... Parts>
struct custom_parts_t
{
using _custom_query_t = custom_query_t<Db, Parts...>;
using _result_type_provider = detail::get_first_if<is_return_value_t, noop, Parts...>;
using _result_methods_t = typename _result_type_provider::template _result_methods_t<_result_type_provider>;
};
}
template<typename Database, typename... Parts>
struct custom_query_t:
private detail::custom_parts_t<Database, Parts...>::_result_methods_t
{
using _methods_t = typename detail::custom_parts_t<Database, Parts...>::_result_methods_t;
using _traits = make_traits<no_value_t, tag::is_statement>;
using _nodes = detail::type_vector<Parts...>;
template <typename Database, typename... Parts>
struct custom_query_t : private detail::custom_parts_t<Database, Parts...>::_result_methods_t
{
using _methods_t = typename detail::custom_parts_t<Database, Parts...>::_result_methods_t;
using _traits = make_traits<no_value_t, tag::is_statement>;
using _nodes = detail::type_vector<Parts...>;
using _parameter_check = typename std::conditional<detail::type_vector_size<parameters_of<custom_query_t>>::value == 0,
consistent_t, assert_no_parameters_t>::type;
using _run_check = detail::get_first_if<is_inconsistent_t, consistent_t,
_parameter_check>;
using _prepare_check = consistent_t;
using _parameter_check =
typename std::conditional<detail::type_vector_size<parameters_of<custom_query_t>>::value == 0,
consistent_t,
assert_no_parameters_t>::type;
using _run_check = detail::get_first_if<is_inconsistent_t, consistent_t, _parameter_check>;
using _prepare_check = consistent_t;
custom_query_t(Parts... parts):
_parts(parts...)
{}
custom_query_t(Parts... parts) : _parts(parts...)
{
}
custom_query_t(std::tuple<Parts...> parts):
_parts(parts)
{}
custom_query_t(std::tuple<Parts...> parts) : _parts(parts)
{
}
custom_query_t(const custom_query_t&) = default;
custom_query_t(custom_query_t&&) = default;
custom_query_t& operator=(const custom_query_t&) = default;
custom_query_t& operator=(custom_query_t&&) = default;
~custom_query_t() = default;
custom_query_t(const custom_query_t&) = default;
custom_query_t(custom_query_t&&) = default;
custom_query_t& operator=(const custom_query_t&) = default;
custom_query_t& operator=(custom_query_t&&) = default;
~custom_query_t() = default;
template<typename Db>
auto _run(Db& db) const -> decltype(std::declval<_methods_t>()._run(db, *this))
{
_run_check::_();
return _methods_t::_run(db, *this);
}
template <typename Db>
auto _run(Db& db) const -> decltype(std::declval<_methods_t>()._run(db, *this))
{
_run_check::_();
return _methods_t::_run(db, *this);
}
template<typename Db>
auto _prepare(Db& db) const -> decltype(std::declval<_methods_t>()._prepare(db, *this))
{
_prepare_check::_();
return _methods_t::_prepare(db, *this);
}
template <typename Db>
auto _prepare(Db& db) const -> decltype(std::declval<_methods_t>()._prepare(db, *this))
{
_prepare_check::_();
return _methods_t::_prepare(db, *this);
}
static constexpr size_t _get_static_no_of_parameters()
{
return std::tuple_size<parameters_of<custom_query_t>>::value;
}
static constexpr size_t _get_static_no_of_parameters()
{
return std::tuple_size<parameters_of<custom_query_t>>::value;
}
size_t _get_no_of_parameters() const
{
return _get_static_no_of_parameters();
}
size_t _get_no_of_parameters() const
{
return _get_static_no_of_parameters();
}
template<typename Part>
auto with_result_type_of(Part part)
-> custom_query_t<Database, Part, Parts...>
{
return {tuple_cat(std::make_tuple(part), _parts)};
}
template <typename Part>
auto with_result_type_of(Part part) -> custom_query_t<Database, Part, Parts...>
{
return {tuple_cat(std::make_tuple(part), _parts)};
}
std::tuple<Parts...> _parts;
};
std::tuple<Parts...> _parts;
};
template<typename Context, typename Database, typename... Parts>
struct serializer_t<Context, custom_query_t<Database, Parts...>>
{
using _serialize_check = serialize_check_of<Context, Parts...>;
using T = custom_query_t<Database, Parts...>;
template <typename Context, typename Database, typename... Parts>
struct serializer_t<Context, custom_query_t<Database, Parts...>>
{
using _serialize_check = serialize_check_of<Context, Parts...>;
using T = custom_query_t<Database, Parts...>;
static Context& _(const T& t, Context& context)
{
interpret_tuple_without_braces(t._parts, " ", context);
return context;
}
};
static Context& _(const T& t, Context& context)
{
interpret_tuple_without_braces(t._parts, " ", context);
return context;
}
};
template<typename... Parts>
auto custom_query(Parts... parts)
-> custom_query_t<void, wrap_operand_t<Parts>...>
{
static_assert(sizeof...(Parts) > 0, "custom query requires at least one argument");
return custom_query_t<void, wrap_operand_t<Parts>...>(parts...);
}
template <typename... Parts>
auto custom_query(Parts... parts) -> custom_query_t<void, wrap_operand_t<Parts>...>
{
static_assert(sizeof...(Parts) > 0, "custom query requires at least one argument");
return custom_query_t<void, wrap_operand_t<Parts>...>(parts...);
}
template<typename Database, typename... Parts>
auto dynamic_custom_query(const Database&, Parts... parts)
-> custom_query_t<Database, wrap_operand_t<Parts>...>
{
static_assert(sizeof...(Parts) > 0, "custom query requires at least one query argument");
static_assert(std::is_base_of<connection, Database>::value, "Invalid database parameter");
template <typename Database, typename... Parts>
auto dynamic_custom_query(const Database&, Parts... parts) -> custom_query_t<Database, wrap_operand_t<Parts>...>
{
static_assert(sizeof...(Parts) > 0, "custom query requires at least one query argument");
static_assert(std::is_base_of<connection, Database>::value, "Invalid database parameter");
return custom_query_t<Database, wrap_operand_t<Parts>...>(parts...);
}
return custom_query_t<Database, wrap_operand_t<Parts>...>(parts...);
}
}
#endif

View 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_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>
#include <sqlpp11/data_types/no_value.h>
#endif

View 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

View 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_BOOLEAN_COLUMN_OPERATORS_H
#define SQLPP_BOOLEAN_COLUMN_OPERATORS_H
#include <sqlpp11/data_types/column_operators.h>
namespace sqlpp
{
struct boolean;
template <typename Column>
struct column_operators<Column, boolean>
{
};
}
#endif

View 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

View 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

View 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

View 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

View File

@@ -0,0 +1,56 @@
/*
* 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);
}
template <typename Target>
void _post_bind(Target& target, size_t index)
{
target._post_bind_boolean_result(index, &this->_value, &this->_is_null);
}
};
}
#endif

View File

@@ -1,17 +1,17 @@
/*
* 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
@@ -24,17 +24,20 @@
* 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_WRAP_OPERAND_H
#define SQLPP_BOOLEAN_WRAP_OPERAND_H
#include <sqlpp11/wrap_operand.h>
namespace sqlpp
{
template<typename T, typename Enable = void>
struct wrap_operand;
template<typename T>
using wrap_operand_t = typename wrap_operand<T>::type;
struct boolean_operand;
template <>
struct wrap_operand<bool, void>
{
using type = boolean_operand;
};
}
#endif

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View File

@@ -0,0 +1,72 @@
/*
* 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 Target>
void _post_bind(Target& target, size_t index)
{
target._post_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

View 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

View 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

View 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

View 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

View File

@@ -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

View 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

View 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

View 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_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);
}
template <typename Target>
void _post_bind(Target& target, size_t index)
{
target._post_bind_floating_point_result(index, &this->_value, &this->_is_null);
}
};
}
#endif

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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_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);
}
template <typename Target>
void _post_bind(Target& target, size_t index)
{
target._post_bind_integral_result(index, &this->_value, &this->_is_null);
}
};
}
#endif

View 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

View File

@@ -1,17 +1,17 @@
/*
* 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
@@ -27,25 +27,12 @@
#ifndef SQLPP_NO_VALUE_H
#define SQLPP_NO_VALUE_H
#include <type_traits>
#include <sqlpp11/value_type_fwd.h>
#include <sqlpp11/data_types/no_value/data_type.h>
#include <sqlpp11/data_types/no_value/operand.h>
#include <sqlpp11/data_types/no_value/wrap_operand.h>
#include <sqlpp11/data_types/no_value/expression_operators.h>
#include <sqlpp11/data_types/no_value/column_operators.h>
#include <sqlpp11/data_types/no_value/parameter_value.h>
#include <sqlpp11/data_types/no_value/result_field.h>
namespace sqlpp
{
struct no_value_t
{
using _tag = void;
};
template<typename Base>
struct expression_operators<Base, no_value_t>
{
};
template<typename Base>
struct column_operators<Base, no_value_t>
{
};
}
#endif

View 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_NO_VALUE_COLUMN_OPERATORS_H
#define SQLPP_NO_VALUE_COLUMN_OPERATORS_H
#include <sqlpp11/data_types/column_operators.h>
namespace sqlpp
{
struct no_value_t;
template <typename Base>
struct column_operators<Base, no_value_t>
{
};
}
#endif

View 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_NO_VALUE_DATA_TYPE_H
#define SQLPP_NO_VALUE_DATA_TYPE_H
#include <sqlpp11/type_traits.h>
namespace sqlpp
{
struct no_value_t
{
using _traits = make_traits<no_value_t>;
using _cpp_value_type = void;
template <typename T>
using _is_valid_operand = wrong_t<T>;
};
}
#endif

View 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_NO_VALUE_EXPRESSION_OPERATORS_H
#define SQLPP_NO_VALUE_EXPRESSION_OPERATORS_H
#include <sqlpp11/expression_return_types.h>
#include <sqlpp11/expression_operators.h>
#include <sqlpp11/basic_expression_operators.h>
namespace sqlpp
{
template <typename Expression>
struct expression_operators<Expression, no_value_t> : public basic_expression_operators<Expression, no_value_t>
{
};
}
#endif

View File

@@ -0,0 +1,35 @@
/*
* 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_VALUE_OPERAND_H
#define SQLPP_NO_VALUE_OPERAND_H
namespace sqlpp
{
// There is no no_value operand
}
#endif

View File

@@ -0,0 +1,35 @@
/*
* 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_VALUE_PARAMETER_VALUE_H
#define SQLPP_NO_VALUE_PARAMETER_VALUE_H
namespace sqlpp
{
// There is no no_value parameter
}
#endif

View 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_NO_VALUE_RESULT_FIELD_H
#define SQLPP_NO_VALUE_RESULT_FIELD_H
#include <sqlpp11/result_field.h>
#include <sqlpp11/data_types/no_value/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, no_value_t, CanBeNull, NullIsTrivialValue>>
{
template <typename Target>
void _bind(Target&, size_t)
{
}
template <typename Target>
void _post_bind(Target&, size_t)
{
}
void _validate() const
{
}
void _invalidate() const
{
}
constexpr bool is_null() const
{
return true;
}
};
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, no_value_t, CanBeNull, NullIsTrivialValue>>&)
{
os << "NULL";
return os;
}
}
#endif

View File

@@ -0,0 +1,35 @@
/*
* 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_VALUE_WRAP_OPERAND_H
#define SQLPP_NO_VALUE_WRAP_OPERAND_H
namespace sqlpp
{
// There is no no_value operand
}
#endif

View 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

View 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

View 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

View 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

View File

@@ -0,0 +1,103 @@
/*
* 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_CONCAT_H
#define SQLPP_CONCAT_H
#include <sqlpp11/type_traits.h>
#include <sqlpp11/char_sequence.h>
#include <sqlpp11/interpret_tuple.h>
#include <sqlpp11/expression_operators.h>
#include <sqlpp11/alias_operators.h>
#include <sqlpp11/logic.h>
#include <sqlpp11/wrap_operand.h>
namespace sqlpp
{
struct text;
struct concat_alias_t
{
struct _alias_t
{
static constexpr const char _literal[] = "concat_";
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
template <typename T>
struct _member_t
{
T concat;
};
};
};
template <typename... Args>
struct concat_t : public expression_operators<concat_t<Args...>, text>, public alias_operators<concat_t<Args...>>
{
using _traits = make_traits<text, tag::is_expression, tag::is_selectable>;
using _nodes = detail::type_vector<Args...>;
using _auto_alias_t = concat_alias_t;
concat_t(Args... args) : _args(args...)
{
}
concat_t(const concat_t&) = default;
concat_t(concat_t&&) = default;
concat_t& operator=(const concat_t&) = default;
concat_t& operator=(concat_t&&) = default;
~concat_t() = default;
std::tuple<Args...> _args;
};
template <typename Context, typename... Args>
struct serializer_t<Context, concat_t<Args...>>
{
using _serialize_check = serialize_check_of<Context, Args...>;
using T = concat_t<Args...>;
static Context& _(const T& t, Context& context)
{
context << "(";
interpret_tuple(t._args, "||", context);
context << ")";
return context;
}
};
template <typename... Args>
auto concat(Args... args) -> concat_t<Args...>
{
static_assert(sizeof...(Args) >= 2, "concat requires two arguments at least");
static_assert(logic::all_t<is_text_t<wrap_operand_t<Args>>::value...>::value,
"at least one non-text argument detected in concat()");
return {args...};
}
}
#endif

View 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

View 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

View 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_LIKE_H
#define SQLPP_LIKE_H
#include <sqlpp11/expression_operators.h>
#include <sqlpp11/alias_operators.h>
#include <sqlpp11/type_traits.h>
#include <sqlpp11/char_sequence.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>>
{
using _traits = make_traits<boolean, tag::is_expression, tag::is_selectable>;
using _nodes = detail::type_vector<Operand, Pattern>;
struct _alias_t
{
// workaround for msvc bug https://connect.microsoft.com/VisualStudio/Feedback/Details/2100550
// static constexpr const char _literal[] = "like_";
static constexpr const char _literal[6] = "like_";
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
template <typename T>
struct _member_t
{
T like;
T& operator()()
{
return like;
}
const T& operator()() const
{
return like;
}
};
};
like_t(Operand operand, Pattern pattern) : _operand(operand), _pattern(pattern)
{
}
like_t(const like_t&) = default;
like_t(like_t&&) = default;
like_t& operator=(const like_t&) = default;
like_t& operator=(like_t&&) = default;
~like_t() = default;
Operand _operand;
Pattern _pattern;
};
template <typename Context, typename Operand, typename Pattern>
struct serializer_t<Context, like_t<Operand, Pattern>>
{
using _serialize_check = serialize_check_of<Context, Operand, Pattern>;
using T = like_t<Operand, Pattern>;
static Context& _(const T& t, Context& context)
{
serialize_operand(t._operand, context);
context << " LIKE(";
serialize(t._pattern, context);
context << ")";
return context;
}
};
}
#endif

View 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

View 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

View File

@@ -0,0 +1,78 @@
/*
* 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 Target>
void _post_bind(Target& target, size_t index)
{
const char* text{nullptr};
size_t len{};
target._post_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

View 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

View 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

View 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

View 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::microsecond_point;
template <typename T>
using _is_valid_operand = is_day_or_time_point_t<T>;
};
}
#endif

View 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

View 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

View 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

View File

@@ -0,0 +1,74 @@
/*
* 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 Target>
void _post_bind(Target& target, size_t i)
{
target._post_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

View 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

View 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

View File

@@ -1,17 +1,17 @@
/*
* 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
@@ -27,33 +27,35 @@
#ifndef SQLPP_DEFAULT_VALUE_H
#define SQLPP_DEFAULT_VALUE_H
#include <sqlpp11/no_value.h>
#include <sqlpp11/data_types/no_value.h>
namespace sqlpp
{
struct default_value_t
{
using _traits = make_traits<no_value_t, tag::is_expression>;
using _nodes = detail::type_vector<>;
struct default_value_t
{
using _traits = make_traits<no_value_t, tag::is_expression>;
using _nodes = detail::type_vector<>;
static constexpr bool _is_trivial() { return false; }
};
static constexpr bool _is_trivial()
{
return false;
}
};
template<typename Context>
struct serializer_t<Context, default_value_t>
{
using _serialize_check = consistent_t;
using Operand = default_value_t;
template <typename Context>
struct serializer_t<Context, default_value_t>
{
using _serialize_check = consistent_t;
using Operand = default_value_t;
static Context& _(const Operand& t, Context& context)
{
context << "DEFAULT";
return context;
}
};
constexpr default_value_t default_value = {};
static Context& _(const Operand&, Context& context)
{
context << "DEFAULT";
return context;
}
};
constexpr default_value_t default_value = {};
}
#endif

View File

@@ -1,17 +1,17 @@
/*
* 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
@@ -28,49 +28,63 @@
#define SQLPP_DETAIL_COPY_TUPLE_ARGS_H
#include <tuple>
#include <sqlpp11/auto_alias.h>
namespace sqlpp
{
template<typename Table>
struct all_of_t;
template <typename Table>
struct all_of_t;
namespace detail
{
template<typename T>
struct as_tuple
{
static std::tuple<T> _(T t) { return std::tuple<T>{ t }; }
};
namespace detail
{
template <typename T>
struct as_column_tuple
{
static std::tuple<auto_alias_t<T>> _(T t)
{
return std::tuple<auto_alias_t<T>>(auto_alias_t<T>{t});
}
};
template<typename T>
struct as_tuple<all_of_t<T>>
{
static typename all_of_t<T>::_column_tuple_t _(all_of_t<T>) { return { }; }
};
template <typename T>
struct as_column_tuple<all_of_t<T>>
{
static typename all_of_t<T>::_column_tuple_t _(all_of_t<T>)
{
return {};
}
};
template<typename... Args>
struct as_tuple<std::tuple<Args...>>
{
static std::tuple<Args...> _(std::tuple<Args...> t) { return t; }
};
template <typename... Args>
struct as_column_tuple<std::tuple<Args...>>
{
static std::tuple<auto_alias_t<Args>...> _(std::tuple<Args...> t)
{
return t;
}
};
template<template<typename, typename...> class Target, typename First, typename T>
struct copy_tuple_args_impl
{
static_assert(wrong_t<copy_tuple_args_impl>::value, "copy_tuple_args must be called with a tuple");
};
template <template <typename, typename...> class Target, typename First, typename T>
struct copy_tuple_args_impl
{
static_assert(wrong_t<copy_tuple_args_impl>::value, "copy_tuple_args must be called with a tuple");
};
template<template<typename First, typename...> class Target, typename First, typename... Args>
struct copy_tuple_args_impl<Target, First, std::tuple<Args...>>
{
using type = Target<First, Args...>;
};
template <template <typename First, typename...> class Target, typename First, typename... Args>
struct copy_tuple_args_impl<Target, First, std::tuple<Args...>>
{
using type = Target<First, Args...>;
};
template<template<typename First, typename...> class Target, typename First, typename T>
using copy_tuple_args_t = typename copy_tuple_args_impl<Target, First, T>::type;
template <template <typename First, typename...> class Target, typename First, typename T>
using copy_tuple_args_t = typename copy_tuple_args_impl<Target, First, T>::type;
}
template <typename... Columns>
auto column_tuple_merge(Columns... columns) -> decltype(std::tuple_cat(as_column_tuple<Columns>::_(columns)...))
{
return std::tuple_cat(as_column_tuple<Columns>::_(columns)...);
}
}
}
#endif

View 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

View File

@@ -1,17 +1,17 @@
/*
* 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
@@ -32,43 +32,55 @@
namespace sqlpp
{
namespace detail
{
template<std::size_t NextIndex, std::size_t... Ints>
struct field_index_sequence
{
static constexpr std::size_t _next_index = NextIndex;
};
namespace detail
{
template <std::size_t NextIndex, std::size_t... Ints>
struct field_index_sequence
{
static constexpr std::size_t _next_index = NextIndex;
};
template<typename T, typename... Fields>
struct make_field_index_sequence_impl
{
static_assert(wrong_t<make_field_index_sequence_impl>::value, "invalid field index sequence arguments");
};
template <typename T, typename... Fields>
struct make_field_index_sequence_impl
{
static_assert(wrong_t<make_field_index_sequence_impl>::value, "invalid field index sequence arguments");
};
template<std::size_t NextIndex, std::size_t... Ints, typename NameType, typename ValueType, bool CanBeNull, bool NullIsTrivialValue, typename... Rest>
struct make_field_index_sequence_impl<field_index_sequence<NextIndex, Ints...>, field_spec_t<NameType, ValueType, CanBeNull, NullIsTrivialValue>, Rest...>
{
using type = typename make_field_index_sequence_impl<field_index_sequence<NextIndex + 1, Ints..., NextIndex>, Rest...>::type;
};
template <std::size_t NextIndex,
std::size_t... Ints,
typename NameType,
typename ValueType,
bool CanBeNull,
bool NullIsTrivialValue,
typename... Rest>
struct make_field_index_sequence_impl<field_index_sequence<NextIndex, Ints...>,
field_spec_t<NameType, ValueType, CanBeNull, NullIsTrivialValue>,
Rest...>
{
using type = typename make_field_index_sequence_impl<field_index_sequence<NextIndex + 1, Ints..., NextIndex>,
Rest...>::type;
};
template<std::size_t NextIndex, std::size_t... Ints, typename AliasProvider, typename FieldTuple, typename... Rest>
struct make_field_index_sequence_impl<field_index_sequence<NextIndex, Ints...>, multi_field_spec_t<AliasProvider, FieldTuple>, Rest...>
{
using type = typename make_field_index_sequence_impl<field_index_sequence<NextIndex + std::tuple_size<FieldTuple>::value, Ints..., NextIndex>, Rest...>::type;
};
template <std::size_t NextIndex, std::size_t... Ints, typename AliasProvider, typename FieldTuple, typename... Rest>
struct make_field_index_sequence_impl<field_index_sequence<NextIndex, Ints...>,
multi_field_spec_t<AliasProvider, FieldTuple>,
Rest...>
{
using type = typename make_field_index_sequence_impl<
field_index_sequence<NextIndex + std::tuple_size<FieldTuple>::value, Ints..., NextIndex>,
Rest...>::type;
};
template<std::size_t NextIndex, std::size_t... Ints>
struct make_field_index_sequence_impl<field_index_sequence<NextIndex, Ints...>>
{
using type = field_index_sequence<NextIndex, Ints...>;
};
template <std::size_t NextIndex, std::size_t... Ints>
struct make_field_index_sequence_impl<field_index_sequence<NextIndex, Ints...>>
{
using type = field_index_sequence<NextIndex, Ints...>;
};
template<std::size_t StartIndex, typename... Fields>
using make_field_index_sequence = typename make_field_index_sequence_impl<field_index_sequence<StartIndex>, Fields...>::type;
}
template <std::size_t StartIndex, typename... Fields>
using make_field_index_sequence =
typename make_field_index_sequence_impl<field_index_sequence<StartIndex>, Fields...>::type;
}
}
#endif

View File

@@ -1,17 +1,17 @@
/*
* 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
@@ -31,30 +31,27 @@
namespace sqlpp
{
namespace detail
{
template<template<typename> class Predicate, typename Default, typename... T>
struct get_first_if_impl;
namespace detail
{
template <template <typename> class Predicate, typename Default, typename... T>
struct get_first_if_impl;
template<template<typename> class Predicate, typename Default>
struct get_first_if_impl<Predicate, Default>
{
using type = Default;
};
template <template <typename> class Predicate, typename Default>
struct get_first_if_impl<Predicate, Default>
{
using type = Default;
};
template<template<typename> class Predicate, typename Default, typename T, typename... Rest>
struct get_first_if_impl<Predicate, Default, T, Rest...>
{
using rest = typename get_first_if_impl<Predicate, Default, Rest...>::type;
using type = typename std::conditional<Predicate<T>::value,
T,
rest>::type;
};
template <template <typename> class Predicate, typename Default, typename T, typename... Rest>
struct get_first_if_impl<Predicate, Default, T, Rest...>
{
using rest = typename get_first_if_impl<Predicate, Default, Rest...>::type;
using type = typename std::conditional<Predicate<T>::value, T, rest>::type;
};
template<template<typename> class Predicate, typename Default, typename... T>
using get_first_if = typename get_first_if_impl<Predicate, Default, T...>::type;
}
template <template <typename> class Predicate, typename Default, typename... T>
using get_first_if = typename get_first_if_impl<Predicate, Default, T...>::type;
}
}
#endif

View File

@@ -1,17 +1,17 @@
/*
* 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
@@ -31,30 +31,27 @@
namespace sqlpp
{
namespace detail
{
template<template<typename> class Predicate, typename Default, typename... T>
struct get_last_if_impl;
namespace detail
{
template <template <typename> class Predicate, typename Default, typename... T>
struct get_last_if_impl;
template<template<typename> class Predicate, typename Default>
struct get_last_if_impl<Predicate, Default>
{
using type = Default;
};
template <template <typename> class Predicate, typename Default>
struct get_last_if_impl<Predicate, Default>
{
using type = Default;
};
template<template<typename> class Predicate, typename Default, typename T, typename... Rest>
struct get_last_if_impl<Predicate, Default, T, Rest...>
{
using rest = typename get_last_if_impl<Predicate, Default, Rest...>::type;
using type = typename std::conditional<std::is_same<rest, Default>::value and Predicate<T>::value,
T,
rest>::type;
};
template <template <typename> class Predicate, typename Default, typename T, typename... Rest>
struct get_last_if_impl<Predicate, Default, T, Rest...>
{
using rest = typename get_last_if_impl<Predicate, Default, Rest...>::type;
using type = typename std::conditional<std::is_same<rest, Default>::value and Predicate<T>::value, T, rest>::type;
};
template<template<typename> class Predicate, typename Default, typename... T>
using get_last_if = typename get_last_if_impl<Predicate, Default, T...>::type;
}
template <template <typename> class Predicate, typename Default, typename... T>
using get_last_if = typename get_last_if_impl<Predicate, Default, T...>::type;
}
}
#endif

Some files were not shown because too many files have changed in this diff Show More