30 #ifndef TCLAP_DOCBOOKOUTPUT_H
31 #define TCLAP_DOCBOOKOUTPUT_H
50 class DocBookOutput :
public CmdLineOutput
60 virtual void usage(CmdLineInterface& c);
101 std::list<Arg*> argList = _cmd.getArgList();
102 std::string progName = _cmd.getProgramName();
103 std::string
version = _cmd.getVersion();
104 XorHandler xorHandler = _cmd.getXorHandler();
105 std::vector< std::vector<Arg*> > xorList = xorHandler.getXorList();
108 std::cout <<
"<?xml version='1.0'?>" << std::endl;
109 std::cout <<
"<!DOCTYPE book PUBLIC \"-//Norman Walsh//DTD DocBk XML V4.2//EN\"" << std::endl;
110 std::cout <<
"\t\"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd\">" << std::endl << std::endl;
112 std::cout <<
"<book>" << std::endl;
113 std::cout <<
"<refentry>" << std::endl;
115 std::cout <<
"<refmeta>" << std::endl;
116 std::cout <<
"<refentrytitle>" << std::endl;
117 std::cout << progName << std::endl;
118 std::cout <<
"</refentrytitle>" << std::endl;
119 std::cout <<
"<manvolnum>1</manvolnum>" << std::endl;
120 std::cout <<
"</refmeta>" << std::endl;
122 std::cout <<
"<refnamediv>" << std::endl;
123 std::cout <<
"<refname>" << std::endl;
124 std::cout << progName << std::endl;
125 std::cout <<
"</refname>" << std::endl;
126 std::cout <<
"</refnamediv>" << std::endl;
128 std::cout <<
"<cmdsynopsis>" << std::endl;
130 std::cout <<
"<command>" << progName <<
"</command>" << std::endl;
133 for (
int i = 0; (
unsigned int)i < xorList.size(); i++ )
135 std::cout <<
"<group choice='req'>" << std::endl;
137 it != xorList[i].end(); it++ )
140 std::cout <<
"</group>" << std::endl;
145 if ( !xorHandler.contains( (*it) ) )
148 std::cout <<
"</cmdsynopsis>" << std::endl;
150 std::cout <<
"<refsect1>" << std::endl;
151 std::cout <<
"<title>Description</title>" << std::endl;
152 std::cout <<
"<para>" << std::endl;
153 std::cout << _cmd.getMessage() << std::endl;
154 std::cout <<
"</para>" << std::endl;
155 std::cout <<
"</refsect1>" << std::endl;
157 std::cout <<
"<refsect1>" << std::endl;
158 std::cout <<
"<title>Options</title>" << std::endl;
159 std::cout <<
"<para>" << std::endl;
160 std::cout <<
"<itemizedlist>" << std::endl;
162 for (
int i = 0; (
unsigned int)i < xorList.size(); i++ )
164 std::cout <<
"<itemizedlist>" << std::endl;
165 size_t xlen = xorList.size() - 1;
168 it != xorList[i].end(); it++, xcount++ )
172 std::cout <<
"<listitem>OR</listitem>" << std::endl;
175 std::cout <<
"</itemizedlist>" << std::endl;
180 if ( !xorHandler.contains( (*it) ) )
183 std::cout <<
"</itemizedlist>" << std::endl;
184 std::cout <<
"</para>" << std::endl;
185 std::cout <<
"</refsect1>" << std::endl;
187 std::cout <<
"<refsect1>" << std::endl;
188 std::cout <<
"<title>Version</title>" << std::endl;
189 std::cout <<
"<para>" << std::endl;
190 std::cout <<
version << std::endl;
191 std::cout <<
"</para>" << std::endl;
192 std::cout <<
"</refsect1>" << std::endl;
194 std::cout <<
"</refentry>" << std::endl;
195 std::cout <<
"</book>" << std::endl;
202 std::cout << e.what() << std::endl;
210 while ( (p = s.find_first_of(r)) != std::string::npos )
220 while ( (p = s.find_first_of(r)) != std::string::npos )
228 std::string lt =
"<";
229 std::string gt =
">";
231 std::string
id = a->shortID();
237 std::string choice =
"opt";
238 if ( a->isRequired() )
241 std::string repeat =
"norepeat";
242 if ( a->acceptsMultipleValues() )
247 std::cout <<
"<arg choice='" << choice
248 <<
"' repeat='" << repeat <<
"'>"
249 <<
id <<
"</arg>" << std::endl;
255 std::string lt =
"<";
256 std::string gt =
">";
258 std::string
id = a->
longID();
268 std::cout <<
"<simplelist>" << std::endl;
270 std::cout <<
"<member>" << std::endl;
271 std::cout <<
id << std::endl;
272 std::cout <<
"</member>" << std::endl;
274 std::cout <<
"<member>" << std::endl;
275 std::cout << desc << std::endl;
276 std::cout <<
"</member>" << std::endl;
278 std::cout <<
"</simplelist>" << std::endl;