aboutsummaryrefslogtreecommitdiff
path: root/common/default/test.hxx
blob: 76d105f4ffa7f4c11356244d54173bb8c5c0ef9e (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
// file      : common/default/test.hxx
// copyright : Copyright (c) 2009-2017 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};

#pragma db value(unsigned long) default(0)

#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