1d291ea28SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3d291ea28SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4d291ea28SAndrew Rist * or more contributor license agreements. See the NOTICE file
5d291ea28SAndrew Rist * distributed with this work for additional information
6d291ea28SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7d291ea28SAndrew Rist * to you under the Apache License, Version 2.0 (the
8d291ea28SAndrew Rist * "License"); you may not use this file except in compliance
9d291ea28SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11d291ea28SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13d291ea28SAndrew Rist * Unless required by applicable law or agreed to in writing,
14d291ea28SAndrew Rist * software distributed under the License is distributed on an
15d291ea28SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16d291ea28SAndrew Rist * KIND, either express or implied. See the License for the
17d291ea28SAndrew Rist * specific language governing permissions and limitations
18d291ea28SAndrew Rist * under the License.
19cdf0e10cSrcweir *
20d291ea28SAndrew Rist *************************************************************/
21cdf0e10cSrcweir
22cdf0e10cSrcweir #include <precomp.h>
23cdf0e10cSrcweir #include "cmd_run.hxx"
24cdf0e10cSrcweir
25cdf0e10cSrcweir
26cdf0e10cSrcweir // NOT FULLY DEFINED SERVICES
27cdf0e10cSrcweir #include <cosv/file.hxx>
28cdf0e10cSrcweir #include <cosv/x.hxx>
29cdf0e10cSrcweir #include <ary/ary.hxx>
30cdf0e10cSrcweir #include <ary/cpp/c_gate.hxx>
31cdf0e10cSrcweir #include <ary/idl/i_ce.hxx>
32cdf0e10cSrcweir #include <ary/idl/i_gate.hxx>
33cdf0e10cSrcweir #include <ary/idl/i_module.hxx>
34cdf0e10cSrcweir #include <ary/idl/ip_ce.hxx>
35cdf0e10cSrcweir #include <autodoc/filecoli.hxx>
36cdf0e10cSrcweir #include <autodoc/parsing.hxx>
37cdf0e10cSrcweir #include <autodoc/prs_code.hxx>
38cdf0e10cSrcweir #include <autodoc/prs_docu.hxx>
39cdf0e10cSrcweir #include <parser/unoidl.hxx>
40cdf0e10cSrcweir #include <adc_cl.hxx>
41cdf0e10cSrcweir #include "adc_cmd_parse.hxx"
42cdf0e10cSrcweir #include "adc_cmds.hxx"
43cdf0e10cSrcweir
44cdf0e10cSrcweir namespace autodoc
45cdf0e10cSrcweir {
46cdf0e10cSrcweir namespace command
47cdf0e10cSrcweir {
48cdf0e10cSrcweir namespace run
49cdf0e10cSrcweir {
50cdf0e10cSrcweir
Parser(const Parse & i_command)51cdf0e10cSrcweir Parser::Parser( const Parse & i_command )
52cdf0e10cSrcweir : rCommand(i_command),
53cdf0e10cSrcweir pCppParser(),
54cdf0e10cSrcweir pCppDocuInterpreter(),
55cdf0e10cSrcweir pIdlParser()
56cdf0e10cSrcweir {
57cdf0e10cSrcweir }
58cdf0e10cSrcweir
~Parser()59cdf0e10cSrcweir Parser::~Parser()
60cdf0e10cSrcweir {
61cdf0e10cSrcweir }
62cdf0e10cSrcweir
63cdf0e10cSrcweir bool
Perform()64cdf0e10cSrcweir Parser::Perform()
65cdf0e10cSrcweir {
66cdf0e10cSrcweir Cout() << "Parsing the repository "
67cdf0e10cSrcweir << rCommand.ReposyName()
68cdf0e10cSrcweir << " ..."
69cdf0e10cSrcweir << Endl();
70cdf0e10cSrcweir try
71cdf0e10cSrcweir {
72cdf0e10cSrcweir ::ary::Repository &
73cdf0e10cSrcweir rAry = CommandLine::Get_().TheRepository();
74cdf0e10cSrcweir rAry.Set_Title(rCommand.ReposyName());
75cdf0e10cSrcweir
76cdf0e10cSrcweir Dyn< FileCollector_Ifc >
77cdf0e10cSrcweir pFiles( ParseToolsFactory().Create_FileCollector(6000) );
78cdf0e10cSrcweir
79cdf0e10cSrcweir bool bIDL = false;
80cdf0e10cSrcweir bool bCpp = false;
81cdf0e10cSrcweir
82cdf0e10cSrcweir command::Parse::ProjectIterator
83cdf0e10cSrcweir itEnd = rCommand.ProjectsEnd();
84cdf0e10cSrcweir for ( command::Parse::ProjectIterator it = rCommand.ProjectsBegin();
85cdf0e10cSrcweir it != itEnd;
86cdf0e10cSrcweir ++it )
87cdf0e10cSrcweir {
88cdf0e10cSrcweir uintt nCount = GatherFiles( *pFiles, *(*it) );
89cdf0e10cSrcweir Cout() << nCount
90cdf0e10cSrcweir << " files found to parse in project "
91cdf0e10cSrcweir << (*it)->Name()
92cdf0e10cSrcweir << "."
93cdf0e10cSrcweir << Endl();
94cdf0e10cSrcweir
95cdf0e10cSrcweir switch ( (*it)->Language().eLanguage )
96cdf0e10cSrcweir {
97cdf0e10cSrcweir case command::S_LanguageInfo::idl:
98cdf0e10cSrcweir {
99cdf0e10cSrcweir Get_IdlParser().Run(*pFiles);
100cdf0e10cSrcweir bIDL = true;
101cdf0e10cSrcweir } break;
102cdf0e10cSrcweir case command::S_LanguageInfo::cpp:
103cdf0e10cSrcweir {
104cdf0e10cSrcweir Get_CppParser().Run( *pFiles );
105cdf0e10cSrcweir bCpp = true;
106cdf0e10cSrcweir } break;
107cdf0e10cSrcweir default:
108cdf0e10cSrcweir Cerr() << "Project in yet unimplemented language skipped."
109cdf0e10cSrcweir << Endl();
110cdf0e10cSrcweir }
111cdf0e10cSrcweir } // end for
112cdf0e10cSrcweir
113cdf0e10cSrcweir if (bCpp)
114cdf0e10cSrcweir {
115cdf0e10cSrcweir rAry.Gate_Cpp().Calculate_AllSecondaryInformation();
116cdf0e10cSrcweir }
117cdf0e10cSrcweir if (bIDL)
118cdf0e10cSrcweir {
119cdf0e10cSrcweir rAry.Gate_Idl().Calculate_AllSecondaryInformation(
120cdf0e10cSrcweir rCommand.DevelopersManual_RefFilePath() );
121cdf0e10cSrcweir
122cdf0e10cSrcweir // ::ary::idl::SecondariesPilot &
123cdf0e10cSrcweir // rIdl2sPilot = rAry.Gate_Idl().Secondaries();
124cdf0e10cSrcweir //
125cdf0e10cSrcweir // rIdl2sPilot.CheckAllInterfaceBases( rAry.Gate_Idl() );
126cdf0e10cSrcweir // rIdl2sPilot.Connect_Types2Ces();
127cdf0e10cSrcweir // rIdl2sPilot.Gather_CrossReferences();
128cdf0e10cSrcweir //
129cdf0e10cSrcweir // if (NOT rCommand.DevelopersManual_RefFilePath().empty())
130cdf0e10cSrcweir // {
131cdf0e10cSrcweir // csv::File
132cdf0e10cSrcweir // aFile(rCommand.DevelopersManual_RefFilePath(), csv::CFM_READ);
133cdf0e10cSrcweir // if ( aFile.open() )
134cdf0e10cSrcweir // {
135cdf0e10cSrcweir // rIdl2sPilot.Read_Links2DevManual(aFile);
136cdf0e10cSrcweir // aFile.close();
137cdf0e10cSrcweir // }
138cdf0e10cSrcweir // }
139cdf0e10cSrcweir } // endif (bIDL)
140cdf0e10cSrcweir
141cdf0e10cSrcweir return true;
142cdf0e10cSrcweir
143cdf0e10cSrcweir } // end try
144cdf0e10cSrcweir catch (csv::Exception & xx)
145cdf0e10cSrcweir {
146cdf0e10cSrcweir xx.GetInfo(Cerr());
147cdf0e10cSrcweir Cerr() << " program will exit." << Endl();
148cdf0e10cSrcweir
149cdf0e10cSrcweir return false;
150cdf0e10cSrcweir }
151cdf0e10cSrcweir }
152cdf0e10cSrcweir
153cdf0e10cSrcweir CodeParser_Ifc &
Get_CppParser()154cdf0e10cSrcweir Parser::Get_CppParser()
155cdf0e10cSrcweir {
156cdf0e10cSrcweir if ( NOT pCppParser )
157cdf0e10cSrcweir Create_CppParser();
158cdf0e10cSrcweir return *pCppParser;
159cdf0e10cSrcweir }
160cdf0e10cSrcweir
161cdf0e10cSrcweir IdlParser &
Get_IdlParser()162cdf0e10cSrcweir Parser::Get_IdlParser()
163cdf0e10cSrcweir {
164cdf0e10cSrcweir if ( NOT pIdlParser )
165cdf0e10cSrcweir Create_IdlParser();
166cdf0e10cSrcweir return *pIdlParser;
167cdf0e10cSrcweir }
168cdf0e10cSrcweir
169cdf0e10cSrcweir void
Create_CppParser()170cdf0e10cSrcweir Parser::Create_CppParser()
171cdf0e10cSrcweir {
172cdf0e10cSrcweir pCppParser = ParseToolsFactory().Create_Parser_Cplusplus();
173cdf0e10cSrcweir pCppDocuInterpreter = ParseToolsFactory().Create_DocuParser_AutodocStyle();
174cdf0e10cSrcweir
175cdf0e10cSrcweir pCppParser->Setup( CommandLine::Get_().TheRepository(),
176*b32aa359SDamjan Jovanovic *pCppDocuInterpreter,
177*b32aa359SDamjan Jovanovic CommandLine::Get_().IgnoreDefines() );
178cdf0e10cSrcweir }
179cdf0e10cSrcweir
180cdf0e10cSrcweir void
Create_IdlParser()181cdf0e10cSrcweir Parser::Create_IdlParser()
182cdf0e10cSrcweir {
183cdf0e10cSrcweir pIdlParser = new IdlParser(CommandLine::Get_().TheRepository());
184cdf0e10cSrcweir }
185cdf0e10cSrcweir
186cdf0e10cSrcweir const ParseToolsFactory_Ifc &
ParseToolsFactory()187cdf0e10cSrcweir Parser::ParseToolsFactory()
188cdf0e10cSrcweir {
189cdf0e10cSrcweir return ParseToolsFactory_Ifc::GetIt_();
190cdf0e10cSrcweir }
191cdf0e10cSrcweir
192cdf0e10cSrcweir uintt
GatherFiles(FileCollector_Ifc & o_rFiles,const S_ProjectData & i_rProject)193cdf0e10cSrcweir Parser::GatherFiles( FileCollector_Ifc & o_rFiles,
194cdf0e10cSrcweir const S_ProjectData & i_rProject )
195cdf0e10cSrcweir {
196cdf0e10cSrcweir uintt ret = 0;
197cdf0e10cSrcweir o_rFiles.EraseAll();
198cdf0e10cSrcweir
199cdf0e10cSrcweir typedef StringVector StrVector;
200cdf0e10cSrcweir typedef StrVector::const_iterator StrIterator;
201cdf0e10cSrcweir const S_Sources &
202cdf0e10cSrcweir rSources = i_rProject.Sources();
203cdf0e10cSrcweir const StrVector &
204cdf0e10cSrcweir rExtensions = i_rProject.Language().aExtensions;
205cdf0e10cSrcweir
206cdf0e10cSrcweir StrIterator it;
207cdf0e10cSrcweir StrIterator itTreesEnd = rSources.aTrees.end();
208cdf0e10cSrcweir StrIterator itDirsEnd = rSources.aDirectories.end();
209cdf0e10cSrcweir StrIterator itFilesEnd = rSources.aFiles.end();
210cdf0e10cSrcweir StrIterator itExt;
211cdf0e10cSrcweir StrIterator itExtEnd = rExtensions.end();
212cdf0e10cSrcweir
213cdf0e10cSrcweir csv::StreamStr aDir(500);
214cdf0e10cSrcweir i_rProject.RootDirectory().Get( aDir );
215cdf0e10cSrcweir
216cdf0e10cSrcweir uintt nProjectDir_AddPosition =
217cdf0e10cSrcweir ( strcmp(aDir.c_str(),".\\") == 0 OR strcmp(aDir.c_str(),"./") == 0 )
218cdf0e10cSrcweir ? 0
219cdf0e10cSrcweir : uintt( aDir.tellp() );
220cdf0e10cSrcweir
221cdf0e10cSrcweir for ( it = rSources.aDirectories.begin();
222cdf0e10cSrcweir it != itDirsEnd;
223cdf0e10cSrcweir ++it )
224cdf0e10cSrcweir {
225cdf0e10cSrcweir aDir.seekp( nProjectDir_AddPosition );
226cdf0e10cSrcweir aDir << *it;
227cdf0e10cSrcweir
228cdf0e10cSrcweir for ( itExt = rExtensions.begin();
229cdf0e10cSrcweir itExt != itExtEnd;
230cdf0e10cSrcweir ++itExt )
231cdf0e10cSrcweir {
232cdf0e10cSrcweir ret += o_rFiles.AddFilesFrom( aDir.c_str(),
233cdf0e10cSrcweir *itExt,
234cdf0e10cSrcweir FileCollector_Ifc::flat );
235cdf0e10cSrcweir } // end for itExt
236cdf0e10cSrcweir } // end for it
237cdf0e10cSrcweir for ( it = rSources.aTrees.begin();
238cdf0e10cSrcweir it != itTreesEnd;
239cdf0e10cSrcweir ++it )
240cdf0e10cSrcweir {
241cdf0e10cSrcweir aDir.seekp( nProjectDir_AddPosition );
242cdf0e10cSrcweir aDir << *it;
243cdf0e10cSrcweir
244cdf0e10cSrcweir for ( itExt = rExtensions.begin();
245cdf0e10cSrcweir itExt != itExtEnd;
246cdf0e10cSrcweir ++itExt )
247cdf0e10cSrcweir {
248cdf0e10cSrcweir ret += o_rFiles.AddFilesFrom( aDir.c_str(),
249cdf0e10cSrcweir *itExt,
250cdf0e10cSrcweir FileCollector_Ifc::recursive );
251cdf0e10cSrcweir } // end for itExt
252cdf0e10cSrcweir } // end for it
253cdf0e10cSrcweir for ( it = rSources.aFiles.begin();
254cdf0e10cSrcweir it != itFilesEnd;
255cdf0e10cSrcweir ++it )
256cdf0e10cSrcweir {
257cdf0e10cSrcweir aDir.seekp( nProjectDir_AddPosition );
258cdf0e10cSrcweir aDir << *it;
259cdf0e10cSrcweir
260cdf0e10cSrcweir o_rFiles.AddFile( aDir.c_str() );
261cdf0e10cSrcweir } // end for it
262cdf0e10cSrcweir ret += rSources.aFiles.size();
263cdf0e10cSrcweir
264cdf0e10cSrcweir return ret;
265cdf0e10cSrcweir }
266cdf0e10cSrcweir
267cdf0e10cSrcweir
268cdf0e10cSrcweir } // namespace run
269cdf0e10cSrcweir } // namespace command
270cdf0e10cSrcweir
271cdf0e10cSrcweir
272cdf0e10cSrcweir #if 0
273cdf0e10cSrcweir inline const ParseToolsFactory_Ifc &
274cdf0e10cSrcweir CommandRunner::ParseToolsFactory()
275cdf0e10cSrcweir { return ParseToolsFactory_Ifc::GetIt_(); }
276cdf0e10cSrcweir
277cdf0e10cSrcweir
278cdf0e10cSrcweir inline const command::S_LanguageInfo &
279cdf0e10cSrcweir CommandRunner::Get_ProjectLanguage( const command::Parse & i_rCommand,
280cdf0e10cSrcweir const command::S_ProjectData & i_rProject )
281cdf0e10cSrcweir {
282cdf0e10cSrcweir if ( i_rProject.pLanguage )
283cdf0e10cSrcweir return *i_rProject.pLanguage;
284cdf0e10cSrcweir return *i_rCommand.GlobalLanguageInfo();
285cdf0e10cSrcweir }
286cdf0e10cSrcweir
287cdf0e10cSrcweir inline bool
288cdf0e10cSrcweir CommandRunner::HasParsedCpp() const
289cdf0e10cSrcweir { return pCppParser; }
290cdf0e10cSrcweir inline bool
291cdf0e10cSrcweir CommandRunner::HasParsedIdl() const
292cdf0e10cSrcweir { return pIdlParser; }
293cdf0e10cSrcweir
294cdf0e10cSrcweir
295cdf0e10cSrcweir
296cdf0e10cSrcweir
297cdf0e10cSrcweir
298cdf0e10cSrcweir CommandRunner::CommandRunner()
299cdf0e10cSrcweir : pCommandLine(0),
300cdf0e10cSrcweir pReposy(0),
301cdf0e10cSrcweir pNewReposy(0),
302cdf0e10cSrcweir nResultCode(0)
303cdf0e10cSrcweir {
304cdf0e10cSrcweir Cout() << "\nAutodoc version 2.2.1"
305cdf0e10cSrcweir << "\n-------------------"
306cdf0e10cSrcweir << "\n" << Endl();
307cdf0e10cSrcweir }
308cdf0e10cSrcweir
309cdf0e10cSrcweir CommandRunner::~CommandRunner()
310cdf0e10cSrcweir {
311cdf0e10cSrcweir ary::Repository::Destroy_();
312cdf0e10cSrcweir Cout() << "\n" << Endl();
313cdf0e10cSrcweir }
314cdf0e10cSrcweir
315cdf0e10cSrcweir void
316cdf0e10cSrcweir CommandRunner::Run( const CommandLine & i_rCL )
317cdf0e10cSrcweir {
318cdf0e10cSrcweir ary::Repository::Destroy_();
319cdf0e10cSrcweir // ary::Repository::Destroy_();
320cdf0e10cSrcweir pReposy = 0;
321cdf0e10cSrcweir pNewReposy = 0;
322cdf0e10cSrcweir nResultCode = 0;
323cdf0e10cSrcweir pCommandLine = &i_rCL;
324cdf0e10cSrcweir
325cdf0e10cSrcweir pCommandLine->Run();
326cdf0e10cSrcweir }
327cdf0e10cSrcweir
328cdf0e10cSrcweir void
329cdf0e10cSrcweir CommandRunner::Parse()
330cdf0e10cSrcweir {
331cdf0e10cSrcweir try
332cdf0e10cSrcweir {
333cdf0e10cSrcweir
334cdf0e10cSrcweir csv_assert( pCommandLine->Cmd_Parse() != 0 );
335cdf0e10cSrcweir const command::Parse &
336cdf0e10cSrcweir rCmd = *pCommandLine->Cmd_Parse();
337cdf0e10cSrcweir
338cdf0e10cSrcweir Cout() << "Parsing the repository "
339cdf0e10cSrcweir << rCmd.ReposyName()
340cdf0e10cSrcweir << " ..."
341cdf0e10cSrcweir << Endl();
342cdf0e10cSrcweir
343cdf0e10cSrcweir if ( pReposy == 0 )
344cdf0e10cSrcweir pReposy = & ary::Repository::Create_( rCmd.ReposyName(), 0 );
345cdf0e10cSrcweir if ( pNewReposy == 0 )
346cdf0e10cSrcweir pNewReposy = & ary::Repository::Create_( rCmd.ReposyName() );
347cdf0e10cSrcweir
348cdf0e10cSrcweir Dyn< FileCollector_Ifc > pFiles;
349cdf0e10cSrcweir pFiles = ParseToolsFactory().Create_FileCollector(6000);
350cdf0e10cSrcweir
351cdf0e10cSrcweir bool bCpp = false;
352cdf0e10cSrcweir bool bIDL = false;
353cdf0e10cSrcweir
354cdf0e10cSrcweir command::Parse::ProjectIterator itEnd = rCmd.ProjectsEnd();
355cdf0e10cSrcweir for ( command::Parse::ProjectIterator it = rCmd.ProjectsBegin();
356cdf0e10cSrcweir it != itEnd;
357cdf0e10cSrcweir ++it )
358cdf0e10cSrcweir {
359cdf0e10cSrcweir
360cdf0e10cSrcweir uintt nCount = GatherFiles( *pFiles, rCmd, *(*it) );
361cdf0e10cSrcweir Cout() << nCount
362cdf0e10cSrcweir << " files found to parse in project "
363cdf0e10cSrcweir << (*it)->Name()
364cdf0e10cSrcweir << "."
365cdf0e10cSrcweir << Endl();
366cdf0e10cSrcweir
367cdf0e10cSrcweir
368cdf0e10cSrcweir switch ( Get_ProjectLanguage(rCmd, *(*it)).eLanguage )
369cdf0e10cSrcweir {
370cdf0e10cSrcweir case command::S_LanguageInfo::cpp:
371cdf0e10cSrcweir {
372cdf0e10cSrcweir Get_CppParser().Run( (*it)->Name(),
373cdf0e10cSrcweir (*it)->RootDirectory(),
374cdf0e10cSrcweir *pFiles );
375cdf0e10cSrcweir bCpp = true;
376cdf0e10cSrcweir } break;
377cdf0e10cSrcweir case command::S_LanguageInfo::idl:
378cdf0e10cSrcweir {
379cdf0e10cSrcweir Get_IdlParser().Run(*pFiles);
380cdf0e10cSrcweir bIDL = true;
381cdf0e10cSrcweir } break;
382cdf0e10cSrcweir default:
383cdf0e10cSrcweir Cerr() << "Project in yet unimplemented language skipped."
384cdf0e10cSrcweir << Endl();
385cdf0e10cSrcweir }
386cdf0e10cSrcweir } // end for
387cdf0e10cSrcweir
388cdf0e10cSrcweir if (bCpp)
389cdf0e10cSrcweir pReposy->RwGate_Cpp().Connect_AllTypes_2_TheirRelated_CodeEntites();
390cdf0e10cSrcweir if (bIDL)
391cdf0e10cSrcweir {
392cdf0e10cSrcweir pNewReposy->Gate_Idl().Secondaries().Connect_Types2Ces();
393cdf0e10cSrcweir pNewReposy->Gate_Idl().Secondaries().Gather_CrossReferences();
394cdf0e10cSrcweir }
395cdf0e10cSrcweir
396cdf0e10cSrcweir } // end try
397cdf0e10cSrcweir catch (csv::Exception & xx)
398cdf0e10cSrcweir {
399cdf0e10cSrcweir xx.GetInfo(Cerr());
400cdf0e10cSrcweir Cerr() << " program will exit." << Endl();
401cdf0e10cSrcweir nResultCode = 1;
402cdf0e10cSrcweir }
403cdf0e10cSrcweir catch (...)
404cdf0e10cSrcweir {
405cdf0e10cSrcweir Cerr() << "Unknown exception - program will exit." << Endl();
406cdf0e10cSrcweir nResultCode = 1;
407cdf0e10cSrcweir }
408cdf0e10cSrcweir }
409cdf0e10cSrcweir
410cdf0e10cSrcweir void
411cdf0e10cSrcweir CommandRunner::Load()
412cdf0e10cSrcweir {
413cdf0e10cSrcweir Cout() << "This would load the repository from the directory "
414cdf0e10cSrcweir << pCommandLine->Cmd_Load()->ReposyDir()
415cdf0e10cSrcweir << "."
416cdf0e10cSrcweir << Endl();
417cdf0e10cSrcweir }
418cdf0e10cSrcweir
419cdf0e10cSrcweir
420cdf0e10cSrcweir void
421cdf0e10cSrcweir CommandRunner::Save()
422cdf0e10cSrcweir {
423cdf0e10cSrcweir Cout() << "This would save the repository into the directory "
424cdf0e10cSrcweir << pCommandLine->Cmd_Save()->ReposyDir()
425cdf0e10cSrcweir << "."
426cdf0e10cSrcweir << Endl();
427cdf0e10cSrcweir }
428cdf0e10cSrcweir
429cdf0e10cSrcweir
430cdf0e10cSrcweir void
431cdf0e10cSrcweir CommandRunner::CreateHtml()
432cdf0e10cSrcweir {
433cdf0e10cSrcweir Cout() << "Creating HTML-output into the directory "
434cdf0e10cSrcweir << pCommandLine->Cmd_CreateHtml()->OutputDir()
435cdf0e10cSrcweir << "."
436cdf0e10cSrcweir << Endl();
437cdf0e10cSrcweir
438cdf0e10cSrcweir if ( HasParsedCpp() )
439cdf0e10cSrcweir CreateHtml_NewStyle();
440cdf0e10cSrcweir if ( HasParsedIdl() )
441cdf0e10cSrcweir CreateHtml_OldIdlStyle();
442cdf0e10cSrcweir }
443cdf0e10cSrcweir
444cdf0e10cSrcweir
445cdf0e10cSrcweir
446cdf0e10cSrcweir void
447cdf0e10cSrcweir CommandRunner::CreateXml()
448cdf0e10cSrcweir {
449cdf0e10cSrcweir Cout() << "This would create the XML-output into the directory "
450cdf0e10cSrcweir << pCommandLine->Cmd_CreateXml()->OutputDir()
451cdf0e10cSrcweir << "."
452cdf0e10cSrcweir << Endl();
453cdf0e10cSrcweir }
454cdf0e10cSrcweir
455cdf0e10cSrcweir CodeParser_Ifc &
456cdf0e10cSrcweir CommandRunner::Get_CppParser()
457cdf0e10cSrcweir {
458cdf0e10cSrcweir if ( NOT pCppParser )
459cdf0e10cSrcweir Create_CppParser();
460cdf0e10cSrcweir return *pCppParser;
461cdf0e10cSrcweir }
462cdf0e10cSrcweir
463cdf0e10cSrcweir IdlParser &
464cdf0e10cSrcweir CommandRunner::Get_IdlParser()
465cdf0e10cSrcweir {
466cdf0e10cSrcweir if ( NOT pIdlParser )
467cdf0e10cSrcweir Create_IdlParser();
468cdf0e10cSrcweir return *pIdlParser;
469cdf0e10cSrcweir }
470cdf0e10cSrcweir
471cdf0e10cSrcweir void
472cdf0e10cSrcweir CommandRunner::Create_CppParser()
473cdf0e10cSrcweir {
474cdf0e10cSrcweir pCppParser = ParseToolsFactory().Create_Parser_Cplusplus();
475cdf0e10cSrcweir pCppDocuInterpreter = ParseToolsFactory().Create_DocuParser_AutodocStyle();
476cdf0e10cSrcweir
477cdf0e10cSrcweir pCppParser->Setup( *pReposy,
478cdf0e10cSrcweir *pCppDocuInterpreter );
479cdf0e10cSrcweir }
480cdf0e10cSrcweir
481cdf0e10cSrcweir void
482cdf0e10cSrcweir CommandRunner::Create_IdlParser()
483cdf0e10cSrcweir {
484cdf0e10cSrcweir pIdlParser = new IdlParser(*pNewReposy);
485cdf0e10cSrcweir }
486cdf0e10cSrcweir
487cdf0e10cSrcweir uintt
488cdf0e10cSrcweir CommandRunner::GatherFiles( FileCollector_Ifc & o_rFiles,
489cdf0e10cSrcweir const command::Parse & i_rCommand,
490cdf0e10cSrcweir const command::S_ProjectData & i_rProject )
491cdf0e10cSrcweir {
492cdf0e10cSrcweir uintt ret = 0;
493cdf0e10cSrcweir o_rFiles.EraseAll();
494cdf0e10cSrcweir
495cdf0e10cSrcweir typedef StringVector StrVector;
496cdf0e10cSrcweir typedef StrVector::const_iterator StrIterator;
497cdf0e10cSrcweir const command::S_Sources &
498cdf0e10cSrcweir rSources = i_rProject.aFiles;
499cdf0e10cSrcweir const StrVector &
500cdf0e10cSrcweir rExtensions = Get_ProjectLanguage(i_rCommand,i_rProject).aExtensions;
501cdf0e10cSrcweir
502cdf0e10cSrcweir StrIterator it;
503cdf0e10cSrcweir StrIterator itDirsEnd = rSources.aDirectories.end();
504cdf0e10cSrcweir StrIterator itTreesEnd = i_rProject.aFiles.aTrees.end();
505cdf0e10cSrcweir StrIterator itFilesEnd = i_rProject.aFiles.aFiles.end();
506cdf0e10cSrcweir StrIterator itExt;
507cdf0e10cSrcweir StrIterator itExtEnd = rExtensions.end();
508cdf0e10cSrcweir
509cdf0e10cSrcweir csv::StreamStr aDir(500);
510cdf0e10cSrcweir i_rProject.aRootDirectory.Get( aDir );
511cdf0e10cSrcweir
512cdf0e10cSrcweir uintt nProjectDir_AddPosition =
513cdf0e10cSrcweir ( strcmp(aDir.c_str(),".\\") == 0 OR strcmp(aDir.c_str(),"./") == 0 )
514cdf0e10cSrcweir ? 0
515cdf0e10cSrcweir : uintt( aDir.tellp() );
516cdf0e10cSrcweir
517cdf0e10cSrcweir for ( it = rSources.aDirectories.begin();
518cdf0e10cSrcweir it != itDirsEnd;
519cdf0e10cSrcweir ++it )
520cdf0e10cSrcweir {
521cdf0e10cSrcweir aDir.seekp( nProjectDir_AddPosition );
522cdf0e10cSrcweir aDir << *it;
523cdf0e10cSrcweir
524cdf0e10cSrcweir for ( itExt = rExtensions.begin();
525cdf0e10cSrcweir itExt != itExtEnd;
526cdf0e10cSrcweir ++itExt )
527cdf0e10cSrcweir {
528cdf0e10cSrcweir ret += o_rFiles.AddFilesFrom( aDir.c_str(),
529cdf0e10cSrcweir *itExt,
530cdf0e10cSrcweir FileCollector_Ifc::flat );
531cdf0e10cSrcweir } // end for itExt
532cdf0e10cSrcweir } // end for it
533cdf0e10cSrcweir for ( it = rSources.aTrees.begin();
534cdf0e10cSrcweir it != itTreesEnd;
535cdf0e10cSrcweir ++it )
536cdf0e10cSrcweir {
537cdf0e10cSrcweir aDir.seekp( nProjectDir_AddPosition );
538cdf0e10cSrcweir aDir << *it;
539cdf0e10cSrcweir
540cdf0e10cSrcweir for ( itExt = rExtensions.begin();
541cdf0e10cSrcweir itExt != itExtEnd;
542cdf0e10cSrcweir ++itExt )
543cdf0e10cSrcweir {
544cdf0e10cSrcweir ret += o_rFiles.AddFilesFrom( aDir.c_str(),
545cdf0e10cSrcweir *itExt,
546cdf0e10cSrcweir FileCollector_Ifc::recursive );
547cdf0e10cSrcweir } // end for itExt
548cdf0e10cSrcweir } // end for it
549cdf0e10cSrcweir for ( it = rSources.aFiles.begin();
550cdf0e10cSrcweir it != itFilesEnd;
551cdf0e10cSrcweir ++it )
552cdf0e10cSrcweir {
553cdf0e10cSrcweir aDir.seekp( nProjectDir_AddPosition );
554cdf0e10cSrcweir aDir << *it;
555cdf0e10cSrcweir
556cdf0e10cSrcweir o_rFiles.AddFile( aDir.c_str() );
557cdf0e10cSrcweir } // end for it
558cdf0e10cSrcweir ret += rSources.aFiles.size();
559cdf0e10cSrcweir
560cdf0e10cSrcweir return ret;
561cdf0e10cSrcweir }
562cdf0e10cSrcweir
563cdf0e10cSrcweir void
564cdf0e10cSrcweir CommandRunner::CreateHtml_NewStyle()
565cdf0e10cSrcweir {
566cdf0e10cSrcweir const ary::cpp::DisplayGate &
567cdf0e10cSrcweir rGate = pReposy->DisplayGate_Cpp();
568cdf0e10cSrcweir
569cdf0e10cSrcweir Dyn< autodoc::HtmlDisplay_UdkStd > pHtmlDisplay;
570cdf0e10cSrcweir pHtmlDisplay = DisplayToolsFactory_Ifc::GetIt_()
571cdf0e10cSrcweir .Create_HtmlDisplay_UdkStd();
572cdf0e10cSrcweir
573cdf0e10cSrcweir pHtmlDisplay->Run( pCommandLine->Cmd_CreateHtml()->OutputDir(),
574cdf0e10cSrcweir rGate,
575cdf0e10cSrcweir DisplayToolsFactory_Ifc::GetIt_().Create_StdFrame() );
576cdf0e10cSrcweir }
577cdf0e10cSrcweir
578cdf0e10cSrcweir void
579cdf0e10cSrcweir CommandRunner::CreateHtml_OldIdlStyle()
580cdf0e10cSrcweir {
581cdf0e10cSrcweir ary::idl::Gate &
582cdf0e10cSrcweir rAryGate = pNewReposy->Gate_Idl();
583cdf0e10cSrcweir
584cdf0e10cSrcweir // Read DevManualLinkFile:
585cdf0e10cSrcweir // KORR_FUTURE
586cdf0e10cSrcweir csv::File
587cdf0e10cSrcweir aFile("devmanref.txt", csv::CFM_READ);
588cdf0e10cSrcweir if ( aFile.open() )
589cdf0e10cSrcweir {
590cdf0e10cSrcweir rAryGate.Secondaries().Read_Links2DevManual(aFile);
591cdf0e10cSrcweir aFile.close();
592cdf0e10cSrcweir }
593cdf0e10cSrcweir
594cdf0e10cSrcweir // New Style Output
595cdf0e10cSrcweir Dyn<autodoc::HtmlDisplay_Idl_Ifc> pNewDisplay;
596cdf0e10cSrcweir pNewDisplay = DisplayToolsFactory_Ifc::GetIt_()
597cdf0e10cSrcweir .Create_HtmlDisplay_Idl();
598cdf0e10cSrcweir pNewDisplay->Run( pCommandLine->Cmd_CreateHtml()->OutputDir(),
599cdf0e10cSrcweir rAryGate,
600cdf0e10cSrcweir DisplayToolsFactory_Ifc::GetIt_().Create_StdFrame() );
601cdf0e10cSrcweir }
602cdf0e10cSrcweir #endif // 0
603cdf0e10cSrcweir
604cdf0e10cSrcweir } // namespace autodoc
605