1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: adc_cmd_parse.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 #include "adc_cmd_parse.hxx"
35 // NOT FULLY DEFINED SERVICES
36 #include <cosv/tpl/tpltools.hxx>
38 #include "adc_cmds.hxx"
39 #include "cmd_run.hxx"
51 const String
C_FileEnding_hxx("*.hxx");
52 const String
C_FileEnding_h("*.h");
53 const String
C_FileEnding_idl("*.idl");
54 const String
C_FileEnding_java("*.java");
57 CHECK( bool b
, const String
& text
)
60 throw X_CommandLine( text
);
63 } // anonymous namespace
67 //************************** S_LanguageInfo ***********************//
69 S_LanguageInfo::~S_LanguageInfo()
74 S_LanguageInfo::do_Init( opt_iter
& it
,
77 ++it
; // Cur is language.
78 CHECKOPT( it
!= itEnd AND
79 ( *it
== C_arg_Cplusplus OR
85 if ( *it
== C_arg_Cplusplus
) {
88 else if ( *it
== C_arg_Idl
) {
91 else if ( *it
== C_arg_Java
) {
100 case cpp
: aExtensions
.push_back( C_FileEnding_hxx
);
101 aExtensions
.push_back( C_FileEnding_h
);
102 CommandLine::Get_().Set_CppUsed();
104 case idl
: aExtensions
.push_back( C_FileEnding_idl
);
105 CommandLine::Get_().Set_IdlUsed();
107 case java
: aExtensions
.push_back( C_FileEnding_java
);
109 default: // do nothing.
113 ++it
; // Cur is next option.
117 S_LanguageInfo::InitExtensions( opt_iter
& it
,
121 CHECKOPT( it
!= itEnd
AND (*it
).char_at(0) == '.',
123 C_opt_ExtensionsAll
);
125 StreamLock
slCheck(150);
126 slCheck() << C_opt_ExtensionsAll
127 << " used without previous "
130 CHECK( eLanguage
!= none
,
134 aExtensions
.push_back(*it
);
136 } while (it
!= itEnd
AND (*it
).char_at(0) == '.');
141 //************************** Parse ***********************//
147 sDevelopersManual_RefFilePath()
153 csv::erase_container_of_heap_ptrs(aProjects
);
157 Parse::do_Init( opt_iter
& it
,
160 for ( ; it
!= itEnd
; )
162 if (*it
== C_opt_Name
)
163 do_clName(it
, itEnd
);
164 else if (*it
== C_opt_LangAll
)
165 aGlobalLanguage
.Init(it
, itEnd
);
166 else if (*it
== C_opt_ExtensionsAll
)
167 aGlobalLanguage
.InitExtensions(it
, itEnd
);
168 else if (*it
== C_opt_DevmanFile
)
169 do_clDevManual(it
, itEnd
);
170 else if (*it
== C_opt_Project
)
171 do_clProject(it
, itEnd
);
172 else if ( *it
== C_opt_SourceTree
173 OR
*it
== C_opt_SourceDir
174 OR
*it
== C_opt_SourceFile
)
175 do_clDefaultProject(it
, itEnd
);
182 Parse::do_clName( opt_iter
& it
,
186 CHECKOPT( it
!= itEnd
AND (*it
).char_at(0) != '-',
189 sRepositoryName
= *it
;
194 Parse::do_clDevManual( opt_iter
& it
,
198 CHECKOPT( it
!= itEnd
AND (*it
).char_at(0) != '-',
201 sDevelopersManual_RefFilePath
= *it
;
206 Parse::do_clProject( opt_iter
& it
,
209 if ( aProjects
.size() == 1 )
211 if ( aProjects
.front()->IsDefault() )
212 throw X_CommandLine( "Both, named projects and a default project, cannot be used together." );
215 S_ProjectData
* dpProject
= new S_ProjectData(aGlobalLanguage
);
217 dpProject
->Init(it
, itEnd
);
218 aProjects
.push_back(dpProject
);
222 Parse::do_clDefaultProject( opt_iter
& it
,
225 if ( aProjects
.size() > 0 )
227 throw X_CommandLine( "Both, named projects and a default project, cannot be used together." );
230 S_ProjectData
* dpProject
= new S_ProjectData( aGlobalLanguage
,
231 S_ProjectData::default_prj
);
232 dpProject
->Init(it
, itEnd
);
233 aProjects
.push_back(dpProject
);
237 Parse::do_Run() const
241 return aParser
.Perform();
245 Parse::inq_RunningRank() const
247 return static_cast<int>(rank_Parse
);
252 //************************** S_Sources ***********************//
255 S_Sources::do_Init( opt_iter
& it
,
260 csv_assert((*it
)[0] == '-');
262 for ( ; it
!= itEnd
; ++it
)
266 if (*it
== C_opt_SourceTree
)
268 else if (*it
== C_opt_SourceDir
)
269 pList
= &aDirectories
;
270 else if (*it
== C_opt_SourceFile
)
276 pList
->push_back(*it
);
282 //************************** S_ProjectData ***********************//
285 S_ProjectData::S_ProjectData( const S_LanguageInfo
& i_globalLanguage
)
288 aLanguage(i_globalLanguage
),
294 S_ProjectData::S_ProjectData( const S_LanguageInfo
& i_globalLanguage
,
298 aLanguage(i_globalLanguage
),
304 S_ProjectData::~S_ProjectData()
309 S_ProjectData::do_Init( opt_iter
& it
,
314 CHECKOPT( it
!= itEnd
AND (*it
).char_at(0) != '-',
320 CHECKOPT( it
!= itEnd
AND (*it
).char_at(0) != '-',
323 aRootDirectory
.Set((*it
).c_str(), true);
327 for ( ; it
!= itEnd
; )
329 if ( *it
== C_opt_SourceTree
330 OR
*it
== C_opt_SourceDir
331 OR
*it
== C_opt_SourceFile
)
332 aFiles
.Init(it
, itEnd
);
333 // else if (*it == C_opt_Lang)
334 // aLanguage.Init(it, itEnd);
335 // else if (*it == C_opt_Extensions)
336 // aLanguage.InitExtensions(it, itEnd);
342 } // namespace command
343 } // namespace autodoc