xref: /AOO41X/main/autodoc/source/exes/adc_uni/adc_cl.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #include <precomp.h>
29*cdf0e10cSrcweir #include <adc_cl.hxx>
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir // NOT FULLY DEFINED SERVICES
33*cdf0e10cSrcweir #include <algorithm>
34*cdf0e10cSrcweir #include <cosv/x.hxx>
35*cdf0e10cSrcweir #include <cosv/file.hxx>
36*cdf0e10cSrcweir #include <cosv/tpl/tpltools.hxx>
37*cdf0e10cSrcweir #include <ary/ary.hxx>
38*cdf0e10cSrcweir #include <tools/tkpchars.hxx>
39*cdf0e10cSrcweir #include <adc_msg.hxx>
40*cdf0e10cSrcweir #include "adc_cmds.hxx"
41*cdf0e10cSrcweir #include "adc_cmd_parse.hxx"
42*cdf0e10cSrcweir #include "cmd_sincedata.hxx"
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir namespace autodoc
46*cdf0e10cSrcweir {
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir CommandLine * CommandLine::pTheInstance_ = 0;
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir const char * const C_sUserGuide =
51*cdf0e10cSrcweir "\n\n\n"
52*cdf0e10cSrcweir "               General Use of Autodoc\n"
53*cdf0e10cSrcweir "               ----------------------\n"
54*cdf0e10cSrcweir "\n"
55*cdf0e10cSrcweir "   Example for C++:\n"
56*cdf0e10cSrcweir "\n"
57*cdf0e10cSrcweir "   -html <OutputDirectory> -name \"UDK 3.x anything\" -lg c++\n"
58*cdf0e10cSrcweir "        -p <ProjName> <ProjectRootDirectory>\n"
59*cdf0e10cSrcweir "            -t <SourceDir_relativeToProjectRoot>\n"
60*cdf0e10cSrcweir "\n"
61*cdf0e10cSrcweir "   There may be several projects specified by -p.\n"
62*cdf0e10cSrcweir "\n"
63*cdf0e10cSrcweir "\n"
64*cdf0e10cSrcweir "   Example for IDL:\n"
65*cdf0e10cSrcweir "\n"
66*cdf0e10cSrcweir "   -html <OutputDirectory> -name \"UDK 3.x anything\" -lg idl\n"
67*cdf0e10cSrcweir "         -t <SourceDir1> <SourceDir2>\n"
68*cdf0e10cSrcweir "\n"
69*cdf0e10cSrcweir "   For both languages, instead of or in addition to -t may be\n"
70*cdf0e10cSrcweir "   used -d (no subdirectories) or -f (just one file). There can\n"
71*cdf0e10cSrcweir "   be multiple arguments after each of these options (-t -d -f).\n"
72*cdf0e10cSrcweir "\n"
73*cdf0e10cSrcweir "\n"
74*cdf0e10cSrcweir "           Replacing @since Tag Content\n"
75*cdf0e10cSrcweir "           ----------------------------\n"
76*cdf0e10cSrcweir "\n"
77*cdf0e10cSrcweir "   In both languages you can give a transformation file to replace\n"
78*cdf0e10cSrcweir "   entries in @since tags by different entries.\n"
79*cdf0e10cSrcweir "   This file is given by the option\n"
80*cdf0e10cSrcweir "       -sincefile <TransformationFilePath>\n"
81*cdf0e10cSrcweir "   This option has to appear between the -html and the -lg option.\n"
82*cdf0e10cSrcweir "   Example:\n"
83*cdf0e10cSrcweir "   -html <OutputDirectory> -sincefile replacesince.txt\n"
84*cdf0e10cSrcweir "       -name \"UDK 3.x anything\" -lg idl -t <SourceDir>\n"
85*cdf0e10cSrcweir "\n"
86*cdf0e10cSrcweir "\n";
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir #if 0   // FUTURE
90*cdf0e10cSrcweir "\n\n\n"
91*cdf0e10cSrcweir "               Use of Autodoc\n"
92*cdf0e10cSrcweir "               --------------\n"
93*cdf0e10cSrcweir "\n"
94*cdf0e10cSrcweir "   Basics:\n"
95*cdf0e10cSrcweir "\n"
96*cdf0e10cSrcweir "   Autodoc may perform different tasks.\n"
97*cdf0e10cSrcweir "\n"
98*cdf0e10cSrcweir "   Possible tasks are\n"
99*cdf0e10cSrcweir "       - parsing source code\n"
100*cdf0e10cSrcweir "       - creating HTML-output.\n"
101*cdf0e10cSrcweir "   On the command line each task starts with a specific\n"
102*cdf0e10cSrcweir "   option:\n"
103*cdf0e10cSrcweir "       '-parse' for parsing source code,\n"
104*cdf0e10cSrcweir "       '-html' for creating HTML.\n"
105*cdf0e10cSrcweir "   All command line options, related to one task, have to follow before\n"
106*cdf0e10cSrcweir "   the starting option of the next task.\n"
107*cdf0e10cSrcweir "\n"
108*cdf0e10cSrcweir "   Within the task '-parse', there may be defined different projects.\n"
109*cdf0e10cSrcweir "   A project definition is started with '-p'.\n"
110*cdf0e10cSrcweir "   All not project specific options within the task '-parse' have to\n"
111*cdf0e10cSrcweir "   appear in front of the first '-p'.\n"
112*cdf0e10cSrcweir "   There can be no project at all. Then all options, available for\n"
113*cdf0e10cSrcweir "   projects, can be used like for one nameless default project, without using\n"
114*cdf0e10cSrcweir "   '-p', but these options still have to appear behind all other\n"
115*cdf0e10cSrcweir "   options of the task '-parse'.\n"
116*cdf0e10cSrcweir "\n"
117*cdf0e10cSrcweir "\n"
118*cdf0e10cSrcweir "   Legend:\n"
119*cdf0e10cSrcweir "\n"
120*cdf0e10cSrcweir "       <SomeText>      Describes an argument.\n"
121*cdf0e10cSrcweir "       'SomeText'      Within '...' is the literal value of an argument.\n"
122*cdf0e10cSrcweir "       +               There can be multiple arguments.\n"
123*cdf0e10cSrcweir "       |               Separator for alternative literal values of an argument.\n"
124*cdf0e10cSrcweir "\n"
125*cdf0e10cSrcweir "\n"
126*cdf0e10cSrcweir "   Syntax:\n"
127*cdf0e10cSrcweir "\n"
128*cdf0e10cSrcweir "   -parse\n"
129*cdf0e10cSrcweir "       -name <RepositoryName>]\n"
130*cdf0e10cSrcweir "       -lg 'c++'|'idl'\n"
131*cdf0e10cSrcweir "       -extg <AdditonalExtensions>+\n"
132*cdf0e10cSrcweir "       -docg 'usehtml'\n"
133*cdf0e10cSrcweir "       -p <ProjectName> <ProjectRootDir>\n"
134*cdf0e10cSrcweir "           -l 'c++'|'idl'\n"
135*cdf0e10cSrcweir "           -ext <AdditonalExtensions>+\n"
136*cdf0e10cSrcweir "           -doc 'usehtml'\n"
137*cdf0e10cSrcweir "           -d <SourceDir_relative2ProjectRootDir_nosubdirs>+\n"
138*cdf0e10cSrcweir "           -t <SourceTree_relative2ProjectRootDir>+\n"
139*cdf0e10cSrcweir "           -f <SourceFile_relative2ProjectRootDir>+\n"
140*cdf0e10cSrcweir "   -html <OutputDir>\n"
141*cdf0e10cSrcweir "       -xlinks <Namespace> <ExternLinksRootDir>\n"
142*cdf0e10cSrcweir "   -i <CommandFilePath>\n"
143*cdf0e10cSrcweir "   -v <VerboseNr>\n"
144*cdf0e10cSrcweir "\n"
145*cdf0e10cSrcweir "\n"
146*cdf0e10cSrcweir "   Detailed Options Description:\n"
147*cdf0e10cSrcweir "\n"
148*cdf0e10cSrcweir "   Option      Arguments\n"
149*cdf0e10cSrcweir "   ----------------------------------------------------------\n"
150*cdf0e10cSrcweir "\n"
151*cdf0e10cSrcweir "   -parse      \n\n"
152*cdf0e10cSrcweir "               Starts the task \"Parse source code\".\n"
153*cdf0e10cSrcweir "               May be omitted, if it would be the first option on the\n"
154*cdf0e10cSrcweir "               command line.\n"
155*cdf0e10cSrcweir "\n"
156*cdf0e10cSrcweir "   -name       <RepositoryName>\n\n"
157*cdf0e10cSrcweir "               This name is used for naming the repository in\n"
158*cdf0e10cSrcweir "               human readable output. In future it may be used also for\n"
159*cdf0e10cSrcweir "               identifiing a repository in searches.\n"
160*cdf0e10cSrcweir "\n"
161*cdf0e10cSrcweir "   -lg         'c++|'idl'\n\n"
162*cdf0e10cSrcweir "               Identifies the programming language to be parsed.\n"
163*cdf0e10cSrcweir "                   'c++':  C++\n"
164*cdf0e10cSrcweir "                           Files with extensions '.h', '.hxx' are parsed.\n"
165*cdf0e10cSrcweir "                   'idl':  UNO-IDL\n"
166*cdf0e10cSrcweir "                           Files with extensions '.idl' are parsed.\n"
167*cdf0e10cSrcweir "               Here the language is set globally for all projects.\n"
168*cdf0e10cSrcweir "               A project can override this by using '-l'.\n"
169*cdf0e10cSrcweir "\n"
170*cdf0e10cSrcweir "   -extg       <.AdditionalExtension>+\n\n"
171*cdf0e10cSrcweir "               Has to follow immediately behind '-lg'.\n"
172*cdf0e10cSrcweir "               Specifies additional extensions, that will be recognised as\n"
173*cdf0e10cSrcweir "               source code files of the previously specified programming\n"
174*cdf0e10cSrcweir "               language.  Each extension has to start with '.'.\n"
175*cdf0e10cSrcweir "               It is possible to include extensionless files, too,\n"
176*cdf0e10cSrcweir "               by the argument '.'\n"
177*cdf0e10cSrcweir "               Here these extensions are set globally for all projects.\n"
178*cdf0e10cSrcweir "               A project can override this by using '-l' and '-ext'.\n"
179*cdf0e10cSrcweir "\n"
180*cdf0e10cSrcweir "   -docg       'html'|'nohtml'\n\n"
181*cdf0e10cSrcweir "               Specifies the default for all comments in source code, so \n"
182*cdf0e10cSrcweir "               that HTML-tags are interpreted as such or else treated as\n"
183*cdf0e10cSrcweir "               regular text.\n"
184*cdf0e10cSrcweir "               Without this option, the default is 'nohtml'.\n"
185*cdf0e10cSrcweir "               Here the default is set globally for all projects.\n"
186*cdf0e10cSrcweir "               A project can override this by using '-doc'.\n"
187*cdf0e10cSrcweir "\n"
188*cdf0e10cSrcweir "   -p          <ProjectName> <ProjectRootDirectory>\n\n"
189*cdf0e10cSrcweir "               ProjectName is used in output as human readable identifier\n"
190*cdf0e10cSrcweir "               for the project. ProjectRootDirectory is the path,\n"
191*cdf0e10cSrcweir "               where the arguments of '-d', '-t' and '-f' are relative to.\n"
192*cdf0e10cSrcweir "               This option can be omitted, then there is no project name\n"
193*cdf0e10cSrcweir "               and all paths are relative to the current working directory.\n"
194*cdf0e10cSrcweir "\n"
195*cdf0e10cSrcweir "   -l          'c++|'idl'\n\n"
196*cdf0e10cSrcweir "               Overrides -lg and -extg for the current project, which is\n"
197*cdf0e10cSrcweir "               specified by the last previous '-p'.\n"
198*cdf0e10cSrcweir "               For details see at option '-lg'.\n"
199*cdf0e10cSrcweir "\n"
200*cdf0e10cSrcweir "   -ext        <.AdditionalExtension>+\n\n"
201*cdf0e10cSrcweir "               Can be used only immediately behind '-l'.\n"
202*cdf0e10cSrcweir "               Overrides -extg for the current project, which is\n"
203*cdf0e10cSrcweir "               specified by the last previous '-p'.\n"
204*cdf0e10cSrcweir "               For details see at option '-extg'.\n"
205*cdf0e10cSrcweir "\n"
206*cdf0e10cSrcweir "   -doc        'html'|'nohtml'\n\n"
207*cdf0e10cSrcweir "               Overrides -docg for the current project, which is\n"
208*cdf0e10cSrcweir "               specified by the last previous '-p'.\n"
209*cdf0e10cSrcweir "               For details see at option '-docg'.\n"
210*cdf0e10cSrcweir "\n"
211*cdf0e10cSrcweir "   -d          <SourceDir_relative2ProjectRootDir_nosubdirs>+\n\n"
212*cdf0e10cSrcweir "               For the current project all files in the given\n"
213*cdf0e10cSrcweir "               directories are parsed, which have valid extensions.\n"
214*cdf0e10cSrcweir "               Subdirectories are NOT parsed.\n"
215*cdf0e10cSrcweir "\n"
216*cdf0e10cSrcweir "   -t          <SourceTree_relative2ProjectRootDir>+\n\n"
217*cdf0e10cSrcweir "               For the current project all files in the given\n"
218*cdf0e10cSrcweir "               directories AND its subdirectories are parsed, which\n"
219*cdf0e10cSrcweir "               have valid extensions.\n"
220*cdf0e10cSrcweir "\n"
221*cdf0e10cSrcweir "   -f          <SourceFile_relative2ProjectRootDir>+\n\n"
222*cdf0e10cSrcweir "               For the current project and language the given files\n"
223*cdf0e10cSrcweir "               are parsed. It doesn't matter, if their extensions match\n"
224*cdf0e10cSrcweir "               the valid extensions.\n"
225*cdf0e10cSrcweir "\n"
226*cdf0e10cSrcweir "   -html       <OutputRootDir>\n\n"
227*cdf0e10cSrcweir "               Starts the task \"Create HTML output\".\n"
228*cdf0e10cSrcweir "\n"
229*cdf0e10cSrcweir "   -xlinks     <Namespace> <ExternLinksRootDir>\n\n"
230*cdf0e10cSrcweir "               This option allows, to create links to external\n"
231*cdf0e10cSrcweir "               HTML-documents.\n"
232*cdf0e10cSrcweir "               For all source code objects (like classes or functions)\n"
233*cdf0e10cSrcweir "               which belong in the given namespace, the given root\n"
234*cdf0e10cSrcweir "               directory is used as a base for links to them.\n"
235*cdf0e10cSrcweir "               Presently, this works only for C++-mappings of IDL-items.\n"
236*cdf0e10cSrcweir "               The given namespace has to be absolute.\n"
237*cdf0e10cSrcweir "\n"
238*cdf0e10cSrcweir "   -i          <CommandFilePath>\n\n"
239*cdf0e10cSrcweir "               This option is replaced by the contents of the given\n"
240*cdf0e10cSrcweir "               file. The file has to be ASCII and each option\n"
241*cdf0e10cSrcweir "               has to start in the first column of a new line.\n"
242*cdf0e10cSrcweir "               So each valid line starts with a '-'.\n"
243*cdf0e10cSrcweir "               Empty lines are allowed.\n"
244*cdf0e10cSrcweir "               Comment lines have to start with '#'\n"
245*cdf0e10cSrcweir "\n"
246*cdf0e10cSrcweir "   -v          <VerboseNumber>\n\n"
247*cdf0e10cSrcweir "               Show details during parsing:\n"
248*cdf0e10cSrcweir "                   2    shows each parsed letter,\n"
249*cdf0e10cSrcweir "                   4    shows stored objects.\n"
250*cdf0e10cSrcweir "                   1    shows recognised tokens.\n"
251*cdf0e10cSrcweir "               These bit-values can be combined.\n"
252*cdf0e10cSrcweir "               This option suppresses errors, because of\n"
253*cdf0e10cSrcweir "               missing output options (no '-html').\n";
254*cdf0e10cSrcweir #endif // 0, FUTURE
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir 
257*cdf0e10cSrcweir CommandLine::CommandLine()
258*cdf0e10cSrcweir     :   nDebugStyle(0),
259*cdf0e10cSrcweir         pSinceTransformator(new command::SinceTagTransformationData),
260*cdf0e10cSrcweir         aCommands(),
261*cdf0e10cSrcweir         bInitOk(false),
262*cdf0e10cSrcweir         pCommand_CreateHtml(0),
263*cdf0e10cSrcweir         pReposy( & ary::Repository::Create_() ),
264*cdf0e10cSrcweir         bCpp(false),
265*cdf0e10cSrcweir         bIdl(false)
266*cdf0e10cSrcweir {
267*cdf0e10cSrcweir     csv_assert(pTheInstance_ == 0);
268*cdf0e10cSrcweir     pTheInstance_ = this;
269*cdf0e10cSrcweir }
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir CommandLine::~CommandLine()
272*cdf0e10cSrcweir {
273*cdf0e10cSrcweir     csv::erase_container_of_heap_ptrs(aCommands);
274*cdf0e10cSrcweir     pTheInstance_ = 0;
275*cdf0e10cSrcweir }
276*cdf0e10cSrcweir 
277*cdf0e10cSrcweir int
278*cdf0e10cSrcweir CommandLine::Run() const
279*cdf0e10cSrcweir {
280*cdf0e10cSrcweir     Cout() << "\nAutodoc version 2.2.5"
281*cdf0e10cSrcweir            << "\n---------------------"
282*cdf0e10cSrcweir            << "\n" << Endl();
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir     bool
285*cdf0e10cSrcweir         ok = true;
286*cdf0e10cSrcweir     for ( CommandList::const_iterator it = aCommands.begin();
287*cdf0e10cSrcweir           ok AND it != aCommands.end();
288*cdf0e10cSrcweir           ++it )
289*cdf0e10cSrcweir     {
290*cdf0e10cSrcweir         ok = (*it)->Run();
291*cdf0e10cSrcweir     }
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir     if (pCommand_CreateHtml != 0)
294*cdf0e10cSrcweir     {
295*cdf0e10cSrcweir         StreamStr aDiagnosticMessagesFile(700);
296*cdf0e10cSrcweir         aDiagnosticMessagesFile
297*cdf0e10cSrcweir             << pCommand_CreateHtml->OutputDir()
298*cdf0e10cSrcweir             << csv::ploc::Delimiter()
299*cdf0e10cSrcweir             << "Autodoc_DiagnosticMessages.txt";
300*cdf0e10cSrcweir         TheMessages().WriteFile(aDiagnosticMessagesFile.c_str());
301*cdf0e10cSrcweir     }
302*cdf0e10cSrcweir 
303*cdf0e10cSrcweir     return ok ? 0 : 1;
304*cdf0e10cSrcweir }
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir CommandLine &
307*cdf0e10cSrcweir CommandLine::Get_()
308*cdf0e10cSrcweir {
309*cdf0e10cSrcweir     csv_assert(pTheInstance_ != 0);
310*cdf0e10cSrcweir     return *pTheInstance_;
311*cdf0e10cSrcweir }
312*cdf0e10cSrcweir 
313*cdf0e10cSrcweir bool
314*cdf0e10cSrcweir CommandLine::DoesTransform_SinceTag() const
315*cdf0e10cSrcweir {
316*cdf0e10cSrcweir     return pSinceTransformator->DoesTransform();
317*cdf0e10cSrcweir }
318*cdf0e10cSrcweir 
319*cdf0e10cSrcweir //bool
320*cdf0e10cSrcweir //CommandLine::Strip_SinceTagText( String & io_sSinceTagValue ) const
321*cdf0e10cSrcweir //{
322*cdf0e10cSrcweir //    return pSinceTransformator->StripSinceTagText(io_sSinceTagValue);
323*cdf0e10cSrcweir //}
324*cdf0e10cSrcweir 
325*cdf0e10cSrcweir const String &
326*cdf0e10cSrcweir CommandLine::DisplayOf_SinceTagValue( const String & i_sVersionNumber ) const
327*cdf0e10cSrcweir {
328*cdf0e10cSrcweir     return pSinceTransformator->DisplayOf(i_sVersionNumber);
329*cdf0e10cSrcweir }
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir void
332*cdf0e10cSrcweir CommandLine::do_Init( int                 argc,
333*cdf0e10cSrcweir                       char *              argv[] )
334*cdf0e10cSrcweir {
335*cdf0e10cSrcweir   try
336*cdf0e10cSrcweir   {
337*cdf0e10cSrcweir     bInitOk = false;
338*cdf0e10cSrcweir     StringVector    aParameters;
339*cdf0e10cSrcweir 
340*cdf0e10cSrcweir     char * * itpEnd = &argv[0] + argc;
341*cdf0e10cSrcweir     for ( char * * itp = &argv[1]; itp != itpEnd; ++itp )
342*cdf0e10cSrcweir     {
343*cdf0e10cSrcweir      	if ( strncmp(*itp, "-I:", 3) != 0 )
344*cdf0e10cSrcweir             aParameters.push_back(String(*itp));
345*cdf0e10cSrcweir         else
346*cdf0e10cSrcweir             load_IncludedCommands(aParameters, (*itp)+3);
347*cdf0e10cSrcweir     }
348*cdf0e10cSrcweir 
349*cdf0e10cSrcweir     StringVector::const_iterator itEnd = aParameters.end();
350*cdf0e10cSrcweir     for ( StringVector::const_iterator it = aParameters.begin();
351*cdf0e10cSrcweir           it != itEnd;
352*cdf0e10cSrcweir         )
353*cdf0e10cSrcweir     {
354*cdf0e10cSrcweir         if ( *it == command::C_opt_Verbose )
355*cdf0e10cSrcweir             do_clVerbose(it,itEnd);
356*cdf0e10cSrcweir         else if ( *it == command::C_opt_LangAll
357*cdf0e10cSrcweir                   OR *it == command::C_opt_Name
358*cdf0e10cSrcweir                   OR *it == command::C_opt_DevmanFile )
359*cdf0e10cSrcweir             do_clParse(it,itEnd);
360*cdf0e10cSrcweir         else if (*it == command::C_opt_CreateHtml)
361*cdf0e10cSrcweir             do_clCreateHtml(it,itEnd);
362*cdf0e10cSrcweir         else if (*it == command::C_opt_SinceFile)
363*cdf0e10cSrcweir             do_clSinceFile(it,itEnd);
364*cdf0e10cSrcweir         else if (*it == command::C_opt_ExternNamespace)
365*cdf0e10cSrcweir         {
366*cdf0e10cSrcweir             sExternNamespace = *(++it);
367*cdf0e10cSrcweir             ++it;
368*cdf0e10cSrcweir             if ( strncmp(sExternNamespace.c_str(), "::", 2) != 0)
369*cdf0e10cSrcweir             {
370*cdf0e10cSrcweir              	throw command::X_CommandLine(
371*cdf0e10cSrcweir                         "-extnsp needs an absolute qualified namespace, starting with \"::\"."
372*cdf0e10cSrcweir                         );
373*cdf0e10cSrcweir             }
374*cdf0e10cSrcweir         }
375*cdf0e10cSrcweir         else if (*it == command::C_opt_ExternRoot)
376*cdf0e10cSrcweir         {
377*cdf0e10cSrcweir             ++it;
378*cdf0e10cSrcweir             StreamLock sl(1000);
379*cdf0e10cSrcweir             if ( csv::compare(*it, 0, "http://", 7) != 0 )
380*cdf0e10cSrcweir             {
381*cdf0e10cSrcweir                 sl() << "http://" << *it;
382*cdf0e10cSrcweir             }
383*cdf0e10cSrcweir             if ( *(sl().end()-1) != '/')
384*cdf0e10cSrcweir                 sl() << '/';
385*cdf0e10cSrcweir             sExternRoot = sl().c_str();
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir             ++it;
388*cdf0e10cSrcweir         }
389*cdf0e10cSrcweir //        else if (*it == command::C_opt_CreateXml)
390*cdf0e10cSrcweir //            do_clCreateXml(it,itEnd);
391*cdf0e10cSrcweir //        else if (command::C_opt_Load)
392*cdf0e10cSrcweir //            do_clLoad(it,itEnd);
393*cdf0e10cSrcweir //        else if (*it == command::C_opt_Save)
394*cdf0e10cSrcweir //            do_clSave(it,itEnd);
395*cdf0e10cSrcweir         else if (*it == "-h" OR *it == "-?" OR *it == "?")
396*cdf0e10cSrcweir             // Leads to displaying help, because bInitOk stays on false.
397*cdf0e10cSrcweir          	return;
398*cdf0e10cSrcweir         else if ( *it == command::C_opt_Parse )
399*cdf0e10cSrcweir             // Only for backwards compatibility.
400*cdf0e10cSrcweir             //   Just ignore "-parse".
401*cdf0e10cSrcweir             ++it;
402*cdf0e10cSrcweir         else
403*cdf0e10cSrcweir         {
404*cdf0e10cSrcweir             StreamLock sl(200);
405*cdf0e10cSrcweir          	throw command::X_CommandLine(
406*cdf0e10cSrcweir                             sl() << "Unknown commandline option \""
407*cdf0e10cSrcweir                                  << *it
408*cdf0e10cSrcweir                                  << "\"."
409*cdf0e10cSrcweir                                  << c_str );
410*cdf0e10cSrcweir         }
411*cdf0e10cSrcweir     }   // end for
412*cdf0e10cSrcweir     sort_Commands();
413*cdf0e10cSrcweir 
414*cdf0e10cSrcweir     bInitOk = true;
415*cdf0e10cSrcweir 
416*cdf0e10cSrcweir   }   // end try
417*cdf0e10cSrcweir   catch ( command::X_CommandLine & xxx )
418*cdf0e10cSrcweir   {
419*cdf0e10cSrcweir     xxx.Report( Cerr() );
420*cdf0e10cSrcweir   }
421*cdf0e10cSrcweir   catch ( csv::Exception & xxx )
422*cdf0e10cSrcweir   {
423*cdf0e10cSrcweir     xxx.GetInfo( Cerr() );
424*cdf0e10cSrcweir   }
425*cdf0e10cSrcweir }
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir void
428*cdf0e10cSrcweir CommandLine::do_PrintUse() const
429*cdf0e10cSrcweir {
430*cdf0e10cSrcweir     Cout() << C_sUserGuide << Endl();
431*cdf0e10cSrcweir }
432*cdf0e10cSrcweir 
433*cdf0e10cSrcweir bool
434*cdf0e10cSrcweir CommandLine::inq_CheckParameters() const
435*cdf0e10cSrcweir {
436*cdf0e10cSrcweir     if (NOT bInitOk OR aCommands.size() == 0)
437*cdf0e10cSrcweir         return false;
438*cdf0e10cSrcweir     return true;
439*cdf0e10cSrcweir }
440*cdf0e10cSrcweir 
441*cdf0e10cSrcweir void
442*cdf0e10cSrcweir CommandLine::load_IncludedCommands( StringVector &      out,
443*cdf0e10cSrcweir                                     const char *        i_filePath )
444*cdf0e10cSrcweir {
445*cdf0e10cSrcweir     CharacterSource
446*cdf0e10cSrcweir         aIncludedCommands;
447*cdf0e10cSrcweir     csv::File
448*cdf0e10cSrcweir         aFile(i_filePath, csv::CFM_READ);
449*cdf0e10cSrcweir     if (NOT aFile.open())
450*cdf0e10cSrcweir     {
451*cdf0e10cSrcweir      	Cerr() << "Command include file \""
452*cdf0e10cSrcweir                << i_filePath
453*cdf0e10cSrcweir                << "\" not found."
454*cdf0e10cSrcweir                << Endl();
455*cdf0e10cSrcweir         throw command::X_CommandLine("Invalid file in option -I:<command-file>.");
456*cdf0e10cSrcweir     }
457*cdf0e10cSrcweir     aIncludedCommands.LoadText(aFile);
458*cdf0e10cSrcweir     aFile.close();
459*cdf0e10cSrcweir 
460*cdf0e10cSrcweir     bool bInToken = false;
461*cdf0e10cSrcweir     StreamLock aTransmit(200);
462*cdf0e10cSrcweir     for ( ; NOT aIncludedCommands.IsFinished(); aIncludedCommands.MoveOn() )
463*cdf0e10cSrcweir     {
464*cdf0e10cSrcweir         if (bInToken)
465*cdf0e10cSrcweir         {
466*cdf0e10cSrcweir             if (aIncludedCommands.CurChar() <= 32)
467*cdf0e10cSrcweir             {
468*cdf0e10cSrcweir                 const char *
469*cdf0e10cSrcweir                     pToken = aIncludedCommands.CutToken();
470*cdf0e10cSrcweir                 bInToken = false;
471*cdf0e10cSrcweir 
472*cdf0e10cSrcweir              	if ( strncmp(pToken, "-I:", 3) != 0 )
473*cdf0e10cSrcweir              	{
474*cdf0e10cSrcweir              	    aTransmit().seekp(0);
475*cdf0e10cSrcweir              	    aTransmit() << pToken;
476*cdf0e10cSrcweir              	    aTransmit().replace_all('\\', *csv::ploc::Delimiter());
477*cdf0e10cSrcweir              	    aTransmit().replace_all('/', *csv::ploc::Delimiter());
478*cdf0e10cSrcweir                     out.push_back(String(aTransmit().c_str()));
479*cdf0e10cSrcweir              	}
480*cdf0e10cSrcweir                 else
481*cdf0e10cSrcweir                     load_IncludedCommands(out, pToken+3);
482*cdf0e10cSrcweir             }
483*cdf0e10cSrcweir         }
484*cdf0e10cSrcweir         else
485*cdf0e10cSrcweir         {
486*cdf0e10cSrcweir             if (aIncludedCommands.CurChar() > 32)
487*cdf0e10cSrcweir             {
488*cdf0e10cSrcweir                 aIncludedCommands.CutToken();
489*cdf0e10cSrcweir                 bInToken = true;
490*cdf0e10cSrcweir             }
491*cdf0e10cSrcweir         }   // endif (bInToken) else
492*cdf0e10cSrcweir 
493*cdf0e10cSrcweir     }   // end while()
494*cdf0e10cSrcweir }
495*cdf0e10cSrcweir 
496*cdf0e10cSrcweir namespace
497*cdf0e10cSrcweir {
498*cdf0e10cSrcweir inline int
499*cdf0e10cSrcweir v_nr(StringVector::const_iterator it)
500*cdf0e10cSrcweir {
501*cdf0e10cSrcweir  	return int( *(*it).c_str() ) - int('0');
502*cdf0e10cSrcweir }
503*cdf0e10cSrcweir }   // anonymous namespace
504*cdf0e10cSrcweir 
505*cdf0e10cSrcweir void
506*cdf0e10cSrcweir CommandLine::do_clVerbose(  opt_iter &          it,
507*cdf0e10cSrcweir                             opt_iter            itEnd )
508*cdf0e10cSrcweir {
509*cdf0e10cSrcweir     ++it;
510*cdf0e10cSrcweir     if ( it == itEnd ? true : v_nr(it) < 0 OR v_nr(it) > 7 )
511*cdf0e10cSrcweir         throw command::X_CommandLine( "Missing or invalid number in -v option." );
512*cdf0e10cSrcweir     nDebugStyle = v_nr(it);
513*cdf0e10cSrcweir     ++it;
514*cdf0e10cSrcweir }
515*cdf0e10cSrcweir 
516*cdf0e10cSrcweir void
517*cdf0e10cSrcweir CommandLine::do_clParse( opt_iter &          it,
518*cdf0e10cSrcweir                          opt_iter            itEnd )
519*cdf0e10cSrcweir {
520*cdf0e10cSrcweir     command::Command *
521*cdf0e10cSrcweir         pCmd_Parse = new command::Parse;
522*cdf0e10cSrcweir     pCmd_Parse->Init(it, itEnd);
523*cdf0e10cSrcweir     aCommands.push_back(pCmd_Parse);
524*cdf0e10cSrcweir }
525*cdf0e10cSrcweir 
526*cdf0e10cSrcweir void
527*cdf0e10cSrcweir CommandLine::do_clCreateHtml( opt_iter &          it,
528*cdf0e10cSrcweir                               opt_iter            itEnd )
529*cdf0e10cSrcweir {
530*cdf0e10cSrcweir     pCommand_CreateHtml = new command::CreateHtml;
531*cdf0e10cSrcweir     pCommand_CreateHtml->Init(it, itEnd);
532*cdf0e10cSrcweir     aCommands.push_back(pCommand_CreateHtml);
533*cdf0e10cSrcweir }
534*cdf0e10cSrcweir 
535*cdf0e10cSrcweir void
536*cdf0e10cSrcweir CommandLine::do_clSinceFile( opt_iter &          it,
537*cdf0e10cSrcweir                              opt_iter            itEnd )
538*cdf0e10cSrcweir {
539*cdf0e10cSrcweir     pSinceTransformator->Init(it, itEnd);
540*cdf0e10cSrcweir }
541*cdf0e10cSrcweir 
542*cdf0e10cSrcweir 
543*cdf0e10cSrcweir namespace
544*cdf0e10cSrcweir {
545*cdf0e10cSrcweir 
546*cdf0e10cSrcweir struct Less_RunningRank
547*cdf0e10cSrcweir {
548*cdf0e10cSrcweir     bool                operator()(
549*cdf0e10cSrcweir                             const command::Command * const &
550*cdf0e10cSrcweir                                                 i1,
551*cdf0e10cSrcweir                             const command::Command * const &
552*cdf0e10cSrcweir                                                 i2 ) const
553*cdf0e10cSrcweir                         { return i1->RunningRank() < i2->RunningRank(); }
554*cdf0e10cSrcweir };
555*cdf0e10cSrcweir 
556*cdf0e10cSrcweir }   // anonymous namespace
557*cdf0e10cSrcweir 
558*cdf0e10cSrcweir 
559*cdf0e10cSrcweir 
560*cdf0e10cSrcweir void
561*cdf0e10cSrcweir CommandLine::sort_Commands()
562*cdf0e10cSrcweir {
563*cdf0e10cSrcweir     std::sort( aCommands.begin(),
564*cdf0e10cSrcweir                aCommands.end(),
565*cdf0e10cSrcweir                Less_RunningRank() );
566*cdf0e10cSrcweir }
567*cdf0e10cSrcweir 
568*cdf0e10cSrcweir }   // namespace autodoc
569