23#ifndef TCLAP_DOCBOOKOUTPUT_H
24#define TCLAP_DOCBOOKOUTPUT_H
103 std::vector< std::vector<Arg*> > xorList = xorHandler.
getXorList();
106 std::cout <<
"<?xml version='1.0'?>" << std::endl;
107 std::cout <<
"<!DOCTYPE refentry PUBLIC \"-//OASIS//DTD DocBook XML V4.2//EN\"" << std::endl;
108 std::cout <<
"\t\"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd\">" << std::endl << std::endl;
110 std::cout <<
"<refentry>" << std::endl;
112 std::cout <<
"<refmeta>" << std::endl;
113 std::cout <<
"<refentrytitle>" << progName <<
"</refentrytitle>" << std::endl;
114 std::cout <<
"<manvolnum>1</manvolnum>" << std::endl;
115 std::cout <<
"</refmeta>" << std::endl;
117 std::cout <<
"<refnamediv>" << std::endl;
118 std::cout <<
"<refname>" << progName <<
"</refname>" << std::endl;
119 std::cout <<
"<refpurpose>" << _cmd.
getMessage() <<
"</refpurpose>" << std::endl;
120 std::cout <<
"</refnamediv>" << std::endl;
122 std::cout <<
"<refsynopsisdiv>" << std::endl;
123 std::cout <<
"<cmdsynopsis>" << std::endl;
125 std::cout <<
"<command>" << progName <<
"</command>" << std::endl;
128 for (
int i = 0; (
unsigned int)i < xorList.size(); i++ )
130 std::cout <<
"<group choice='req'>" << std::endl;
132 it != xorList[i].end(); it++ )
135 std::cout <<
"</group>" << std::endl;
140 if ( !xorHandler.
contains( (*it) ) )
143 std::cout <<
"</cmdsynopsis>" << std::endl;
144 std::cout <<
"</refsynopsisdiv>" << std::endl;
146 std::cout <<
"<refsect1>" << std::endl;
147 std::cout <<
"<title>Description</title>" << std::endl;
148 std::cout <<
"<para>" << std::endl;
150 std::cout <<
"</para>" << std::endl;
151 std::cout <<
"</refsect1>" << std::endl;
153 std::cout <<
"<refsect1>" << std::endl;
154 std::cout <<
"<title>Options</title>" << std::endl;
156 std::cout <<
"<variablelist>" << std::endl;
161 std::cout <<
"</variablelist>" << std::endl;
162 std::cout <<
"</refsect1>" << std::endl;
164 std::cout <<
"<refsect1>" << std::endl;
165 std::cout <<
"<title>Version</title>" << std::endl;
166 std::cout <<
"<para>" << std::endl;
167 std::cout << xversion << std::endl;
168 std::cout <<
"</para>" << std::endl;
169 std::cout <<
"</refsect1>" << std::endl;
171 std::cout <<
"</refentry>" << std::endl;
178 static_cast<void>(_cmd);
179 std::cout << e.
what() << std::endl;
188 while ( (p = s.find_first_of(r)) != std::string::npos )
198 while ( (p = s.find_first_of(r)) != std::string::npos )
206 size_t p = s.find_last_of(
'/');
207 if ( p != std::string::npos )
215 std::string lt =
"<";
216 std::string gt =
">";
224 std::string choice =
"opt";
228 std::cout <<
"<arg choice='" << choice <<
'\'';
230 std::cout <<
" rep='repeat'";
234 if ( !a->getFlag().empty() )
235 std::cout << a->flagStartChar() << a->getFlag();
237 std::cout << a->nameStartString() << a->getName();
238 if ( a->isValueRequired() )
240 std::string arg = a->shortID();
245 arg.erase(0, arg.find_last_of(theDelimiter) + 1);
246 std::cout << theDelimiter;
247 std::cout << "<replaceable>" << arg << "</replaceable>";
249 std::cout << "</arg>" << std::endl;
253inline void DocBookOutput::printLongArg(Arg* a)
255 std::string lt = "<";
256 std::string gt = ">";
258 std::string desc = a->getDescription();
259 substituteSpecialChars(desc,'<
',lt);
260 substituteSpecialChars(desc,'>
',gt);
262 std::cout << "<varlistentry>" << std::endl;
264 if ( !a->getFlag().empty() )
266 std::cout << "<term>" << std::endl;
267 std::cout << "<option>";
268 std::cout << a->flagStartChar() << a->getFlag();
269 std::cout << "</option>" << std::endl;
270 std::cout << "</term>" << std::endl;
273 std::cout << "<term>" << std::endl;
274 std::cout << "<option>";
275 std::cout << a->nameStartString() << a->getName();
276 if ( a->isValueRequired() )
278 std::string arg = a->shortID();
283 arg.erase(0, arg.find_last_of(theDelimiter) + 1);
284 std::cout << theDelimiter;
285 std::cout << "<replaceable>" << arg << "</replaceable>";
287 std::cout << "</option>" << std::endl;
288 std::cout << "</term>" << std::endl;
290 std::cout << "<listitem>" << std::endl;
291 std::cout << "<para>" << std::endl;
292 std::cout << desc << std::endl;
293 std::cout << "</para>" << std::endl;
294 std::cout << "</listitem>" << std::endl;
296 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 XorHandler & getXorHandler()=0
Returns the XorHandler.
virtual std::list< Arg * > & getArgList()=0
Returns the argList.
virtual std::string & getProgramName()=0
Returns the program name string.
virtual char getDelimiter()=0
Returns the delimiter string.
virtual std::string & getVersion()=0
Returns the version string.
virtual std::string & getMessage()=0
Returns the message 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.
This class handles lists of Arg's that are to be XOR'd on the command line.
std::vector< std::vector< Arg * > > & getXorList()
bool contains(const Arg *a)
Simply checks whether the Arg is contained in one of the arg lists.
std::vector< Arg * >::iterator ArgVectorIterator
Typedef of an Arg vector iterator.
std::list< Arg * >::iterator ArgListIterator
Typedef of an Arg list iterator.