aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql/types/driver.cxx19
-rw-r--r--mysql/types/test.hxx3
-rw-r--r--mysql/types/traits.hxx39
-rw-r--r--pgsql/types/driver.cxx3
-rw-r--r--pgsql/types/test.hxx3
-rw-r--r--pgsql/types/traits.hxx39
-rw-r--r--sqlite/types/driver.cxx4
-rw-r--r--sqlite/types/test.hxx5
-rw-r--r--sqlite/types/traits.hxx39
9 files changed, 22 insertions, 132 deletions
diff --git a/mysql/types/driver.cxx b/mysql/types/driver.cxx
index 6625adf..f397084 100644
--- a/mysql/types/driver.cxx
+++ b/mysql/types/driver.cxx
@@ -54,24 +54,25 @@ main (int argc, char* argv[])
o.year_ = 2010;
string short_str (128, 's');
- buffer short_buf (short_str.c_str (), short_str.size ());
string medium_str (250, 'm');
- buffer medium_buf (medium_str.c_str (), medium_str.size ());
string long_str (2040, 'l');
- buffer long_buf (long_str.c_str (), long_str.size ());
+
+ const char* sb (short_str.c_str ()), *se (sb + short_str.size ());
+ const char* mb (medium_str.c_str ()), *me (mb + medium_str.size ());
+ const char* lb (long_str.c_str ()), *le (lb + long_str.size ());
o.char_ = short_str;
- o.binary_ = short_buf;
+ o.binary_.assign (sb, se);
o.varchar_ = medium_str;
- o.varbinary_ = medium_buf;
+ o.varbinary_.assign (mb, me);
o.tinytext_ = short_str;
- o.tinyblob_ = short_buf;
+ o.tinyblob_.assign (sb, se);
o.text_ = long_str;
- o.blob_ = long_buf;
+ o.blob_.assign (lb, le);
o.mediumtext_ = long_str;
- o.mediumblob_ = long_buf;
+ o.mediumblob_.assign (lb, le);
o.longtext_ = long_str;
- o.longblob_ = long_buf;
+ o.longblob_.assign (lb, le);
o.bit_.a = 1;
o.bit_.b = 0;
diff --git a/mysql/types/test.hxx b/mysql/types/test.hxx
index 209782e..1f6b771 100644
--- a/mysql/types/test.hxx
+++ b/mysql/types/test.hxx
@@ -8,11 +8,12 @@
#include <set>
#include <string>
+#include <vector>
#include <memory> // std::auto_ptr
#include <odb/core.hxx>
-#include <common/buffer.hxx>
+typedef std::vector<char> buffer;
struct date_time
{
diff --git a/mysql/types/traits.hxx b/mysql/types/traits.hxx
index 2698afc..09d50a1 100644
--- a/mysql/types/traits.hxx
+++ b/mysql/types/traits.hxx
@@ -10,7 +10,7 @@
#include <odb/mysql/traits.hxx>
-#include "test.hxx" // date_time, buffer, string_ptr
+#include "test.hxx" // date_time, string_ptr
namespace odb
{
@@ -57,43 +57,6 @@ namespace odb
};
template <>
- class value_traits<buffer, id_blob>
- {
- public:
- typedef buffer value_type;
- typedef buffer query_type;
- typedef details::buffer image_type;
-
- static void
- set_value (buffer& v,
- const details::buffer& b,
- std::size_t n,
- bool is_null)
- {
- if (!is_null)
- v.assign (b.data (), n);
- else
- v.assign (0, 0);
- }
-
- static void
- set_image (details::buffer& b,
- std::size_t& n,
- bool& is_null,
- const buffer& v)
- {
- is_null = false;
- n = v.size ();
-
- if (n > b.capacity ())
- b.capacity (n);
-
- if (n != 0)
- std::memcpy (b.data (), v.data (), n);
- }
- };
-
- template <>
class value_traits<bitfield, id_bit>
{
public:
diff --git a/pgsql/types/driver.cxx b/pgsql/types/driver.cxx
index 745d2ee..d6d675c 100644
--- a/pgsql/types/driver.cxx
+++ b/pgsql/types/driver.cxx
@@ -51,8 +51,7 @@ main (int argc, char* argv[])
o.varchar_ = medium_str;
o.text_ = long_str;
- buffer long_buf (long_str.c_str (), long_str.size ());
- o.bytea_ = long_buf;
+ o.bytea_.assign (long_str.c_str (), long_str.c_str () + long_str.size ());
unsigned char varbit_buf[8] = {1, 3, 1, 3, 1, 3, 1, 3};
o.varbit_.size = 52;
diff --git a/pgsql/types/test.hxx b/pgsql/types/test.hxx
index 48c30ee..500887a 100644
--- a/pgsql/types/test.hxx
+++ b/pgsql/types/test.hxx
@@ -8,6 +8,7 @@
#include <set>
#include <string>
+#include <vector>
#include <memory> // std::auto_ptr
#include <cstring> // std::memcmp
#include <cstddef> // std::size_t
@@ -139,7 +140,7 @@ struct object
std::string text_;
#pragma db type ("BYTEA")
- buffer bytea_;
+ std::vector<char> bytea_;
#pragma db type ("VARBIT(1024)")
varbit varbit_;
diff --git a/pgsql/types/traits.hxx b/pgsql/types/traits.hxx
index b3aec70..9852727 100644
--- a/pgsql/types/traits.hxx
+++ b/pgsql/types/traits.hxx
@@ -12,49 +12,12 @@
#include <odb/pgsql/traits.hxx>
#include <odb/pgsql/details/endian-traits.hxx>
-#include "test.hxx" // varbit, buffer, ubuffer, string_ptr
+#include "test.hxx" // varbit, ubuffer, string_ptr
namespace odb
{
namespace pgsql
{
- template <>
- class value_traits<buffer, id_bytea>
- {
- public:
- typedef buffer value_type;
- typedef buffer query_type;
- typedef details::buffer image_type;
-
- static void
- set_value (buffer& v,
- const details::buffer& b,
- std::size_t n,
- bool is_null)
- {
- if (!is_null)
- v.assign (b.data (), n);
- else
- v.assign (0, 0);
- }
-
- static void
- set_image (details::buffer& b,
- std::size_t& n,
- bool& is_null,
- const buffer& v)
- {
- is_null = false;
- n = v.size ();
-
- if (n > b.capacity ())
- b.capacity (n);
-
- if (n != 0)
- std::memcpy (b.data (), v.data (), n);
- }
- };
-
// The first 4 bytes of the image is a signed int specifying the
// number of significant bits contained by the BIT. The following
// bytes contain the bit data.
diff --git a/sqlite/types/driver.cxx b/sqlite/types/driver.cxx
index 855cada..3c14c7a 100644
--- a/sqlite/types/driver.cxx
+++ b/sqlite/types/driver.cxx
@@ -13,6 +13,7 @@
#include <odb/sqlite/database.hxx>
#include <odb/sqlite/transaction.hxx>
+#include <common/buffer.hxx>
#include <common/common.hxx>
#include "test.hxx"
@@ -35,10 +36,9 @@ main (int argc, char* argv[])
o.real_ = 1.123;
string long_str (2040, 'l');
- buffer long_buf (long_str.c_str (), long_str.size ());
o.text_ = long_str;
- o.blob_ = long_buf;
+ o.blob_.assign (long_str.c_str (), long_str.c_str () + long_str.size ());
{
transaction t (db->begin ());
diff --git a/sqlite/types/test.hxx b/sqlite/types/test.hxx
index 22cde8e..79b0a33 100644
--- a/sqlite/types/test.hxx
+++ b/sqlite/types/test.hxx
@@ -8,12 +8,11 @@
#include <set>
#include <string>
+#include <vector>
#include <memory> // std::auto_ptr
#include <odb/core.hxx>
-#include <common/buffer.hxx>
-
typedef std::auto_ptr<std::string> string_ptr;
#pragma db object
@@ -44,7 +43,7 @@ struct object
std::string text_;
#pragma db type ("BLOB")
- buffer blob_;
+ std::vector<char> blob_;
// Test NULL value.
//
diff --git a/sqlite/types/traits.hxx b/sqlite/types/traits.hxx
index 70b7b26..486e608 100644
--- a/sqlite/types/traits.hxx
+++ b/sqlite/types/traits.hxx
@@ -10,50 +10,13 @@
#include <odb/sqlite/traits.hxx>
-#include "test.hxx" // buffer, string_ptr
+#include "test.hxx" // string_ptr
namespace odb
{
namespace sqlite
{
template <>
- class value_traits<buffer, id_blob>
- {
- public:
- typedef buffer value_type;
- typedef buffer query_type;
- typedef details::buffer image_type;
-
- static void
- set_value (buffer& v,
- const details::buffer& b,
- std::size_t n,
- bool is_null)
- {
- if (!is_null)
- v.assign (b.data (), n);
- else
- v.assign (0, 0);
- }
-
- static void
- set_image (details::buffer& b,
- std::size_t& n,
- bool& is_null,
- const buffer& v)
- {
- is_null = false;
- n = v.size ();
-
- if (n > b.capacity ())
- b.capacity (n);
-
- if (n != 0)
- std::memcpy (b.data (), v.data (), n);
- }
- };
-
- template <>
class value_traits<string_ptr, id_text>
{
public: