xref: /aoo41x/main/autodoc/source/parser/cpp/pev.hxx (revision cdf0e10c)
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_CPP_PEV_HXX
29 #define ADC_CPP_PEV_HXX
30 
31 
32 
33 // USED SERVICES
34 	// BASE CLASSES
35 #include <tokens/tokproct.hxx>
36 	// COMPONENTS
37 	// PARAMETERS
38 #include <ary/cpp/c_types4cpp.hxx>
39 
40 namespace ary
41 {
42     namespace cpp
43     {
44         class Gate;
45         class InputContext;
46 
47         class Namespace;
48         class Class;
49         class Enum;
50         class Typedef;
51         class Function;
52         class Variable;
53         class EnumValue;
54 
55         class DefineEntity;
56     }
57 
58     class Documentation;
59 }
60 
61 
62 namespace cpp
63 {
64 
65 
66 class PeEnvironment : protected TokenProcessing_Types
67 {
68   public:
69     // INQUIRY
70 	virtual				~PeEnvironment() {}
71 
72     // OPERATIONS
73         // Token results
74 	void				SetTokenResult(
75 							E_TokenDone			i_eDone,
76 							E_EnvStackAction	i_eWhat2DoWithEnvStack,
77 							ParseEnvironment *	i_pParseEnv2Push = 0 );
78 
79         // Owner stack
80 	void                OpenNamespace(
81 							ary::cpp::Namespace &
82                                                 io_rOpenedNamespace );
83 	void                OpenExternC(
84 	                    	bool				i_bOnlyForOneDeclaration = false );
85 	void                OpenClass(
86 							ary::cpp::Class &	io_rOpenedClass );
87 	void                OpenEnum(
88 							ary::cpp::Enum &	io_rOpenedEnum );
89 	void                CloseBlock();           /// Handles a '}' on file scope.
90 	void                CloseClass();
91 	void                CloseEnum();
92     void                SetCurProtection(       /// Handles 'public:', 'protected:' and 'private:' on class scope.
93                             ary::cpp::E_Protection
94                                                 i_eProtection );
95     void                OpenTemplate(
96                             const StringVector &
97                                                 i_rParameters );
98     /// Removes parameters from this object.
99     DYN StringVector *  Get_CurTemplateParameters();
100     /// Checks, if a template is still open, and if yes, closes it.
101     void                Close_OpenTemplate();
102 
103         // Special events
104     void                Event_Class_FinishedBase(
105                             const String  &     i_sParameterName );
106 
107     void                Event_Store_Typedef(
108                             ary::cpp::Typedef & io_rTypedef );
109     void                Event_Store_EnumValue(
110                             ary::cpp::EnumValue &
111                                                 io_rEnumValue );
112     void                Event_Store_CppDefinition(
113                             ary::cpp::DefineEntity  &
114                                                 io_rDefinition );
115 
116     void                Event_EnterFunction_ParameterList();
117     void                Event_Function_FinishedParameter(
118                             const String  &     i_sParameterName );
119     void                Event_LeaveFunction_ParameterList();
120     void                Event_EnterFunction_Implementation();
121     void                Event_LeaveFunction_Implementation();
122 
123     void                Event_Store_Function(
124                             ary::cpp::Function &
125                                                 io_rFunction );
126     void                Event_Store_Variable(
127                             ary::cpp::Variable &
128                                                 io_rVariable );
129         // Error recovery
130     void                StartWaitingFor_Recovery();
131 
132     // INQUIRY
133     ary::cpp::Gate &  AryGate() const;
134 	const ary::cpp::InputContext &
135 						Context() const;
136 	String              CurFileName() const;
137 	uintt               LineCount() const;
138 	bool                IsWaitingFor_Recovery() const;
139 	bool                IsExternC() const;
140 
141   private:
142 	virtual void        do_SetTokenResult(
143 							E_TokenDone			i_eDone,
144 							E_EnvStackAction	i_eWhat2DoWithEnvStack,
145 							ParseEnvironment *	i_pParseEnv2Push ) = 0;
146 	virtual void        do_OpenNamespace(
147 							ary::cpp::Namespace &
148 												io_rOpenedNamespace ) = 0;
149 	virtual void        do_OpenExternC(
150 							bool				i_bOnlyForOneDeclaration ) = 0;
151 	virtual void        do_OpenClass(
152 							ary::cpp::Class &	io_rOpenedClass ) = 0;
153 	virtual void        do_OpenEnum(
154 							ary::cpp::Enum &	io_rOpenedEnum ) = 0;
155 	virtual void        do_CloseBlock() = 0;
156 	virtual void        do_CloseClass() = 0;
157 	virtual void        do_CloseEnum() = 0;
158     virtual void        do_SetCurProtection(
159                             ary::cpp::E_Protection
160 												i_eProtection ) = 0;
161     virtual void        do_OpenTemplate(
162                             const StringVector &
163                                                 i_rParameters ) = 0;
164     virtual DYN StringVector *
165                         do_Get_CurTemplateParameters() = 0;
166     virtual void        do_Close_OpenTemplate() = 0;
167 	virtual void        do_Event_Class_FinishedBase(
168                             const String  &     i_sBaseName ) = 0;
169 
170     virtual void        do_Event_Store_Typedef(
171 							ary::cpp::Typedef & io_rTypedef ) = 0;
172     virtual void        do_Event_Store_EnumValue(
173                             ary::cpp::EnumValue &
174                                                 io_rEnumValue ) = 0;
175     virtual void        do_Event_Store_CppDefinition(
176                             ary::cpp::DefineEntity &
177                                                 io_rDefinition ) = 0;
178     virtual void        do_Event_EnterFunction_ParameterList() = 0;
179     virtual void        do_Event_Function_FinishedParameter(
180                             const String  &     i_sParameterName ) = 0;
181 	virtual void        do_Event_LeaveFunction_ParameterList() = 0;
182     virtual void        do_Event_EnterFunction_Implementation() = 0;
183     virtual void        do_Event_LeaveFunction_Implementation() = 0;
184     virtual void        do_Event_Store_Function(
185 							ary::cpp::Function &
186                                                 io_rFunction ) = 0;
187 	virtual void        do_Event_Store_Variable(
188                             ary::cpp::Variable &
189                                                 io_rVariable ) = 0;
190     virtual void        do_StartWaitingFor_Recovery() = 0;
191     virtual ary::cpp::Gate &
192 						inq_AryGate() const = 0;
193 	virtual const ary::cpp::InputContext &
194 						inq_Context() const = 0;
195 	virtual String 		inq_CurFileName() const = 0;
196 	virtual uintt       inq_LineCount() const = 0;
197     virtual bool        inq_IsWaitingFor_Recovery() const = 0;
198 	virtual bool        inq_IsExternC() const = 0;
199 };
200 
201 
202 
203 // IMPLEMENTATION
204 
205 inline void
206 PeEnvironment::SetTokenResult( E_TokenDone			i_eDone,
207 							   E_EnvStackAction	    i_eWhat2DoWithEnvStack,
208 							   ParseEnvironment *	i_pParseEnv2Push )
209     { do_SetTokenResult(i_eDone, i_eWhat2DoWithEnvStack,  i_pParseEnv2Push); }
210 inline void
211 PeEnvironment::OpenNamespace( ary::cpp::Namespace & io_rOpenedNamespace )
212 	{ do_OpenNamespace(io_rOpenedNamespace); }
213 inline void
214 PeEnvironment::OpenExternC( bool i_bOnlyForOneDeclaration )
215     { do_OpenExternC(i_bOnlyForOneDeclaration); }
216 inline void
217 PeEnvironment::OpenClass( ary::cpp::Class &	io_rOpenedClass )
218     { do_OpenClass(io_rOpenedClass); }
219 inline void
220 PeEnvironment::OpenEnum( ary::cpp::Enum & io_rOpenedEnum )
221     { do_OpenEnum(io_rOpenedEnum); }
222 inline void
223 PeEnvironment::CloseBlock()
224     { do_CloseBlock(); }
225 inline void
226 PeEnvironment::CloseClass()
227     { do_CloseClass(); }
228 inline void
229 PeEnvironment::CloseEnum()
230     { do_CloseEnum(); }
231 inline void
232 PeEnvironment::SetCurProtection( ary::cpp::E_Protection i_eProtection )
233     { do_SetCurProtection(i_eProtection); }
234 inline void
235 PeEnvironment::OpenTemplate( const StringVector & i_rParameters )
236     { do_OpenTemplate(i_rParameters); }
237 inline DYN StringVector *
238 PeEnvironment::Get_CurTemplateParameters()
239     { return do_Get_CurTemplateParameters(); }
240 inline void
241 PeEnvironment::Close_OpenTemplate()
242     { do_Close_OpenTemplate(); }
243 inline void
244 PeEnvironment::Event_Class_FinishedBase( const String  &  i_sBaseName )
245     { do_Event_Class_FinishedBase(i_sBaseName); }
246 inline void
247 PeEnvironment::Event_Store_Typedef( ary::cpp::Typedef & io_rTypedef )
248     { do_Event_Store_Typedef(io_rTypedef); }
249 inline void
250 PeEnvironment::Event_Store_EnumValue( ary::cpp::EnumValue & io_rEnumValue )
251     { do_Event_Store_EnumValue(io_rEnumValue); }
252 inline void
253 PeEnvironment::Event_Store_CppDefinition( ary::cpp::DefineEntity & io_rDefinition )
254     { do_Event_Store_CppDefinition(io_rDefinition); }
255 inline void
256 PeEnvironment::Event_EnterFunction_ParameterList()
257     { do_Event_EnterFunction_ParameterList(); }
258 inline void
259 PeEnvironment::Event_Function_FinishedParameter( const String  & i_sParameterName )
260     { do_Event_Function_FinishedParameter(i_sParameterName); }
261 inline void
262 PeEnvironment::Event_LeaveFunction_ParameterList()
263     { do_Event_LeaveFunction_ParameterList(); }
264 inline void
265 PeEnvironment::Event_EnterFunction_Implementation()
266     { do_Event_EnterFunction_Implementation(); }
267 inline void
268 PeEnvironment::Event_LeaveFunction_Implementation()
269 	{ do_Event_LeaveFunction_Implementation(); }
270 inline void
271 PeEnvironment::Event_Store_Function( ary::cpp::Function & io_rFunction )
272 	{ do_Event_Store_Function(io_rFunction); }
273 inline void
274 PeEnvironment::Event_Store_Variable( ary::cpp::Variable & io_rVariable )
275 	{ do_Event_Store_Variable(io_rVariable); }
276 inline void
277 PeEnvironment::StartWaitingFor_Recovery()
278 	{ do_StartWaitingFor_Recovery(); }
279 inline ary::cpp::Gate &
280 PeEnvironment::AryGate() const
281 	{ return inq_AryGate(); }
282 inline const ary::cpp::InputContext &
283 PeEnvironment::Context() const
284 	{ return inq_Context(); }
285 inline String
286 PeEnvironment::CurFileName() const
287 	{ return inq_CurFileName(); }
288 inline uintt
289 PeEnvironment::LineCount() const
290 	{ return inq_LineCount(); }
291 inline bool
292 PeEnvironment::IsWaitingFor_Recovery() const
293     { return inq_IsWaitingFor_Recovery(); }
294 inline bool
295 PeEnvironment::IsExternC() const
296     { return inq_IsExternC(); }
297 
298 
299 
300 }   // namespace cpp
301 
302 
303 #endif
304 
305