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_CTX2ARY_HXX
29 #define ADC_CPP_CTX2ARY_HXX
30 
31 
32 
33 // USED SERVICES
34 	// BASE CLASSES
35 #include <ary/cpp/inpcontx.hxx>
36 #include <doc_deal.hxx>
37 #include "pev.hxx"
38 #include "fevnthdl.hxx"
39 	// COMPONENTS
40 	// PARAMETERS
41 
42 namespace ary
43 {
44 namespace loc
45 {
46     class File;
47 }
48 }
49 
50 
51 
52 namespace cpp
53 {
54 
55 
56 /** @descr
57     This class provides information about the context of an
58     CodeEntity, which is going to be stored in the repository.
59     The information is used mainly by class ary::cpp::Gate.
60 
61     Also it provides information for the parser about actual
62     state of several public variables.
63 
64     @todo
65     Include events, which allow correct storing of inline
66     documentation after enum values, parameters,
67     base classes.
68 */
69 class ContextForAry : public ary::cpp::InputContext,
70                       public cpp::PeEnvironment,
71                       public cpp::FileScope_EventHandler,
72                       public DocuDealer
73 {
74   public:
75     // LIFECYCLE
76                         ContextForAry(
77                             ary::cpp::Gate &  io_rAryGate );
78 	virtual				~ContextForAry();
79 
80     // OPERATIONS
81     void                ResetResult()           { aTokenResult.Reset(); }
82 
83     // INQUIRY
84     const TokenProcessing_Result &
85                         CurResult() const       { return aTokenResult; }
86     // ACCESS
87     TokenProcessing_Result &
88                         CurResult()             { return aTokenResult; }
89 
90   private:
91     // Interface ary::cpp::InputContext:
92     virtual ary::loc::File &
93                         inq_CurFile() const;
94     virtual ary::cpp::Namespace &
95                         inq_CurNamespace() const;
96     virtual ary::cpp::Class *
97                         inq_CurClass() const;
98     virtual ary::cpp::Enum *
99                         inq_CurEnum() const;
100 
101     virtual Owner &     inq_CurOwner() const;
102     virtual ary::cpp::E_Protection
103                         inq_CurProtection() const;
104 
105     // Interface PeEnvironment
106 	virtual void        do_SetTokenResult(
107 							E_TokenDone			i_eDone,
108 							E_EnvStackAction	i_eWhat2DoWithEnvStack,
109 							ParseEnvironment *	i_pParseEnv2Push );
110 	virtual void        do_OpenNamespace(
111 							ary::cpp::Namespace &
112                                                 io_rOpenedNamespace );
113 	virtual void        do_OpenExternC(
114 		                	bool				i_bOnlyForOneDeclaration );
115 	virtual void        do_OpenClass(
116 							ary::cpp::Class &	io_rOpenedClass );
117 	virtual void        do_OpenEnum(
118 							ary::cpp::Enum &	io_rOpenedEnum );
119 	virtual void        do_CloseBlock();
120 	virtual void        do_CloseClass();
121 	virtual void        do_CloseEnum();
122     virtual void        do_SetCurProtection(
123                             ary::cpp::E_Protection
124                                                 i_eProtection );
125     virtual void        do_OpenTemplate(
126                             const StringVector &
127                                                 i_rParameters );
128     virtual DYN StringVector *
129                         do_Get_CurTemplateParameters();
130     virtual void        do_Close_OpenTemplate();
131     virtual void        do_Event_Class_FinishedBase(
132                             const String  &     i_sBaseName );
133 
134     virtual void        do_Event_Store_Typedef(
135                             ary::cpp::Typedef & io_rTypedef );
136     virtual void        do_Event_Store_EnumValue(
137                             ary::cpp::EnumValue &
138                                                 io_rEnumValue );
139     virtual void        do_Event_Store_CppDefinition(
140                             ary::cpp::DefineEntity &
141                                                 io_rDefinition );
142     virtual void        do_Event_EnterFunction_ParameterList();
143     virtual void        do_Event_Function_FinishedParameter(
144                             const String  &     i_sParameterName );
145     virtual void        do_Event_LeaveFunction_ParameterList();
146     virtual void        do_Event_EnterFunction_Implementation();
147     virtual void        do_Event_LeaveFunction_Implementation();
148     virtual void        do_Event_Store_Function(
149                             ary::cpp::Function &
150                                                 io_rFunction );
151     virtual void        do_Event_Store_Variable(
152                             ary::cpp::Variable &
153                                                 io_rVariable );
154     virtual void        do_TakeDocu(
155 							DYN ary::doc::OldCppDocu &
156                                                 let_drInfo );
157     virtual void        do_StartWaitingFor_Recovery();
158     virtual ary::cpp::Gate &
159                         inq_AryGate() const;
160 	virtual const ary::cpp::InputContext &
161 						inq_Context() const;
162 	virtual String		inq_CurFileName() const;
163     virtual uintt       inq_LineCount() const;
164     virtual bool        inq_IsWaitingFor_Recovery() const;
165 	virtual bool        inq_IsExternC() const;
166 
167     // Interface FileScope_EventHandler
168     virtual void        do_SetCurFile(
169                             ary::loc::File &    io_rCurFile );
170     virtual void        do_Event_IncrLineCount();
171 	virtual void        do_Event_SwBracketOpen();
172 	virtual void        do_Event_SwBracketClose();
173 	virtual void        do_Event_Semicolon();
174 
175 	// Local types
176     struct S_FileScopeInfo;
177     struct S_OwnerStack;
178     struct S_DocuDistributor;
179 	struct S_RecoveryGuard;
180 
181     // DATA
182     ary::cpp::Gate *    pGate;
183 	TokenProcessing_Result
184 						aTokenResult;
185     Dyn<S_FileScopeInfo>
186 						pFileScopeInfo;
187     Dyn<S_OwnerStack>   pOwnerStack;
188     Dyn<S_DocuDistributor>
189                         pDocuDistributor;
190     Dyn<S_RecoveryGuard>
191                         pRecoveryGuard;
192 };
193 
194 
195 
196 
197 }   // namespace cpp
198 #endif
199