aboutsummaryrefslogtreecommitdiff
path: root/common/default/test.hxx
blob: 45ae3907541d04007d2c1dd1825860af00433061 (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
// file      : common/default/test.hxx
// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
// license   : GNU GPL v2; see accompanying LICENSE file

#ifndef TEST_HXX
#define TEST_HXX

#include <string>
#include <odb/core.hxx>

enum color {red, green, blue};

typedef unsigned long ulong;
#pragma db value(ulong) default(0) // @@ Can't do value(unsigned long).

#pragma db object
struct object
{
  #pragma db id
  unsigned long obj_id;

  // NULL.
  //
  #pragma db null default(null)
  unsigned long null;

  // Boolean.
  //
  #pragma db default(true)
  bool b;

  // Integers.
  //
  #pragma db default(1234)
  unsigned long pi;

  #pragma db default(-1234)
  long ni;

  // 0 default taken from the type.
  unsigned long zi;

  // Floats.
  //
  #pragma db default(1.234)
  double pf;

  #pragma db default(-1.234)
  double nf;

  #pragma db default(0.0)
  double zf;

  #pragma db default(1.123e+10)
  double sf;

  // Strings. MySQL doesn't support default values on TEXT
  // columns, so make the type VARCHAR.
  //
  #pragma db type("VARCHAR(64)") default("Someone's string")
  std::string str;

  // Enums.
  //
  #pragma db default(green)
  color e;
};

#endif // TEST_HXX