From d288c658971bc626295b71d52de3932253c0d6a6 Mon Sep 17 00:00:00 2001 From: rbock Date: Sun, 2 Feb 2014 14:58:08 +0100 Subject: [PATCH] Minor code cleanup (set -> type_set) --- include/sqlpp11/detail/set.h | 201 -------------------- include/sqlpp11/detail/type_set.h | 201 ++++++++++++++++++++ include/sqlpp11/on.h | 2 +- include/sqlpp11/select_flags.h | 2 +- include/sqlpp11/table.h | 4 +- include/sqlpp11/table_alias.h | 4 +- include/sqlpp11/vendor/column_list.h | 2 +- include/sqlpp11/vendor/concat.h | 2 +- include/sqlpp11/vendor/group_by.h | 2 +- include/sqlpp11/vendor/having.h | 2 +- include/sqlpp11/vendor/in.h | 2 +- include/sqlpp11/vendor/insert_list.h | 2 +- include/sqlpp11/vendor/insert_value_list.h | 2 +- include/sqlpp11/vendor/is_null.h | 2 +- include/sqlpp11/vendor/like.h | 2 +- include/sqlpp11/vendor/select_column_list.h | 2 +- include/sqlpp11/vendor/select_flag_list.h | 2 +- include/sqlpp11/vendor/update_list.h | 2 +- include/sqlpp11/vendor/using.h | 2 +- include/sqlpp11/vendor/where.h | 2 +- 20 files changed, 221 insertions(+), 221 deletions(-) delete mode 100644 include/sqlpp11/detail/set.h create mode 100644 include/sqlpp11/detail/type_set.h diff --git a/include/sqlpp11/detail/set.h b/include/sqlpp11/detail/set.h deleted file mode 100644 index 2b1a153f..00000000 --- a/include/sqlpp11/detail/set.h +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright (c) 2013, 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_SET_H -#define SQLPP_DETAIL_SET_H - -#include -#include - -namespace sqlpp -{ - namespace detail - { - template - struct make_set; - - template - class empty {}; - - template - struct is_superset_of_impl - : std::false_type {}; - - template - struct is_superset_of_impl - : std::true_type {}; - - template - struct is_superset_of_impl - : std::integral_constant::value and is_superset_of_impl::value> {}; - - template - struct is_disjunct_from_impl - : std::false_type {}; - - template - struct is_disjunct_from_impl - : std::true_type {}; - - template - struct is_disjunct_from_impl - : std::integral_constant::value and is_disjunct_from_impl::value> {}; - - template - struct set: empty... - { - struct size: std::integral_constant {}; - - template - struct contains - : std::integral_constant, set>::value> {}; - - template - struct is_superset_of - { - static_assert(::sqlpp::vendor::wrong_t::value, "invalid argument for is_superset_of"); - }; - - template - struct is_superset_of> - : is_superset_of_impl{}; - - template - struct join - { - static_assert(::sqlpp::vendor::wrong_t::value, "invalid argument for set::join"); - }; - - template - struct join> - : make_set {}; - - template - struct is_disjunct_from - { - static_assert(::sqlpp::vendor::wrong_t::value, "invalid argument for is_disjunct_from"); - }; - - template - struct is_disjunct_from> - : is_disjunct_from_impl{}; - - template - struct is_subset_of - { - static_assert(::sqlpp::vendor::wrong_t::value, "invalid argument for is_subset_of"); - }; - - template - struct is_subset_of> - : is_superset_of_impl, Element...>{}; - - template - struct equals - { - static_assert(::sqlpp::vendor::wrong_t::value, "invalid argument for equals"); - }; - - template - struct equals> - : std::integral_constant, Element...>::value - and - is_superset_of_impl, T...>::value> {}; - - template - struct insert - { - typedef set type; - }; - - template - struct insert::value>::type> - { - typedef set type; - }; - - template class Predicate, typename T, typename Enable = void> - struct insert_if - { - typedef set type; - }; - - template class Predicate, typename T> - struct insert_if::value and Predicate::value>::type> - { - typedef set type; - }; - - }; - - template<> - struct make_set<> - { - typedef set<> type; - }; - - template - struct make_set - { - typedef typename make_set::type::template insert::type type; - }; - - template class Predicate, typename... T> - struct make_set_if; - - template class Predicate> - struct make_set_if - { - typedef set<> type; - }; - - template class Predicate, typename T, typename... Rest> - struct make_set_if - { - typedef typename make_set_if::type::template insert_if::type type; - }; - - template class Predicate, typename... T> - struct make_set_if_not - { - template - struct InversePredicate - { - static constexpr bool value = not Predicate::value; - }; - using type = typename make_set_if::type; - }; - - template - struct has_duplicates - : std::integral_constant::type::size::value != sizeof...(T)> {}; - - } -} - - -#endif diff --git a/include/sqlpp11/detail/type_set.h b/include/sqlpp11/detail/type_set.h new file mode 100644 index 00000000..a63e0caf --- /dev/null +++ b/include/sqlpp11/detail/type_set.h @@ -0,0 +1,201 @@ +/* + * Copyright (c) 2013, 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_TYPE_SET_H +#define SQLPP_DETAIL_TYPE_SET_H + +#include +#include + +namespace sqlpp +{ + namespace detail + { + template + struct make_set; + + template + class type_set_element {}; + + template + struct is_superset_of_impl + : std::false_type {}; + + template + struct is_superset_of_impl + : std::true_type {}; + + template + struct is_superset_of_impl + : std::integral_constant::value and is_superset_of_impl::value> {}; + + template + struct is_disjunct_from_impl + : std::false_type {}; + + template + struct is_disjunct_from_impl + : std::true_type {}; + + template + struct is_disjunct_from_impl + : std::integral_constant::value and is_disjunct_from_impl::value> {}; + + template + struct type_set: type_set_element... + { + struct size: std::integral_constant {}; + + template + struct contains + : std::integral_constant, type_set>::value> {}; + + template + struct is_superset_of + { + static_assert(::sqlpp::vendor::wrong_t::value, "invalid argument for is_superset_of"); + }; + + template + struct is_superset_of> + : is_superset_of_impl{}; + + template + struct join + { + static_assert(::sqlpp::vendor::wrong_t::value, "invalid argument for type_set::join"); + }; + + template + struct join> + : make_set {}; + + template + struct is_disjunct_from + { + static_assert(::sqlpp::vendor::wrong_t::value, "invalid argument for is_disjunct_from"); + }; + + template + struct is_disjunct_from> + : is_disjunct_from_impl{}; + + template + struct is_subset_of + { + static_assert(::sqlpp::vendor::wrong_t::value, "invalid argument for is_subset_of"); + }; + + template + struct is_subset_of> + : is_superset_of_impl, Element...>{}; + + template + struct equals + { + static_assert(::sqlpp::vendor::wrong_t::value, "invalid argument for equals"); + }; + + template + struct equals> + : std::integral_constant, Element...>::value + and + is_superset_of_impl, T...>::value> {}; + + template + struct insert + { + using type = type_set; + }; + + template + struct insert::value>::type> + { + using type = type_set; + }; + + template class Predicate, typename T, typename Enable = void> + struct insert_if + { + using type = type_set; + }; + + template class Predicate, typename T> + struct insert_if::value and Predicate::value>::type> + { + using type = type_set; + }; + + }; + + template<> + struct make_set<> + { + using type = type_set<>; + }; + + template + struct make_set + { + using type = typename make_set::type::template insert::type; + }; + + template class Predicate, typename... T> + struct make_set_if; + + template class Predicate> + struct make_set_if + { + using type = type_set<>; + }; + + template class Predicate, typename T, typename... Rest> + struct make_set_if + { + using type = typename make_set_if::type::template insert_if::type; + }; + + template class Predicate, typename... T> + struct make_set_if_not + { + template + struct InversePredicate + { + static constexpr bool value = not Predicate::value; + }; + using type = typename make_set_if::type; + }; + + template + struct has_duplicates + : std::integral_constant::type::size::value != sizeof...(T)> {}; + + } +} + + +#endif diff --git a/include/sqlpp11/on.h b/include/sqlpp11/on.h index e628f33c..c8ab0b0b 100644 --- a/include/sqlpp11/on.h +++ b/include/sqlpp11/on.h @@ -28,7 +28,7 @@ #define SQLPP_ON_H #include -#include +#include #include #include diff --git a/include/sqlpp11/select_flags.h b/include/sqlpp11/select_flags.h index ffd15b30..3bcce768 100644 --- a/include/sqlpp11/select_flags.h +++ b/include/sqlpp11/select_flags.h @@ -29,7 +29,7 @@ #include #include -#include +#include #include #include diff --git a/include/sqlpp11/table.h b/include/sqlpp11/table.h index 0066889d..afa9f95e 100644 --- a/include/sqlpp11/table.h +++ b/include/sqlpp11/table.h @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include @@ -41,7 +41,7 @@ namespace sqlpp template struct table_t: public table_base_t, public ColumnSpec::_name_t::template _member_t>... { - using _table_set = detail::set; // Hint need a set here to be similar to a join (which always represents more than one table) + using _table_set = detail::type_set
; // Hint need a type_set here to be similar to a join (which always represents more than one table) using _all_columns = typename detail::make_set...>::type; static_assert(_all_columns::size::value, "at least one column required per table"); using _required_insert_columns = typename detail::make_set_if...>::type; diff --git a/include/sqlpp11/table_alias.h b/include/sqlpp11/table_alias.h index 2fa87c45..269d80b1 100644 --- a/include/sqlpp11/table_alias.h +++ b/include/sqlpp11/table_alias.h @@ -31,7 +31,7 @@ #include #include #include -#include +#include namespace sqlpp { @@ -42,7 +42,7 @@ namespace sqlpp { //FIXME: Need to add join functionality using _is_table = std::true_type; - using _table_set = detail::set; + using _table_set = detail::type_set; struct _value_type: Table::_value_type { diff --git a/include/sqlpp11/vendor/column_list.h b/include/sqlpp11/vendor/column_list.h index 4659e1b2..289cf25f 100644 --- a/include/sqlpp11/vendor/column_list.h +++ b/include/sqlpp11/vendor/column_list.h @@ -28,7 +28,7 @@ #define SQLPP_COLUMN_LIST_H #include -#include +#include #include #include diff --git a/include/sqlpp11/vendor/concat.h b/include/sqlpp11/vendor/concat.h index 0aa524b9..0f2acc8d 100644 --- a/include/sqlpp11/vendor/concat.h +++ b/include/sqlpp11/vendor/concat.h @@ -29,7 +29,7 @@ #include #include -#include +#include namespace sqlpp { diff --git a/include/sqlpp11/vendor/group_by.h b/include/sqlpp11/vendor/group_by.h index db3e5d82..1e5480cf 100644 --- a/include/sqlpp11/vendor/group_by.h +++ b/include/sqlpp11/vendor/group_by.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include namespace sqlpp { diff --git a/include/sqlpp11/vendor/having.h b/include/sqlpp11/vendor/having.h index 47fbc7cd..dd6be6d4 100644 --- a/include/sqlpp11/vendor/having.h +++ b/include/sqlpp11/vendor/having.h @@ -31,7 +31,7 @@ #include #include #include -#include +#include namespace sqlpp { diff --git a/include/sqlpp11/vendor/in.h b/include/sqlpp11/vendor/in.h index c3e20b25..993a3288 100644 --- a/include/sqlpp11/vendor/in.h +++ b/include/sqlpp11/vendor/in.h @@ -30,7 +30,7 @@ #include #include #include -#include +#include namespace sqlpp { diff --git a/include/sqlpp11/vendor/insert_list.h b/include/sqlpp11/vendor/insert_list.h index db3af25e..ac1680b0 100644 --- a/include/sqlpp11/vendor/insert_list.h +++ b/include/sqlpp11/vendor/insert_list.h @@ -28,7 +28,7 @@ #define SQLPP_INSERT_LIST_H #include -#include +#include #include #include #include diff --git a/include/sqlpp11/vendor/insert_value_list.h b/include/sqlpp11/vendor/insert_value_list.h index f3d2b4ba..a42cff0f 100644 --- a/include/sqlpp11/vendor/insert_value_list.h +++ b/include/sqlpp11/vendor/insert_value_list.h @@ -28,7 +28,7 @@ #define SQLPP_INSERT_VALUE_LIST_H #include -#include +#include #include #include diff --git a/include/sqlpp11/vendor/is_null.h b/include/sqlpp11/vendor/is_null.h index 1bbafb64..7b7dab61 100644 --- a/include/sqlpp11/vendor/is_null.h +++ b/include/sqlpp11/vendor/is_null.h @@ -29,7 +29,7 @@ #include #include -#include +#include namespace sqlpp { diff --git a/include/sqlpp11/vendor/like.h b/include/sqlpp11/vendor/like.h index 8647cb08..6ad5d9a9 100644 --- a/include/sqlpp11/vendor/like.h +++ b/include/sqlpp11/vendor/like.h @@ -29,7 +29,7 @@ #include #include -#include +#include namespace sqlpp { diff --git a/include/sqlpp11/vendor/select_column_list.h b/include/sqlpp11/vendor/select_column_list.h index 82d28111..dcbcc8e6 100644 --- a/include/sqlpp11/vendor/select_column_list.h +++ b/include/sqlpp11/vendor/select_column_list.h @@ -37,7 +37,7 @@ #include #include #include -#include +#include namespace sqlpp { diff --git a/include/sqlpp11/vendor/select_flag_list.h b/include/sqlpp11/vendor/select_flag_list.h index 7833bef1..14b1d978 100644 --- a/include/sqlpp11/vendor/select_flag_list.h +++ b/include/sqlpp11/vendor/select_flag_list.h @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include diff --git a/include/sqlpp11/vendor/update_list.h b/include/sqlpp11/vendor/update_list.h index 435a2d83..4cc70255 100644 --- a/include/sqlpp11/vendor/update_list.h +++ b/include/sqlpp11/vendor/update_list.h @@ -28,7 +28,7 @@ #define SQLPP_UPDATE_LIST_H #include -#include +#include #include #include diff --git a/include/sqlpp11/vendor/using.h b/include/sqlpp11/vendor/using.h index 410a2cfe..24b7ba69 100644 --- a/include/sqlpp11/vendor/using.h +++ b/include/sqlpp11/vendor/using.h @@ -28,7 +28,7 @@ #define SQLPP_USING_H #include -#include +#include #include #include diff --git a/include/sqlpp11/vendor/where.h b/include/sqlpp11/vendor/where.h index e4e87505..94d7a85c 100644 --- a/include/sqlpp11/vendor/where.h +++ b/include/sqlpp11/vendor/where.h @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include #include