From f01ad68661d62af62087b7b1ae29628f028e9eaa Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 11 Sep 2012 13:55:47 +0200 Subject: Add support for mapping std::array to BLOB and char[16] to UUID types --- doc/manual.xhtml | 109 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 63 insertions(+), 46 deletions(-) (limited to 'doc') diff --git a/doc/manual.xhtml b/doc/manual.xhtml index 8438ff8..3939952 100644 --- a/doc/manual.xhtml +++ b/doc/manual.xhtml @@ -13244,13 +13244,15 @@ class person NCHAR, and NVARCHAR types, as well as for mapping the std::vector<char>, std::vector<unsigned char>, - char[N], and unsigned char[N] types - to the MySQL BLOB types. However, these mappings are not enabled by - default (in particular, by default, std::vector will - be treated as a container). To enable the alternative mappings for these - types we need to specify the database type explicitly using the - db type pragma (Section - 12.4.3, "type"), for example:

+ char[N], unsigned char[N], + std::array<char, N>, and std::array<unsigned char, N> + types to the MySQL BLOB types. However, these mappings are not enabled + by default (in particular, by default, std::vector and + std::array will be treated as containers). To enable the + alternative mappings for these types we need to specify the database + type explicitly using the db type pragma + (Section 12.4.3, "type"), for + example:

 #pragma db object
@@ -13264,8 +13266,8 @@ class object
   #pragma db type("BLOB")
   std::vector<char> buf_;
 
-  #pragma db type("BLOB")
-  unsigned char[16] uuid_;
+  #pragma db type("BINARY(16)")
+  unsigned char uuid_[16];
 };
   
@@ -13920,13 +13922,15 @@ class object

The SQLite ODB runtime library also provides support for mapping the std::vector<char>, std::vector<unsigned char>, - char[N], and unsigned char[N] types to - the SQLite BLOB type. However, this mapping is not enabled by default - (in particular, by default, std::vector will be treated - as a container). To enable the BLOB mapping for these types we need - to specify the database type explicitly using the - db type pragma (Section 12.4.3, - "type"), for example:

+ char[N], unsigned char[N], + std::array<char, N>, and std::array<unsigned char, N> + types to the SQLite BLOB type. However, this mapping is not enabled + by default (in particular, by default, std::vector and + std::array will be treated as containers). To enable the + BLOB mapping for these types we need to specify the database type + explicitly using the db type pragma + (Section 12.4.3, "type"), for + example:

 #pragma db object
@@ -13938,7 +13942,7 @@ class object
   std::vector<char> buf_;
 
   #pragma db type("BLOB")
-  unsigned char[16] uuid_;
+  unsigned char uuid_[16];
 };
   
@@ -14711,16 +14715,19 @@ class object

The PostgreSQL ODB runtime library also provides support for mapping the std::string type to the PostgreSQL CHAR - and VARCHAR types, as well as for mapping the - std::vector<char>, + and VARCHAR types as well as the char[16] + array to the PostgreSQL UUID type. There is also support + for mapping the std::vector<char>, std::vector<unsigned char>, - char[N], and unsigned char[N] types to - the PostgreSQL BYTEA type. However, these mappings are not - enabled by default (in particular, by default, std::vector - will be treated as a container). To enable the alternative mappings for - these types we need to specify the database type explicitly - using the db type pragma (Section - 12.4.3, "type"), for example:

+ char[N], unsigned char[N], + std::array<char, N>, and std::array<unsigned char, N> + types to the PostgreSQL BYTEA type. However, these mappings + are not enabled by default (in particular, by default, + std::vector and std::array will be treated + as containers). To enable the alternative mappings for these types we + need to specify the database type explicitly using the + db type pragma (Section 12.4.3, + "type"), for example:

 #pragma db object
@@ -14731,11 +14738,14 @@ class object
   #pragma db type("CHAR(2)")
   std::string state_;
 
+  #pragma db type("UUID")
+  char uuid_[16];
+
   #pragma db type("BYTEA")
   std::vector<char> buf_;
 
   #pragma db type("BYTEA")
-  unsigned char[16] uuid_;
+  unsigned char data_[256];
 };
   
@@ -15398,14 +15408,15 @@ class object NCLOB types, as well as for mapping the std::vector<char>, std::vector<unsigned char>, - char[N], and unsigned char[N] types to - the Oracle BLOB and RAW types. However, these - mappings are not enabled by default (in particular, by default, - std::vector will be treated as a container). To enable the - alternative mappings for these types we need to specify the - database type explicitly using the db type pragma - (Section 12.4.3, "type"), for - example:

+ char[N], unsigned char[N], + std::array<char, N>, and std::array<unsigned char, N> + types to the Oracle BLOB and RAW types. + However, these mappings are not enabled by default (in particular, by + default, std::vector and std::array will be + treated as containers). To enable the alternative mappings for these + types we need to specify the database type explicitly using the + db type pragma (Section 12.4.3, + "type"), for example:

 #pragma db object
@@ -15420,7 +15431,7 @@ class object
   std::vector<char> buf_;
 
   #pragma db type("RAW(16)")
-  unsigned char[16] uuid_;
+  unsigned char uuid_[16];
 };
   
@@ -16231,15 +16242,18 @@ class object std::string type to the SQL Server CHAR and TEXT types as well as std::wstring to NCHAR and NTEXT. There is also support - for mapping the std::vector<char>, + for mapping the char[16] array to the SQL Server + UNIQUEIDENTIFIER type as well as the + std::vector<char>, std::vector<unsigned char>, - char[N], and unsigned char[N] types to - the SQL Server BINARY, VARBINARY, and - IMAGE types. However, these - mappings are not enabled by default (in particular, by default, - std::vector will be treated as a container). To enable the - alternative mappings for these types we need to specify the - database type explicitly using the db type pragma + char[N], unsigned char[N], + std::array<char, N>, and std::array<unsigned char, N> + types to the SQL Server BINARY, VARBINARY, and + IMAGE types. However, these mappings are not enabled + by default (in particular, by default, std::vector and + std::array will be treated as containers). To enable the + alternative mappings for these types we need to specify the database + type explicitly using the db type pragma (Section 12.4.3, "type"), for example:

@@ -16252,11 +16266,14 @@ class object #pragma db type ("CHAR(5)") std::string str_; + #pragma db type("UNIQUEIDENTIFIER") + char uuid_[16]; + #pragma db type("VARBINARY(max)") std::vector<char> buf_; - #pragma db type("BINARY(16)") - unsigned char[16] uuid_; + #pragma db type("BINARY(256)") + unsigned char data_[256]; }; -- cgit v1.1