From b0cbea713f15e511630d2626c4694f119206dc94 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 4 Oct 2009 10:04:34 +0200 Subject: Add options for various include settings --include-with-brackets --include-prefix --guard-prefix --- cli/generator.cxx | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'cli/generator.cxx') diff --git a/cli/generator.cxx b/cli/generator.cxx index f7a9a1f..844981a 100644 --- a/cli/generator.cxx +++ b/cli/generator.cxx @@ -38,13 +38,10 @@ namespace "//\n\n"; string - make_guard (string const& file, string const& prefix, context& ctx) + make_guard (string const& file, context& ctx) { string g (file); - if (!prefix.empty ()) - g = prefix + '_' + g; - // Split words, e.g., "FooBar" to "Foo_Bar" and convert everything // to upper case. // @@ -159,13 +156,25 @@ generate (options const& ops, semantics::cli_unit& unit, path const& p) typedef compiler::ostream_filter cxx_filter; + // Include settings. + // + bool br (ops.include_with_brackets ()); + string ip (ops.include_prefix ()); + string gp (ops.guard_prefix ()); + + if (!ip.empty () && ip[ip.size () - 1] != '/') + ip.append ("/"); + + if (!gp.empty () && gp[gp.size () - 1] != '_') + gp.append ("_"); + // HXX // { cxx_filter filt (hxx); context ctx (hxx, unit, ops); - string guard (make_guard (hxx_name, "", ctx)); + string guard (make_guard (gp + hxx_name, ctx)); hxx << "#ifndef " << guard << endl << "#define " << guard << endl @@ -177,7 +186,8 @@ generate (options const& ops, semantics::cli_unit& unit, path const& p) if (inl) { - hxx << "#include \"" << ixx_name << "\"" << endl + hxx << "#include " << (br ? '<' : '"') << ip << ixx_name << + (br ? '>' : '"') << endl << endl; } @@ -199,7 +209,8 @@ generate (options const& ops, semantics::cli_unit& unit, path const& p) cxx_filter filt (cxx); context ctx (cxx, unit, ops); - cxx << "#include \"" << hxx_name << "\"" << endl + cxx << "#include " << (br ? '<' : '"') << ip << hxx_name << + (br ? '>' : '"') << endl << endl; if (!inl) -- cgit v1.1