summaryrefslogtreecommitdiff
path: root/cli/generator.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2009-10-04 10:04:34 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2009-10-04 10:04:34 +0200
commitb0cbea713f15e511630d2626c4694f119206dc94 (patch)
tree340c55eb7c946034387839297c62a576123afab3 /cli/generator.cxx
parent9f995b41e72b25c0c7ffe8e2568e166d86f27bcc (diff)
Add options for various include settings
--include-with-brackets --include-prefix --guard-prefix
Diffstat (limited to 'cli/generator.cxx')
-rw-r--r--cli/generator.cxx25
1 files changed, 18 insertions, 7 deletions
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<compiler::cxx_indenter, char> 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)