From 1c4d041b891ac0d2f296a77c792d4390ff30aacd Mon Sep 17 00:00:00 2001 From: rbock Date: Wed, 15 Jan 2014 23:05:24 +0100 Subject: [PATCH] Cleaned up some outdated serialize functions --- include/sqlpp11/assignment_list.h | 14 ------- include/sqlpp11/boolean.h | 12 ------ include/sqlpp11/floating_point.h | 12 ------ include/sqlpp11/functions.h | 10 ++--- include/sqlpp11/in.h | 11 ----- include/sqlpp11/integral.h | 12 ------ include/sqlpp11/like.h | 10 ----- include/sqlpp11/parameter_list.h | 64 ------------------------------ include/sqlpp11/select_flag_list.h | 7 ---- include/sqlpp11/table_alias.h | 6 --- include/sqlpp11/using.h | 16 -------- 11 files changed, 5 insertions(+), 169 deletions(-) diff --git a/include/sqlpp11/assignment_list.h b/include/sqlpp11/assignment_list.h index f301dd0c..4b20f9b7 100644 --- a/include/sqlpp11/assignment_list.h +++ b/include/sqlpp11/assignment_list.h @@ -63,20 +63,6 @@ namespace sqlpp _dynamic_assignments.emplace_back(std::forward(assignment)); } - template - void serialize(std::ostream& os, Db& db) const - { - os << " SET "; - detail::serialize_tuple(os, db, _assignments, ','); - _dynamic_assignments.serialize(os, db, sizeof...(Assignments) == 0); - } - - size_t _set_parameter_index(size_t index) - { - index = set_parameter_index(_assignments, index); - return index; - } - _parameter_tuple_t _assignments; typename detail::serializable_list _dynamic_assignments; }; diff --git a/include/sqlpp11/boolean.h b/include/sqlpp11/boolean.h index bb9ce319..828ec5f4 100644 --- a/include/sqlpp11/boolean.h +++ b/include/sqlpp11/boolean.h @@ -91,12 +91,6 @@ namespace sqlpp return *this; } - template - void serialize(std::ostream& os, Db& db) const - { - os << value(); - } - bool is_null() const { return _is_null; @@ -153,12 +147,6 @@ namespace sqlpp _value = 0; } - template - void serialize(std::ostream& os, Db& db) const - { - os << value(); - } - bool is_null() const { if (not _is_valid) diff --git a/include/sqlpp11/floating_point.h b/include/sqlpp11/floating_point.h index 7eae7ac0..f9aff2bc 100644 --- a/include/sqlpp11/floating_point.h +++ b/include/sqlpp11/floating_point.h @@ -76,12 +76,6 @@ namespace sqlpp return *this; } - template - void serialize(std::ostream& os, Db& db) const - { - os << value(); - } - bool is_null() const { return _is_null; @@ -140,12 +134,6 @@ namespace sqlpp _value = 0; } - template - void serialize(std::ostream& os, Db& db) const - { - os << value(); - } - bool is_null() const { if (not _is_valid) diff --git a/include/sqlpp11/functions.h b/include/sqlpp11/functions.h index 645b04a8..44e3118a 100644 --- a/include/sqlpp11/functions.h +++ b/include/sqlpp11/functions.h @@ -84,12 +84,12 @@ namespace sqlpp return { std::forward(s) }; } - template - auto flatten(const Expression& exp, const Db& db) -> verbatim_t::type::_value_type::_base_value_type> + template + auto flatten(const Expression& exp, const Context& context) -> verbatim_t::type::_value_type::_base_value_type> { - std::ostringstream os; - exp.serialize(os, db); - return { os.str() }; + context.clear(); + interpret(exp, context); + return { context.str() }; } template diff --git a/include/sqlpp11/in.h b/include/sqlpp11/in.h index 7ed87ef6..6d188f98 100644 --- a/include/sqlpp11/in.h +++ b/include/sqlpp11/in.h @@ -74,17 +74,6 @@ namespace sqlpp in_t& operator=(in_t&&) = default; ~in_t() = default; - template - void serialize(std::ostream& os, Db& db) const - { - static_assert((NotInverted and Db::_supports_in) - or (_inverted and Db::_supports_not_in), "in() and/or not_in() not supported by current database"); - _operand.serialize(os, db); - os << (_inverted ? " NOT IN(" : " IN("); - serialize_tuple(os, db, _args, ','); - os << ")"; - } - Operand _operand; std::tuple _args; }; diff --git a/include/sqlpp11/integral.h b/include/sqlpp11/integral.h index 17b49c19..37ab4a11 100644 --- a/include/sqlpp11/integral.h +++ b/include/sqlpp11/integral.h @@ -79,12 +79,6 @@ namespace sqlpp _is_null = true; } - template - void serialize(std::ostream& os, Db& db) const - { - os << value(); - } - bool is_null() const { return _is_null; @@ -143,12 +137,6 @@ namespace sqlpp _is_valid = true; } - template - void serialize(std::ostream& os, Db& db) const - { - os << value(); - } - bool is_null() const { if (not _is_valid) diff --git a/include/sqlpp11/like.h b/include/sqlpp11/like.h index 6e5b4c75..2b72b6be 100644 --- a/include/sqlpp11/like.h +++ b/include/sqlpp11/like.h @@ -70,16 +70,6 @@ namespace sqlpp like_t& operator=(like_t&&) = default; ~like_t() = default; - template - void serialize(std::ostream& os, Db& db) const - { - static_assert(Db::_supports_like, "like() not supported by current database"); - _operand.serialize(os, db); - os << " LIKE("; - _pattern.serialize(os, db); - os << ")"; - } - Operand _operand; Pattern _pattern; }; diff --git a/include/sqlpp11/parameter_list.h b/include/sqlpp11/parameter_list.h index 37b32f8e..ac109cf1 100644 --- a/include/sqlpp11/parameter_list.h +++ b/include/sqlpp11/parameter_list.h @@ -124,70 +124,6 @@ namespace sqlpp using type = parameter_list_t::type>::type>; }; - template - size_t set_parameter_index(T& t, size_t index); - - namespace detail - { - template - struct set_parameter_index_t - { - size_t operator()(Exp& e, size_t index) - { - return index; - } - }; - - template - struct set_parameter_index_t::value, void>::type> - { - size_t operator()(Exp& e, size_t index) - { - return e._set_parameter_index(index); - } - }; - - template - struct set_parameter_index_t, void> - { - template struct type{}; - - size_t operator()(std::tuple& t, size_t index) - { - return impl(t, index, type<0>()); - } - private: - template - size_t impl(std::tuple& t, size_t index, const type&) - { - index = sqlpp::set_parameter_index(std::get(t), index); - return impl(t, index, type()); - } - - size_t impl(std::tuple& t, size_t index, const type&) - { - return index; - } - }; - - template - struct set_parameter_index_t::value, void>::type> - { - size_t operator()(Exp& e, size_t index) - { - return e._set_parameter_index(index); - } - }; - - } - - - template - size_t set_parameter_index(T& t, size_t index) - { - return detail::set_parameter_index_t()(t, index); - } - } #endif diff --git a/include/sqlpp11/select_flag_list.h b/include/sqlpp11/select_flag_list.h index 44b10fa1..666c78e4 100644 --- a/include/sqlpp11/select_flag_list.h +++ b/include/sqlpp11/select_flag_list.h @@ -107,13 +107,6 @@ namespace sqlpp using _is_select_flag_list = std::true_type; - template - void serialize(std::ostream& os, Db& db) const - { - detail::serialize_tuple(os, db, _flags, ' '); - os << ' '; - } - std::tuple _flags; }; diff --git a/include/sqlpp11/table_alias.h b/include/sqlpp11/table_alias.h index 879f067f..91887b5e 100644 --- a/include/sqlpp11/table_alias.h +++ b/include/sqlpp11/table_alias.h @@ -59,12 +59,6 @@ namespace sqlpp _table(table) {} - template - void serialize(std::ostream& os, Db& db) const - { - os << "("; _table.serialize(os, db); os << ") AS " << _name_t::_get_name(); - } - Table _table; }; diff --git a/include/sqlpp11/using.h b/include/sqlpp11/using.h index 10e5b905..8371833c 100644 --- a/include/sqlpp11/using.h +++ b/include/sqlpp11/using.h @@ -59,22 +59,6 @@ namespace sqlpp _dynamic_tables.emplace_back(std::forward(table)); } - template - void serialize(std::ostream& os, Db& db) const - { - if (sizeof...(Table) == 0 and _dynamic_tables.empty()) - return; - os << " USING "; - detail::serialize_tuple(os, db, _tables, ','); - _dynamic_tables.serialize(os, db, sizeof...(Table) == 0); - } - - size_t _set_parameter_index(size_t index) - { - index = set_parameter_index(_tables, index); - return index; - } - _parameter_tuple_t _tables; detail::serializable_list _dynamic_tables; };