Updated core
[LibreOffice.git] / autodoc / source / parser_i / idl / pe_enum2.cxx
blobc5d4943143f7dd04036f69759b0e927030199f7a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "sal/config.h"
22 #include "sal/types.h"
24 #include <precomp.h>
25 #include <s2_luidl/pe_enum2.hxx>
28 // NOT FULLY DECLARED SERVICES
29 #include <ary/idl/i_enum.hxx>
30 #include <ary/idl/i_enumvalue.hxx>
31 #include <ary/idl/i_gate.hxx>
32 #include <ary/idl/ip_ce.hxx>
33 #include <ary/doc/d_oldidldocu.hxx>
34 #include <s2_luidl/pe_evalu.hxx>
35 #include <s2_luidl/tk_punct.hxx>
36 #include <s2_luidl/tk_ident.hxx>
37 #include <s2_luidl/tk_keyw.hxx>
40 namespace csi
42 namespace uidl
46 #ifdef DF
47 #undef DF
48 #endif
49 #define DF &PE_Enum::On_Default
51 PE_Enum::F_TOK
52 PE_Enum::aDispatcher[PE_Enum::e_STATES_MAX][PE_Enum::tt_MAX] =
53 { { DF, DF }, // e_none
54 { &PE_Enum::On_expect_name_Identifier,
55 DF }, // expect_name
56 { DF, &PE_Enum::On_expect_curl_bracket_open_Punctuation }, // expect_curl_bracket_open
57 { &PE_Enum::On_expect_value_Identifier,
58 &PE_Enum::On_expect_value_Punctuation }, // expect_value
59 { DF, &PE_Enum::On_expect_finish_Punctuation } // expect_finish
64 inline void
65 PE_Enum::CallHandler( const char * i_sTokenText,
66 E_TokenType i_eTokenType )
67 { (this->*aDispatcher[eState][i_eTokenType])(i_sTokenText); }
72 PE_Enum::PE_Enum()
73 : eState(e_none),
74 sData_Name(),
75 nDataId(0),
76 pPE_Value(0),
77 sName(),
78 sAssignment()
80 pPE_Value = new PE_Value(sName, sAssignment, false);
83 void
84 PE_Enum::EstablishContacts( UnoIDL_PE * io_pParentPE,
85 ary::Repository & io_rRepository,
86 TokenProcessing_Result & o_rResult )
88 UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult);
89 pPE_Value->EstablishContacts(this,io_rRepository,o_rResult);
92 PE_Enum::~PE_Enum()
96 void
97 PE_Enum::ProcessToken( const Token & i_rToken )
99 i_rToken.Trigger(*this);
102 void
103 PE_Enum::Process_Identifier( const TokIdentifier & i_rToken )
105 CallHandler(i_rToken.Text(), tt_identifier);
108 void
109 PE_Enum::Process_Punctuation( const TokPunctuation & i_rToken )
111 CallHandler(i_rToken.Text(), tt_punctuation);
114 void
115 PE_Enum::On_expect_name_Identifier(const char * i_sText)
117 sName = i_sText;
119 SetResult(done,stay);
120 eState = expect_curl_bracket_open;
123 void
124 PE_Enum::On_expect_curl_bracket_open_Punctuation(const char * i_sText)
126 if ( i_sText[0] == '{')
128 sData_Name = sName;
129 ary::idl::Enum &
130 rCe = Gate().Ces().Store_Enum(CurNamespace().CeId(), sData_Name);
131 PassDocuAt(rCe);
132 nDataId = rCe.CeId();
134 SetResult(done,stay);
135 eState = expect_value;
137 else
139 On_Default(i_sText);
143 void
144 PE_Enum::On_expect_value_Punctuation(const char * i_sText)
146 if ( i_sText[0] == '}' )
148 SetResult(done,stay);
149 eState = expect_finish;
151 else
153 On_Default(i_sText);
157 void
158 PE_Enum::On_expect_value_Identifier(SAL_UNUSED_PARAMETER const char *)
160 SetResult( not_done, push_sure, pPE_Value.Ptr() );
163 void
164 PE_Enum::On_expect_finish_Punctuation(const char * i_sText)
166 if ( i_sText[0] == ';')
168 SetResult(done,pop_success);
169 eState = e_none;
171 else
173 On_Default(i_sText);
177 void
178 PE_Enum::On_Default(SAL_UNUSED_PARAMETER const char * )
180 SetResult(not_done,pop_failure);
181 eState = e_none;
184 void
185 PE_Enum::EmptySingleValueData()
187 sName = "";
188 sAssignment = "";
191 void
192 PE_Enum::CreateSingleValue()
194 ary::idl::EnumValue &
195 rCe = Gate().Ces().Store_EnumValue( nDataId, sName, sAssignment );
196 pPE_Value->PassDocuAt(rCe);
199 void
200 PE_Enum::InitData()
202 eState = expect_name;
204 sData_Name.clear();
205 nDataId = 0;
207 EmptySingleValueData();
210 void
211 PE_Enum::ReceiveData()
213 switch (eState)
215 case expect_value:
217 if (sName.length() == 0)
219 On_Default("");
220 break;
223 CreateSingleValue();
224 EmptySingleValueData();
225 } break;
226 default:
227 SetResult(not_done, pop_failure);
228 eState = e_none;
229 } // end switch
232 void
233 PE_Enum::TransferData()
235 csv_assert(sData_Name.length() > 0);
236 eState = e_none;
239 UnoIDL_PE &
240 PE_Enum::MyPE()
242 return *this;
245 } // namespace uidl
246 } // namespace csi
248 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */