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