diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-11-03 10:11:24 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-11-03 10:11:24 +0200 |
commit | 1bbe6fe0d6269851ac69a383189b0809d86ef40f (patch) | |
tree | 7f39a72083b5bbf2073dd68664c767ac5d40fd45 /common/blob/test.hxx | |
parent | cee18c8947e5d0ecae1c1daf2c003737da5f4305 (diff) |
Add support for mapping char[N] and unsigned char[N] types to BLOB
New test: common/blob.
Diffstat (limited to 'common/blob/test.hxx')
-rw-r--r-- | common/blob/test.hxx | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/common/blob/test.hxx b/common/blob/test.hxx new file mode 100644 index 0000000..5fb501e --- /dev/null +++ b/common/blob/test.hxx @@ -0,0 +1,55 @@ +// file : common/blob/test.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include <vector> +#include <cstring> // std::memcmp + +#include <odb/core.hxx> + +#ifdef ODB_COMPILER +# ifdef ODB_DATABASE_PGSQL +# define BLOB_TYPE "BYTEA" +# else +# define BLOB_TYPE "BLOB" +# endif +#endif + +#pragma db object +struct object +{ + object () {} + object (unsigned long id): id_ (id) {} + + #pragma db id + unsigned long id_; + + #pragma db type(BLOB_TYPE) + std::vector<char> vc; + + #pragma db type(BLOB_TYPE) + std::vector<unsigned char> vuc; + + #pragma db type(BLOB_TYPE) + char c[1024]; + + #pragma db type(BLOB_TYPE) + unsigned char uc[1024]; +}; + +inline bool +operator== (const object& x, const object& y) +{ + return + x.id_ == y.id_ && + x.vc == y.vc && + x.vuc == y.vuc && + std::memcmp (x.c, y.c, sizeof (x.c)) == 0 && + std::memcmp (x.uc, y.uc, sizeof (x.uc)) == 0; +} + +#endif // TEST_HXX |