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