From 3ac67fb63eec3534046fe2eb72bc2d37aca1cd98 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 10 Sep 2012 12:12:06 +0200 Subject: Add support for alternative UTF-16 image for TEXT in SQLite Use it to handle QString and support std::wstring on Windows. --- NEWS | 9 +++++---- doc/manual.xhtml | 14 ++++++++++---- odb/relational/sqlite/context.cxx | 3 ++- odb/relational/sqlite/source.cxx | 4 +++- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/NEWS b/NEWS index e33c5a0..47e165e 100644 --- a/NEWS +++ b/NEWS @@ -53,10 +53,11 @@ Version 2.1.0 more information, refer to Section 20.1, "Basic Types" in the ODB manual as well as the 'qt' example in the odb-examples package. - * SQLite improvements: Ability to specify the virtual filesystem (vfs) - module in the database constructor (Section 14.2, "SQLite Database - Class"). Ability to pass database name as std::wstring on Windows - (Section 14.2, "SQLite Database Class"). + * SQLite improvements: Persistence support for std::wstring on Windows + (Section 14.1, "SQLite Type Mapping"). Ability to pass the database + name as std::wstring on Windows (Section 14.2, "SQLite Database Class"). + Ability to specify the virtual filesystem (vfs) module in the database + constructor (Section 14.2, "SQLite Database Class"). * The id() pragma that was used to declare a persistent class without an object id has been renamed to no_id. diff --git a/doc/manual.xhtml b/doc/manual.xhtml index a9be249..8438ff8 100644 --- a/doc/manual.xhtml +++ b/doc/manual.xhtml @@ -13901,6 +13901,12 @@ class object TEXT NOT NULL + + + std::wstring (Windows only) + TEXT + NOT NULL +

SQLite represents the NaN FLOAT value @@ -14030,8 +14036,8 @@ namespace odb header file to make this class available in your application.

The first constructor opens the specified SQLite database. The - name argument is the database file - name to open. If this argument is empty, then a temporary, + name argument is the database file name to open in + the UTF-8 encoding. If this argument is empty, then a temporary, on-disk database is created. If this argument is the :memory: special value, then a temporary, in-memory database is created. The flags argument allows us to @@ -14058,8 +14064,8 @@ auto_ptr<odb::database> db (

The second constructor is the same as the first except that the database - name is passes as std::wstring. This constructor is only - available when compiling for Windows.

+ name is passes as std::wstring in the UTF-16 encoding. This + constructor is only available when compiling for Windows.

The third constructor extracts the database parameters from the command line. The following options are recognized:

diff --git a/odb/relational/sqlite/context.cxx b/odb/relational/sqlite/context.cxx index 52c7751..5dc3fa8 100644 --- a/odb/relational/sqlite/context.cxx +++ b/odb/relational/sqlite/context.cxx @@ -53,7 +53,8 @@ namespace relational {"float", "REAL", 0, true}, {"double", "REAL", 0, true}, - {"::std::string", "TEXT", 0, false} + {"::std::string", "TEXT", 0, false}, + {"::std::wstring", "TEXT", 0, false} }; } diff --git a/odb/relational/sqlite/source.cxx b/odb/relational/sqlite/source.cxx index 1e93568..7d29c1e 100644 --- a/odb/relational/sqlite/source.cxx +++ b/odb/relational/sqlite/source.cxx @@ -51,7 +51,9 @@ namespace relational virtual void traverse_text (member_info& mi) { - os << b << ".type = sqlite::bind::text;" + os << b << ".type = sqlite::image_traits<" << endl + << " " << mi.fq_type () << "," << endl + << " sqlite::id_text>::bind_value;" << b << ".buffer = " << arg << "." << mi.var << "value.data ();" << b << ".size = &" << arg << "." << mi.var << "size;" << b << ".capacity = " << arg << "." << mi.var << -- cgit v1.1