1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef ADC_ADC_CMD_PARSE_HXX
29 #define ADC_ADC_CMD_PARSE_HXX
30 
31 
32 
33 // USED SERVICES
34 	// BASE CLASSES
35 #include "adc_cmd.hxx"
36 	// COMPONENTS
37 #include <cosv/ploc.hxx>
38 	// PARAMETERS
39 
40 namespace autodoc
41 {
42 namespace command
43 {
44 
45 /** A command context which holds the currently parsed programing language
46     and its valid file extensions.
47 */
48 struct S_LanguageInfo : public Context
49 {
50     enum E_ProgrammingLanguage
51     {
52         none,
53         cpp,
54         idl,
55         java
56     };
57                         S_LanguageInfo()
58                             :   eLanguage(none),
59                                 aExtensions() {}
60                         ~S_LanguageInfo();
61 
62     void                InitExtensions(
63                             opt_iter &          it,
64                             opt_iter            itEnd );
65     // DATA
66     E_ProgrammingLanguage
67                         eLanguage;
68     StringVector        aExtensions;        // An empty string is possible and means exactly that: files without extension.
69 
70   private:
71     // Interface Context:
72     virtual void        do_Init(
73                             opt_iter &          it,
74                             opt_iter            itEnd );
75 };
76 
77 
78 class S_ProjectData;
79 
80 
81 /** A command that parses source code into the Autodoc Repository.
82 */
83 class Parse : public Command
84 {
85   public:
86     typedef std::vector< DYN S_ProjectData * >  ProjectList;
87     typedef ProjectList::const_iterator         ProjectIterator;
88 
89                         Parse();
90                         ~Parse();
91 
92     // INQUIRY
93     const String &      ReposyName() const;
94     const S_LanguageInfo &
95                         GlobalLanguage() const;
96     ProjectIterator     ProjectsBegin() const;
97     ProjectIterator     ProjectsEnd() const;
98     const String &      DevelopersManual_RefFilePath() const
99                                                 { return sDevelopersManual_RefFilePath; }
100 
101   private:
102     // Interface Context:
103     virtual void        do_Init(
104                             opt_iter &          i_nCurArgsBegin,
105                             opt_iter            i_nEndOfAllArgs );
106     // Interface Command:
107     virtual bool        do_Run() const;
108     virtual int         inq_RunningRank() const;
109 
110     // Locals
111     void                do_clName(
112                             opt_iter &          it,
113                             opt_iter            itEnd );
114     void                do_clDevManual(
115                             opt_iter &          it,
116                             opt_iter            itEnd );
117     void                do_clProject(
118                             opt_iter &          it,
119                             opt_iter            itEnd );
120     void                do_clDefaultProject(
121                             opt_iter &          it,
122                             opt_iter            itEnd );
123 
124     // DATA
125     String              sRepositoryName;
126     S_LanguageInfo      aGlobalLanguage;
127 
128     ProjectList         aProjects;
129 
130     String              sDevelopersManual_RefFilePath;
131 };
132 
133 inline const String &
134 Parse::ReposyName() const
135     { return sRepositoryName; }
136 inline const S_LanguageInfo &
137 Parse::GlobalLanguage() const
138     { return aGlobalLanguage; }
139 inline Parse::ProjectIterator
140 Parse::ProjectsBegin() const
141     { return aProjects.begin(); }
142 inline Parse::ProjectIterator
143 Parse::ProjectsEnd() const
144     { return aProjects.end(); }
145 //inline const String &
146 //Parse::DevelopersManual_RefFilePath() const
147 //    { return sDevelopersManual_RefFilePath; }
148 //inline const String &
149 //Parse::DevelopersManual_HtmlRoot() const
150 //    { return sDevelopersManual_HtmlRoot; }
151 
152 
153 struct S_Sources : public Context
154 {
155     StringVector        aTrees;
156     StringVector        aDirectories;
157     StringVector        aFiles;
158 
159   private:
160     // Interface Context:
161     virtual void        do_Init(
162                             opt_iter &          it,
163                             opt_iter            itEnd );
164 };
165 
166 class S_ProjectData : public Context
167 {
168   public:
169     enum E_Default { default_prj };
170 
171                         S_ProjectData(
172                             const S_LanguageInfo &
173                                                 i_globalLanguage );
174                         S_ProjectData(
175                             const S_LanguageInfo &
176                                                 i_globalLanguage,
177                             E_Default           unused );
178                         ~S_ProjectData();
179 
180     bool                IsDefault() const       { return bIsDefault; }
181     const String &      Name() const            { return sName; }
182     const csv::ploc::Path &
183                         RootDirectory() const   { return aRootDirectory; }
184     const S_LanguageInfo &
185                         Language() const        { return aLanguage; }
186     const S_Sources     Sources() const         { return aFiles; }
187 
188   private:
189     // Interface Context:
190     virtual void        do_Init(
191                             opt_iter &          it,
192                             opt_iter            itEnd );
193     // Locals
194 
195     // DATA
196     String              sName;
197     csv::ploc::Path     aRootDirectory;
198     S_LanguageInfo      aLanguage;
199     S_Sources           aFiles;
200     bool                bIsDefault;
201 };
202 
203 
204 }   // namespace command
205 }   // namespace autodoc
206 
207 
208 #endif
209