From fa1fa57d5fe1cb901520f03e7f802a156aae1034 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 10 Mar 2011 12:07:10 +0200 Subject: Move the rest of generators to new ctor-less context --- odb/header.cxx | 108 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 55 insertions(+), 53 deletions(-) (limited to 'odb/header.cxx') diff --git a/odb/header.cxx b/odb/header.cxx index 458c822..140a781 100644 --- a/odb/header.cxx +++ b/odb/header.cxx @@ -4,17 +4,15 @@ // license : GNU GPL v3; see accompanying LICENSE file #include -#include +#include +#include + +using namespace std; namespace { struct data_member: traversal::data_member, context { - data_member (context& c) - : context (c) - { - } - virtual void traverse (semantics::data_member& m) { @@ -36,8 +34,7 @@ namespace struct class_: traversal::class_, context { - class_ (context& c) - : context (c), member_ (c) + class_ () { member_names_ >> member_; } @@ -77,62 +74,67 @@ namespace }; } -void -generate_header (context& ctx) +namespace header { - ctx.os << "#include " << endl - << "#include " << endl // std::size_t - << endl; - - ctx.os << "#include " << endl - << "#include " << endl - << "#include " << endl; - - // In case of a boost TR1 implementation, we cannot distinguish - // between the boost::shared_ptr and std::tr1::shared_ptr usage since - // the latter is just a using-declaration for the former. To resolve - // this we will include TR1 traits if the Boost TR1 header is included. - // - if (ctx.unit.count ("tr1-pointer-used") && - ctx.unit.get ("tr1-pointer-used")) - { - ctx.os << "#include " << endl; - } - else if (ctx.unit.count ("boost-pointer-used") && - ctx.unit.get ("boost-pointer-used")) + void + generate () { - ctx.os << "#ifdef BOOST_TR1_MEMORY_HPP_INCLUDED" << endl - << "# include " << endl - << "#endif" << endl; - } - - ctx.os << "#include " << endl; + context ctx; + ostream& os (ctx.os); + + os << "#include " << endl + << "#include " << endl // std::size_t + << endl; + + os << "#include " << endl + << "#include " << endl + << "#include " << endl; + + // In case of a boost TR1 implementation, we cannot distinguish + // between the boost::shared_ptr and std::tr1::shared_ptr usage since + // the latter is just a using-declaration for the former. To resolve + // this we will include TR1 traits if the Boost TR1 header is included. + // + if (ctx.unit.count ("tr1-pointer-used") && + ctx.unit.get ("tr1-pointer-used")) + { + os << "#include " << endl; + } + else if (ctx.unit.count ("boost-pointer-used") && + ctx.unit.get ("boost-pointer-used")) + { + os << "#ifdef BOOST_TR1_MEMORY_HPP_INCLUDED" << endl + << "# include " << endl + << "#endif" << endl; + } - if (ctx.options.generate_query ()) - ctx.os << "#include " << endl; + os << "#include " << endl; - ctx.os << endl; + if (ctx.options.generate_query ()) + os << "#include " << endl; + os << endl; - /* - traversal::unit unit; - traversal::defines unit_defines; - traversal::namespace_ ns; - class_ c (ctx); + /* + traversal::unit unit; + traversal::defines unit_defines; + traversal::namespace_ ns; + class_ c; - unit >> unit_defines >> ns; - unit_defines >> c; + unit >> unit_defines >> ns; + unit_defines >> c; - traversal::defines ns_defines; + traversal::defines ns_defines; - ns >> ns_defines >> ns; - ns_defines >> c; + ns >> ns_defines >> ns; + ns_defines >> c; - ctx.os << "namespace odb" + os << "namespace odb" << "{"; - unit.dispatch (ctx.unit); + unit.dispatch (ctx.unit); - ctx.os << "}"; - */ + os << "}"; + */ + } } -- cgit v1.1