merge the formfield patch from ooo-build
[ooovba.git] / autodoc / source / exes / adc_uni / adc_cmd_parse.cxx
blob108dce0c89431a0b534c91e0c92d2fbcdeafd9a7
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: adc_cmd_parse.cxx,v $
10 * $Revision: 1.11 $
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 ************************************************************************/
31 #include <precomp.h>
32 #include "adc_cmd_parse.hxx"
35 // NOT FULLY DEFINED SERVICES
36 #include <cosv/tpl/tpltools.hxx>
37 #include <adc_cl.hxx>
38 #include "adc_cmds.hxx"
39 #include "cmd_run.hxx"
43 namespace autodoc
45 namespace command
48 namespace
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");
56 inline void
57 CHECK( bool b, const String & text )
59 if (NOT b)
60 throw X_CommandLine( text );
63 } // anonymous namespace
67 //************************** S_LanguageInfo ***********************//
69 S_LanguageInfo::~S_LanguageInfo()
73 void
74 S_LanguageInfo::do_Init( opt_iter & it,
75 opt_iter itEnd )
77 ++it; // Cur is language.
78 CHECKOPT( it != itEnd AND
79 ( *it == C_arg_Cplusplus OR
80 *it == C_arg_Idl OR
81 *it == C_arg_Java ),
82 "language",
83 C_opt_LangAll );
85 if ( *it == C_arg_Cplusplus ) {
86 eLanguage = cpp;
88 else if ( *it == C_arg_Idl ) {
89 eLanguage = idl;
91 else if ( *it == C_arg_Java ) {
92 eLanguage = java;
94 else {
95 csv_assert(false);
98 switch (eLanguage)
100 case cpp: aExtensions.push_back( C_FileEnding_hxx );
101 aExtensions.push_back( C_FileEnding_h );
102 CommandLine::Get_().Set_CppUsed();
103 break;
104 case idl: aExtensions.push_back( C_FileEnding_idl );
105 CommandLine::Get_().Set_IdlUsed();
106 break;
107 case java: aExtensions.push_back( C_FileEnding_java );
108 break;
109 default: // do nothing.
113 ++it; // Cur is next option.
116 void
117 S_LanguageInfo::InitExtensions( opt_iter & it,
118 opt_iter itEnd )
120 ++it;
121 CHECKOPT( it != itEnd AND (*it).char_at(0) == '.',
122 "extensions",
123 C_opt_ExtensionsAll );
125 StreamLock slCheck(150);
126 slCheck() << C_opt_ExtensionsAll
127 << " used without previous "
128 << C_opt_LangAll;
130 CHECK( eLanguage != none,
131 slCheck().c_str() );
133 do {
134 aExtensions.push_back(*it);
135 ++it;
136 } while (it != itEnd AND (*it).char_at(0) == '.');
141 //************************** Parse ***********************//
143 Parse::Parse()
144 : sRepositoryName(),
145 aGlobalLanguage(),
146 aProjects(),
147 sDevelopersManual_RefFilePath()
151 Parse::~Parse()
153 csv::erase_container_of_heap_ptrs(aProjects);
156 void
157 Parse::do_Init( opt_iter & it,
158 opt_iter itEnd )
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);
176 else
177 break;
178 } // for
181 void
182 Parse::do_clName( opt_iter & it,
183 opt_iter itEnd )
185 ++it;
186 CHECKOPT( it != itEnd AND (*it).char_at(0) != '-',
187 "name",
188 C_opt_Name );
189 sRepositoryName = *it;
190 ++it;
193 void
194 Parse::do_clDevManual( opt_iter & it,
195 opt_iter itEnd )
197 ++it;
198 CHECKOPT( it != itEnd AND (*it).char_at(0) != '-',
199 "link file path",
200 C_opt_DevmanFile );
201 sDevelopersManual_RefFilePath = *it;
202 ++it;
205 void
206 Parse::do_clProject( opt_iter & it,
207 opt_iter itEnd )
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);
216 ++it;
217 dpProject->Init(it, itEnd);
218 aProjects.push_back(dpProject);
221 void
222 Parse::do_clDefaultProject( opt_iter & it,
223 opt_iter itEnd )
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);
236 bool
237 Parse::do_Run() const
239 run::Parser
240 aParser(*this);
241 return aParser.Perform();
245 Parse::inq_RunningRank() const
247 return static_cast<int>(rank_Parse);
252 //************************** S_Sources ***********************//
254 void
255 S_Sources::do_Init( opt_iter & it,
256 opt_iter itEnd )
258 StringVector *
259 pList = 0;
260 csv_assert((*it)[0] == '-');
262 for ( ; it != itEnd; ++it)
264 if ((*it)[0] == '-')
266 if (*it == C_opt_SourceTree)
267 pList = &aTrees;
268 else if (*it == C_opt_SourceDir)
269 pList = &aDirectories;
270 else if (*it == C_opt_SourceFile)
271 pList = &aFiles;
272 else
273 return;
275 else
276 pList->push_back(*it);
277 } // end for
282 //************************** S_ProjectData ***********************//
285 S_ProjectData::S_ProjectData( const S_LanguageInfo & i_globalLanguage )
286 : sName(),
287 aRootDirectory(),
288 aLanguage(i_globalLanguage),
289 aFiles(),
290 bIsDefault(false)
294 S_ProjectData::S_ProjectData( const S_LanguageInfo & i_globalLanguage,
295 E_Default )
296 : sName(),
297 aRootDirectory("."),
298 aLanguage(i_globalLanguage),
299 aFiles(),
300 bIsDefault(true)
304 S_ProjectData::~S_ProjectData()
308 void
309 S_ProjectData::do_Init( opt_iter & it,
310 opt_iter itEnd )
312 if (NOT IsDefault())
314 CHECKOPT( it != itEnd AND (*it).char_at(0) != '-',
315 "name",
316 C_opt_Project );
317 sName = *it;
318 ++it;
320 CHECKOPT( it != itEnd AND (*it).char_at(0) != '-',
321 "root directory",
322 C_opt_Project );
323 aRootDirectory.Set((*it).c_str(), true);
324 ++it;
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);
337 else
338 break;
339 } // for
342 } // namespace command
343 } // namespace autodoc