Bump for 3.6-28
[LibreOffice.git] / autodoc / source / parser_i / idl / pe_enum2.cxx
blobce8a8067ca7ca9a02b0a4334839d3156156b1530
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include "sal/config.h"
31 #include "sal/types.h"
33 #include <precomp.h>
34 #include <s2_luidl/pe_enum2.hxx>
37 // NOT FULLY DECLARED SERVICES
38 #include <ary/idl/i_enum.hxx>
39 #include <ary/idl/i_enumvalue.hxx>
40 #include <ary/idl/i_gate.hxx>
41 #include <ary/idl/ip_ce.hxx>
42 #include <ary/doc/d_oldidldocu.hxx>
43 #include <s2_luidl/pe_evalu.hxx>
44 #include <s2_luidl/tk_punct.hxx>
45 #include <s2_luidl/tk_ident.hxx>
46 #include <s2_luidl/tk_keyw.hxx>
49 namespace csi
51 namespace uidl
55 #ifdef DF
56 #undef DF
57 #endif
58 #define DF &PE_Enum::On_Default
60 PE_Enum::F_TOK
61 PE_Enum::aDispatcher[PE_Enum::e_STATES_MAX][PE_Enum::tt_MAX] =
62 { { DF, DF }, // e_none
63 { &PE_Enum::On_expect_name_Identifier,
64 DF }, // expect_name
65 { DF, &PE_Enum::On_expect_curl_bracket_open_Punctuation }, // expect_curl_bracket_open
66 { &PE_Enum::On_expect_value_Identifier,
67 &PE_Enum::On_expect_value_Punctuation }, // expect_value
68 { DF, &PE_Enum::On_expect_finish_Punctuation } // expect_finish
73 inline void
74 PE_Enum::CallHandler( const char * i_sTokenText,
75 E_TokenType i_eTokenType )
76 { (this->*aDispatcher[eState][i_eTokenType])(i_sTokenText); }
81 PE_Enum::PE_Enum()
82 : eState(e_none),
83 sData_Name(),
84 nDataId(0),
85 pPE_Value(0),
86 sName(),
87 sAssignment()
89 pPE_Value = new PE_Value(sName, sAssignment, false);
92 void
93 PE_Enum::EstablishContacts( UnoIDL_PE * io_pParentPE,
94 ary::Repository & io_rRepository,
95 TokenProcessing_Result & o_rResult )
97 UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult);
98 pPE_Value->EstablishContacts(this,io_rRepository,o_rResult);
101 PE_Enum::~PE_Enum()
105 void
106 PE_Enum::ProcessToken( const Token & i_rToken )
108 i_rToken.Trigger(*this);
111 void
112 PE_Enum::Process_Identifier( const TokIdentifier & i_rToken )
114 CallHandler(i_rToken.Text(), tt_identifier);
117 void
118 PE_Enum::Process_Punctuation( const TokPunctuation & i_rToken )
120 CallHandler(i_rToken.Text(), tt_punctuation);
123 void
124 PE_Enum::On_expect_name_Identifier(const char * i_sText)
126 sName = i_sText;
128 SetResult(done,stay);
129 eState = expect_curl_bracket_open;
132 void
133 PE_Enum::On_expect_curl_bracket_open_Punctuation(const char * i_sText)
135 if ( i_sText[0] == '{')
137 sData_Name = sName;
138 ary::idl::Enum &
139 rCe = Gate().Ces().Store_Enum(CurNamespace().CeId(), sData_Name);
140 PassDocuAt(rCe);
141 nDataId = rCe.CeId();
143 SetResult(done,stay);
144 eState = expect_value;
146 else
148 On_Default(i_sText);
152 void
153 PE_Enum::On_expect_value_Punctuation(const char * i_sText)
155 if ( i_sText[0] == '}' )
157 SetResult(done,stay);
158 eState = expect_finish;
160 else
162 On_Default(i_sText);
166 void
167 PE_Enum::On_expect_value_Identifier(SAL_UNUSED_PARAMETER const char *)
169 SetResult( not_done, push_sure, pPE_Value.Ptr() );
172 void
173 PE_Enum::On_expect_finish_Punctuation(const char * i_sText)
175 if ( i_sText[0] == ';')
177 SetResult(done,pop_success);
178 eState = e_none;
180 else
182 On_Default(i_sText);
186 void
187 PE_Enum::On_Default(SAL_UNUSED_PARAMETER const char * )
189 SetResult(not_done,pop_failure);
190 eState = e_none;
193 void
194 PE_Enum::EmptySingleValueData()
196 sName = "";
197 sAssignment = "";
200 void
201 PE_Enum::CreateSingleValue()
203 ary::idl::EnumValue &
204 rCe = Gate().Ces().Store_EnumValue( nDataId, sName, sAssignment );
205 pPE_Value->PassDocuAt(rCe);
208 void
209 PE_Enum::InitData()
211 eState = expect_name;
213 sData_Name.clear();
214 nDataId = 0;
216 EmptySingleValueData();
219 void
220 PE_Enum::ReceiveData()
222 switch (eState)
224 case expect_value:
226 if (sName.length() == 0)
228 On_Default("");
229 break;
232 CreateSingleValue();
233 EmptySingleValueData();
234 } break;
235 default:
236 SetResult(not_done, pop_failure);
237 eState = e_none;
238 } // end switch
241 void
242 PE_Enum::TransferData()
244 csv_assert(sData_Name.length() > 0);
245 eState = e_none;
248 UnoIDL_PE &
249 PE_Enum::MyPE()
251 return *this;
254 } // namespace uidl
255 } // namespace csi
257 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */