0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-15 20:31:16 +08:00

Make g++-4.8 compile again

This commit is contained in:
rbock 2014-01-18 16:10:46 +01:00
parent 312e735d6d
commit 87302fa27f
26 changed files with 528 additions and 439 deletions

View File

@ -45,21 +45,24 @@ namespace sqlpp
Expression _expression; Expression _expression;
}; };
template<typename Context, typename Expression, typename AliasProvider> namespace vendor
struct vendor::interpreter_t<Context, expression_alias_t<Expression, AliasProvider>> {
{ template<typename Context, typename Expression, typename AliasProvider>
using T = expression_alias_t<Expression, AliasProvider>; struct interpreter_t<Context, expression_alias_t<Expression, AliasProvider>>
static Context& _(const T& t, Context& context)
{ {
context << '('; using T = expression_alias_t<Expression, AliasProvider>;
interpret(t._expression, context);
context << ") AS ";
context << T::_name_t::_get_name();
return context;
}
};
static Context& _(const T& t, Context& context)
{
context << '(';
interpret(t._expression, context);
context << ") AS ";
context << T::_name_t::_get_name();
return context;
}
};
}
} }
#endif #endif

View File

@ -75,26 +75,29 @@ namespace sqlpp
}; };
} }
template<typename Context, typename Select> namespace vendor
struct vendor::interpreter_t<Context, vendor::any_t<Select>>
{
using T = vendor::any_t<Select>;
static Context& _(const T& t, Context& context)
{
context << "ANY(";
interpret(t._select, context);
context << ")";
return context;
}
};
template<typename T>
auto any(T&& t) -> typename vendor::any_t<typename operand_t<T, is_select_t>::type>
{ {
return { std::forward<T>(t) }; template<typename Context, typename Select>
} struct interpreter_t<Context, vendor::any_t<Select>>
{
using T = vendor::any_t<Select>;
static Context& _(const T& t, Context& context)
{
context << "ANY(";
interpret(t._select, context);
context << ")";
return context;
}
};
template<typename T>
auto any(T&& t) -> typename vendor::any_t<typename operand_t<T, is_select_t>::type>
{
return { std::forward<T>(t) };
}
}
} }
#endif #endif

View File

@ -74,25 +74,28 @@ namespace sqlpp
}; };
} }
template<typename Context, typename Expr> namespace vendor
struct vendor::interpreter_t<Context, vendor::avg_t<Expr>> {
{ template<typename Context, typename Expr>
using T = vendor::avg_t<Expr>; struct interpreter_t<Context, vendor::avg_t<Expr>>
static Context& _(const T& t, Context& context)
{ {
context << "AVG("; using T = vendor::avg_t<Expr>;
interpret(t._expr, context);
context << ")"; static Context& _(const T& t, Context& context)
return context; {
} context << "AVG(";
}; interpret(t._expr, context);
context << ")";
return context;
}
};
}
template<typename T> template<typename T>
auto avg(T&& t) -> typename vendor::avg_t<typename operand_t<T, is_value_t>::type> auto avg(T&& t) -> typename vendor::avg_t<typename operand_t<T, is_value_t>::type>
{ {
return { std::forward<T>(t) }; return { std::forward<T>(t) };
} }
} }

View File

@ -78,18 +78,21 @@ namespace sqlpp
} }
}; };
template<typename Context, typename... Args> namespace vendor
struct vendor::interpreter_t<Context, column_t<Args...>> {
{ template<typename Context, typename... Args>
using T = column_t<Args...>; struct interpreter_t<Context, column_t<Args...>>
static Context& _(const T& t, Context& context)
{ {
context << T::_table::_name_t::_get_name() << '.' << T::_name_t::_get_name(); using T = column_t<Args...>;
return context;
}
};
static Context& _(const T& t, Context& context)
{
context << T::_table::_name_t::_get_name() << '.' << T::_name_t::_get_name();
return context;
}
};
}
} }
#endif #endif

View File

@ -74,25 +74,28 @@ namespace sqlpp
}; };
} }
template<typename Context, typename Expr> namespace vendor
struct vendor::interpreter_t<Context, vendor::count_t<Expr>> {
{ template<typename Context, typename Expr>
using T = vendor::count_t<Expr>; struct interpreter_t<Context, vendor::count_t<Expr>>
static Context& _(const T& t, Context& context)
{ {
context << "COUNT("; using T = vendor::count_t<Expr>;
interpret(t._expr, context);
context << ")"; static Context& _(const T& t, Context& context)
return context; {
} context << "COUNT(";
}; interpret(t._expr, context);
context << ")";
return context;
}
};
}
template<typename T> template<typename T>
auto count(T&& t) -> typename vendor::count_t<typename operand_t<T, is_value_t>::type> auto count(T&& t) -> typename vendor::count_t<typename operand_t<T, is_value_t>::type>
{ {
return { std::forward<T>(t) }; return { std::forward<T>(t) };
} }
} }

View File

@ -73,26 +73,29 @@ namespace sqlpp
}; };
} }
template<typename Context, typename Select> namespace vendor
struct vendor::interpreter_t<Context, vendor::exists_t<Select>> {
{ template<typename Context, typename Select>
using T = vendor::exists_t<Select>; struct interpreter_t<Context, vendor::exists_t<Select>>
static Context& _(const T& t, Context& context)
{ {
context << "EXISTS("; using T = vendor::exists_t<Select>;
interpret(t._select, context);
context << ")"; static Context& _(const T& t, Context& context)
return context; {
} context << "EXISTS(";
}; interpret(t._select, context);
context << ")";
return context;
}
};
}
template<typename T> template<typename T>
auto exists(T&& t) -> typename vendor::exists_t<typename operand_t<T, is_select_t>::type> auto exists(T&& t) -> typename vendor::exists_t<typename operand_t<T, is_select_t>::type>
{ {
return { std::forward<T>(t) }; return { std::forward<T>(t) };
} }
} }

View File

@ -67,17 +67,20 @@ namespace sqlpp
std::string _verbatim; std::string _verbatim;
}; };
template<typename Context, typename ValueType> namespace vendor
struct vendor::interpreter_t<Context, verbatim_t<ValueType>> {
{ template<typename Context, typename ValueType>
using T = verbatim_t<ValueType>; struct interpreter_t<Context, verbatim_t<ValueType>>
static Context& _(const T& t, Context& context)
{ {
context << t._verbatim; using T = verbatim_t<ValueType>;
return context;
} static Context& _(const T& t, Context& context)
}; {
context << t._verbatim;
return context;
}
};
}
template<typename ValueType, typename StringType> template<typename ValueType, typename StringType>
auto verbatim(StringType&& s) -> verbatim_t<ValueType> auto verbatim(StringType&& s) -> verbatim_t<ValueType>
@ -93,7 +96,7 @@ namespace sqlpp
interpret(exp, context); interpret(exp, context);
return { context.str() }; return { context.str() };
} }
template<typename Container> template<typename Container>
struct value_list_t // to be used in .in() method struct value_list_t // to be used in .in() method
{ {
@ -103,33 +106,36 @@ namespace sqlpp
_container_t _container; _container_t _container;
}; };
template<typename Context, typename Container> namespace vendor
struct vendor::interpreter_t<Context, value_list_t<Container>> {
{ template<typename Context, typename Container>
using T = value_list_t<Container>; struct interpreter_t<Context, value_list_t<Container>>
static Context& _(const T& t, Context& context)
{ {
bool first = true; using T = value_list_t<Container>;
for (const auto& entry: t._container)
{
if (first)
first = false;
else
context << ',';
interpret(value(entry), context); static Context& _(const T& t, Context& context)
{
bool first = true;
for (const auto& entry: t._container)
{
if (first)
first = false;
else
context << ',';
interpret(value(entry), context);
}
return context;
} }
return context; };
} }
};
template<typename Container> template<typename Container>
auto value_list(Container&& c) -> value_list_t<typename std::decay<Container>::type> auto value_list(Container&& c) -> value_list_t<typename std::decay<Container>::type>
{ {
static_assert(not is_value_t<typename std::decay<Container>::type::value_type>::value, "value_list() is to be called with a container of non-sql-type like std::vector<int>, or std::list(string)"); static_assert(not is_value_t<typename std::decay<Container>::type::value_type>::value, "value_list() is to be called with a container of non-sql-type like std::vector<int>, or std::list(string)");
return { std::forward<Container>(c) }; return { std::forward<Container>(c) };
} }
template<typename T> template<typename T>
constexpr const char* get_sql_name(const T&) constexpr const char* get_sql_name(const T&)

View File

@ -133,19 +133,22 @@ namespace sqlpp
InsertList _insert_list; InsertList _insert_list;
}; };
template<typename Context, typename Database, typename Table, typename InsertList> namespace vendor
struct vendor::interpreter_t<Context, insert_t<Database, Table, InsertList>> {
{ template<typename Context, typename Database, typename Table, typename InsertList>
using T = insert_t<Database, Table, InsertList>; struct interpreter_t<Context, insert_t<Database, Table, InsertList>>
static Context& _(const T& t, Context& context)
{ {
context << "INSERT INTO "; using T = insert_t<Database, Table, InsertList>;
interpret(t._table, context);
interpret(t._insert_list, context); static Context& _(const T& t, Context& context)
return context; {
} context << "INSERT INTO ";
}; interpret(t._table, context);
interpret(t._insert_list, context);
return context;
}
};
}
template<typename Table> template<typename Table>
insert_t<void, typename std::decay<Table>::type> insert_into(Table&& table) insert_t<void, typename std::decay<Table>::type> insert_into(Table&& table)

View File

@ -141,24 +141,27 @@ namespace sqlpp
}; };
// FIXME: Need to check if db supports the join type. e.g. sqlite does not support right outer or full outer join // FIXME: Need to check if db supports the join type. e.g. sqlite does not support right outer or full outer join
template<typename Context, typename JoinType, typename Lhs, typename Rhs, typename On> namespace vendor
struct vendor::interpreter_t<Context, join_t<JoinType, Lhs, Rhs, On>> {
{ template<typename Context, typename JoinType, typename Lhs, typename Rhs, typename On>
using T = join_t<JoinType, Lhs, Rhs, On>; struct interpreter_t<Context, join_t<JoinType, Lhs, Rhs, On>>
static Context& _(const T& t, Context& context)
{ {
static_assert(not vendor::is_noop<On>::value, "joined tables require on()"); using T = join_t<JoinType, Lhs, Rhs, On>;
interpret(t._lhs, context);
context << JoinType::_name;
context << " JOIN ";
context << "(";
interpret(t._rhs, context);
interpret(t._on, context);
return context;
}
};
static Context& _(const T& t, Context& context)
{
static_assert(not vendor::is_noop<On>::value, "joined tables require on()");
interpret(t._lhs, context);
context << JoinType::_name;
context << " JOIN ";
context << "(";
interpret(t._rhs, context);
interpret(t._on, context);
return context;
}
};
}
} }
#endif #endif

View File

@ -74,25 +74,28 @@ namespace sqlpp
}; };
} }
template<typename Context, typename Expr> namespace vendor
struct vendor::interpreter_t<Context, vendor::max_t<Expr>> {
{ template<typename Context, typename Expr>
using T = vendor::max_t<Expr>; struct interpreter_t<Context, vendor::max_t<Expr>>
static Context& _(const T& t, Context& context)
{ {
context << "MAX("; using T = vendor::max_t<Expr>;
interpret(t._expr, context);
context << ")"; static Context& _(const T& t, Context& context)
return context; {
} context << "MAX(";
}; interpret(t._expr, context);
context << ")";
return context;
}
};
}
template<typename T> template<typename T>
auto max(T&& t) -> typename vendor::max_t<typename operand_t<T, is_value_t>::type> auto max(T&& t) -> typename vendor::max_t<typename operand_t<T, is_value_t>::type>
{ {
return { std::forward<T>(t) }; return { std::forward<T>(t) };
} }
} }

View File

@ -74,25 +74,28 @@ namespace sqlpp
}; };
} }
template<typename Context, typename Expr> namespace vendor
struct vendor::interpreter_t<Context, vendor::min_t<Expr>> {
{ template<typename Context, typename Expr>
using T = vendor::min_t<Expr>; struct interpreter_t<Context, vendor::min_t<Expr>>
static Context& _(const T& t, Context& context)
{ {
context << "MIN("; using T = vendor::min_t<Expr>;
interpret(t._expr, context);
context << ")"; static Context& _(const T& t, Context& context)
return context; {
} context << "MIN(";
}; interpret(t._expr, context);
context << ")";
return context;
}
};
}
template<typename T> template<typename T>
auto min(T&& t) -> typename vendor::min_t<typename operand_t<T, is_value_t>::type> auto min(T&& t) -> typename vendor::min_t<typename operand_t<T, is_value_t>::type>
{ {
return { std::forward<T>(t) }; return { std::forward<T>(t) };
} }
} }

View File

@ -55,23 +55,26 @@ namespace sqlpp
std::tuple<NamedExpr...> _columns; std::tuple<NamedExpr...> _columns;
}; };
template<typename Context, typename AliasProvider, typename... NamedExpr> namespace vendor
struct vendor::interpreter_t<Context, multi_column_t<AliasProvider, NamedExpr...>> {
{ template<typename Context, typename AliasProvider, typename... NamedExpr>
using T = multi_column_t<AliasProvider, NamedExpr...>; struct interpreter_t<Context, multi_column_t<AliasProvider, NamedExpr...>>
static Context& _(const T& t, Context& context)
{ {
interpret_tuple(t._columns, ',', context); using T = multi_column_t<AliasProvider, NamedExpr...>;
return context;
} static Context& _(const T& t, Context& context)
}; {
interpret_tuple(t._columns, ',', context);
return context;
}
};
}
namespace detail namespace detail
{ {
template<typename AliasProvider, typename... Expr> template<typename AliasProvider, typename... Expr>
using make_multi_column_t = using make_multi_column_t =
multi_column_t<typename std::decay<AliasProvider>::type, decltype(make_expression_tuple(std::declval<Expr>()...))>; multi_column_t<typename std::decay<AliasProvider>::type, decltype(make_expression_tuple(std::declval<Expr>()...))>;
} }
template<typename AliasProvider, typename... NamedExpr> template<typename AliasProvider, typename... NamedExpr>

View File

@ -54,24 +54,27 @@ namespace sqlpp
vendor::interpretable_list_t<Database> _dynamic_expressions; vendor::interpretable_list_t<Database> _dynamic_expressions;
}; };
template<typename Context, typename Database, typename... Expr> namespace vendor
struct vendor::interpreter_t<Context, on_t<Database, Expr...>> {
{ template<typename Context, typename Database, typename... Expr>
using T = on_t<Database, Expr...>; struct interpreter_t<Context, on_t<Database, Expr...>>
static Context& _(const T& t, Context& context)
{ {
if (sizeof...(Expr) == 0 and t._dynamic_expressions.empty()) using T = on_t<Database, Expr...>;
return context;
context << " ON ";
interpret_tuple(t._expressions, " AND ", context);
if (sizeof...(Expr) and not t._dynamic_expressions.empty())
context << " AND ";
interpret_list(t._dynamic_expressions, " AND ", context);
return context;
}
};
static Context& _(const T& t, Context& context)
{
if (sizeof...(Expr) == 0 and t._dynamic_expressions.empty())
return context;
context << " ON ";
interpret_tuple(t._expressions, " AND ", context);
if (sizeof...(Expr) and not t._dynamic_expressions.empty())
context << " AND ";
interpret_list(t._dynamic_expressions, " AND ", context);
return context;
}
};
}
} }
#endif #endif

View File

@ -49,17 +49,20 @@ namespace sqlpp
~parameter_t() = default; ~parameter_t() = default;
}; };
template<typename Context, typename ValueType, typename NameType> namespace vendor
struct vendor::interpreter_t<Context, parameter_t<ValueType, NameType>> {
{ template<typename Context, typename ValueType, typename NameType>
using T = parameter_t<ValueType, NameType>; struct interpreter_t<Context, parameter_t<ValueType, NameType>>
static Context& _(const T& t, Context& context)
{ {
context << "?"; using T = parameter_t<ValueType, NameType>;
return context;
} static Context& _(const T& t, Context& context)
}; {
context << "?";
return context;
}
};
}
template<typename NamedExpr> template<typename NamedExpr>
auto parameter(NamedExpr&& namedExpr) auto parameter(NamedExpr&& namedExpr)

View File

@ -165,20 +165,23 @@ namespace sqlpp
Where _where; Where _where;
}; };
template<typename Context, typename Database, typename Table, typename Using, typename Where> namespace vendor
struct vendor::interpreter_t<Context, remove_t<Database, Table, Using, Where>> {
{ template<typename Context, typename Database, typename Table, typename Using, typename Where>
using T = remove_t<Database, Table, Using, Where>; struct interpreter_t<Context, remove_t<Database, Table, Using, Where>>
static Context& _(const T& t, Context& context)
{ {
context << "DELETE FROM "; using T = remove_t<Database, Table, Using, Where>;
interpret(t._table, context);
interpret(t._using, context); static Context& _(const T& t, Context& context)
interpret(t._where, context); {
return context; context << "DELETE FROM ";
} interpret(t._table, context);
}; interpret(t._using, context);
interpret(t._where, context);
return context;
}
};
}
template<typename Table> template<typename Table>
constexpr remove_t<void, typename std::decay<Table>::type> remove_from(Table&& table) constexpr remove_t<void, typename std::decay<Table>::type> remove_from(Table&& table)

View File

@ -606,42 +606,44 @@ namespace sqlpp
Offset _offset; Offset _offset;
}; };
template<typename Context, namespace vendor
typename Database, {
typename Flags, template<typename Context,
typename ExpressionList, typename Database,
typename From, typename Flags,
typename Where, typename ExpressionList,
typename GroupBy, typename From,
typename Having, typename Where,
typename OrderBy, typename GroupBy,
typename Limit, typename Having,
typename Offset typename OrderBy,
> typename Limit,
struct vendor::interpreter_t<Context, select_t<Database, typename Offset
Flags, >
ExpressionList, struct interpreter_t<Context, select_t<Database,
From, Flags,
Where, ExpressionList,
GroupBy, From,
Having, Where,
OrderBy, GroupBy,
Limit, Having,
Offset>> OrderBy,
{ Limit,
using T = select_t<Database, Offset>>
Flags,
ExpressionList,
From,
Where,
GroupBy,
Having,
OrderBy,
Limit,
Offset>;
static Context& _(const T& t, Context& context)
{ {
using T = select_t<Database,
Flags,
ExpressionList,
From,
Where,
GroupBy,
Having,
OrderBy,
Limit,
Offset>;
static Context& _(const T& t, Context& context)
{
context << "SELECT "; context << "SELECT ";
interpret(t._flags, context); interpret(t._flags, context);
@ -655,8 +657,9 @@ namespace sqlpp
interpret(t._offset, context); interpret(t._offset, context);
return context; return context;
} }
}; };
}
// construct select flag list // construct select flag list
@ -664,7 +667,7 @@ namespace sqlpp
{ {
template<typename... Expr> template<typename... Expr>
using make_select_flag_list_t = using make_select_flag_list_t =
vendor::select_flag_list_t<decltype(make_flag_tuple(std::declval<Expr>()...))>; vendor::select_flag_list_t<decltype(make_flag_tuple(std::declval<Expr>()...))>;
} }
// construct select expression list // construct select expression list
@ -672,7 +675,7 @@ namespace sqlpp
{ {
template<typename... Expr> template<typename... Expr>
using make_select_expression_list_t = using make_select_expression_list_t =
vendor::select_expression_list_t<void, decltype(make_expression_tuple(std::declval<Expr>()...))>; vendor::select_expression_list_t<void, decltype(make_expression_tuple(std::declval<Expr>()...))>;
} }
template<typename... NamedExpr> template<typename... NamedExpr>
@ -681,7 +684,7 @@ namespace sqlpp
{ {
return { return {
{ detail::make_flag_tuple(std::forward<NamedExpr>(namedExpr)...) }, { detail::make_flag_tuple(std::forward<NamedExpr>(namedExpr)...) },
{ detail::make_expression_tuple(std::forward<NamedExpr>(namedExpr)...) } { detail::make_expression_tuple(std::forward<NamedExpr>(namedExpr)...) }
}; };
} }
template<typename Db, typename... NamedExpr> template<typename Db, typename... NamedExpr>
@ -690,7 +693,7 @@ namespace sqlpp
{ {
return { return {
{ detail::make_flag_tuple(std::forward<NamedExpr>(namedExpr)...) }, { detail::make_flag_tuple(std::forward<NamedExpr>(namedExpr)...) },
{ detail::make_expression_tuple(std::forward<NamedExpr>(namedExpr)...) } { detail::make_expression_tuple(std::forward<NamedExpr>(namedExpr)...) }
}; };
} }

View File

@ -75,25 +75,28 @@ namespace sqlpp
}; };
} }
template<typename Context, typename Select> namespace vendor
struct vendor::interpreter_t<Context, vendor::some_t<Select>> {
{ template<typename Context, typename Select>
using T = vendor::some_t<Select>; struct interpreter_t<Context, vendor::some_t<Select>>
static Context& _(const T& t, Context& context)
{ {
context << "SOME("; using T = vendor::some_t<Select>;
interpret(t._select, context);
context << ")"; static Context& _(const T& t, Context& context)
return context; {
} context << "SOME(";
}; interpret(t._select, context);
context << ")";
return context;
}
};
}
template<typename T> template<typename T>
auto some(T&& t) -> typename vendor::some_t<typename operand_t<T, is_select_t>::type> auto some(T&& t) -> typename vendor::some_t<typename operand_t<T, is_select_t>::type>
{ {
return { std::forward<T>(t) }; return { std::forward<T>(t) };
} }
} }

View File

@ -43,27 +43,30 @@ namespace sqlpp
Expression _expression; Expression _expression;
}; };
template<typename Context, typename Expression, sort_type SortType> namespace vendor
struct vendor::interpreter_t<Context, sort_order_t<Expression, SortType>> {
{ template<typename Context, typename Expression, sort_type SortType>
using T = sort_order_t<Expression, SortType>; struct interpreter_t<Context, sort_order_t<Expression, SortType>>
static Context& _(const T& t, Context& context)
{ {
interpret(t._expression, context); using T = sort_order_t<Expression, SortType>;
switch(SortType)
{
case sort_type::asc:
context << " ASC";
break;
default:
context << " DESC";
break;
}
return context;
}
};
static Context& _(const T& t, Context& context)
{
interpret(t._expression, context);
switch(SortType)
{
case sort_type::asc:
context << " ASC";
break;
default:
context << " DESC";
break;
}
return context;
}
};
}
} }
#endif #endif

View File

@ -74,25 +74,28 @@ namespace sqlpp
}; };
} }
template<typename Context, typename Expr> namespace vendor
struct vendor::interpreter_t<Context, vendor::sum_t<Expr>> {
{ template<typename Context, typename Expr>
using T = vendor::sum_t<Expr>; struct interpreter_t<Context, vendor::sum_t<Expr>>
static Context& _(const T& t, Context& context)
{ {
context << "SUM("; using T = vendor::sum_t<Expr>;
interpret(t._expr, context);
context << ")"; static Context& _(const T& t, Context& context)
return context; {
} context << "SUM(";
}; interpret(t._expr, context);
context << ")";
return context;
}
};
}
template<typename T> template<typename T>
auto sum(T&& t) -> typename vendor::sum_t<typename operand_t<T, is_value_t>::type> auto sum(T&& t) -> typename vendor::sum_t<typename operand_t<T, is_value_t>::type>
{ {
return { std::forward<T>(t) }; return { std::forward<T>(t) };
} }
} }

View File

@ -99,19 +99,22 @@ namespace sqlpp
return {}; return {};
} }
template<typename Context, typename X> namespace vendor
struct vendor::interpreter_t<Context, X, typename std::enable_if<std::is_base_of<table_base_t, X>::value and not is_pseudo_table_t<X>::value, void>::type> {
{ template<typename Context, typename X>
using T = X; struct interpreter_t<Context, X, typename std::enable_if<std::is_base_of<table_base_t, X>::value and not is_pseudo_table_t<X>::value, void>::type>
static Context& _(const T& t, Context& context)
{ {
context << T::_name_t::_get_name(); using T = X;
return context;
} static Context& _(const T& t, Context& context)
}; {
context << T::_name_t::_get_name();
return context;
}
};
}
} }
#endif #endif

View File

@ -61,20 +61,23 @@ namespace sqlpp
Table _table; Table _table;
}; };
template<typename Context, typename X> namespace vendor
struct vendor::interpreter_t<Context, X, typename std::enable_if<std::is_base_of<table_alias_base_t, X>::value, void>::type> {
{ template<typename Context, typename X>
using T = X; struct interpreter_t<Context, X, typename std::enable_if<std::is_base_of<table_alias_base_t, X>::value, void>::type>
static Context& _(const T& t, Context& context)
{ {
context << "("; using T = X;
interpret(t._table, context);
context << ") AS " << T::_name_t::_get_name();
return context;
}
};
static Context& _(const T& t, Context& context)
{
context << "(";
interpret(t._table, context);
context << ") AS " << T::_name_t::_get_name();
return context;
}
};
}
} }
#endif #endif

View File

@ -53,16 +53,19 @@ namespace sqlpp
_operand_t _value; _operand_t _value;
}; };
template<typename Context, typename Type> namespace vendor
struct vendor::interpreter_t<Context, tvin_t<Type>> {
{ template<typename Context, typename Type>
using T = tvin_t<Type>; struct interpreter_t<Context, tvin_t<Type>>
static void _(const T& t, Context& context)
{ {
static_assert(detail::wrong<T>::value, "tvin() must not be used with anything but =, ==, != and !"); using T = tvin_t<Type>;
}
}; static void _(const T& t, Context& context)
{
static_assert(detail::wrong<T>::value, "tvin() must not be used with anything but =, ==, != and !");
}
};
}
template<typename T> template<typename T>
struct tvin_wrap_t struct tvin_wrap_t
@ -104,31 +107,33 @@ namespace sqlpp
typename tvin_t<T>::_operand_t _value; typename tvin_t<T>::_operand_t _value;
}; };
template<typename Context, typename Type> namespace vendor
struct vendor::interpreter_t<Context, tvin_wrap_t<Type>> {
{ template<typename Context, typename Type>
using T = tvin_wrap_t<Type>; struct interpreter_t<Context, tvin_wrap_t<Type>>
static Context& _(const T& t, Context& context)
{ {
if (t._is_trivial()) using T = tvin_wrap_t<Type>;
{
context << "NULL";
}
else
{
interpret(t._value, context);
}
return context;
}
};
static Context& _(const T& t, Context& context)
{
if (t._is_trivial())
{
context << "NULL";
}
else
{
interpret(t._value, context);
}
return context;
}
};
}
template<typename T> template<typename T>
auto tvin(T t) -> tvin_t<typename std::decay<T>::type> auto tvin(T t) -> tvin_t<typename std::decay<T>::type>
{ {
return {t}; return {t};
} }
} }

View File

@ -167,25 +167,28 @@ namespace sqlpp
Where _where; Where _where;
}; };
template<typename Context, namespace vendor
typename Database, {
typename Table, template<typename Context,
typename Assignments, typename Database,
typename Where typename Table,
> typename Assignments,
struct vendor::interpreter_t<Context, update_t<Database, Table, Assignments, Where>> typename Where
{ >
using T = update_t<Database, Table, Assignments, Where>; struct interpreter_t<Context, update_t<Database, Table, Assignments, Where>>
{
using T = update_t<Database, Table, Assignments, Where>;
static Context& _(const T& t, Context& context) static Context& _(const T& t, Context& context)
{ {
context << "UPDATE "; context << "UPDATE ";
interpret(t._table, context); interpret(t._table, context);
interpret(t._assignments, context); interpret(t._assignments, context);
interpret(t._where, context); interpret(t._where, context);
return context; return context;
} }
}; };
}
template<typename Table> template<typename Table>
constexpr update_t<void, typename std::decay<Table>::type> update(Table&& table) constexpr update_t<void, typename std::decay<Table>::type> update(Table&& table)

View File

@ -45,15 +45,18 @@ namespace sqlpp
}; };
static constexpr all_t all = {}; static constexpr all_t all = {};
template<typename Context> namespace vendor
struct vendor::interpreter_t<Context, all_t> {
{ template<typename Context>
static Context& _(const all_t&, Context& context) struct interpreter_t<Context, all_t>
{ {
context << "ALL"; static Context& _(const all_t&, Context& context)
return context; {
} context << "ALL";
}; return context;
}
};
}
struct distinct_t struct distinct_t
{ {
@ -64,15 +67,18 @@ namespace sqlpp
}; };
static constexpr distinct_t distinct = {}; static constexpr distinct_t distinct = {};
template<typename Context> namespace vendor
struct vendor::interpreter_t<Context, distinct_t> {
{ template<typename Context>
static Context& _(const distinct_t&, Context& context) struct interpreter_t<Context, distinct_t>
{ {
context << "DISTINCT"; static Context& _(const distinct_t&, Context& context)
return context; {
} context << "DISTINCT";
}; return context;
}
};
}
struct straight_join_t struct straight_join_t
{ {
@ -83,15 +89,18 @@ namespace sqlpp
}; };
static constexpr straight_join_t straight_join = {}; static constexpr straight_join_t straight_join = {};
template<typename Context> namespace vendor
struct vendor::interpreter_t<Context, straight_join_t> {
{ template<typename Context>
static Context& _(const straight_join_t&, Context& context) struct interpreter_t<Context, straight_join_t>
{ {
context << "STRAIGHT_JOIN"; static Context& _(const straight_join_t&, Context& context)
return context; {
} context << "STRAIGHT_JOIN";
}; return context;
}
};
}
namespace vendor namespace vendor
{ {

View File

@ -70,18 +70,21 @@ namespace sqlpp
Select _select; Select _select;
}; };
template<typename Context, typename Select, typename... NamedExpr> namespace vendor
struct vendor::interpreter_t<Context, select_pseudo_table_t<Select, NamedExpr...>> {
{ template<typename Context, typename Select, typename... NamedExpr>
using T = select_pseudo_table_t<Select, NamedExpr...>; struct interpreter_t<Context, select_pseudo_table_t<Select, NamedExpr...>>
static Context& _(const T& t, Context& context)
{ {
interpret(t._select, context); using T = select_pseudo_table_t<Select, NamedExpr...>;
return context;
} static Context& _(const T& t, Context& context)
}; {
interpret(t._select, context);
return context;
}
};
}
} }
#endif #endif

View File

@ -65,17 +65,20 @@ namespace sqlpp
std::string _name; std::string _name;
}; };
template<typename Context> namespace vendor
struct vendor::interpreter_t<Context, verbatim_table_t> {
{ template<typename Context>
using T = verbatim_table_t; struct interpreter_t<Context, verbatim_table_t>
static Context& _(const T& t, Context& context)
{ {
context << t._name; using T = verbatim_table_t;
return context;
} static Context& _(const T& t, Context& context)
}; {
context << t._name;
return context;
}
};
}
verbatim_table_t verbatim_table(std::string name) verbatim_table_t verbatim_table(std::string name)