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_cmd_parse.hxx"
24cdf0e10cSrcweir
25cdf0e10cSrcweir
26cdf0e10cSrcweir // NOT FULLY DEFINED SERVICES
27cdf0e10cSrcweir #include <cosv/tpl/tpltools.hxx>
28cdf0e10cSrcweir #include <adc_cl.hxx>
29cdf0e10cSrcweir #include "adc_cmds.hxx"
30cdf0e10cSrcweir #include "cmd_run.hxx"
31cdf0e10cSrcweir
32cdf0e10cSrcweir
33cdf0e10cSrcweir
34cdf0e10cSrcweir namespace autodoc
35cdf0e10cSrcweir {
36cdf0e10cSrcweir namespace command
37cdf0e10cSrcweir {
38cdf0e10cSrcweir
39cdf0e10cSrcweir namespace
40cdf0e10cSrcweir {
41cdf0e10cSrcweir
42cdf0e10cSrcweir const String C_FileEnding_hxx("*.hxx");
43cdf0e10cSrcweir const String C_FileEnding_h("*.h");
44cdf0e10cSrcweir const String C_FileEnding_idl("*.idl");
45cdf0e10cSrcweir const String C_FileEnding_java("*.java");
46cdf0e10cSrcweir
47cdf0e10cSrcweir inline void
CHECK(bool b,const String & text)48cdf0e10cSrcweir CHECK( bool b, const String & text )
49cdf0e10cSrcweir {
50cdf0e10cSrcweir if (NOT b)
51cdf0e10cSrcweir throw X_CommandLine( text );
52cdf0e10cSrcweir }
53cdf0e10cSrcweir
54cdf0e10cSrcweir } // anonymous namespace
55cdf0e10cSrcweir
56cdf0e10cSrcweir
57cdf0e10cSrcweir
58cdf0e10cSrcweir //************************** S_LanguageInfo ***********************//
59cdf0e10cSrcweir
~S_LanguageInfo()60cdf0e10cSrcweir S_LanguageInfo::~S_LanguageInfo()
61cdf0e10cSrcweir {
62cdf0e10cSrcweir }
63cdf0e10cSrcweir
64cdf0e10cSrcweir void
do_Init(opt_iter & it,opt_iter itEnd)65cdf0e10cSrcweir S_LanguageInfo::do_Init( opt_iter & it,
66cdf0e10cSrcweir opt_iter itEnd )
67cdf0e10cSrcweir {
68cdf0e10cSrcweir ++it; // Cur is language.
69cdf0e10cSrcweir CHECKOPT( it != itEnd AND
70cdf0e10cSrcweir ( *it == C_arg_Cplusplus OR
71cdf0e10cSrcweir *it == C_arg_Idl OR
72cdf0e10cSrcweir *it == C_arg_Java ),
73cdf0e10cSrcweir "language",
74cdf0e10cSrcweir C_opt_LangAll );
75cdf0e10cSrcweir
76cdf0e10cSrcweir if ( *it == C_arg_Cplusplus ) {
77cdf0e10cSrcweir eLanguage = cpp;
78cdf0e10cSrcweir }
79cdf0e10cSrcweir else if ( *it == C_arg_Idl ) {
80cdf0e10cSrcweir eLanguage = idl;
81cdf0e10cSrcweir }
82cdf0e10cSrcweir else if ( *it == C_arg_Java ) {
83cdf0e10cSrcweir eLanguage = java;
84cdf0e10cSrcweir }
85cdf0e10cSrcweir else {
86cdf0e10cSrcweir csv_assert(false);
87cdf0e10cSrcweir }
88cdf0e10cSrcweir
89cdf0e10cSrcweir switch (eLanguage)
90cdf0e10cSrcweir {
91cdf0e10cSrcweir case cpp: aExtensions.push_back( C_FileEnding_hxx );
92cdf0e10cSrcweir aExtensions.push_back( C_FileEnding_h );
93cdf0e10cSrcweir CommandLine::Get_().Set_CppUsed();
94cdf0e10cSrcweir break;
95cdf0e10cSrcweir case idl: aExtensions.push_back( C_FileEnding_idl );
96cdf0e10cSrcweir CommandLine::Get_().Set_IdlUsed();
97cdf0e10cSrcweir break;
98cdf0e10cSrcweir case java: aExtensions.push_back( C_FileEnding_java );
99cdf0e10cSrcweir break;
100cdf0e10cSrcweir default: // do nothing.
101cdf0e10cSrcweir ;
102cdf0e10cSrcweir }
103cdf0e10cSrcweir
104cdf0e10cSrcweir ++it; // Cur is next option.
105cdf0e10cSrcweir }
106cdf0e10cSrcweir
107cdf0e10cSrcweir void
InitExtensions(opt_iter & it,opt_iter itEnd)108cdf0e10cSrcweir S_LanguageInfo::InitExtensions( opt_iter & it,
109cdf0e10cSrcweir opt_iter itEnd )
110cdf0e10cSrcweir {
111cdf0e10cSrcweir ++it;
112cdf0e10cSrcweir CHECKOPT( it != itEnd AND (*it).char_at(0) == '.',
113cdf0e10cSrcweir "extensions",
114cdf0e10cSrcweir C_opt_ExtensionsAll );
115cdf0e10cSrcweir
116cdf0e10cSrcweir StreamLock slCheck(150);
117cdf0e10cSrcweir slCheck() << C_opt_ExtensionsAll
118cdf0e10cSrcweir << " used without previous "
119cdf0e10cSrcweir << C_opt_LangAll;
120cdf0e10cSrcweir
121cdf0e10cSrcweir CHECK( eLanguage != none,
122cdf0e10cSrcweir slCheck().c_str() );
123cdf0e10cSrcweir
124cdf0e10cSrcweir do {
125cdf0e10cSrcweir aExtensions.push_back(*it);
126cdf0e10cSrcweir ++it;
127cdf0e10cSrcweir } while (it != itEnd AND (*it).char_at(0) == '.');
128cdf0e10cSrcweir }
129cdf0e10cSrcweir
130cdf0e10cSrcweir
131cdf0e10cSrcweir
132cdf0e10cSrcweir //************************** Parse ***********************//
133cdf0e10cSrcweir
Parse()134cdf0e10cSrcweir Parse::Parse()
135cdf0e10cSrcweir : sRepositoryName(),
136cdf0e10cSrcweir aGlobalLanguage(),
137cdf0e10cSrcweir aProjects(),
138cdf0e10cSrcweir sDevelopersManual_RefFilePath()
139cdf0e10cSrcweir {
140cdf0e10cSrcweir }
141cdf0e10cSrcweir
~Parse()142cdf0e10cSrcweir Parse::~Parse()
143cdf0e10cSrcweir {
144cdf0e10cSrcweir csv::erase_container_of_heap_ptrs(aProjects);
145cdf0e10cSrcweir }
146cdf0e10cSrcweir
147cdf0e10cSrcweir void
do_Init(opt_iter & it,opt_iter itEnd)148cdf0e10cSrcweir Parse::do_Init( opt_iter & it,
149cdf0e10cSrcweir opt_iter itEnd )
150cdf0e10cSrcweir {
151cdf0e10cSrcweir for ( ; it != itEnd; )
152cdf0e10cSrcweir {
153cdf0e10cSrcweir if (*it == C_opt_Name)
154cdf0e10cSrcweir do_clName(it, itEnd);
155cdf0e10cSrcweir else if (*it == C_opt_LangAll)
156cdf0e10cSrcweir aGlobalLanguage.Init(it, itEnd);
157cdf0e10cSrcweir else if (*it == C_opt_ExtensionsAll)
158cdf0e10cSrcweir aGlobalLanguage.InitExtensions(it, itEnd);
159cdf0e10cSrcweir else if (*it == C_opt_DevmanFile)
160cdf0e10cSrcweir do_clDevManual(it, itEnd);
161cdf0e10cSrcweir else if (*it == C_opt_Project)
162cdf0e10cSrcweir do_clProject(it, itEnd);
163cdf0e10cSrcweir else if ( *it == C_opt_SourceTree
164cdf0e10cSrcweir OR *it == C_opt_SourceDir
165cdf0e10cSrcweir OR *it == C_opt_SourceFile )
166cdf0e10cSrcweir do_clDefaultProject(it, itEnd);
167cdf0e10cSrcweir else
168cdf0e10cSrcweir break;
169cdf0e10cSrcweir } // for
170cdf0e10cSrcweir }
171cdf0e10cSrcweir
172cdf0e10cSrcweir void
do_clName(opt_iter & it,opt_iter itEnd)173cdf0e10cSrcweir Parse::do_clName( opt_iter & it,
174cdf0e10cSrcweir opt_iter itEnd )
175cdf0e10cSrcweir {
176cdf0e10cSrcweir ++it;
177cdf0e10cSrcweir CHECKOPT( it != itEnd AND (*it).char_at(0) != '-',
178cdf0e10cSrcweir "name",
179cdf0e10cSrcweir C_opt_Name );
180cdf0e10cSrcweir sRepositoryName = *it;
181cdf0e10cSrcweir ++it;
182cdf0e10cSrcweir }
183cdf0e10cSrcweir
184cdf0e10cSrcweir void
do_clDevManual(opt_iter & it,opt_iter itEnd)185cdf0e10cSrcweir Parse::do_clDevManual( opt_iter & it,
186cdf0e10cSrcweir opt_iter itEnd )
187cdf0e10cSrcweir {
188cdf0e10cSrcweir ++it;
189cdf0e10cSrcweir CHECKOPT( it != itEnd AND (*it).char_at(0) != '-',
190cdf0e10cSrcweir "link file path",
191cdf0e10cSrcweir C_opt_DevmanFile );
192cdf0e10cSrcweir sDevelopersManual_RefFilePath = *it;
193cdf0e10cSrcweir ++it;
194cdf0e10cSrcweir }
195cdf0e10cSrcweir
196cdf0e10cSrcweir void
do_clProject(opt_iter & it,opt_iter itEnd)197cdf0e10cSrcweir Parse::do_clProject( opt_iter & it,
198cdf0e10cSrcweir opt_iter itEnd )
199cdf0e10cSrcweir {
200cdf0e10cSrcweir if ( aProjects.size() == 1 )
201cdf0e10cSrcweir {
202cdf0e10cSrcweir if ( aProjects.front()->IsDefault() )
203cdf0e10cSrcweir throw X_CommandLine( "Both, named projects and a default project, cannot be used together." );
204cdf0e10cSrcweir }
205cdf0e10cSrcweir
206cdf0e10cSrcweir S_ProjectData * dpProject = new S_ProjectData(aGlobalLanguage);
207cdf0e10cSrcweir ++it;
208cdf0e10cSrcweir dpProject->Init(it, itEnd);
209cdf0e10cSrcweir aProjects.push_back(dpProject);
210cdf0e10cSrcweir }
211cdf0e10cSrcweir
212cdf0e10cSrcweir void
do_clDefaultProject(opt_iter & it,opt_iter itEnd)213cdf0e10cSrcweir Parse::do_clDefaultProject( opt_iter & it,
214cdf0e10cSrcweir opt_iter itEnd )
215cdf0e10cSrcweir {
216cdf0e10cSrcweir if ( aProjects.size() > 0 )
217cdf0e10cSrcweir {
218cdf0e10cSrcweir throw X_CommandLine( "Both, named projects and a default project, cannot be used together." );
219cdf0e10cSrcweir }
220cdf0e10cSrcweir
221cdf0e10cSrcweir S_ProjectData * dpProject = new S_ProjectData( aGlobalLanguage,
222cdf0e10cSrcweir S_ProjectData::default_prj );
223cdf0e10cSrcweir dpProject->Init(it, itEnd);
224cdf0e10cSrcweir aProjects.push_back(dpProject);
225cdf0e10cSrcweir }
226cdf0e10cSrcweir
227cdf0e10cSrcweir bool
do_Run() const228cdf0e10cSrcweir Parse::do_Run() const
229cdf0e10cSrcweir {
230cdf0e10cSrcweir run::Parser
231cdf0e10cSrcweir aParser(*this);
232cdf0e10cSrcweir return aParser.Perform();
233cdf0e10cSrcweir }
234cdf0e10cSrcweir
235cdf0e10cSrcweir int
inq_RunningRank() const236cdf0e10cSrcweir Parse::inq_RunningRank() const
237cdf0e10cSrcweir {
238cdf0e10cSrcweir return static_cast<int>(rank_Parse);
239cdf0e10cSrcweir }
240cdf0e10cSrcweir
241cdf0e10cSrcweir
242cdf0e10cSrcweir
243cdf0e10cSrcweir //************************** S_Sources ***********************//
244cdf0e10cSrcweir
245cdf0e10cSrcweir void
do_Init(opt_iter & it,opt_iter itEnd)246cdf0e10cSrcweir S_Sources::do_Init( opt_iter & it,
247cdf0e10cSrcweir opt_iter itEnd )
248cdf0e10cSrcweir {
249cdf0e10cSrcweir StringVector *
250cdf0e10cSrcweir pList = 0;
251cdf0e10cSrcweir csv_assert((*it)[0] == '-');
252cdf0e10cSrcweir
253cdf0e10cSrcweir for ( ; it != itEnd; ++it)
254cdf0e10cSrcweir {
255cdf0e10cSrcweir if ((*it)[0] == '-')
256cdf0e10cSrcweir {
257cdf0e10cSrcweir if (*it == C_opt_SourceTree)
258cdf0e10cSrcweir pList = &aTrees;
259cdf0e10cSrcweir else if (*it == C_opt_SourceDir)
260cdf0e10cSrcweir pList = &aDirectories;
261cdf0e10cSrcweir else if (*it == C_opt_SourceFile)
262cdf0e10cSrcweir pList = &aFiles;
263cdf0e10cSrcweir else
264cdf0e10cSrcweir return;
265cdf0e10cSrcweir }
266cdf0e10cSrcweir else
267cdf0e10cSrcweir pList->push_back(*it);
268cdf0e10cSrcweir } // end for
269cdf0e10cSrcweir }
270cdf0e10cSrcweir
271cdf0e10cSrcweir
272cdf0e10cSrcweir
273cdf0e10cSrcweir //************************** S_ProjectData ***********************//
274cdf0e10cSrcweir
275cdf0e10cSrcweir
S_ProjectData(const S_LanguageInfo & i_globalLanguage)276cdf0e10cSrcweir S_ProjectData::S_ProjectData( const S_LanguageInfo & i_globalLanguage )
277cdf0e10cSrcweir : sName(),
278cdf0e10cSrcweir aRootDirectory(),
279cdf0e10cSrcweir aLanguage(i_globalLanguage),
280cdf0e10cSrcweir aFiles(),
281cdf0e10cSrcweir bIsDefault(false)
282cdf0e10cSrcweir {
283cdf0e10cSrcweir }
284cdf0e10cSrcweir
S_ProjectData(const S_LanguageInfo & i_globalLanguage,E_Default)285cdf0e10cSrcweir S_ProjectData::S_ProjectData( const S_LanguageInfo & i_globalLanguage,
286cdf0e10cSrcweir E_Default )
287cdf0e10cSrcweir : sName(),
288cdf0e10cSrcweir aRootDirectory("."),
289cdf0e10cSrcweir aLanguage(i_globalLanguage),
290cdf0e10cSrcweir aFiles(),
291cdf0e10cSrcweir bIsDefault(true)
292cdf0e10cSrcweir {
293cdf0e10cSrcweir }
294cdf0e10cSrcweir
~S_ProjectData()295cdf0e10cSrcweir S_ProjectData::~S_ProjectData()
296cdf0e10cSrcweir {
297cdf0e10cSrcweir }
298cdf0e10cSrcweir
299cdf0e10cSrcweir void
do_Init(opt_iter & it,opt_iter itEnd)300cdf0e10cSrcweir S_ProjectData::do_Init( opt_iter & it,
301cdf0e10cSrcweir opt_iter itEnd )
302cdf0e10cSrcweir {
303cdf0e10cSrcweir if (NOT IsDefault())
304cdf0e10cSrcweir {
305cdf0e10cSrcweir CHECKOPT( it != itEnd AND (*it).char_at(0) != '-',
306cdf0e10cSrcweir "name",
307cdf0e10cSrcweir C_opt_Project );
308cdf0e10cSrcweir sName = *it;
309cdf0e10cSrcweir ++it;
310cdf0e10cSrcweir
311cdf0e10cSrcweir CHECKOPT( it != itEnd AND (*it).char_at(0) != '-',
312cdf0e10cSrcweir "root directory",
313cdf0e10cSrcweir C_opt_Project );
314cdf0e10cSrcweir aRootDirectory.Set((*it).c_str(), true);
315cdf0e10cSrcweir ++it;
316cdf0e10cSrcweir }
317cdf0e10cSrcweir
318cdf0e10cSrcweir for ( ; it != itEnd; )
319cdf0e10cSrcweir {
320cdf0e10cSrcweir if ( *it == C_opt_SourceTree
321cdf0e10cSrcweir OR *it == C_opt_SourceDir
322cdf0e10cSrcweir OR *it == C_opt_SourceFile )
323cdf0e10cSrcweir aFiles.Init(it, itEnd);
324cdf0e10cSrcweir // else if (*it == C_opt_Lang)
325cdf0e10cSrcweir // aLanguage.Init(it, itEnd);
326cdf0e10cSrcweir // else if (*it == C_opt_Extensions)
327cdf0e10cSrcweir // aLanguage.InitExtensions(it, itEnd);
328cdf0e10cSrcweir else
329cdf0e10cSrcweir break;
330cdf0e10cSrcweir } // for
331cdf0e10cSrcweir }
332cdf0e10cSrcweir
333cdf0e10cSrcweir } // namespace command
334cdf0e10cSrcweir } // namespace autodoc
335cdf0e10cSrcweir
336cdf0e10cSrcweir
337cdf0e10cSrcweir
338