summaryrefslogtreecommitdiff
path: root/odb/semantics/relational/column.cxx
blob: a4c39c399f96691e232cd678addbc0c5f228c1ec (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
// file      : odb/semantics/relational/column.cxx
// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license   : GNU GPL v3; see accompanying LICENSE file

#include <cutl/compiler/type-info.hxx>
#include <odb/semantics/relational.hxx>

namespace semantics
{
  namespace relational
  {
    column::
    column (xml::parser& p, uscope&, graph& g)
        : unameable (p, g),
          type_ (p.attribute ("type", string ())),
          null_ (p.attribute<bool> ("null")),
          default__ (p.attribute ("default", string ())),
          options_ (p.attribute ("options", string ()))
    {
      p.content (xml::parser::empty);
    }

    void column::
    serialize (xml::serializer& s) const
    {
      s.start_element (xmlns, "column");
      unameable::serialize_attributes (s);

      s.attribute ("type", type ());
      s.attribute ("null", null ()); // Output even if false.

      if (!default_ ().empty ())
        s.attribute ("default", default_ ());

      if (!options ().empty ())
        s.attribute ("options", options ());

      s.end_element ();
    }

    // type info
    //
    namespace
    {
      struct init
      {
        init ()
        {
          unameable::parser_map_["column"] = &unameable::parser_impl<column>;

          using compiler::type_info;

          {
            type_info ti (typeid (column));
            ti.add_base (typeid (unameable));
            insert (ti);
          }
        }
      } init_;
    }
  }
}