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 LUIDL_PE_STRUC_HXX 25 #define LUIDL_PE_STRUC_HXX 26 27 28 29 // USED SERVICES 30 // BASE CLASSES 31 #include <s2_luidl/parsenv2.hxx> 32 #include <s2_luidl/pestate.hxx> 33 // COMPONENTS 34 #include <s2_luidl/semnode.hxx> 35 #include <ary/qualiname.hxx> 36 // PARAMETERS 37 38 39 40 namespace csi 41 { 42 namespace prl 43 { 44 class TNamespace; 45 } 46 } 47 48 49 50 namespace csi 51 { 52 namespace uidl 53 { 54 55 56 class Struct; 57 class StructElement; 58 class PE_StructElement; 59 class PE_Type; 60 61 62 class PE_Struct : public UnoIDL_PE 63 { 64 public: 65 PE_Struct(); 66 virtual void EstablishContacts( 67 UnoIDL_PE * io_pParentPE, 68 ary::Repository & io_rRepository, 69 TokenProcessing_Result & 70 o_rResult ); 71 ~PE_Struct(); 72 virtual void ProcessToken( 73 const Token & i_rToken ); 74 75 private: 76 struct S_Work 77 { 78 S_Work(); 79 80 void InitData(); 81 void Prepare_PE_QualifiedName(); 82 void Prepare_PE_Element(); 83 void Data_Set_Name( 84 const char * i_sName ); 85 void Data_Set_TemplateParam( 86 const char * i_sTemplateParam ); 87 88 String sData_Name; 89 String sData_TemplateParam; 90 bool bIsPreDeclaration; 91 ary::idl::Ce_id nCurStruct; 92 93 Dyn<PE_StructElement> 94 pPE_Element; 95 ary::idl::Ce_id nCurParsed_ElementRef; 96 Dyn<PE_Type> pPE_Type; 97 ary::idl::Type_id nCurParsed_Base; 98 }; 99 100 struct S_Stati; 101 class PE_StructState; 102 friend struct S_Stati; 103 friend class PE_StructState; 104 105 106 class PE_StructState : public ParseEnvState 107 { 108 public: 109 110 protected: 111 PE_StructState( 112 PE_Struct & i_rStruct ) 113 : rStruct(i_rStruct) {} 114 void MoveState( 115 ParseEnvState & i_rState ) const; 116 void SetResult( 117 E_TokenDone i_eDone, 118 E_EnvStackAction i_eWhat2DoWithEnvStack, 119 UnoIDL_PE * i_pParseEnv2Push = 0 ) const 120 { rStruct.SetResult(i_eDone, i_eWhat2DoWithEnvStack, i_pParseEnv2Push); } 121 122 S_Stati & Stati() const { return *rStruct.pStati; } 123 S_Work & Work() const { return rStruct.aWork; } 124 PE_Struct & PE() const { return rStruct; } 125 126 private: 127 virtual UnoIDL_PE & MyPE(); 128 // DATA 129 PE_Struct & rStruct; 130 }; 131 132 class State_None : public PE_StructState 133 { 134 public: 135 State_None( 136 PE_Struct & i_rStruct ) 137 : PE_StructState(i_rStruct) {} 138 }; 139 class State_WaitForName : public PE_StructState 140 { // -> Name 141 public: 142 State_WaitForName( 143 PE_Struct & i_rStruct ) 144 : PE_StructState(i_rStruct) {} 145 virtual void Process_Identifier( 146 const TokIdentifier & 147 i_rToken ); 148 }; 149 class State_GotName : public PE_StructState 150 { // -> : { ; < 151 public: 152 State_GotName( 153 PE_Struct & i_rStruct ) 154 : PE_StructState(i_rStruct) {} 155 virtual void Process_Punctuation( 156 const TokPunctuation & 157 i_rToken ); 158 }; 159 class State_WaitForTemplateParam : public PE_StructState 160 { // -> Template parameter identifier 161 public: 162 State_WaitForTemplateParam( 163 PE_Struct & i_rStruct ) 164 : PE_StructState(i_rStruct) {} 165 virtual void Process_Identifier( 166 const TokIdentifier & 167 i_rToken ); 168 }; 169 class State_WaitForTemplateEnd : public PE_StructState 170 { // -> > 171 public: 172 State_WaitForTemplateEnd( 173 PE_Struct & i_rStruct ) 174 : PE_StructState(i_rStruct) {} 175 virtual void Process_Punctuation( 176 const TokPunctuation & 177 i_rToken ); 178 }; 179 class State_WaitForBase : public PE_StructState 180 { // -> Base 181 public: 182 State_WaitForBase( 183 PE_Struct & i_rStruct ) 184 : PE_StructState(i_rStruct) {} 185 virtual void On_SubPE_Left(); 186 }; 187 class State_GotBase : public PE_StructState 188 { // -> { 189 public: 190 State_GotBase( 191 PE_Struct & i_rStruct ) 192 : PE_StructState(i_rStruct) {} 193 virtual void Process_Punctuation( 194 const TokPunctuation & 195 i_rToken ); 196 }; 197 class State_WaitForElement : public PE_StructState 198 { // -> Typ } 199 public: 200 State_WaitForElement( 201 PE_Struct & i_rStruct ) 202 : PE_StructState(i_rStruct) {} 203 virtual void Process_Identifier( 204 const TokIdentifier & 205 i_rToken ); 206 virtual void Process_NameSeparator(); 207 virtual void Process_BuiltInType( 208 const TokBuiltInType & 209 i_rToken ); 210 virtual void Process_TypeModifier( 211 const TokTypeModifier & 212 i_rToken ); 213 virtual void Process_Punctuation( 214 const TokPunctuation & 215 i_rToken ); 216 }; 217 class State_WaitForFinish : public PE_StructState 218 { // -> ; 219 public: 220 State_WaitForFinish( 221 PE_Struct & i_rStruct ) 222 : PE_StructState(i_rStruct) {} 223 virtual void Process_Punctuation( 224 const TokPunctuation & 225 i_rToken ); 226 }; 227 228 struct S_Stati 229 { 230 S_Stati( 231 PE_Struct & io_rStruct ); 232 void SetState( 233 ParseEnvState & i_rNextState ) 234 { pCurStatus = &i_rNextState; } 235 236 State_None aNone; 237 State_WaitForName aWaitForName; 238 State_GotName aGotName; 239 State_WaitForTemplateParam 240 aWaitForTemplateParam; 241 State_WaitForTemplateEnd 242 aWaitForTemplateEnd; 243 State_WaitForBase aWaitForBase; 244 State_GotBase aGotBase; 245 State_WaitForElement 246 aWaitForElement; 247 State_WaitForFinish aWaitForFinish; 248 249 ParseEnvState * pCurStatus; 250 }; 251 252 virtual void InitData(); 253 virtual void TransferData(); 254 virtual void ReceiveData(); 255 256 public: 257 258 void store_Struct(); 259 260 private: 261 262 S_Stati & Stati() { return *pStati; } 263 S_Work & Work() { return aWork; } 264 265 // DATA 266 S_Work aWork; 267 Dyn<S_Stati> pStati; 268 }; 269 270 271 inline void 272 PE_Struct::PE_StructState::MoveState( 273 ParseEnvState & i_rState ) const 274 { rStruct.Stati().SetState(i_rState); } 275 276 } // namespace uidl 277 } // namespace csi 278 279 280 #endif 281 282