1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef ADC_ADC_CMD_PARSE_HXX
25 #define ADC_ADC_CMD_PARSE_HXX
26 
27 
28 
29 // USED SERVICES
30 	// BASE CLASSES
31 #include "adc_cmd.hxx"
32 	// COMPONENTS
33 #include <cosv/ploc.hxx>
34 	// PARAMETERS
35 
36 namespace autodoc
37 {
38 namespace command
39 {
40 
41 /** A command context which holds the currently parsed programing language
42     and its valid file extensions.
43 */
44 struct S_LanguageInfo : public Context
45 {
46     enum E_ProgrammingLanguage
47     {
48         none,
49         cpp,
50         idl,
51         java
52     };
S_LanguageInfoautodoc::command::S_LanguageInfo53                         S_LanguageInfo()
54                             :   eLanguage(none),
55                                 aExtensions() {}
56                         ~S_LanguageInfo();
57 
58     void                InitExtensions(
59                             opt_iter &          it,
60                             opt_iter            itEnd );
61     // DATA
62     E_ProgrammingLanguage
63                         eLanguage;
64     StringVector        aExtensions;        // An empty string is possible and means exactly that: files without extension.
65 
66   private:
67     // Interface Context:
68     virtual void        do_Init(
69                             opt_iter &          it,
70                             opt_iter            itEnd );
71 };
72 
73 
74 class S_ProjectData;
75 
76 
77 /** A command that parses source code into the Autodoc Repository.
78 */
79 class Parse : public Command
80 {
81   public:
82     typedef std::vector< DYN S_ProjectData * >  ProjectList;
83     typedef ProjectList::const_iterator         ProjectIterator;
84 
85                         Parse();
86                         ~Parse();
87 
88     // INQUIRY
89     const String &      ReposyName() const;
90     const S_LanguageInfo &
91                         GlobalLanguage() const;
92     ProjectIterator     ProjectsBegin() const;
93     ProjectIterator     ProjectsEnd() const;
DevelopersManual_RefFilePath() const94     const String &      DevelopersManual_RefFilePath() const
95                                                 { return sDevelopersManual_RefFilePath; }
96 
97   private:
98     // Interface Context:
99     virtual void        do_Init(
100                             opt_iter &          i_nCurArgsBegin,
101                             opt_iter            i_nEndOfAllArgs );
102     // Interface Command:
103     virtual bool        do_Run() const;
104     virtual int         inq_RunningRank() const;
105 
106     // Locals
107     void                do_clName(
108                             opt_iter &          it,
109                             opt_iter            itEnd );
110     void                do_clDevManual(
111                             opt_iter &          it,
112                             opt_iter            itEnd );
113     void                do_clProject(
114                             opt_iter &          it,
115                             opt_iter            itEnd );
116     void                do_clDefaultProject(
117                             opt_iter &          it,
118                             opt_iter            itEnd );
119 
120     // DATA
121     String              sRepositoryName;
122     S_LanguageInfo      aGlobalLanguage;
123 
124     ProjectList         aProjects;
125 
126     String              sDevelopersManual_RefFilePath;
127 };
128 
129 inline const String &
ReposyName() const130 Parse::ReposyName() const
131     { return sRepositoryName; }
132 inline const S_LanguageInfo &
GlobalLanguage() const133 Parse::GlobalLanguage() const
134     { return aGlobalLanguage; }
135 inline Parse::ProjectIterator
ProjectsBegin() const136 Parse::ProjectsBegin() const
137     { return aProjects.begin(); }
138 inline Parse::ProjectIterator
ProjectsEnd() const139 Parse::ProjectsEnd() const
140     { return aProjects.end(); }
141 //inline const String &
142 //Parse::DevelopersManual_RefFilePath() const
143 //    { return sDevelopersManual_RefFilePath; }
144 //inline const String &
145 //Parse::DevelopersManual_HtmlRoot() const
146 //    { return sDevelopersManual_HtmlRoot; }
147 
148 
149 struct S_Sources : public Context
150 {
151     StringVector        aTrees;
152     StringVector        aDirectories;
153     StringVector        aFiles;
154 
155   private:
156     // Interface Context:
157     virtual void        do_Init(
158                             opt_iter &          it,
159                             opt_iter            itEnd );
160 };
161 
162 class S_ProjectData : public Context
163 {
164   public:
165     enum E_Default { default_prj };
166 
167                         S_ProjectData(
168                             const S_LanguageInfo &
169                                                 i_globalLanguage );
170                         S_ProjectData(
171                             const S_LanguageInfo &
172                                                 i_globalLanguage,
173                             E_Default           unused );
174                         ~S_ProjectData();
175 
IsDefault() const176     bool                IsDefault() const       { return bIsDefault; }
Name() const177     const String &      Name() const            { return sName; }
178     const csv::ploc::Path &
RootDirectory() const179                         RootDirectory() const   { return aRootDirectory; }
180     const S_LanguageInfo &
Language() const181                         Language() const        { return aLanguage; }
Sources() const182     const S_Sources     Sources() const         { return aFiles; }
183 
184   private:
185     // Interface Context:
186     virtual void        do_Init(
187                             opt_iter &          it,
188                             opt_iter            itEnd );
189     // Locals
190 
191     // DATA
192     String              sName;
193     csv::ploc::Path     aRootDirectory;
194     S_LanguageInfo      aLanguage;
195     S_Sources           aFiles;
196     bool                bIsDefault;
197 };
198 
199 
200 }   // namespace command
201 }   // namespace autodoc
202 
203 
204 #endif
205