From 08b159e18527c2d6844e569b1309b5033b4d47c9 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 16 Mar 2013 07:44:43 +0200 Subject: Add initial support for database model serialization to XML --- odb/semantics/relational/column.cxx | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'odb/semantics/relational/column.cxx') diff --git a/odb/semantics/relational/column.cxx b/odb/semantics/relational/column.cxx index 52385cc..a4c39c3 100644 --- a/odb/semantics/relational/column.cxx +++ b/odb/semantics/relational/column.cxx @@ -3,13 +3,41 @@ // license : GNU GPL v3; see accompanying LICENSE file #include - -#include +#include namespace semantics { namespace relational { + column:: + column (xml::parser& p, uscope&, graph& g) + : unameable (p, g), + type_ (p.attribute ("type", string ())), + null_ (p.attribute ("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 @@ -18,10 +46,10 @@ namespace semantics { init () { + unameable::parser_map_["column"] = &unameable::parser_impl; + using compiler::type_info; - // column - // { type_info ti (typeid (column)); ti.add_base (typeid (unameable)); -- cgit v1.1