summaryrefslogtreecommitdiff
path: root/odb/common.cxx
blob: f398b6ef2e7bb900b3d6b399058716ce3d9e416e (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
// file      : odb/common.cxx
// author    : Boris Kolpackov <boris@codesynthesis.com>
// copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC
// license   : GNU GPL v3; see accompanying LICENSE file

#include <odb/common.hxx>

using namespace std;

//
// object_columns_base
//

void object_columns_base::
composite (semantics::data_member& m)
{
  dispatch (m.type ());
}

void object_columns_base::
traverse (semantics::class_& c)
{
  inherits (c);
  names (c);
}

void object_columns_base::member::
traverse (semantics::data_member& m)
{
  if (m.count ("transient"))
    return;

  if (comp_value (m.type ()))
  {
    string old_prefix (prefix_);

    bool custom (m.count ("column"));
    string name (column_name (m));

    // If the user provided the column prefix, then use it verbatime.
    // Otherwise, append the underscore, unless it is already there.
    //
    prefix_ += name;

    if (!custom)
    {
      size_t n (name.size ());

      if (n != 0 && name[n - 1] != '_')
        prefix_ += '_';
    }

    oc_.composite (m);

    prefix_ = old_prefix;
  }
  else
  {
    oc_.column (m, prefix_ + column_name (m), first_);

    if (first_)
      first_ = false;
  }
}