aboutsummaryrefslogtreecommitdiff
path: root/odb/qt/basic/oracle/qstring-traits.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'odb/qt/basic/oracle/qstring-traits.hxx')
-rw-r--r--odb/qt/basic/oracle/qstring-traits.hxx124
1 files changed, 124 insertions, 0 deletions
diff --git a/odb/qt/basic/oracle/qstring-traits.hxx b/odb/qt/basic/oracle/qstring-traits.hxx
index c0b6775..bca7bab 100644
--- a/odb/qt/basic/oracle/qstring-traits.hxx
+++ b/odb/qt/basic/oracle/qstring-traits.hxx
@@ -64,6 +64,130 @@ namespace odb
}
};
+ class qstring_lob_value_traits
+ {
+ public:
+ typedef QString value_type;
+ typedef QString query_type;
+ typedef lob_callback image_type;
+
+ static void
+ set_value (QString& v,
+ result_callback_type& cb,
+ void*& context,
+ bool is_null)
+ {
+ if (is_null)
+ v = QString ();
+ else
+ {
+ cb = &result_callback;
+ context = &v;
+ }
+ }
+
+ static void
+ set_image (param_callback_type& cb,
+ const void*& context,
+ bool& is_null,
+ const QString& v)
+ {
+ if (v.isNull ())
+ is_null = true;
+ else
+ {
+ is_null = false;
+ cb = &param_callback;
+ context = &v;
+ }
+ }
+
+ static bool
+ result_callback (void* context,
+ ub4*,
+ void* b,
+ ub4 s,
+ chunk_position p)
+ {
+ QString& v (*static_cast<QString*> (context));
+
+ switch (p)
+ {
+ case one_chunk:
+ case first_chunk:
+ {
+ v.clear ();
+
+ // Falling through.
+ }
+ case next_chunk:
+ case last_chunk:
+ {
+ v += QString::fromUtf8(static_cast<char*> (b),
+ static_cast<int> (s));
+ break;
+ }
+ }
+
+ return true;
+ }
+
+ static bool
+ param_callback (const void* context,
+ ub4* position_context,
+ const void** b,
+ ub4* s,
+ chunk_position* p,
+ void* temp_buffer,
+ ub4 capacity)
+ {
+ const QByteArray& v (static_cast<const QString*> (context)->toUtf8 ());
+
+ *s = static_cast<ub4> (v.size ());
+
+ if (*position_context == 0)
+ {
+ if (*s <= capacity)
+ *p = one_chunk;
+ else
+ {
+ *s = capacity;
+ *p = first_chunk;
+ }
+ }
+ else
+ {
+ *s -= *position_context;
+
+ if (*s <= capacity)
+ *p = last_chunk;
+ else
+ {
+ *s = capacity;
+ *p = next_chunk;
+ }
+ }
+
+ std::memcpy (temp_buffer, v.constData () + *position_context, *s);
+ *b = temp_buffer;
+ *position_context += *s;
+
+ return true;
+ }
+ };
+
+ template <>
+ struct LIBODB_ORACLE_EXPORT default_value_traits<QString, id_clob>:
+ qstring_lob_value_traits
+ {
+ };
+
+ template <>
+ struct LIBODB_ORACLE_EXPORT default_value_traits<QString, id_nclob>:
+ qstring_lob_value_traits
+ {
+ };
+
template <>
struct default_type_traits<QString>
{