diff options
Diffstat (limited to 'odb/mssql/query.hxx')
-rw-r--r-- | odb/mssql/query.hxx | 121 |
1 files changed, 84 insertions, 37 deletions
diff --git a/odb/mssql/query.hxx b/odb/mssql/query.hxx index c0788a6..356ed58 100644 --- a/odb/mssql/query.hxx +++ b/odb/mssql/query.hxx @@ -11,6 +11,7 @@ #include <vector> #include <cstddef> // std::size_t +#include <odb/forward.hxx> // odb::query_column #include <odb/query.hxx> #include <odb/mssql/version.hxx> @@ -137,7 +138,7 @@ namespace odb query_base (bool v) : binding_ (0, 0) { - clause_.push_back (clause_part (v)); + append (v); } explicit @@ -181,6 +182,13 @@ namespace odb template <database_type_id ID> query_base (const query_column<bool, ID>&); + // Translate common query representation to SQL Server native. Defined + // in query-dynamic.cxx + // + query_base (const odb::query_base&); + + // Copy c-tor and assignment. + // query_base (const query_base&); query_base& @@ -265,6 +273,8 @@ namespace odb return *this; } + // Implementation details. + // public: template <typename T, database_type_id ID> void @@ -275,14 +285,25 @@ namespace odb append (ref_bind<T>, const char* conv); void + append (details::shared_ptr<query_param>, const char* conv); + + void + append (bool v) + { + clause_.push_back (clause_part (v)); + } + + void append (const std::string& native); void - append (const char* table, const char* column); + append (const char* native) // Clashes with append(bool). + { + append (std::string (native)); + } - private: void - add (details::shared_ptr<query_param>, const char* conv); + append (const char* table, const char* column); private: typedef std::vector<clause_part> clause_type; @@ -405,34 +426,18 @@ namespace odb // query_column // - - template <typename T, typename T2> - class copy_bind: public val_bind<T> + struct LIBODB_MSSQL_EXPORT query_column_base { - public: - explicit - copy_bind (const T2& v): val_bind<T> (val), val (v) {} - - const T val; - }; - - template <typename T> - const T& - type_instance (); - - template <typename T, database_type_id ID> - struct query_column - { - // Note that we keep shalow copies of the table, column, and conversion + // Note that we keep shallow copies of the table, column, and conversion // expression. The latter can be NULL. // - query_column (const char* table, - const char* column, - const char* conv, - unsigned short prec = 0, - unsigned short scale = 0xFFFF) - : table_ (table), column_ (column), conversion_ (conv), - prec_ (prec), scale_ (scale) + query_column_base (const char* table, + const char* column, + const char* conv, + unsigned short prec, + unsigned short scale) + : table_ (table), column_ (column), conversion_ (conv), + prec_ (prec), scale_ (scale) { } @@ -468,6 +473,51 @@ namespace odb return scale_; } + protected: + const char* table_; + const char* column_; + const char* conversion_; + + unsigned short prec_; + unsigned short scale_; + }; + + template <typename T, typename T2> + class copy_bind: public val_bind<T> + { + public: + explicit + copy_bind (const T2& v): val_bind<T> (val), val (v) {} + + const T val; + }; + + template <typename T> + const T& + type_instance (); + + template <typename T, database_type_id ID> + struct query_column: query_column_base + { + // Note that we keep shalow copies of the table, column, and conversion + // expression. The latter can be NULL. + // + query_column (const char* table, + const char* column, + const char* conv, + unsigned short prec = 0, + unsigned short scale = 0xFFFF) + : query_column_base (table, column, conv, prec, scale) {} + + // Implementation is in query-dynamic.ixx. + // + query_column (odb::query_column<T>&, + const char* table, + const char* column, + const char* conv, + unsigned short prec = 0, + unsigned short scale = 0xFFFF); + // is_null, is_not_null // public: @@ -1138,14 +1188,6 @@ namespace odb q.append (c.table (), c.column ()); return q; } - - private: - const char* table_; - const char* column_; - const char* conversion_; - - unsigned short prec_; - unsigned short scale_; }; // Provide operator+() for using columns to construct native @@ -2328,6 +2370,11 @@ namespace odb : query_base (qc) { } + + query (const odb::query_base& q) + : query_base (q) + { + } }; } |