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 "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(),
176cdf0e10cSrcweir                        *pCppDocuInterpreter );
177cdf0e10cSrcweir }
178cdf0e10cSrcweir 
179cdf0e10cSrcweir void
Create_IdlParser()180cdf0e10cSrcweir Parser::Create_IdlParser()
181cdf0e10cSrcweir {
182cdf0e10cSrcweir     pIdlParser = new IdlParser(CommandLine::Get_().TheRepository());
183cdf0e10cSrcweir }
184cdf0e10cSrcweir 
185cdf0e10cSrcweir const ParseToolsFactory_Ifc &
ParseToolsFactory()186cdf0e10cSrcweir Parser::ParseToolsFactory()
187cdf0e10cSrcweir {
188cdf0e10cSrcweir     return ParseToolsFactory_Ifc::GetIt_();
189cdf0e10cSrcweir }
190cdf0e10cSrcweir 
191cdf0e10cSrcweir uintt
GatherFiles(FileCollector_Ifc & o_rFiles,const S_ProjectData & i_rProject)192cdf0e10cSrcweir Parser::GatherFiles( FileCollector_Ifc &    o_rFiles,
193cdf0e10cSrcweir                      const S_ProjectData &  i_rProject )
194cdf0e10cSrcweir {
195cdf0e10cSrcweir     uintt ret = 0;
196cdf0e10cSrcweir     o_rFiles.EraseAll();
197cdf0e10cSrcweir 
198cdf0e10cSrcweir     typedef StringVector                StrVector;
199cdf0e10cSrcweir     typedef StrVector::const_iterator   StrIterator;
200cdf0e10cSrcweir     const S_Sources &
201cdf0e10cSrcweir         rSources = i_rProject.Sources();
202cdf0e10cSrcweir     const StrVector &
203cdf0e10cSrcweir         rExtensions = i_rProject.Language().aExtensions;
204cdf0e10cSrcweir 
205cdf0e10cSrcweir     StrIterator     it;
206cdf0e10cSrcweir     StrIterator     itTreesEnd  = rSources.aTrees.end();
207cdf0e10cSrcweir     StrIterator     itDirsEnd   = rSources.aDirectories.end();
208cdf0e10cSrcweir     StrIterator     itFilesEnd  = rSources.aFiles.end();
209cdf0e10cSrcweir     StrIterator     itExt;
210cdf0e10cSrcweir     StrIterator     itExtEnd    = rExtensions.end();
211cdf0e10cSrcweir 
212cdf0e10cSrcweir     csv::StreamStr aDir(500);
213cdf0e10cSrcweir     i_rProject.RootDirectory().Get( aDir );
214cdf0e10cSrcweir 
215cdf0e10cSrcweir     uintt nProjectDir_AddPosition =
216cdf0e10cSrcweir             ( strcmp(aDir.c_str(),".\\") == 0 OR strcmp(aDir.c_str(),"./") == 0 )
217cdf0e10cSrcweir                 ?   0
218cdf0e10cSrcweir                 :   uintt( aDir.tellp() );
219cdf0e10cSrcweir 
220cdf0e10cSrcweir     for ( it = rSources.aDirectories.begin();
221cdf0e10cSrcweir           it != itDirsEnd;
222cdf0e10cSrcweir           ++it )
223cdf0e10cSrcweir     {
224cdf0e10cSrcweir         aDir.seekp( nProjectDir_AddPosition );
225cdf0e10cSrcweir         aDir << *it;
226cdf0e10cSrcweir 
227cdf0e10cSrcweir         for ( itExt = rExtensions.begin();
228cdf0e10cSrcweir               itExt != itExtEnd;
229cdf0e10cSrcweir               ++itExt )
230cdf0e10cSrcweir         {
231cdf0e10cSrcweir             ret += o_rFiles.AddFilesFrom( aDir.c_str(),
232cdf0e10cSrcweir                                           *itExt,
233cdf0e10cSrcweir                                           FileCollector_Ifc::flat );
234cdf0e10cSrcweir         }   // end for itExt
235cdf0e10cSrcweir     }   // end for it
236cdf0e10cSrcweir     for ( it = rSources.aTrees.begin();
237cdf0e10cSrcweir           it != itTreesEnd;
238cdf0e10cSrcweir           ++it )
239cdf0e10cSrcweir     {
240cdf0e10cSrcweir         aDir.seekp( nProjectDir_AddPosition );
241cdf0e10cSrcweir         aDir << *it;
242cdf0e10cSrcweir 
243cdf0e10cSrcweir         for ( itExt = rExtensions.begin();
244cdf0e10cSrcweir               itExt != itExtEnd;
245cdf0e10cSrcweir               ++itExt )
246cdf0e10cSrcweir         {
247cdf0e10cSrcweir             ret += o_rFiles.AddFilesFrom( aDir.c_str(),
248cdf0e10cSrcweir                                           *itExt,
249cdf0e10cSrcweir                                           FileCollector_Ifc::recursive );
250cdf0e10cSrcweir         }   // end for itExt
251cdf0e10cSrcweir     }   // end for it
252cdf0e10cSrcweir     for ( it = rSources.aFiles.begin();
253cdf0e10cSrcweir           it != itFilesEnd;
254cdf0e10cSrcweir           ++it )
255cdf0e10cSrcweir     {
256cdf0e10cSrcweir         aDir.seekp( nProjectDir_AddPosition );
257cdf0e10cSrcweir         aDir << *it;
258cdf0e10cSrcweir 
259cdf0e10cSrcweir         o_rFiles.AddFile( aDir.c_str() );
260cdf0e10cSrcweir     }   // end for it
261cdf0e10cSrcweir     ret += rSources.aFiles.size();
262cdf0e10cSrcweir 
263cdf0e10cSrcweir     return ret;
264cdf0e10cSrcweir }
265cdf0e10cSrcweir 
266cdf0e10cSrcweir 
267cdf0e10cSrcweir }   // namespace run
268cdf0e10cSrcweir }   // namespace command
269cdf0e10cSrcweir 
270cdf0e10cSrcweir 
271cdf0e10cSrcweir #if 0
272cdf0e10cSrcweir inline const ParseToolsFactory_Ifc &
273cdf0e10cSrcweir CommandRunner::ParseToolsFactory()
274cdf0e10cSrcweir     { return ParseToolsFactory_Ifc::GetIt_(); }
275cdf0e10cSrcweir 
276cdf0e10cSrcweir 
277cdf0e10cSrcweir inline const command::S_LanguageInfo &
278cdf0e10cSrcweir CommandRunner::Get_ProjectLanguage( const command::Parse &          i_rCommand,
279cdf0e10cSrcweir                                     const command::S_ProjectData &  i_rProject )
280cdf0e10cSrcweir {
281cdf0e10cSrcweir     if ( i_rProject.pLanguage )
282cdf0e10cSrcweir         return *i_rProject.pLanguage;
283cdf0e10cSrcweir     return *i_rCommand.GlobalLanguageInfo();
284cdf0e10cSrcweir }
285cdf0e10cSrcweir 
286cdf0e10cSrcweir inline bool
287cdf0e10cSrcweir CommandRunner::HasParsedCpp() const
288cdf0e10cSrcweir     { return pCppParser; }
289cdf0e10cSrcweir inline bool
290cdf0e10cSrcweir CommandRunner::HasParsedIdl() const
291cdf0e10cSrcweir     { return pIdlParser; }
292cdf0e10cSrcweir 
293cdf0e10cSrcweir 
294cdf0e10cSrcweir 
295cdf0e10cSrcweir 
296cdf0e10cSrcweir 
297cdf0e10cSrcweir CommandRunner::CommandRunner()
298cdf0e10cSrcweir     :   pCommandLine(0),
299cdf0e10cSrcweir         pReposy(0),
300cdf0e10cSrcweir         pNewReposy(0),
301cdf0e10cSrcweir         nResultCode(0)
302cdf0e10cSrcweir {
303cdf0e10cSrcweir     Cout() << "\nAutodoc version 2.2.1"
304cdf0e10cSrcweir            << "\n-------------------"
305cdf0e10cSrcweir            << "\n" << Endl();
306cdf0e10cSrcweir }
307cdf0e10cSrcweir 
308cdf0e10cSrcweir CommandRunner::~CommandRunner()
309cdf0e10cSrcweir {
310cdf0e10cSrcweir     ary::Repository::Destroy_();
311cdf0e10cSrcweir     Cout() << "\n" << Endl();
312cdf0e10cSrcweir }
313cdf0e10cSrcweir 
314cdf0e10cSrcweir void
315cdf0e10cSrcweir CommandRunner::Run( const CommandLine & i_rCL )
316cdf0e10cSrcweir {
317cdf0e10cSrcweir     ary::Repository::Destroy_();
318cdf0e10cSrcweir //  ary::Repository::Destroy_();
319cdf0e10cSrcweir     pReposy = 0;
320cdf0e10cSrcweir     pNewReposy = 0;
321cdf0e10cSrcweir     nResultCode = 0;
322cdf0e10cSrcweir     pCommandLine = &i_rCL;
323cdf0e10cSrcweir 
324cdf0e10cSrcweir     pCommandLine->Run();
325cdf0e10cSrcweir }
326cdf0e10cSrcweir 
327cdf0e10cSrcweir void
328cdf0e10cSrcweir CommandRunner::Parse()
329cdf0e10cSrcweir {
330cdf0e10cSrcweir     try
331cdf0e10cSrcweir     {
332cdf0e10cSrcweir 
333cdf0e10cSrcweir     csv_assert( pCommandLine->Cmd_Parse() != 0 );
334cdf0e10cSrcweir     const command::Parse &
335cdf0e10cSrcweir         rCmd = *pCommandLine->Cmd_Parse();
336cdf0e10cSrcweir 
337cdf0e10cSrcweir     Cout() << "Parsing the repository "
338cdf0e10cSrcweir               << rCmd.ReposyName()
339cdf0e10cSrcweir               << " ..."
340cdf0e10cSrcweir               << Endl();
341cdf0e10cSrcweir 
342cdf0e10cSrcweir     if ( pReposy == 0 )
343cdf0e10cSrcweir         pReposy = & ary::Repository::Create_( rCmd.ReposyName(), 0 );
344cdf0e10cSrcweir     if ( pNewReposy == 0 )
345cdf0e10cSrcweir         pNewReposy = & ary::Repository::Create_( rCmd.ReposyName() );
346cdf0e10cSrcweir 
347cdf0e10cSrcweir     Dyn< FileCollector_Ifc > pFiles;
348cdf0e10cSrcweir     pFiles      = ParseToolsFactory().Create_FileCollector(6000);
349cdf0e10cSrcweir 
350cdf0e10cSrcweir     bool bCpp = false;
351cdf0e10cSrcweir     bool bIDL = false;
352cdf0e10cSrcweir 
353cdf0e10cSrcweir     command::Parse::ProjectIterator itEnd = rCmd.ProjectsEnd();
354cdf0e10cSrcweir     for ( command::Parse::ProjectIterator it = rCmd.ProjectsBegin();
355cdf0e10cSrcweir           it != itEnd;
356cdf0e10cSrcweir           ++it )
357cdf0e10cSrcweir     {
358cdf0e10cSrcweir 
359cdf0e10cSrcweir         uintt nCount = GatherFiles( *pFiles, rCmd, *(*it) );
360cdf0e10cSrcweir         Cout() << nCount
361cdf0e10cSrcweir              << " files found to parse in project "
362cdf0e10cSrcweir              << (*it)->Name()
363cdf0e10cSrcweir              << "."
364cdf0e10cSrcweir              << Endl();
365cdf0e10cSrcweir 
366cdf0e10cSrcweir 
367cdf0e10cSrcweir         switch ( Get_ProjectLanguage(rCmd, *(*it)).eLanguage )
368cdf0e10cSrcweir         {
369cdf0e10cSrcweir             case command::S_LanguageInfo::cpp:
370cdf0e10cSrcweir             {
371cdf0e10cSrcweir                 Get_CppParser().Run( (*it)->Name(),
372cdf0e10cSrcweir                                      (*it)->RootDirectory(),
373cdf0e10cSrcweir                                      *pFiles );
374cdf0e10cSrcweir                 bCpp = true;
375cdf0e10cSrcweir             }   break;
376cdf0e10cSrcweir             case command::S_LanguageInfo::idl:
377cdf0e10cSrcweir             {
378cdf0e10cSrcweir                 Get_IdlParser().Run(*pFiles);
379cdf0e10cSrcweir                 bIDL = true;
380cdf0e10cSrcweir             }   break;
381cdf0e10cSrcweir             default:
382cdf0e10cSrcweir                 Cerr() << "Project in yet unimplemented language skipped."
383cdf0e10cSrcweir                        << Endl();
384cdf0e10cSrcweir         }
385cdf0e10cSrcweir     }	// end for
386cdf0e10cSrcweir 
387cdf0e10cSrcweir     if (bCpp)
388cdf0e10cSrcweir 	    pReposy->RwGate_Cpp().Connect_AllTypes_2_TheirRelated_CodeEntites();
389cdf0e10cSrcweir     if (bIDL)
390cdf0e10cSrcweir     {
391cdf0e10cSrcweir         pNewReposy->Gate_Idl().Secondaries().Connect_Types2Ces();
392cdf0e10cSrcweir         pNewReposy->Gate_Idl().Secondaries().Gather_CrossReferences();
393cdf0e10cSrcweir     }
394cdf0e10cSrcweir 
395cdf0e10cSrcweir     }   // end try
396cdf0e10cSrcweir     catch (csv::Exception & xx)
397cdf0e10cSrcweir     {
398cdf0e10cSrcweir         xx.GetInfo(Cerr());
399cdf0e10cSrcweir         Cerr() << " program will exit." << Endl();
400cdf0e10cSrcweir         nResultCode = 1;
401cdf0e10cSrcweir     }
402cdf0e10cSrcweir     catch (...)
403cdf0e10cSrcweir     {
404cdf0e10cSrcweir         Cerr() << "Unknown exception -   program will exit." << Endl();
405cdf0e10cSrcweir         nResultCode = 1;
406cdf0e10cSrcweir     }
407cdf0e10cSrcweir }
408cdf0e10cSrcweir 
409cdf0e10cSrcweir void
410cdf0e10cSrcweir CommandRunner::Load()
411cdf0e10cSrcweir {
412cdf0e10cSrcweir     Cout() << "This would load the repository from the directory "
413cdf0e10cSrcweir               << pCommandLine->Cmd_Load()->ReposyDir()
414cdf0e10cSrcweir               << "."
415cdf0e10cSrcweir               << Endl();
416cdf0e10cSrcweir }
417cdf0e10cSrcweir 
418cdf0e10cSrcweir 
419cdf0e10cSrcweir void
420cdf0e10cSrcweir CommandRunner::Save()
421cdf0e10cSrcweir {
422cdf0e10cSrcweir     Cout() << "This would save the repository into the directory "
423cdf0e10cSrcweir               << pCommandLine->Cmd_Save()->ReposyDir()
424cdf0e10cSrcweir               << "."
425cdf0e10cSrcweir               << Endl();
426cdf0e10cSrcweir }
427cdf0e10cSrcweir 
428cdf0e10cSrcweir 
429cdf0e10cSrcweir void
430cdf0e10cSrcweir CommandRunner::CreateHtml()
431cdf0e10cSrcweir {
432cdf0e10cSrcweir     Cout() << "Creating HTML-output into the directory "
433cdf0e10cSrcweir               << pCommandLine->Cmd_CreateHtml()->OutputDir()
434cdf0e10cSrcweir               << "."
435cdf0e10cSrcweir               << Endl();
436cdf0e10cSrcweir 
437cdf0e10cSrcweir     if ( HasParsedCpp() )
438cdf0e10cSrcweir         CreateHtml_NewStyle();
439cdf0e10cSrcweir     if ( HasParsedIdl() )
440cdf0e10cSrcweir         CreateHtml_OldIdlStyle();
441cdf0e10cSrcweir }
442cdf0e10cSrcweir 
443cdf0e10cSrcweir 
444cdf0e10cSrcweir 
445cdf0e10cSrcweir void
446cdf0e10cSrcweir CommandRunner::CreateXml()
447cdf0e10cSrcweir {
448cdf0e10cSrcweir     Cout() << "This would create the XML-output into the directory "
449cdf0e10cSrcweir               << pCommandLine->Cmd_CreateXml()->OutputDir()
450cdf0e10cSrcweir               << "."
451cdf0e10cSrcweir               << Endl();
452cdf0e10cSrcweir }
453cdf0e10cSrcweir 
454cdf0e10cSrcweir CodeParser_Ifc &
455cdf0e10cSrcweir CommandRunner::Get_CppParser()
456cdf0e10cSrcweir {
457cdf0e10cSrcweir     if ( NOT pCppParser )
458cdf0e10cSrcweir         Create_CppParser();
459cdf0e10cSrcweir     return *pCppParser;
460cdf0e10cSrcweir }
461cdf0e10cSrcweir 
462cdf0e10cSrcweir IdlParser &
463cdf0e10cSrcweir CommandRunner::Get_IdlParser()
464cdf0e10cSrcweir {
465cdf0e10cSrcweir     if ( NOT pIdlParser )
466cdf0e10cSrcweir         Create_IdlParser();
467cdf0e10cSrcweir     return *pIdlParser;
468cdf0e10cSrcweir }
469cdf0e10cSrcweir 
470cdf0e10cSrcweir void
471cdf0e10cSrcweir CommandRunner::Create_CppParser()
472cdf0e10cSrcweir {
473cdf0e10cSrcweir     pCppParser          = ParseToolsFactory().Create_Parser_Cplusplus();
474cdf0e10cSrcweir     pCppDocuInterpreter = ParseToolsFactory().Create_DocuParser_AutodocStyle();
475cdf0e10cSrcweir 
476cdf0e10cSrcweir     pCppParser->Setup( *pReposy,
477cdf0e10cSrcweir                        *pCppDocuInterpreter );
478cdf0e10cSrcweir }
479cdf0e10cSrcweir 
480cdf0e10cSrcweir void
481cdf0e10cSrcweir CommandRunner::Create_IdlParser()
482cdf0e10cSrcweir {
483cdf0e10cSrcweir     pIdlParser = new IdlParser(*pNewReposy);
484cdf0e10cSrcweir }
485cdf0e10cSrcweir 
486cdf0e10cSrcweir uintt
487cdf0e10cSrcweir CommandRunner::GatherFiles( FileCollector_Ifc &            o_rFiles,
488cdf0e10cSrcweir                             const command::Parse &         i_rCommand,
489cdf0e10cSrcweir                             const command::S_ProjectData & i_rProject )
490cdf0e10cSrcweir {
491cdf0e10cSrcweir     uintt ret = 0;
492cdf0e10cSrcweir     o_rFiles.EraseAll();
493cdf0e10cSrcweir 
494cdf0e10cSrcweir     typedef StringVector                StrVector;
495cdf0e10cSrcweir     typedef StrVector::const_iterator   StrIterator;
496cdf0e10cSrcweir     const command::S_Sources &
497cdf0e10cSrcweir         rSources = i_rProject.aFiles;
498cdf0e10cSrcweir     const StrVector &
499cdf0e10cSrcweir         rExtensions = Get_ProjectLanguage(i_rCommand,i_rProject).aExtensions;
500cdf0e10cSrcweir 
501cdf0e10cSrcweir     StrIterator     it;
502cdf0e10cSrcweir     StrIterator     itDirsEnd   = rSources.aDirectories.end();
503cdf0e10cSrcweir     StrIterator     itTreesEnd  = i_rProject.aFiles.aTrees.end();
504cdf0e10cSrcweir     StrIterator     itFilesEnd  = i_rProject.aFiles.aFiles.end();
505cdf0e10cSrcweir     StrIterator     itExt;
506cdf0e10cSrcweir     StrIterator     itExtEnd    = rExtensions.end();
507cdf0e10cSrcweir 
508cdf0e10cSrcweir     csv::StreamStr aDir(500);
509cdf0e10cSrcweir     i_rProject.aRootDirectory.Get( aDir );
510cdf0e10cSrcweir 
511cdf0e10cSrcweir     uintt nProjectDir_AddPosition =
512cdf0e10cSrcweir             ( strcmp(aDir.c_str(),".\\") == 0 OR strcmp(aDir.c_str(),"./") == 0 )
513cdf0e10cSrcweir                 ?   0
514cdf0e10cSrcweir                 :   uintt( aDir.tellp() );
515cdf0e10cSrcweir 
516cdf0e10cSrcweir     for ( it = rSources.aDirectories.begin();
517cdf0e10cSrcweir           it != itDirsEnd;
518cdf0e10cSrcweir           ++it )
519cdf0e10cSrcweir     {
520cdf0e10cSrcweir         aDir.seekp( nProjectDir_AddPosition );
521cdf0e10cSrcweir         aDir << *it;
522cdf0e10cSrcweir 
523cdf0e10cSrcweir         for ( itExt = rExtensions.begin();
524cdf0e10cSrcweir               itExt != itExtEnd;
525cdf0e10cSrcweir               ++itExt )
526cdf0e10cSrcweir         {
527cdf0e10cSrcweir             ret += o_rFiles.AddFilesFrom( aDir.c_str(),
528cdf0e10cSrcweir                                           *itExt,
529cdf0e10cSrcweir                                           FileCollector_Ifc::flat );
530cdf0e10cSrcweir         }   // end for itExt
531cdf0e10cSrcweir     }   // end for it
532cdf0e10cSrcweir     for ( it = rSources.aTrees.begin();
533cdf0e10cSrcweir           it != itTreesEnd;
534cdf0e10cSrcweir           ++it )
535cdf0e10cSrcweir     {
536cdf0e10cSrcweir         aDir.seekp( nProjectDir_AddPosition );
537cdf0e10cSrcweir         aDir << *it;
538cdf0e10cSrcweir 
539cdf0e10cSrcweir         for ( itExt = rExtensions.begin();
540cdf0e10cSrcweir               itExt != itExtEnd;
541cdf0e10cSrcweir               ++itExt )
542cdf0e10cSrcweir         {
543cdf0e10cSrcweir             ret += o_rFiles.AddFilesFrom( aDir.c_str(),
544cdf0e10cSrcweir                                           *itExt,
545cdf0e10cSrcweir                                           FileCollector_Ifc::recursive );
546cdf0e10cSrcweir         }   // end for itExt
547cdf0e10cSrcweir     }   // end for it
548cdf0e10cSrcweir     for ( it = rSources.aFiles.begin();
549cdf0e10cSrcweir           it != itFilesEnd;
550cdf0e10cSrcweir           ++it )
551cdf0e10cSrcweir     {
552cdf0e10cSrcweir         aDir.seekp( nProjectDir_AddPosition );
553cdf0e10cSrcweir         aDir << *it;
554cdf0e10cSrcweir 
555cdf0e10cSrcweir         o_rFiles.AddFile( aDir.c_str() );
556cdf0e10cSrcweir     }   // end for it
557cdf0e10cSrcweir     ret += rSources.aFiles.size();
558cdf0e10cSrcweir 
559cdf0e10cSrcweir     return ret;
560cdf0e10cSrcweir }
561cdf0e10cSrcweir 
562cdf0e10cSrcweir void
563cdf0e10cSrcweir CommandRunner::CreateHtml_NewStyle()
564cdf0e10cSrcweir {
565cdf0e10cSrcweir     const ary::cpp::DisplayGate &
566cdf0e10cSrcweir             rGate = pReposy->DisplayGate_Cpp();
567cdf0e10cSrcweir 
568cdf0e10cSrcweir     Dyn< autodoc::HtmlDisplay_UdkStd > pHtmlDisplay;
569cdf0e10cSrcweir             pHtmlDisplay = DisplayToolsFactory_Ifc::GetIt_()
570cdf0e10cSrcweir                                 .Create_HtmlDisplay_UdkStd();
571cdf0e10cSrcweir 
572cdf0e10cSrcweir     pHtmlDisplay->Run( pCommandLine->Cmd_CreateHtml()->OutputDir(),
573cdf0e10cSrcweir                        rGate,
574cdf0e10cSrcweir                        DisplayToolsFactory_Ifc::GetIt_().Create_StdFrame() );
575cdf0e10cSrcweir }
576cdf0e10cSrcweir 
577cdf0e10cSrcweir void
578cdf0e10cSrcweir CommandRunner::CreateHtml_OldIdlStyle()
579cdf0e10cSrcweir {
580cdf0e10cSrcweir     ary::idl::Gate &
581cdf0e10cSrcweir         rAryGate            = pNewReposy->Gate_Idl();
582cdf0e10cSrcweir 
583cdf0e10cSrcweir     // Read DevManualLinkFile:
584cdf0e10cSrcweir     // KORR_FUTURE
585cdf0e10cSrcweir     csv::File
586cdf0e10cSrcweir         aFile("devmanref.txt", csv::CFM_READ);
587cdf0e10cSrcweir     if ( aFile.open() )
588cdf0e10cSrcweir     {
589cdf0e10cSrcweir         rAryGate.Secondaries().Read_Links2DevManual(aFile);
590cdf0e10cSrcweir      	aFile.close();
591cdf0e10cSrcweir     }
592cdf0e10cSrcweir 
593cdf0e10cSrcweir     // New Style Output
594cdf0e10cSrcweir     Dyn<autodoc::HtmlDisplay_Idl_Ifc> pNewDisplay;
595cdf0e10cSrcweir         pNewDisplay         = DisplayToolsFactory_Ifc::GetIt_()
596cdf0e10cSrcweir                                 .Create_HtmlDisplay_Idl();
597cdf0e10cSrcweir     pNewDisplay->Run( pCommandLine->Cmd_CreateHtml()->OutputDir(),
598cdf0e10cSrcweir                       rAryGate,
599cdf0e10cSrcweir                       DisplayToolsFactory_Ifc::GetIt_().Create_StdFrame() );
600cdf0e10cSrcweir }
601cdf0e10cSrcweir #endif // 0
602cdf0e10cSrcweir 
603cdf0e10cSrcweir }   // namespace autodoc
604cdf0e10cSrcweir 
605cdf0e10cSrcweir 
606cdf0e10cSrcweir 
607cdf0e10cSrcweir 
608