24 #ifndef TCLAP_DOC_BOOK_OUTPUT_H 25 #define TCLAP_DOC_BOOK_OUTPUT_H 77 const std::string &x)
const;
110 std::cout <<
"<?xml version='1.0'?>\n";
112 <<
"<!DOCTYPE refentry PUBLIC \"-//OASIS//DTD DocBook XML V4.2//EN\"\n";
114 <<
"\t\"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd\">\n\n";
116 std::cout <<
"<refentry>\n";
118 std::cout <<
"<refmeta>\n";
119 std::cout <<
"<refentrytitle>" << progName <<
"</refentrytitle>\n";
120 std::cout <<
"<manvolnum>1</manvolnum>\n";
121 std::cout <<
"</refmeta>\n";
123 std::cout <<
"<refnamediv>\n";
124 std::cout <<
"<refname>" << progName <<
"</refname>\n";
125 std::cout <<
"<refpurpose>" << _cmd.
getMessage() <<
"</refpurpose>\n";
126 std::cout <<
"</refnamediv>\n";
128 std::cout <<
"<refsynopsisdiv>\n";
129 std::cout <<
"<cmdsynopsis>\n";
131 std::cout <<
"<command>" << progName <<
"</command>\n";
133 for (std::list<ArgGroup *>::iterator sit = argSets.begin();
134 sit != argSets.end(); ++sit) {
142 if (!(*it)->visibleInHelp()) {
147 (visible == 1 && (**sit).isRequired()));
150 std::cout <<
"</group>\n";
154 std::cout <<
"</cmdsynopsis>\n";
155 std::cout <<
"</refsynopsisdiv>\n";
157 std::cout <<
"<refsect1>\n";
158 std::cout <<
"<title>Description</title>\n";
159 std::cout <<
"<para>\n";
161 std::cout <<
"</para>\n";
162 std::cout <<
"</refsect1>\n";
164 std::cout <<
"<refsect1>\n";
165 std::cout <<
"<title>Options</title>\n";
167 std::cout <<
"<variablelist>\n";
169 for (std::list<ArgGroup *>::iterator sit = argSets.begin();
170 sit != argSets.end(); ++sit) {
174 std::cout <<
"</variablelist>\n";
175 std::cout <<
"</refsect1>\n";
177 std::cout <<
"<refsect1>\n";
178 std::cout <<
"<title>Version</title>\n";
179 std::cout <<
"<para>\n";
180 std::cout << xversion <<
'\n';
181 std::cout <<
"</para>\n";
182 std::cout <<
"</refsect1>\n";
184 std::cout <<
"</refentry>" << std::endl;
188 static_cast<void>(_cmd);
189 std::cout << e.
what() << std::endl;
194 const std::string &x)
const {
196 while ((p = s.find_first_of(r)) != std::string::npos) {
204 while ((p = s.find_first_of(r)) != std::string::npos) {
210 std::string lt =
"<";
211 std::string gt =
">";
219 std::string choice =
"opt";
224 std::cout <<
"<arg choice='" << choice <<
'\'';
228 if (!a->getFlag().empty()) 229 std::cout << a->flagStartChar() << a->getFlag(); 231 std::cout << a->nameStartString() << a->getName(); 232 if (a->isValueRequired()) { 233 std::string arg = a->shortID(); 234 removeChar(arg, '[
'); 235 removeChar(arg, ']
'); 236 removeChar(arg, '<
'); 237 removeChar(arg, '>
'); 238 removeChar(arg, '.
'); 239 arg.erase(0, arg.find_last_of(theDelimiter) + 1); 240 std::cout << theDelimiter; 241 std::cout << "<replaceable>" << arg << "</replaceable>"; 243 std::cout << "</arg>" << std::endl; 246 inline void DocBookOutput::printLongArg(const ArgGroup &group) const { 247 const std::string lt = "<"; 248 const std::string gt = ">"; 250 bool forceRequired = group.isRequired() && CountVisibleArgs(group) == 1; 251 for (ArgGroup::const_iterator it = group.begin(); it != group.end(); ++it) { 253 if (!a.visibleInHelp()) { 257 std::string desc = a.getDescription(forceRequired || a.isRequired()); 258 substituteSpecialChars(desc, '<
', lt); 259 substituteSpecialChars(desc, '>
', gt); 261 std::cout << "<varlistentry>\n"; 263 if (!a.getFlag().empty()) { 264 std::cout << "<term>\n"; 265 std::cout << "<option>"; 266 std::cout << a.flagStartChar() << a.getFlag(); 267 std::cout << "</option>\n"; 268 std::cout << "</term>\n"; 271 std::cout << "<term>\n"; 272 std::cout << "<option>"; 273 std::cout << a.nameStartString() << a.getName(); 274 if (a.isValueRequired()) { 275 std::string arg = a.shortID(); 276 removeChar(arg, '[
'); 277 removeChar(arg, ']
'); 278 removeChar(arg, '<
'); 279 removeChar(arg, '>
'); 280 removeChar(arg, '.
'); 281 arg.erase(0, arg.find_last_of(theDelimiter) + 1); 282 std::cout << theDelimiter; 283 std::cout << "<replaceable>" << arg << "</replaceable>"; 286 std::cout << "</option>\n"; 287 std::cout << "</term>\n"; 289 std::cout << "<listitem>\n"; 290 std::cout << "<para>\n"; 291 std::cout << desc << '\n
'; 292 std::cout << "</para>\n"; 293 std::cout << "</listitem>\n"; 295 std::cout << "</varlistentry>" << std::endl; 300 #endif // TCLAP_DOC_BOOK_OUTPUT_H virtual bool isRequired() const =0
Returns true if this argument group is required.
void printLongArg(const ArgGroup &it) const
A virtual base class that defines the essential data for all arguments.
A simple class that defines and argument exception.
virtual void usage(CmdLineInterface &c)
Prints the usage to stdout.
Thrown when TCLAP thinks the program should exit.
void removeChar(std::string &s, char r) const
virtual std::string getMessage() const =0
Returns the message string.
const char * GroupChoice(const ArgGroup &group)
Container::iterator iterator
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 bool acceptsMultipleValues()
Use by output classes to determine whether an Arg accepts multiple values.
virtual std::list< ArgGroup * > getArgGroups()=0
Returns the list of ArgGroups.
int CountVisibleArgs(const ArgGroup &g)
virtual void version(CmdLineInterface &c)
Prints the version to stdout.
virtual bool showAsGroup() const
If arguments in this group should show up as grouped in help.
void printShortArg(Arg *it, bool required)
void substituteSpecialChars(std::string &s, char r, const std::string &x) const
Substitutes the char r for string x in string s.
virtual std::string getProgramName() const =0
Returns the program name string.
virtual char getDelimiter() const =0
Returns the delimiter string.
ArgGroup is the base class for implementing groups of arguments that are mutually exclusive (it repla...
virtual std::string getVersion() const =0
Returns the version string.
A class that generates DocBook output for usage() method for the given CmdLine and its Args...
virtual void failure(CmdLineInterface &c, ArgException &e)
Prints (to stderr) an error message, short usage Can be overridden to produce alternative behavior...
const char * what() const
Returns the arg id and error text.
The interface that any output object must implement.