mirror of
https://github.com/rbock/sqlpp11.git
synced 2026-01-06 13:10:34 -06:00
Cleaned up some outdated serialize functions
This commit is contained in:
@@ -63,20 +63,6 @@ namespace sqlpp
|
||||
_dynamic_assignments.emplace_back(std::forward<Assignment>(assignment));
|
||||
}
|
||||
|
||||
template<typename Db>
|
||||
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<Database> _dynamic_assignments;
|
||||
};
|
||||
|
||||
@@ -91,12 +91,6 @@ namespace sqlpp
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename Db>
|
||||
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<typename Db>
|
||||
void serialize(std::ostream& os, Db& db) const
|
||||
{
|
||||
os << value();
|
||||
}
|
||||
|
||||
bool is_null() const
|
||||
{
|
||||
if (not _is_valid)
|
||||
|
||||
@@ -76,12 +76,6 @@ namespace sqlpp
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename Db>
|
||||
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<typename Db>
|
||||
void serialize(std::ostream& os, Db& db) const
|
||||
{
|
||||
os << value();
|
||||
}
|
||||
|
||||
bool is_null() const
|
||||
{
|
||||
if (not _is_valid)
|
||||
|
||||
@@ -84,12 +84,12 @@ namespace sqlpp
|
||||
return { std::forward<StringType>(s) };
|
||||
}
|
||||
|
||||
template<typename Expression, typename Db>
|
||||
auto flatten(const Expression& exp, const Db& db) -> verbatim_t<typename std::decay<Expression>::type::_value_type::_base_value_type>
|
||||
template<typename Expression, typename Context>
|
||||
auto flatten(const Expression& exp, const Context& context) -> verbatim_t<typename std::decay<Expression>::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<typename Container>
|
||||
|
||||
@@ -74,17 +74,6 @@ namespace sqlpp
|
||||
in_t& operator=(in_t&&) = default;
|
||||
~in_t() = default;
|
||||
|
||||
template<typename Db>
|
||||
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...> _args;
|
||||
};
|
||||
|
||||
@@ -79,12 +79,6 @@ namespace sqlpp
|
||||
_is_null = true;
|
||||
}
|
||||
|
||||
template<typename Db>
|
||||
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<typename Db>
|
||||
void serialize(std::ostream& os, Db& db) const
|
||||
{
|
||||
os << value();
|
||||
}
|
||||
|
||||
bool is_null() const
|
||||
{
|
||||
if (not _is_valid)
|
||||
|
||||
@@ -70,16 +70,6 @@ namespace sqlpp
|
||||
like_t& operator=(like_t&&) = default;
|
||||
~like_t() = default;
|
||||
|
||||
template<typename Db>
|
||||
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;
|
||||
};
|
||||
|
||||
@@ -124,70 +124,6 @@ namespace sqlpp
|
||||
using type = parameter_list_t<typename detail::get_parameter_tuple<typename std::decay<Exp>::type>::type>;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
size_t set_parameter_index(T& t, size_t index);
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template<typename Exp, typename Enable = void>
|
||||
struct set_parameter_index_t
|
||||
{
|
||||
size_t operator()(Exp& e, size_t index)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Exp>
|
||||
struct set_parameter_index_t<Exp, typename std::enable_if<is_parameter_t<Exp>::value, void>::type>
|
||||
{
|
||||
size_t operator()(Exp& e, size_t index)
|
||||
{
|
||||
return e._set_parameter_index(index);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename... Param>
|
||||
struct set_parameter_index_t<std::tuple<Param...>, void>
|
||||
{
|
||||
template<size_t> struct type{};
|
||||
|
||||
size_t operator()(std::tuple<Param...>& t, size_t index)
|
||||
{
|
||||
return impl(t, index, type<0>());
|
||||
}
|
||||
private:
|
||||
template<size_t pos>
|
||||
size_t impl(std::tuple<Param...>& t, size_t index, const type<pos>&)
|
||||
{
|
||||
index = sqlpp::set_parameter_index(std::get<pos>(t), index);
|
||||
return impl(t, index, type<pos + 1>());
|
||||
}
|
||||
|
||||
size_t impl(std::tuple<Param...>& t, size_t index, const type<sizeof...(Param)>&)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Exp>
|
||||
struct set_parameter_index_t<Exp, typename std::enable_if<not std::is_same<typename Exp::_parameter_tuple_t, void>::value, void>::type>
|
||||
{
|
||||
size_t operator()(Exp& e, size_t index)
|
||||
{
|
||||
return e._set_parameter_index(index);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
size_t set_parameter_index(T& t, size_t index)
|
||||
{
|
||||
return detail::set_parameter_index_t<T>()(t, index);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -107,13 +107,6 @@ namespace sqlpp
|
||||
|
||||
using _is_select_flag_list = std::true_type;
|
||||
|
||||
template<typename Db>
|
||||
void serialize(std::ostream& os, Db& db) const
|
||||
{
|
||||
detail::serialize_tuple(os, db, _flags, ' ');
|
||||
os << ' ';
|
||||
}
|
||||
|
||||
std::tuple<Flag...> _flags;
|
||||
};
|
||||
|
||||
|
||||
@@ -59,12 +59,6 @@ namespace sqlpp
|
||||
_table(table)
|
||||
{}
|
||||
|
||||
template<typename Db>
|
||||
void serialize(std::ostream& os, Db& db) const
|
||||
{
|
||||
os << "("; _table.serialize(os, db); os << ") AS " << _name_t::_get_name();
|
||||
}
|
||||
|
||||
Table _table;
|
||||
};
|
||||
|
||||
|
||||
@@ -59,22 +59,6 @@ namespace sqlpp
|
||||
_dynamic_tables.emplace_back(std::forward<T>(table));
|
||||
}
|
||||
|
||||
template<typename Db>
|
||||
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<Database> _dynamic_tables;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user