mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-15 20:31:16 +08:00
Moved data types into separate folder, split boolean
Each file within data_types/boolean/ is relatively short and easy to grok.
This commit is contained in:
parent
12eabd28f4
commit
173d6adbc9
@ -2,7 +2,7 @@
|
|||||||
#define TEST_SAMPLE_H
|
#define TEST_SAMPLE_H
|
||||||
|
|
||||||
#include <sqlpp11/table.h>
|
#include <sqlpp11/table.h>
|
||||||
#include <sqlpp11/column_types.h>
|
#include <sqlpp11/data_types.h>
|
||||||
#include <sqlpp11/char_sequence.h>
|
#include <sqlpp11/char_sequence.h>
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
|
44
include/sqlpp11/alias_operators.h
Normal file
44
include/sqlpp11/alias_operators.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013-2015, Roland Bock
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer in the documentation and/or
|
||||||
|
* other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SQLPP_ALIAS_OPERATORS_H
|
||||||
|
#define SQLPP_ALIAS_OPERATORS_H
|
||||||
|
|
||||||
|
#include <sqlpp11/alias.h>
|
||||||
|
|
||||||
|
namespace sqlpp
|
||||||
|
{
|
||||||
|
template <typename Expr>
|
||||||
|
struct alias_operators
|
||||||
|
{
|
||||||
|
template <typename alias_provider>
|
||||||
|
expression_alias_t<Expr, alias_provider> as(const alias_provider&) const
|
||||||
|
{
|
||||||
|
return {*static_cast<const Expr*>(this)};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif
|
@ -27,7 +27,7 @@
|
|||||||
#ifndef SQLPP_ANY_H
|
#ifndef SQLPP_ANY_H
|
||||||
#define SQLPP_ANY_H
|
#define SQLPP_ANY_H
|
||||||
|
|
||||||
#include <sqlpp11/boolean.h>
|
#include <sqlpp11/data_types/boolean.h>
|
||||||
#include <sqlpp11/char_sequence.h>
|
#include <sqlpp11/char_sequence.h>
|
||||||
#include <sqlpp11/detail/type_set.h>
|
#include <sqlpp11/detail/type_set.h>
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
#include <sqlpp11/expression_fwd.h>
|
#include <sqlpp11/expression_fwd.h>
|
||||||
#include <sqlpp11/in_fwd.h>
|
#include <sqlpp11/in_fwd.h>
|
||||||
#include <sqlpp11/is_null_fwd.h>
|
#include <sqlpp11/is_null_fwd.h>
|
||||||
#include <sqlpp11/wrap_operand_fwd.h>
|
#include <sqlpp11/wrap_operand.h>
|
||||||
#include <sqlpp11/logic.h>
|
#include <sqlpp11/logic.h>
|
||||||
|
|
||||||
namespace sqlpp
|
namespace sqlpp
|
||||||
@ -219,15 +219,6 @@ namespace sqlpp
|
|||||||
return {*static_cast<const Expr*>(this), wrap_operand_t<T>{t}...};
|
return {*static_cast<const Expr*>(this), wrap_operand_t<T>{t}...};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Expr>
|
|
||||||
struct alias_operators
|
|
||||||
{
|
|
||||||
template <typename alias_provider>
|
|
||||||
expression_alias_t<Expr, alias_provider> as(const alias_provider&) const
|
|
||||||
{
|
|
||||||
return {*static_cast<const Expr*>(this)};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -27,11 +27,7 @@
|
|||||||
#ifndef SQLPP_COLUMN_TYPES_H
|
#ifndef SQLPP_COLUMN_TYPES_H
|
||||||
#define SQLPP_COLUMN_TYPES_H
|
#define SQLPP_COLUMN_TYPES_H
|
||||||
|
|
||||||
#include <sqlpp11/boolean.h>
|
#warning column_types.h is deprecated, please include data_types.h instead
|
||||||
#include <sqlpp11/day_point.h>
|
#include <sqlpp11/data_types.h>
|
||||||
#include <sqlpp11/time_point.h>
|
|
||||||
#include <sqlpp11/integral.h>
|
|
||||||
#include <sqlpp11/floating_point.h>
|
|
||||||
#include <sqlpp11/text.h>
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
#include <sqlpp11/char_sequence.h>
|
#include <sqlpp11/char_sequence.h>
|
||||||
#include <sqlpp11/select_flags.h>
|
#include <sqlpp11/select_flags.h>
|
||||||
#include <sqlpp11/integral.h>
|
#include <sqlpp11/data_types/integral.h>
|
||||||
|
|
||||||
namespace sqlpp
|
namespace sqlpp
|
||||||
{
|
{
|
||||||
|
37
include/sqlpp11/data_types.h
Normal file
37
include/sqlpp11/data_types.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013-2015, Roland Bock
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer in the documentation and/or
|
||||||
|
* other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SQLPP_DATA_TYPES_H
|
||||||
|
#define SQLPP_DATA_TYPES_H
|
||||||
|
|
||||||
|
#include <sqlpp11/data_types/boolean.h>
|
||||||
|
#include <sqlpp11/data_types/integral.h>
|
||||||
|
#include <sqlpp11/data_types/floating_point.h>
|
||||||
|
#include <sqlpp11/data_types/text.h>
|
||||||
|
#include <sqlpp11/data_types/day_point.h>
|
||||||
|
#include <sqlpp11/data_types/time_point.h>
|
||||||
|
|
||||||
|
#endif
|
39
include/sqlpp11/data_types/boolean.h
Normal file
39
include/sqlpp11/data_types/boolean.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* 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/expression_operators.h>
|
||||||
|
#include <sqlpp11/data_types/boolean/column_operators.h>
|
||||||
|
#include <sqlpp11/data_types/boolean/parameter_type.h>
|
||||||
|
#include <sqlpp11/data_types/boolean/result_field.h>
|
||||||
|
#include <sqlpp11/data_types/boolean/operand.h>
|
||||||
|
#include <sqlpp11/data_types/boolean/wrap_operand.h>
|
||||||
|
#include <sqlpp11/data_types/boolean/serialize.h>
|
||||||
|
|
||||||
|
#endif
|
@ -24,16 +24,18 @@
|
|||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SQLPP_DETAIL_WRAP_OPERAND_FWD_H
|
#ifndef SQLPP_BOOLEAN_COLUMN_OPERATORS_H
|
||||||
#define SQLPP_DETAIL_WRAP_OPERAND_FWD_H
|
#define SQLPP_BOOLEAN_COLUMN_OPERATORS_H
|
||||||
|
|
||||||
|
#include <sqlpp11/data_types/column_operators.h>
|
||||||
|
|
||||||
namespace sqlpp
|
namespace sqlpp
|
||||||
{
|
{
|
||||||
template <typename T, typename Enable = void>
|
struct boolean;
|
||||||
struct wrap_operand;
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename Base>
|
||||||
using wrap_operand_t = typename wrap_operand<T>::type;
|
struct column_operators<Base, boolean>
|
||||||
|
{
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
45
include/sqlpp11/data_types/boolean/data_type.h
Normal file
45
include/sqlpp11/data_types/boolean/data_type.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013-2015, Roland Bock
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer in the documentation and/or
|
||||||
|
* other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SQLPP_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 _tag = tag::is_boolean;
|
||||||
|
using _cpp_value_type = bool;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
using _is_valid_operand = is_boolean_t<T>;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
65
include/sqlpp11/data_types/boolean/expression_operators.h
Normal file
65
include/sqlpp11/data_types/boolean/expression_operators.h
Normal 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_BOOLEAN_EXPRESSION_OPERATORS_H
|
||||||
|
#define SQLPP_BOOLEAN_EXPRESSION_OPERATORS_H
|
||||||
|
|
||||||
|
#include <sqlpp11/basic_expression_operators.h>
|
||||||
|
|
||||||
|
namespace sqlpp
|
||||||
|
{
|
||||||
|
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)};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
68
include/sqlpp11/data_types/boolean/operand.h
Normal file
68
include/sqlpp11/data_types/boolean/operand.h
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013-2015, Roland Bock
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer in the documentation and/or
|
||||||
|
* other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SQLPP_BOOLEAN_OPERAND_H
|
||||||
|
#define SQLPP_BOOLEAN_OPERAND_H
|
||||||
|
|
||||||
|
#include <sqlpp11/type_traits.h>
|
||||||
|
#include <sqlpp11/alias_operators.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;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
108
include/sqlpp11/data_types/boolean/parameter_type.h
Normal file
108
include/sqlpp11/data_types/boolean/parameter_type.h
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013-2015, Roland Bock
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer in the documentation and/or
|
||||||
|
* other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SQLPP_BOOLEAN_PARAMETER_TYPE_H
|
||||||
|
#define SQLPP_BOOLEAN_PARAMETER_TYPE_H
|
||||||
|
|
||||||
|
#include <sqlpp11/data_types/parameter_value.h>
|
||||||
|
#include <sqlpp11/data_types/boolean/data_type.h>
|
||||||
|
#include <sqlpp11/data_types/boolean/wrap_operand.h>
|
||||||
|
#include <sqlpp11/data_types/boolean/operand.h>
|
||||||
|
#include <sqlpp11/tvin.h>
|
||||||
|
|
||||||
|
namespace sqlpp
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -24,138 +24,18 @@
|
|||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SQLPP_BOOLEAN_H
|
#ifndef SQLPP_BOOLEAN_RESULT_FIELD_H
|
||||||
#define SQLPP_BOOLEAN_H
|
#define SQLPP_BOOLEAN_RESULT_FIELD_H
|
||||||
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <ostream>
|
|
||||||
#include <sqlpp11/basic_expression_operators.h>
|
#include <sqlpp11/basic_expression_operators.h>
|
||||||
|
#include <sqlpp11/result_field_methods.h>
|
||||||
#include <sqlpp11/type_traits.h>
|
#include <sqlpp11/type_traits.h>
|
||||||
#include <sqlpp11/exception.h>
|
#include <sqlpp11/exception.h>
|
||||||
#include <sqlpp11/tvin.h>
|
|
||||||
#include <sqlpp11/result_field.h>
|
#include <sqlpp11/result_field.h>
|
||||||
|
#include <sqlpp11/data_types/boolean/data_type.h>
|
||||||
|
|
||||||
namespace sqlpp
|
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>
|
template <typename Db, typename FieldSpec>
|
||||||
struct result_field_t<boolean, Db, FieldSpec> : public result_field_methods_t<result_field_t<boolean, Db, FieldSpec>>
|
struct result_field_t<boolean, Db, FieldSpec> : public result_field_methods_t<result_field_t<boolean, Db, FieldSpec>>
|
||||||
{
|
{
|
||||||
@ -223,11 +103,5 @@ namespace sqlpp
|
|||||||
bool _is_null;
|
bool _is_null;
|
||||||
signed char _value;
|
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
|
#endif
|
57
include/sqlpp11/data_types/boolean/serialize.h
Normal file
57
include/sqlpp11/data_types/boolean/serialize.h
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013-2015, Roland Bock
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer in the documentation and/or
|
||||||
|
* other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SQLPP_BOOLEAN_SERIALIZE_H
|
||||||
|
#define SQLPP_BOOLEAN_SERIALIZE_H
|
||||||
|
|
||||||
|
#include <sqlpp11/data_types/boolean/result_field.h>
|
||||||
|
#include <sqlpp11/data_types/boolean/operand.h>
|
||||||
|
#include <ostream>
|
||||||
|
|
||||||
|
namespace sqlpp
|
||||||
|
{
|
||||||
|
struct boolean;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
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
|
43
include/sqlpp11/data_types/boolean/wrap_operand.h
Normal file
43
include/sqlpp11/data_types/boolean/wrap_operand.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013-2015, Roland Bock
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer in the documentation and/or
|
||||||
|
* other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SQLPP_BOOLEAN_WRAP_OPERAND_H
|
||||||
|
#define SQLPP_BOOLEAN_WRAP_OPERAND_H
|
||||||
|
|
||||||
|
#include <sqlpp11/wrap_operand.h>
|
||||||
|
|
||||||
|
namespace sqlpp
|
||||||
|
{
|
||||||
|
struct boolean_operand;
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct wrap_operand<bool, void>
|
||||||
|
{
|
||||||
|
using type = boolean_operand;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
41
include/sqlpp11/data_types/column_operators.h
Normal file
41
include/sqlpp11/data_types/column_operators.h
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013-2015, Roland Bock
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer in the documentation and/or
|
||||||
|
* other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SQLPP_COLUMN_OPERATORS_H
|
||||||
|
#define SQLPP_COLUMN_OPERATORS_H
|
||||||
|
|
||||||
|
#include <sqlpp11/wrong.h>
|
||||||
|
|
||||||
|
namespace sqlpp
|
||||||
|
{
|
||||||
|
template <typename Column, typename ValueType>
|
||||||
|
struct column_operators
|
||||||
|
{
|
||||||
|
static_assert(wrong_t<column_operators>::value, "Missing column operators for ValueType");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -28,7 +28,7 @@
|
|||||||
#define SQLPP_DAY_POINT_H
|
#define SQLPP_DAY_POINT_H
|
||||||
|
|
||||||
#include <date.h>
|
#include <date.h>
|
||||||
#include <sqlpp11/time_point.h>
|
#include <sqlpp11/data_types/time_point.h>
|
||||||
#include <sqlpp11/basic_expression_operators.h>
|
#include <sqlpp11/basic_expression_operators.h>
|
||||||
#include <sqlpp11/type_traits.h>
|
#include <sqlpp11/type_traits.h>
|
||||||
#include <sqlpp11/exception.h>
|
#include <sqlpp11/exception.h>
|
41
include/sqlpp11/data_types/parameter_value.h
Normal file
41
include/sqlpp11/data_types/parameter_value.h
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013-2015, Roland Bock
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer in the documentation and/or
|
||||||
|
* other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SQLPP_PARAMETER_VALUE_H
|
||||||
|
#define SQLPP_PARAMETER_VALUE_H
|
||||||
|
|
||||||
|
#include <sqlpp11/wrong.h>
|
||||||
|
|
||||||
|
namespace sqlpp
|
||||||
|
{
|
||||||
|
template <typename ValueType>
|
||||||
|
struct parameter_value_t
|
||||||
|
{
|
||||||
|
static_assert(wrong_t<parameter_value_t>::value, "Missing parameter value type for ValueType");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
308
include/sqlpp11/data_types/wrap_operand.h
Normal file
308
include/sqlpp11/data_types/wrap_operand.h
Normal file
@ -0,0 +1,308 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013-2015, Roland Bock
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer in the documentation and/or
|
||||||
|
* other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SQLPP_DETAIL_WRAP_OPERAND_H
|
||||||
|
#define SQLPP_DETAIL_WRAP_OPERAND_H
|
||||||
|
|
||||||
|
#include <date.h>
|
||||||
|
#include <string>
|
||||||
|
#include <sqlpp11/date_time_fwd.h>
|
||||||
|
#include <sqlpp11/serializer.h>
|
||||||
|
#include <sqlpp11/type_traits.h>
|
||||||
|
#include <sqlpp11/basic_expression_operators.h>
|
||||||
|
|
||||||
|
namespace sqlpp
|
||||||
|
{
|
||||||
|
struct integral;
|
||||||
|
struct floating_point;
|
||||||
|
struct text;
|
||||||
|
|
||||||
|
struct day_point_operand : public alias_operators<day_point_operand>
|
||||||
|
{
|
||||||
|
using _traits = make_traits<day_point, tag::is_expression, tag::is_wrapped_value>;
|
||||||
|
using _nodes = detail::type_vector<>;
|
||||||
|
using _is_aggregate_expression = std::true_type;
|
||||||
|
|
||||||
|
using _value_t = ::sqlpp::chrono::day_point;
|
||||||
|
|
||||||
|
day_point_operand() : _t{}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
day_point_operand(_value_t t) : _t(t)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
day_point_operand(const day_point_operand&) = default;
|
||||||
|
day_point_operand(day_point_operand&&) = default;
|
||||||
|
day_point_operand& operator=(const day_point_operand&) = default;
|
||||||
|
day_point_operand& operator=(day_point_operand&&) = default;
|
||||||
|
~day_point_operand() = default;
|
||||||
|
|
||||||
|
bool _is_trivial() const
|
||||||
|
{
|
||||||
|
return _t == _value_t{};
|
||||||
|
}
|
||||||
|
|
||||||
|
_value_t _t;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename Context>
|
||||||
|
struct serializer_t<Context, day_point_operand>
|
||||||
|
{
|
||||||
|
using _serialize_check = consistent_t;
|
||||||
|
using Operand = day_point_operand;
|
||||||
|
|
||||||
|
static Context& _(const Operand& t, Context& context)
|
||||||
|
{
|
||||||
|
const auto ymd = ::date::year_month_day{t._t};
|
||||||
|
context << "DATE '" << ymd << "'";
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename Period>
|
||||||
|
struct time_point_operand : public alias_operators<time_point_operand<Period>>
|
||||||
|
{
|
||||||
|
using _traits = make_traits<time_point, tag::is_expression, tag::is_wrapped_value>;
|
||||||
|
using _nodes = detail::type_vector<>;
|
||||||
|
using _is_aggregate_expression = std::true_type;
|
||||||
|
|
||||||
|
using _value_t = std::chrono::time_point<std::chrono::system_clock, Period>;
|
||||||
|
|
||||||
|
time_point_operand() : _t{}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
time_point_operand(_value_t t) : _t(t)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
time_point_operand(const time_point_operand&) = default;
|
||||||
|
time_point_operand(time_point_operand&&) = default;
|
||||||
|
time_point_operand& operator=(const time_point_operand&) = default;
|
||||||
|
time_point_operand& operator=(time_point_operand&&) = default;
|
||||||
|
~time_point_operand() = default;
|
||||||
|
|
||||||
|
bool _is_trivial() const
|
||||||
|
{
|
||||||
|
return _t == _value_t{};
|
||||||
|
}
|
||||||
|
|
||||||
|
_value_t _t;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename Context, typename Period>
|
||||||
|
struct serializer_t<Context, time_point_operand<Period>>
|
||||||
|
{
|
||||||
|
using _serialize_check = consistent_t;
|
||||||
|
using Operand = time_point_operand<Period>;
|
||||||
|
|
||||||
|
static Context& _(const Operand& t, Context& context)
|
||||||
|
{
|
||||||
|
const auto dp = ::date::floor<::date::days>(t._t);
|
||||||
|
const auto time = ::date::make_time(t._t - dp);
|
||||||
|
const auto ymd = ::date::year_month_day{dp};
|
||||||
|
context << "TIMESTAMP '" << ymd << ' ' << time << "'";
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct integral_operand : public alias_operators<integral_operand>
|
||||||
|
{
|
||||||
|
using _traits = make_traits<integral, tag::is_expression, tag::is_wrapped_value>;
|
||||||
|
using _nodes = detail::type_vector<>;
|
||||||
|
using _is_aggregate_expression = std::true_type;
|
||||||
|
|
||||||
|
using _value_t = int64_t;
|
||||||
|
|
||||||
|
integral_operand() : _t{}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
integral_operand(_value_t t) : _t(t)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
integral_operand(const integral_operand&) = default;
|
||||||
|
integral_operand(integral_operand&&) = default;
|
||||||
|
integral_operand& operator=(const integral_operand&) = default;
|
||||||
|
integral_operand& operator=(integral_operand&&) = default;
|
||||||
|
~integral_operand() = default;
|
||||||
|
|
||||||
|
bool _is_trivial() const
|
||||||
|
{
|
||||||
|
return _t == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
_value_t _t;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename Context>
|
||||||
|
struct serializer_t<Context, integral_operand>
|
||||||
|
{
|
||||||
|
using _serialize_check = consistent_t;
|
||||||
|
using Operand = integral_operand;
|
||||||
|
|
||||||
|
static Context& _(const Operand& t, Context& context)
|
||||||
|
{
|
||||||
|
context << t._t;
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct floating_point_operand : public alias_operators<floating_point_operand>
|
||||||
|
{
|
||||||
|
using _traits = make_traits<floating_point, tag::is_expression, tag::is_wrapped_value>;
|
||||||
|
using _nodes = detail::type_vector<>;
|
||||||
|
using _is_aggregate_expression = std::true_type;
|
||||||
|
|
||||||
|
using _value_t = double;
|
||||||
|
|
||||||
|
floating_point_operand() : _t{}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
floating_point_operand(_value_t t) : _t(t)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
floating_point_operand(const floating_point_operand&) = default;
|
||||||
|
floating_point_operand(floating_point_operand&&) = default;
|
||||||
|
floating_point_operand& operator=(const floating_point_operand&) = default;
|
||||||
|
floating_point_operand& operator=(floating_point_operand&&) = default;
|
||||||
|
~floating_point_operand() = default;
|
||||||
|
|
||||||
|
bool _is_trivial() const
|
||||||
|
{
|
||||||
|
return _t == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
_value_t _t;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename Context>
|
||||||
|
struct serializer_t<Context, floating_point_operand>
|
||||||
|
{
|
||||||
|
using _serialize_check = consistent_t;
|
||||||
|
using Operand = floating_point_operand;
|
||||||
|
|
||||||
|
static Context& _(const Operand& t, Context& context)
|
||||||
|
{
|
||||||
|
context << t._t;
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct text_operand : public alias_operators<text_operand>
|
||||||
|
{
|
||||||
|
using _traits = make_traits<text, tag::is_expression, tag::is_wrapped_value>;
|
||||||
|
using _nodes = detail::type_vector<>;
|
||||||
|
using _is_aggregate_expression = std::true_type;
|
||||||
|
|
||||||
|
using _value_t = std::string;
|
||||||
|
|
||||||
|
text_operand() : _t{}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
text_operand(_value_t t) : _t(t)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
text_operand(const text_operand&) = default;
|
||||||
|
text_operand(text_operand&&) = default;
|
||||||
|
text_operand& operator=(const text_operand&) = default;
|
||||||
|
text_operand& operator=(text_operand&&) = default;
|
||||||
|
~text_operand() = default;
|
||||||
|
|
||||||
|
bool _is_trivial() const
|
||||||
|
{
|
||||||
|
return _t.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
_value_t _t;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename Context>
|
||||||
|
struct serializer_t<Context, text_operand>
|
||||||
|
{
|
||||||
|
using _serialize_check = consistent_t;
|
||||||
|
using Operand = text_operand;
|
||||||
|
|
||||||
|
static Context& _(const Operand& t, Context& context)
|
||||||
|
{
|
||||||
|
context << '\'' << context.escape(t._t) << '\'';
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T, typename Enable = void>
|
||||||
|
struct wrap_operand
|
||||||
|
{
|
||||||
|
using type = T;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct wrap_operand<bool, void>
|
||||||
|
{
|
||||||
|
using type = boolean_operand;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename Period>
|
||||||
|
struct wrap_operand<std::chrono::time_point<std::chrono::system_clock, Period>, void>
|
||||||
|
{
|
||||||
|
using type = time_point_operand<Period>;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct wrap_operand<std::chrono::time_point<std::chrono::system_clock, sqlpp::chrono::days>, void>
|
||||||
|
{
|
||||||
|
using type = day_point_operand;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct wrap_operand<T, typename std::enable_if<std::is_integral<T>::value>::type>
|
||||||
|
{
|
||||||
|
using type = integral_operand;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct wrap_operand<T, typename std::enable_if<std::is_floating_point<T>::value>::type>
|
||||||
|
{
|
||||||
|
using type = floating_point_operand;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct wrap_operand<
|
||||||
|
T,
|
||||||
|
typename std::enable_if<std::is_convertible<T, std::string>::value and not is_result_field_t<T>::value>::type>
|
||||||
|
{
|
||||||
|
using type = text_operand;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -28,7 +28,7 @@
|
|||||||
#define SQLPP_EXISTS_H
|
#define SQLPP_EXISTS_H
|
||||||
|
|
||||||
#include <sqlpp11/char_sequence.h>
|
#include <sqlpp11/char_sequence.h>
|
||||||
#include <sqlpp11/boolean.h>
|
#include <sqlpp11/data_types/boolean.h>
|
||||||
|
|
||||||
namespace sqlpp
|
namespace sqlpp
|
||||||
{
|
{
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#define SQLPP_EXPRESSION_H
|
#define SQLPP_EXPRESSION_H
|
||||||
|
|
||||||
#include <sqlpp11/alias.h>
|
#include <sqlpp11/alias.h>
|
||||||
#include <sqlpp11/boolean.h>
|
#include <sqlpp11/data_types/boolean.h>
|
||||||
#include <sqlpp11/tvin.h>
|
#include <sqlpp11/tvin.h>
|
||||||
#include <sqlpp11/rhs_wrap.h>
|
#include <sqlpp11/rhs_wrap.h>
|
||||||
#include <sqlpp11/noop.h>
|
#include <sqlpp11/noop.h>
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
#include <sqlpp11/parameter.h>
|
#include <sqlpp11/parameter.h>
|
||||||
#include <sqlpp11/parameter_list.h>
|
#include <sqlpp11/parameter_list.h>
|
||||||
#include <sqlpp11/column_types.h>
|
#include <sqlpp11/data_types.h>
|
||||||
#include <sqlpp11/in.h>
|
#include <sqlpp11/in.h>
|
||||||
#include <sqlpp11/not_in.h>
|
#include <sqlpp11/not_in.h>
|
||||||
#include <sqlpp11/is_null.h>
|
#include <sqlpp11/is_null.h>
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
#include <sqlpp11/type_traits.h>
|
#include <sqlpp11/type_traits.h>
|
||||||
#include <sqlpp11/char_sequence.h>
|
#include <sqlpp11/char_sequence.h>
|
||||||
#include <sqlpp11/boolean.h>
|
#include <sqlpp11/data_types/boolean.h>
|
||||||
#include <sqlpp11/in_fwd.h>
|
#include <sqlpp11/in_fwd.h>
|
||||||
#include <sqlpp11/detail/type_set.h>
|
#include <sqlpp11/detail/type_set.h>
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#ifndef SQLPP_IS_NOT_NULL_H
|
#ifndef SQLPP_IS_NOT_NULL_H
|
||||||
#define SQLPP_IS_NOT_NULL_H
|
#define SQLPP_IS_NOT_NULL_H
|
||||||
|
|
||||||
#include <sqlpp11/boolean.h>
|
#include <sqlpp11/data_types/boolean.h>
|
||||||
#include <sqlpp11/type_traits.h>
|
#include <sqlpp11/type_traits.h>
|
||||||
#include <sqlpp11/char_sequence.h>
|
#include <sqlpp11/char_sequence.h>
|
||||||
#include <sqlpp11/detail/type_set.h>
|
#include <sqlpp11/detail/type_set.h>
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#ifndef SQLPP_IS_NULL_H
|
#ifndef SQLPP_IS_NULL_H
|
||||||
#define SQLPP_IS_NULL_H
|
#define SQLPP_IS_NULL_H
|
||||||
|
|
||||||
#include <sqlpp11/boolean.h>
|
#include <sqlpp11/data_types/boolean.h>
|
||||||
#include <sqlpp11/type_traits.h>
|
#include <sqlpp11/type_traits.h>
|
||||||
#include <sqlpp11/char_sequence.h>
|
#include <sqlpp11/char_sequence.h>
|
||||||
#include <sqlpp11/detail/type_set.h>
|
#include <sqlpp11/detail/type_set.h>
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#ifndef SQLPP_LIKE_H
|
#ifndef SQLPP_LIKE_H
|
||||||
#define SQLPP_LIKE_H
|
#define SQLPP_LIKE_H
|
||||||
|
|
||||||
#include <sqlpp11/boolean.h>
|
#include <sqlpp11/data_types/boolean.h>
|
||||||
#include <sqlpp11/type_traits.h>
|
#include <sqlpp11/type_traits.h>
|
||||||
#include <sqlpp11/char_sequence.h>
|
#include <sqlpp11/char_sequence.h>
|
||||||
#include <sqlpp11/detail/type_set.h>
|
#include <sqlpp11/detail/type_set.h>
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sqlpp11/value_type_fwd.h>
|
#include <sqlpp11/value_type_fwd.h>
|
||||||
|
#include <sqlpp11/data_types/column_operators.h>
|
||||||
|
|
||||||
namespace sqlpp
|
namespace sqlpp
|
||||||
{
|
{
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
#include <sqlpp11/type_traits.h>
|
#include <sqlpp11/type_traits.h>
|
||||||
#include <sqlpp11/char_sequence.h>
|
#include <sqlpp11/char_sequence.h>
|
||||||
#include <sqlpp11/boolean.h>
|
#include <sqlpp11/data_types/boolean.h>
|
||||||
#include <sqlpp11/in_fwd.h>
|
#include <sqlpp11/in_fwd.h>
|
||||||
#include <sqlpp11/detail/type_set.h>
|
#include <sqlpp11/detail/type_set.h>
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <sqlpp11/basic_expression_operators.h>
|
#include <sqlpp11/basic_expression_operators.h>
|
||||||
|
#include <sqlpp11/alias_operators.h>
|
||||||
|
|
||||||
namespace sqlpp
|
namespace sqlpp
|
||||||
{
|
{
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <sqlpp11/result_row_fwd.h>
|
#include <sqlpp11/result_row_fwd.h>
|
||||||
#include <sqlpp11/field_spec.h>
|
#include <sqlpp11/field_spec.h>
|
||||||
#include <sqlpp11/text.h>
|
#include <sqlpp11/data_types/text.h>
|
||||||
#include <sqlpp11/detail/field_index_sequence.h>
|
#include <sqlpp11/detail/field_index_sequence.h>
|
||||||
|
|
||||||
namespace sqlpp
|
namespace sqlpp
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#ifndef SQLPP_SOME_H
|
#ifndef SQLPP_SOME_H
|
||||||
#define SQLPP_SOME_H
|
#define SQLPP_SOME_H
|
||||||
|
|
||||||
#include <sqlpp11/boolean.h>
|
#include <sqlpp11/data_types/boolean.h>
|
||||||
#include <sqlpp11/detail/type_set.h>
|
#include <sqlpp11/detail/type_set.h>
|
||||||
#include <sqlpp11/char_sequence.h>
|
#include <sqlpp11/char_sequence.h>
|
||||||
|
|
||||||
|
@ -28,10 +28,11 @@
|
|||||||
#define SQLPP_SORT_ORDER_H
|
#define SQLPP_SORT_ORDER_H
|
||||||
|
|
||||||
#include <sqlpp11/detail/type_set.h>
|
#include <sqlpp11/detail/type_set.h>
|
||||||
#include <sqlpp11/no_value.h>
|
|
||||||
|
|
||||||
namespace sqlpp
|
namespace sqlpp
|
||||||
{
|
{
|
||||||
|
struct no_value_t;
|
||||||
|
|
||||||
enum class sort_type
|
enum class sort_type
|
||||||
{
|
{
|
||||||
asc,
|
asc,
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#define SQLPP_H
|
#define SQLPP_H
|
||||||
|
|
||||||
#include <sqlpp11/alias_provider.h>
|
#include <sqlpp11/alias_provider.h>
|
||||||
#include <sqlpp11/column_types.h>
|
#include <sqlpp11/data_types.h>
|
||||||
#include <sqlpp11/insert.h>
|
#include <sqlpp11/insert.h>
|
||||||
#include <sqlpp11/remove.h>
|
#include <sqlpp11/remove.h>
|
||||||
#include <sqlpp11/update.h>
|
#include <sqlpp11/update.h>
|
||||||
|
@ -27,9 +27,10 @@
|
|||||||
#ifndef SQLPP_VALUE_OR_NULL_H
|
#ifndef SQLPP_VALUE_OR_NULL_H
|
||||||
#define SQLPP_VALUE_OR_NULL_H
|
#define SQLPP_VALUE_OR_NULL_H
|
||||||
|
|
||||||
|
// FIXME: This is very similar to functions.h
|
||||||
#include <sqlpp11/parameter.h>
|
#include <sqlpp11/parameter.h>
|
||||||
#include <sqlpp11/parameter_list.h>
|
#include <sqlpp11/parameter_list.h>
|
||||||
#include <sqlpp11/column_types.h>
|
#include <sqlpp11/data_types.h>
|
||||||
#include <sqlpp11/in.h>
|
#include <sqlpp11/in.h>
|
||||||
#include <sqlpp11/value_type.h>
|
#include <sqlpp11/value_type.h>
|
||||||
#include <sqlpp11/exists.h>
|
#include <sqlpp11/exists.h>
|
||||||
|
@ -32,18 +32,6 @@
|
|||||||
|
|
||||||
namespace sqlpp
|
namespace sqlpp
|
||||||
{
|
{
|
||||||
template <typename ValueType>
|
|
||||||
struct parameter_value_t
|
|
||||||
{
|
|
||||||
static_assert(wrong_t<parameter_value_t>::value, "Missing parameter value type for ValueType");
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Column, typename ValueType>
|
|
||||||
struct column_operators
|
|
||||||
{
|
|
||||||
static_assert(wrong_t<column_operators>::value, "Missing column operators for ValueType");
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Expr, typename ValueType>
|
template <typename Expr, typename ValueType>
|
||||||
struct expression_operators
|
struct expression_operators
|
||||||
{
|
{
|
||||||
|
@ -27,64 +27,32 @@
|
|||||||
#ifndef SQLPP_DETAIL_WRAP_OPERAND_H
|
#ifndef SQLPP_DETAIL_WRAP_OPERAND_H
|
||||||
#define SQLPP_DETAIL_WRAP_OPERAND_H
|
#define SQLPP_DETAIL_WRAP_OPERAND_H
|
||||||
|
|
||||||
|
namespace sqlpp
|
||||||
|
{
|
||||||
|
template <typename T, typename Enable = void>
|
||||||
|
struct wrap_operand
|
||||||
|
{
|
||||||
|
using type = T;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
using wrap_operand_t = typename wrap_operand<T>::type;
|
||||||
|
}
|
||||||
|
|
||||||
#include <date.h>
|
#include <date.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sqlpp11/date_time_fwd.h>
|
#include <sqlpp11/date_time_fwd.h>
|
||||||
#include <sqlpp11/wrap_operand_fwd.h>
|
|
||||||
#include <sqlpp11/serializer.h>
|
#include <sqlpp11/serializer.h>
|
||||||
#include <sqlpp11/type_traits.h>
|
#include <sqlpp11/type_traits.h>
|
||||||
#include <sqlpp11/basic_expression_operators.h>
|
#include <sqlpp11/basic_expression_operators.h>
|
||||||
|
#include <sqlpp11/alias_operators.h>
|
||||||
|
|
||||||
namespace sqlpp
|
namespace sqlpp
|
||||||
{
|
{
|
||||||
struct boolean;
|
|
||||||
struct integral;
|
struct integral;
|
||||||
struct floating_point;
|
struct floating_point;
|
||||||
struct text;
|
struct text;
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct day_point_operand : public alias_operators<day_point_operand>
|
struct day_point_operand : public alias_operators<day_point_operand>
|
||||||
{
|
{
|
||||||
using _traits = make_traits<day_point, tag::is_expression, tag::is_wrapped_value>;
|
using _traits = make_traits<day_point, tag::is_expression, tag::is_wrapped_value>;
|
||||||
@ -305,18 +273,6 @@ namespace sqlpp
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T, typename Enable>
|
|
||||||
struct wrap_operand
|
|
||||||
{
|
|
||||||
using type = T;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct wrap_operand<bool, void>
|
|
||||||
{
|
|
||||||
using type = boolean_operand;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Period>
|
template <typename Period>
|
||||||
struct wrap_operand<std::chrono::time_point<std::chrono::system_clock, Period>, void>
|
struct wrap_operand<std::chrono::time_point<std::chrono::system_clock, Period>, void>
|
||||||
{
|
{
|
||||||
|
@ -121,7 +121,7 @@ print('#ifndef '+get_include_guard_name(namespace, pathToHeader), file=header)
|
|||||||
print('#define '+get_include_guard_name(namespace, pathToHeader), file=header)
|
print('#define '+get_include_guard_name(namespace, pathToHeader), file=header)
|
||||||
print('', file=header)
|
print('', file=header)
|
||||||
print('#include <' + INCLUDE + '/table.h>', file=header)
|
print('#include <' + INCLUDE + '/table.h>', file=header)
|
||||||
print('#include <' + INCLUDE + '/column_types.h>', file=header)
|
print('#include <' + INCLUDE + '/data_types.h>', file=header)
|
||||||
print('#include <' + INCLUDE + '/char_sequence.h>', file=header)
|
print('#include <' + INCLUDE + '/char_sequence.h>', file=header)
|
||||||
print('', file=header)
|
print('', file=header)
|
||||||
print('namespace ' + namespace, file=header)
|
print('namespace ' + namespace, file=header)
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#define TEST_ASSERTTABLES_H
|
#define TEST_ASSERTTABLES_H
|
||||||
|
|
||||||
#include <sqlpp11/table.h>
|
#include <sqlpp11/table.h>
|
||||||
#include <sqlpp11/column_types.h>
|
#include <sqlpp11/data_types.h>
|
||||||
#include <sqlpp11/char_sequence.h>
|
#include <sqlpp11/char_sequence.h>
|
||||||
|
|
||||||
namespace test
|
namespace test
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define TEST_SAMPLE_H
|
#define TEST_SAMPLE_H
|
||||||
|
|
||||||
#include <sqlpp11/table.h>
|
#include <sqlpp11/table.h>
|
||||||
#include <sqlpp11/column_types.h>
|
#include <sqlpp11/data_types.h>
|
||||||
#include <sqlpp11/char_sequence.h>
|
#include <sqlpp11/char_sequence.h>
|
||||||
|
|
||||||
namespace test
|
namespace test
|
||||||
|
Loading…
Reference in New Issue
Block a user