aboutsummaryrefslogtreecommitdiff
path: root/odb/oracle/query.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'odb/oracle/query.hxx')
-rw-r--r--odb/oracle/query.hxx160
1 files changed, 103 insertions, 57 deletions
diff --git a/odb/oracle/query.hxx b/odb/oracle/query.hxx
index 9980833..1bf6853 100644
--- a/odb/oracle/query.hxx
+++ b/odb/oracle/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/oracle/version.hxx>
@@ -136,7 +137,7 @@ namespace odb
query_base (bool v)
: binding_ (0, 0)
{
- clause_.push_back (clause_part (v));
+ append (v);
}
explicit
@@ -180,6 +181,13 @@ namespace odb
template <database_type_id ID>
query_base (const query_column<bool, ID>&);
+ // Translate common query representation to Oracle native. Defined
+ // in query-dynamic.cxx
+ //
+ query_base (const odb::query_base&);
+
+ // Copy c-tor and assignment.
+ //
query_base (const query_base&);
query_base&
@@ -264,24 +272,37 @@ namespace odb
return *this;
}
+ // Implementation details.
+ //
public:
template <typename T, database_type_id ID>
void
- append (val_bind<T>, const char* conv);
+ append (val_bind<T>, const char* conv);
template <typename T, database_type_id ID>
void
- append (ref_bind<T>, const char* conv);
+ 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;
@@ -404,34 +425,18 @@ namespace odb
// query_column
//
-
- 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
+ struct LIBODB_ORACLE_EXPORT query_column_base
{
- // 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 = 0xFFF,
- short scale = 0xFFF)
- : 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,
+ short scale)
+ : table_ (table), column_ (column), conversion_ (conv),
+ prec_ (prec), scale_ (scale)
{
}
@@ -467,6 +472,51 @@ namespace odb
return scale_;
}
+ protected:
+ const char* table_;
+ const char* column_;
+ const char* conversion_;
+
+ unsigned short prec_;
+ 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 = 0xFFF,
+ short scale = 0xFFF)
+ : 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 = 0xFFF,
+ short scale = 0xFFF);
+
// is_null, is_not_null
//
public:
@@ -1137,14 +1187,6 @@ namespace odb
q.append (c.table (), c.column ());
return q;
}
-
- private:
- const char* table_;
- const char* column_;
- const char* conversion_;
-
- unsigned short prec_;
- short scale_;
};
//
@@ -1153,27 +1195,15 @@ namespace odb
// predicates for these types.
//
- struct LIBODB_ORACLE_EXPORT lob_query_column
+ struct LIBODB_ORACLE_EXPORT lob_query_column: query_column_base
{
// Note that we keep shallow copies of the table and column names.
// There is also no need for conversion expression since the only
// valid tests are is IS NULL/IS NOT NULL.
//
lob_query_column (const char* table, const char* column)
- : table_ (table), column_ (column)
- {
- }
-
- const char*
- table () const
+ : query_column_base (table, column, 0, 0xFFF, 0xFFF)
{
- return table_;
- }
-
- const char*
- column () const
- {
- return column_;
}
// is_null, is_not_null
@@ -1194,10 +1224,6 @@ namespace odb
q += "IS NOT NULL";
return q;
}
-
- private:
- const char* table_;
- const char* column_;
};
template <typename T>
@@ -1207,6 +1233,11 @@ namespace odb
: lob_query_column (table, column)
{
}
+
+ // Implementation is in query-dynamic.ixx.
+ //
+ query_column (odb::query_column<T>&,
+ const char* table, const char* column, const char*);
};
template <typename T>
@@ -1216,6 +1247,11 @@ namespace odb
: lob_query_column (table, column)
{
}
+
+ // Implementation is in query-dynamic.ixx.
+ //
+ query_column (odb::query_column<T>&,
+ const char* table, const char* column, const char*);
};
template <typename T>
@@ -1225,6 +1261,11 @@ namespace odb
: lob_query_column (table, column)
{
}
+
+ // Implementation is in query-dynamic.ixx.
+ //
+ query_column (odb::query_column<T>&,
+ const char* table, const char* column, const char*);
};
// Provide operator+() for using columns to construct native
@@ -1890,6 +1931,11 @@ namespace odb
: query_base (qc)
{
}
+
+ query (const odb::query_base& q)
+ : query_base (q)
+ {
+ }
};
}