summaryrefslogtreecommitdiff
path: root/cli/man.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-05-11 12:25:53 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-05-11 12:25:53 +0200
commitaa33636c20b65dbf87e2189dc3d8759b883e7909 (patch)
tree8b57ff0e570429dae4266a0204b7d4ab4f73a744 /cli/man.cxx
parent5a2e172ce1f2d823bf0957602662bbab0c0dcd0b (diff)
Add support for specifying multiple classes with --class option
Diffstat (limited to 'cli/man.cxx')
-rw-r--r--cli/man.cxx40
1 files changed, 28 insertions, 12 deletions
diff --git a/cli/man.cxx b/cli/man.cxx
index ac5d9b1..576ee04 100644
--- a/cli/man.cxx
+++ b/cli/man.cxx
@@ -3,8 +3,13 @@
// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
// license : MIT; see accompanying LICENSE file
+#include <vector>
+#include <iostream>
+
#include "man.hxx"
+using namespace std;
+
namespace
{
struct option: traversal::option, context
@@ -129,17 +134,6 @@ namespace
virtual void
traverse (type& c)
{
- string const& n (options.class_ ());
-
- if (!n.empty ())
- {
- string fqn (fq_name (c, false));
- fqn = string (fqn, 2, fqn.size () - 2); // Get rid of leading ::.
-
- if (n != fqn)
- return;
- }
-
if (!options.exclude_base ())
inherits (c, inherits_base_);
@@ -171,5 +165,27 @@ generate_man (context& ctx)
ns >> ns_names >> ns;
ns_names >> cl;
- unit.dispatch (ctx.unit);
+ if (ctx.options.class_ ().empty ())
+ unit.dispatch (ctx.unit);
+ else
+ {
+ for (vector<string>::const_iterator i (ctx.options.class_ ().begin ());
+ i != ctx.options.class_ ().end (); ++i)
+ {
+ string n (*i);
+
+ // Strip leading :: if present.
+ //
+ if (n.size () > 2 && n[0] == ':' && n[1] == ':')
+ n = string (n, 2, string::npos);
+
+ if (semantics::class_* c = ctx.unit.lookup<semantics::class_> ("", n))
+ cl.traverse (*c);
+ else
+ {
+ cerr << "error: class '" << *i << "' not found" << endl;
+ throw generation_failed ();
+ }
+ }
+ }
}