24 #ifndef TCLAP_DOCBOOKOUTPUT_H
25 #define TCLAP_DOCBOOKOUTPUT_H
104 const std::vector< std::vector<Arg*> > xorList = xorHandler.
getXorList();
107 std::cout <<
"<?xml version='1.0'?>" << std::endl;
108 std::cout <<
"<!DOCTYPE refentry PUBLIC \"-//OASIS//DTD DocBook XML V4.2//EN\"" << std::endl;
109 std::cout <<
"\t\"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd\">" << std::endl << std::endl;
111 std::cout <<
"<refentry>" << std::endl;
113 std::cout <<
"<refmeta>" << std::endl;
114 std::cout <<
"<refentrytitle>" << progName <<
"</refentrytitle>" << std::endl;
115 std::cout <<
"<manvolnum>1</manvolnum>" << std::endl;
116 std::cout <<
"</refmeta>" << std::endl;
118 std::cout <<
"<refnamediv>" << std::endl;
119 std::cout <<
"<refname>" << progName <<
"</refname>" << std::endl;
120 std::cout <<
"<refpurpose>" << _cmd.
getMessage() <<
"</refpurpose>" << std::endl;
121 std::cout <<
"</refnamediv>" << std::endl;
123 std::cout <<
"<refsynopsisdiv>" << std::endl;
124 std::cout <<
"<cmdsynopsis>" << std::endl;
126 std::cout <<
"<command>" << progName <<
"</command>" << std::endl;
129 for (
int i = 0; (
unsigned int)i < xorList.size(); i++ )
131 std::cout <<
"<group choice='req'>" << std::endl;
133 it != xorList[i].end(); it++ )
136 std::cout <<
"</group>" << std::endl;
141 if ( !xorHandler.
contains( (*it) ) )
144 std::cout <<
"</cmdsynopsis>" << std::endl;
145 std::cout <<
"</refsynopsisdiv>" << std::endl;
147 std::cout <<
"<refsect1>" << std::endl;
148 std::cout <<
"<title>Description</title>" << std::endl;
149 std::cout <<
"<para>" << std::endl;
151 std::cout <<
"</para>" << std::endl;
152 std::cout <<
"</refsect1>" << std::endl;
154 std::cout <<
"<refsect1>" << std::endl;
155 std::cout <<
"<title>Options</title>" << std::endl;
157 std::cout <<
"<variablelist>" << std::endl;
162 std::cout <<
"</variablelist>" << std::endl;
163 std::cout <<
"</refsect1>" << std::endl;
165 std::cout <<
"<refsect1>" << std::endl;
166 std::cout <<
"<title>Version</title>" << std::endl;
167 std::cout <<
"<para>" << std::endl;
168 std::cout << xversion << std::endl;
169 std::cout <<
"</para>" << std::endl;
170 std::cout <<
"</refsect1>" << std::endl;
172 std::cout <<
"</refentry>" << std::endl;
179 static_cast<void>(_cmd);
180 std::cout << e.
what() << std::endl;
189 while ( (p = s.find_first_of(r)) != std::string::npos )
199 while ( (p = s.find_first_of(r)) != std::string::npos )
207 size_t p = s.find_last_of(
'/');
208 if ( p != std::string::npos )
216 std::string lt =
"<";
217 std::string gt =
">";
225 std::string choice =
"opt";
229 std::cout <<
"<arg choice='" << choice <<
'\'';
231 std::cout <<
" rep='repeat'";
235 if ( !a->getFlag().empty() )
236 std::cout << a->flagStartChar() << a->getFlag();
238 std::cout << a->nameStartString() << a->getName();
239 if ( a->isValueRequired() )
241 std::string arg = a->shortID();
247 arg.erase(0, arg.find_last_of(theDelimiter) + 1);
248 std::cout << theDelimiter;
249 std::cout << "<replaceable>" << arg << "</replaceable>";
251 std::cout << "</arg>" << std::endl;
255 inline void DocBookOutput::printLongArg(Arg* a)
257 std::string lt = "<";
258 std::string gt = ">";
260 std::string desc = a->getDescription();
261 substituteSpecialChars(desc,'<
',lt);
262 substituteSpecialChars(desc,'>
',gt);
264 std::cout << "<varlistentry>" << std::endl;
266 if ( !a->getFlag().empty() )
268 std::cout << "<term>" << std::endl;
269 std::cout << "<option>";
270 std::cout << a->flagStartChar() << a->getFlag();
271 std::cout << "</option>" << std::endl;
272 std::cout << "</term>" << std::endl;
275 std::cout << "<term>" << std::endl;
276 std::cout << "<option>";
277 std::cout << a->nameStartString() << a->getName();
278 if ( a->isValueRequired() )
280 std::string arg = a->shortID();
286 arg.erase(0, arg.find_last_of(theDelimiter) + 1);
287 std::cout << theDelimiter;
288 std::cout << "<replaceable>" << arg << "</replaceable>";
290 std::cout << "</option>" << std::endl;
291 std::cout << "</term>" << std::endl;
293 std::cout << "<listitem>" << std::endl;
294 std::cout << "<para>" << std::endl;
295 std::cout << desc << std::endl;
296 std::cout << "</para>" << std::endl;
297 std::cout << "</listitem>" << std::endl;
299 std::cout << "</varlistentry>" << std::endl;
A simple class that defines and argument exception.
const char * what() const
Returns the arg id and error text.
A virtual base class that defines the essential data for all arguments.
virtual bool acceptsMultipleValues()
Use by output classes to determine whether an Arg accepts multiple values.
virtual bool isRequired() const
Indicates whether the argument is required.
virtual std::string shortID(const std::string &valueId="val") const
Returns a short ID for the usage.
The base class that manages the command line definition and passes along the parsing to the appropria...
virtual std::string & getVersion()=0
Returns the version string.
virtual XorHandler & getXorHandler()=0
Returns the XorHandler.
virtual std::string & getProgramName()=0
Returns the program name string.
virtual std::string & getMessage()=0
Returns the message string.
virtual std::list< Arg * > & getArgList()=0
Returns the argList.
virtual char getDelimiter()=0
Returns the delimiter string.
The interface that any output object must implement.
A class that generates DocBook output for usage() method for the given CmdLine and its Args.
virtual void version(CmdLineInterface &c)
Prints the version to stdout.
virtual void failure(CmdLineInterface &c, ArgException &e)
Prints (to stderr) an error message, short usage Can be overridden to produce alternative behavior.
void substituteSpecialChars(std::string &s, char r, std::string &x)
Substitutes the char r for string x in string s.
void basename(std::string &s)
void printLongArg(Arg *it)
void printShortArg(Arg *it)
void removeChar(std::string &s, char r)
virtual void usage(CmdLineInterface &c)
Prints the usage to stdout.
Thrown when TCLAP thinks the program should exit.
This class handles lists of Arg's that are to be XOR'd on the command line.
bool contains(const Arg *a)
Simply checks whether the Arg is contained in one of the arg lists.
const std::vector< std::vector< Arg * > > & getXorList() const
std::vector< Arg * >::const_iterator ArgVectorIterator
Typedef of an Arg vector iterator.
std::list< Arg * >::const_iterator ArgListIterator
Typedef of an Arg list iterator.