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