aboutsummaryrefslogtreecommitdiff
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
commit32fcd732e2535090174142dd15b8b74fc444a9c2 (patch)
tree0d869cf45f1282cc1ac04e0d8171410d59d16a1f
parent4e7f517a711d9b6e95512cad1891710bcd591034 (diff)
Add support for alternative UTF-16 image for TEXT in SQLite
Use it to handle QString and support std::wstring on Windows.
-rw-r--r--qt/sqlite/basic/driver.cxx2
-rw-r--r--sqlite/types/driver.cxx17
-rw-r--r--sqlite/types/test.hxx24
3 files changed, 31 insertions, 12 deletions
diff --git a/qt/sqlite/basic/driver.cxx b/qt/sqlite/basic/driver.cxx
index 322e962..c0fb883 100644
--- a/qt/sqlite/basic/driver.cxx
+++ b/qt/sqlite/basic/driver.cxx
@@ -32,7 +32,7 @@ main (int argc, char* argv[])
auto_ptr<database> db (create_database (argc, argv));
object o;
- o.str = "Constantin Michael";
+ o.str = QString::fromUtf8 ("Constantin Micha\xC3\x88l");
o.blob = QByteArray ("\0x13\0xDE\0x00\0x00\0x00\0x54\0xF2\0x6A", 8);
// Persist.
diff --git a/sqlite/types/driver.cxx b/sqlite/types/driver.cxx
index 1214d18..ac8c8d4 100644
--- a/sqlite/types/driver.cxx
+++ b/sqlite/types/driver.cxx
@@ -39,6 +39,9 @@ main (int argc, char* argv[])
string long_str (2040, 'l');
o.text_ = long_str;
+#ifdef _WIN32
+ o.wtext_ = L"t\x00C8st string";
+#endif
o.blob_.assign (long_str.c_str (), long_str.c_str () + long_str.size ());
{
@@ -47,8 +50,6 @@ main (int argc, char* argv[])
t.commit ();
}
- //
- //
{
transaction t (db->begin ());
auto_ptr<object> o1 (db->load<object> (1));
@@ -56,6 +57,18 @@ main (int argc, char* argv[])
assert (o == *o1);
}
+
+ typedef odb::query<object> query;
+ typedef odb::result<object> result;
+
+#ifdef _WIN32
+ {
+ transaction t (db->begin ());
+ result r (db->query<object> (query::wtext == L"t\x00C8st string"));
+ assert (!r.empty ());
+ t.commit ();
+ }
+#endif
}
catch (const odb::exception& e)
{
diff --git a/sqlite/types/test.hxx b/sqlite/types/test.hxx
index 897590d..bd8f48a 100644
--- a/sqlite/types/test.hxx
+++ b/sqlite/types/test.hxx
@@ -44,6 +44,10 @@ struct object
#pragma db type("TEXT")
std::string text_;
+#ifdef _WIN32
+ std::string wtext_;
+#endif
+
#pragma db type("BLOB")
std::vector<char> blob_;
@@ -55,15 +59,17 @@ struct object
bool
operator== (const object& y) const
{
- return
- id_ == y.id_ &&
- bool_ == y.bool_ &&
- integer_ == y.integer_ &&
- real_ == y.real_ &&
- nan_ != nan_ &&
- text_ == y.text_ &&
- blob_ == y.blob_ &&
- ((null_.get () == 0 && y.null_.get () == 0) || *null_ == *y.null_);
+ return id_ == y.id_
+ && bool_ == y.bool_
+ && integer_ == y.integer_
+ && real_ == y.real_
+ && nan_ != nan_
+ && text_ == y.text_
+#ifdef _WIN32
+ && wtext_ == y.wtext_
+#endif
+ && blob_ == y.blob_
+ && ((null_.get () == 0 && y.null_.get () == 0) || *null_ == *y.null_);
}
};