From 02aed5f059797cd5e53a9fe6dde13714f86332d4 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 16 Sep 2011 16:03:25 +0200 Subject: Support for views; integrated part --- odb/sqlite/query.hxx | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) (limited to 'odb/sqlite/query.hxx') diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index 9731d10..c712b58 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -136,6 +136,22 @@ namespace odb { } + // True or false literal. + // + explicit + query (bool v) + : parameters_ (new (details::shared) query_params) + { + clause_.push_back (clause_part (clause_part::native, v ? "1" : "0")); + } + + explicit + query (const char* native) + : parameters_ (new (details::shared) query_params) + { + clause_.push_back (clause_part (clause_part::native, native)); + } + explicit query (const std::string& native) : parameters_ (new (details::shared) query_params) @@ -177,6 +193,9 @@ namespace odb std::string clause () const; + const char* + clause_prefix () const; + binding& parameters_binding () const; @@ -1061,6 +1080,45 @@ namespace odb const char* column_; }; + // Provide operator+() for using columns to construct native + // query fragments (e.g., ORDER BY). + // + template + inline query + operator+ (const query_column& c, const std::string& s) + { + query q (c.table (), c.column ()); + q += s; + return q; + } + + template + inline query + operator+ (const std::string& s, const query_column& c) + { + query q (s); + q.append (c.table (), c.column ()); + return q; + } + + template + inline query + operator+ (const query_column& c, const query& q) + { + query r (c.table (), c.column ()); + r += q; + return r; + } + + template + inline query + operator+ (const query& q, const query_column& c) + { + query r (q); + r.append (c.table (), c.column ()); + return r; + } + // // template @@ -1227,6 +1285,18 @@ namespace odb } explicit + query (bool v) + : query_selector::type (v) + { + } + + explicit + query (const char* q) + : query_selector::type (q) + { + } + + explicit query (const std::string& q) : query_selector::type (q) { -- cgit v1.1