blob: 84448cc95dab9bf20fdc5a18dcf2d58ab5db483e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
// file : common/blob/test.hxx
// copyright : Copyright (c) 2009-2015 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 <vector>
#include <cstring> // std::memcmp
#ifdef HAVE_CXX11
# include <array>
#endif
#include <odb/core.hxx>
#ifdef ODB_COMPILER
# if defined(ODB_DATABASE_PGSQL)
# define BLOB_TYPE "BYTEA"
# elif defined(ODB_DATABASE_MSSQL)
//# define BLOB_TYPE "VARBINARY(1024)"
# define BLOB_TYPE "VARBINARY(max)"
# else
//# define BLOB_TYPE "RAW(1024)"
# 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];
#ifdef HAVE_CXX11
#pragma db type(BLOB_TYPE)
std::array<char, 1024> a;
#pragma db type(BLOB_TYPE)
std::array<char, 1024> ua;
#endif
// Make sure we can still use std::vector<char> and std::array<char>
// as containers.
//
std::vector<unsigned char> cont;
};
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
#ifdef HAVE_CXX11
&& x.a == y.a
&& x.ua == y.ua
#endif
&& x.cont == y.cont;
}
#endif // TEST_HXX
|