diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2013-01-24 15:10:22 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2013-01-24 15:10:22 +0200 |
commit | 89de275db2b77d0abf9fa1ec066ef11e262c88af (patch) | |
tree | 06cb2272c5e791946dc58421ed3f2d03b7c8122e /common/query/array/test.hxx | |
parent | 539c92147e8d58c49f350c4070051a6ddf6b2354 (diff) |
Add support for mapping char[N] to CHAR/VARCHAR database types
Also improve query support for arrays (decaying).
Diffstat (limited to 'common/query/array/test.hxx')
-rw-r--r-- | common/query/array/test.hxx | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/common/query/array/test.hxx b/common/query/array/test.hxx new file mode 100644 index 0000000..32ee413 --- /dev/null +++ b/common/query/array/test.hxx @@ -0,0 +1,77 @@ +// file : common/query/array/test.hxx +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include <common/config.hxx> // HAVE_CXX11 + +#include <cstring> // std::strncpy + +#ifdef HAVE_CXX11 +# include <array> +#endif + +#include <odb/core.hxx> + +#pragma db object +struct object +{ + object () {} + object (unsigned long id, const char* s, const char* b) + : id_ (id) + { + std::strncpy (s_, s, sizeof (s_)); + std::strncpy (s1_, s, sizeof (s1_)); +#ifdef HAVE_CXX11 + std::strncpy (a_.data (), s, a_.size ()); +#endif + c_ = c1_ = *s; + std::memcpy (b_, b, sizeof (b_)); + } + + #pragma db id + unsigned long id_; + + char s_[17]; + char s1_[17]; + +#ifdef HAVE_CXX11 +#ifdef ODB_COMPILER +# if defined(ODB_DATABASE_MYSQL) || \ + defined(ODB_DATABASE_PGSQL) || \ + defined(ODB_DATABASE_ORACLE) || \ + defined(ODB_DATABASE_MSSQL) +# pragma db type("VARCHAR(16)") +# elif defined(ODB_DATABASE_SQLITE) +# pragma db type("TEXT") +# else +# error unknown database +# endif +#endif + std::array<char, 17> a_; +#endif + + char c_; + char c1_; + +#ifdef ODB_COMPILER +# if defined(ODB_DATABASE_MYSQL) +# pragma db type("BINARY(16)") +# elif defined(ODB_DATABASE_SQLITE) +# pragma db type("BLOB") +# elif defined(ODB_DATABASE_PGSQL) +# pragma db type("BYTEA") +# elif defined(ODB_DATABASE_ORACLE) +# pragma db type("RAW(16)") +# elif defined(ODB_DATABASE_MSSQL) +# pragma db type("BINARY(16)") +# else +# error unknown database +# endif +#endif + char b_[16]; +}; + +#endif // TEST_HXX |