aboutsummaryrefslogtreecommitdiff
path: root/odb/sqlite/statement.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-09-10 12:12:06 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-09-10 12:12:06 +0200
commit866f0ce4fa567db60d46741a5c865cdf2741c619 (patch)
treebee686836227a8d83251d7670a6849c43c432481 /odb/sqlite/statement.cxx
parentb3af5d13db8c29b42436c54abd94b73b7a7f00bd (diff)
Add support for alternative UTF-16 image for TEXT in SQLite
Use it to handle QString and support std::wstring on Windows.
Diffstat (limited to 'odb/sqlite/statement.cxx')
-rw-r--r--odb/sqlite/statement.cxx34
1 files changed, 27 insertions, 7 deletions
diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx
index 60cf410..36066ff 100644
--- a/odb/sqlite/statement.cxx
+++ b/odb/sqlite/statement.cxx
@@ -125,6 +125,15 @@ namespace odb
SQLITE_STATIC);
break;
}
+ case bind::text16:
+ {
+ e = sqlite3_bind_text16 (stmt_,
+ j,
+ b.buffer,
+ static_cast<int> (*b.size),
+ SQLITE_STATIC);
+ break;
+ }
case bind::blob:
{
e = sqlite3_bind_blob (stmt_,
@@ -189,17 +198,28 @@ namespace odb
break;
}
case bind::text:
+ case bind::text16:
case bind::blob:
{
- // SQLite documentation recommends that we first call *_text()
- // or *_blob() function in order to force the type conversion,
- // if any.
+ // SQLite documentation recommends that we first call *_text(),
+ // *_text16(), or *_blob() function in order to force the type
+ // conversion, if any.
//
- const void* d (b.type == bind::text
- ? sqlite3_column_text (stmt_, j)
- : sqlite3_column_blob (stmt_, j));
+ const void* d;
- *b.size = static_cast<size_t> (sqlite3_column_bytes (stmt_, j));
+ if (b.type != bind::text16)
+ {
+ d = b.type == bind::text
+ ? sqlite3_column_text (stmt_, j)
+ : sqlite3_column_blob (stmt_, j);
+ *b.size = static_cast<size_t> (sqlite3_column_bytes (stmt_, j));
+ }
+ else
+ {
+ d = sqlite3_column_text16 (stmt_, j);
+ *b.size = static_cast<size_t> (
+ sqlite3_column_bytes16 (stmt_, j));
+ }
if (*b.size > b.capacity)
{