Bump for 3.6-28
[LibreOffice.git] / autodoc / source / exes / adc_uni / adc_cmd_parse.cxx
blob43c26ba149056721318169c8925e30a65bce2739
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include <precomp.h>
30 #include "adc_cmd_parse.hxx"
33 // NOT FULLY DEFINED SERVICES
34 #include <cosv/tpl/tpltools.hxx>
35 #include <adc_cl.hxx>
36 #include "adc_cmds.hxx"
37 #include "cmd_run.hxx"
41 namespace autodoc
43 namespace command
46 namespace
49 const String C_FileEnding_idl("*.idl");
51 inline void
52 CHECK( bool b, const String & text )
54 if (NOT b)
55 throw X_CommandLine( text );
58 } // anonymous namespace
62 //************************** S_LanguageInfo ***********************//
64 S_LanguageInfo::~S_LanguageInfo()
68 void
69 S_LanguageInfo::do_Init( opt_iter & it,
70 opt_iter itEnd )
72 ++it; // Cur is language.
73 CHECKOPT( it != itEnd AND
74 *it == C_arg_Idl,
75 "language",
76 C_opt_LangAll );
78 if ( *it == C_arg_Idl ) {
79 eLanguage = idl;
81 else {
82 csv_assert(false);
85 switch (eLanguage)
87 case idl: aExtensions.push_back( C_FileEnding_idl );
88 CommandLine::Get_().Set_IdlUsed();
89 break;
90 default: // do nothing.
94 ++it; // Cur is next option.
97 void
98 S_LanguageInfo::InitExtensions( opt_iter & it,
99 opt_iter itEnd )
101 ++it;
102 CHECKOPT( it != itEnd AND (*it).char_at(0) == '.',
103 "extensions",
104 C_opt_ExtensionsAll );
106 StreamLock slCheck(150);
107 slCheck() << C_opt_ExtensionsAll
108 << " used without previous "
109 << C_opt_LangAll;
111 CHECK( eLanguage != none,
112 slCheck().c_str() );
114 do {
115 aExtensions.push_back(*it);
116 ++it;
117 } while (it != itEnd AND (*it).char_at(0) == '.');
122 //************************** Parse ***********************//
124 Parse::Parse()
125 : sRepositoryName(),
126 aGlobalLanguage(),
127 aProjects(),
128 sDevelopersManual_RefFilePath()
132 Parse::~Parse()
134 csv::erase_container_of_heap_ptrs(aProjects);
137 void
138 Parse::do_Init( opt_iter & it,
139 opt_iter itEnd )
141 for ( ; it != itEnd; )
143 if (*it == C_opt_Name)
144 do_clName(it, itEnd);
145 else if (*it == C_opt_LangAll)
146 aGlobalLanguage.Init(it, itEnd);
147 else if (*it == C_opt_ExtensionsAll)
148 aGlobalLanguage.InitExtensions(it, itEnd);
149 else if (*it == C_opt_DevmanFile)
150 do_clDevManual(it, itEnd);
151 else if (*it == C_opt_Project)
152 do_clProject(it, itEnd);
153 else if ( *it == C_opt_SourceTree
154 OR *it == C_opt_SourceDir
155 OR *it == C_opt_SourceFile )
156 do_clDefaultProject(it, itEnd);
157 else
158 break;
159 } // for
162 void
163 Parse::do_clName( opt_iter & it,
164 opt_iter itEnd )
166 ++it;
167 CHECKOPT( it != itEnd AND (*it).char_at(0) != '-',
168 "name",
169 C_opt_Name );
170 sRepositoryName = *it;
171 ++it;
174 void
175 Parse::do_clDevManual( opt_iter & it,
176 opt_iter itEnd )
178 ++it;
179 CHECKOPT( it != itEnd AND (*it).char_at(0) != '-',
180 "link file path",
181 C_opt_DevmanFile );
182 sDevelopersManual_RefFilePath = *it;
183 ++it;
186 void
187 Parse::do_clProject( opt_iter & it,
188 opt_iter itEnd )
190 if ( aProjects.size() == 1 )
192 if ( aProjects.front()->IsDefault() )
193 throw X_CommandLine( "Both, named projects and a default project, cannot be used together." );
196 S_ProjectData * dpProject = new S_ProjectData(aGlobalLanguage);
197 ++it;
198 dpProject->Init(it, itEnd);
199 aProjects.push_back(dpProject);
202 void
203 Parse::do_clDefaultProject( opt_iter & it,
204 opt_iter itEnd )
206 if ( !aProjects.empty() )
208 throw X_CommandLine( "Both, named projects and a default project, cannot be used together." );
211 S_ProjectData * dpProject = new S_ProjectData( aGlobalLanguage,
212 S_ProjectData::default_prj );
213 dpProject->Init(it, itEnd);
214 aProjects.push_back(dpProject);
217 bool
218 Parse::do_Run() const
220 run::Parser
221 aParser(*this);
222 return aParser.Perform();
226 Parse::inq_RunningRank() const
228 return static_cast<int>(rank_Parse);
233 //************************** S_Sources ***********************//
235 void
236 S_Sources::do_Init( opt_iter & it,
237 opt_iter itEnd )
239 StringVector *
240 pList = 0;
241 csv_assert((*it)[0] == '-');
243 for ( ; it != itEnd; ++it)
245 if ((*it)[0] == '-')
247 if (*it == C_opt_SourceTree)
248 pList = &aTrees;
249 else if (*it == C_opt_SourceDir)
250 pList = &aDirectories;
251 else if (*it == C_opt_SourceFile)
252 pList = &aFiles;
253 else
254 return;
256 else
257 pList->push_back(*it);
258 } // end for
263 //************************** S_ProjectData ***********************//
266 S_ProjectData::S_ProjectData( const S_LanguageInfo & i_globalLanguage )
267 : sName(),
268 aRootDirectory(),
269 aLanguage(i_globalLanguage),
270 aFiles(),
271 bIsDefault(false)
275 S_ProjectData::S_ProjectData( const S_LanguageInfo & i_globalLanguage,
276 E_Default )
277 : sName(),
278 aRootDirectory("."),
279 aLanguage(i_globalLanguage),
280 aFiles(),
281 bIsDefault(true)
285 S_ProjectData::~S_ProjectData()
289 void
290 S_ProjectData::do_Init( opt_iter & it,
291 opt_iter itEnd )
293 if (NOT IsDefault())
295 CHECKOPT( it != itEnd AND (*it).char_at(0) != '-',
296 "name",
297 C_opt_Project );
298 sName = *it;
299 ++it;
301 CHECKOPT( it != itEnd AND (*it).char_at(0) != '-',
302 "root directory",
303 C_opt_Project );
304 aRootDirectory.Set((*it).c_str(), true);
305 ++it;
308 for ( ; it != itEnd; )
310 if ( *it == C_opt_SourceTree
311 OR *it == C_opt_SourceDir
312 OR *it == C_opt_SourceFile )
313 aFiles.Init(it, itEnd);
314 // else if (*it == C_opt_Lang)
315 // aLanguage.Init(it, itEnd);
316 // else if (*it == C_opt_Extensions)
317 // aLanguage.InitExtensions(it, itEnd);
318 else
319 break;
320 } // for
323 } // namespace command
324 } // namespace autodoc
328 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */