fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / autodoc / source / parser_i / inc / s2_luidl / distrib.hxx
blobeeceabfa476d8815e299cd9f8a06543417a4f192
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 #ifndef LUIDL_DISTRIB_HXX
21 #define LUIDL_DISTRIB_HXX
25 // USED SERVICES
26 // BASE CLASSES
27 #include <s2_luidl/tokrecv.hxx>
28 #include <s2_dsapi/tokrecv.hxx>
29 #include <s2_luidl/tokproct.hxx>
30 // COMPONENTS
31 // PARAMETERS
34 class ParserInfo;
36 namespace ary
38 class Repository;
40 namespace doc
42 class OldIdlDocu;
43 } // namespace inf
44 } // namespace ary)
48 namespace csi
50 namespace dsapi
52 class Token_Receiver;
53 class SapiDocu_PE;
58 namespace uidl
62 typedef std::vector< DYN Token * > TokenQueue;
63 typedef TokenQueue::iterator TokenIterator;
65 class TokenParser_Uidl;
66 class UnoIDL_PE;
67 class Token;
70 class TokenDistributor : private TokenProcessing_Types
73 public:
74 TokenDistributor(
75 ary::Repository & io_rRepository,
76 ParserInfo & io_rParserInfo );
77 void SetTokenProvider(
78 TokenParser_Uidl & io_rTokenSource );
79 void SetTopParseEnvironment(
80 UnoIDL_PE & io_pTopParseEnvironment );
81 ~TokenDistributor();
84 void Reset() { aDocumentation.Reset(); }
85 /** calls pTokenSource->GetNextToken() and checks the incoming tokens, until a
86 usable token is found. This token will be forwarded to
87 pTopParseEnv;
89 void TradeToken();
91 csi::uidl::Token_Receiver &
92 CodeTokens_Receiver();
93 csi::dsapi::Token_Receiver &
94 DocuTokens_Receiver();
96 /** Used from PE_File, if there is a docu to get without
97 an environment to push (this is the case for modules).
99 DYN ary::doc::OldIdlDocu *
100 ReleaseLastParsedDocu()
101 { return aDocumentation.ReleaseLastParsedDocu(); }
103 /** Used from PE_File, if the term "published" was parsed.
104 The next opened parse environment will be set to be published
105 (call ->UnoIDL_PE::SetPublished()).
107 void Set_PublishedOn()
108 { aProcessingData.Set_PublishedOn(); }
111 private:
112 class Documentation;
113 class ProcessingData;
114 friend class ProcessingData;
116 class ProcessingData : public csi::uidl::Token_Receiver,
117 private TokenProcessing_Types
119 public:
120 ProcessingData(
121 ary::Repository & io_rRepository,
122 Documentation & i_rDocuProcessor,
123 ParserInfo & io_rParserInfo );
124 ~ProcessingData();
125 void SetTopParseEnvironment(
126 UnoIDL_PE & io_pTopParseEnvironment );
129 /** is called from pTokenSource before finishing a ::TokenParse2::GetNextToken()
130 call and passes the just parsed token to this class.
132 virtual void Receive(
133 DYN csi::uidl::Token &
134 let_drToken );
135 virtual void Increment_CurLine();
137 void ProcessCurToken();
139 UnoIDL_PE & CurEnvironment() const;
140 bool NextTokenExists() const;
141 void Set_PublishedOn()
142 { bPublishedRecentlyOn = true; }
144 private:
145 typedef uintt TokenQ_Position;
146 typedef std::pair< UnoIDL_PE *, TokenQ_Position > EnvironmentInfo;
147 typedef std::vector< EnvironmentInfo > EnvironmentStack;
149 void AcknowledgeResult();
150 const csi::uidl::Token &
151 CurToken() const;
152 UnoIDL_PE & CurEnv() const;
153 UnoIDL_PE & PushEnv() const;
154 uintt CurTokenPosition() const;
155 uintt CurEnv_TriedTokenPosition() const;
156 void DecrementTryCount();
158 EnvironmentStack aEnvironments;
159 TokenQueue aTokenQueue;
160 TokenIterator itCurToken;
161 TokenProcessing_Result
162 aCurResult;
163 uintt nTryCount;
164 ary::Repository &
165 rRepository;
166 ParserInfo & rParserInfo;
167 Documentation * pDocuProcessor;
168 bool bPublishedRecentlyOn;
171 class Documentation : public csi::dsapi::Token_Receiver
173 public:
174 Documentation(
175 ParserInfo & io_rParserInfo);
176 ~Documentation();
178 void Reset() { bIsPassedFirstDocu = false; }
180 virtual void Receive(
181 DYN csi::dsapi::Token &
182 let_drToken );
183 virtual void Increment_CurLine();
184 DYN ary::doc::OldIdlDocu *
185 ReleaseLastParsedDocu()
186 { return pMostRecentDocu.Release(); }
187 private:
188 Dyn<csi::dsapi::SapiDocu_PE>
189 pDocuParseEnv;
190 ParserInfo & rParserInfo;
191 Dyn<ary::doc::OldIdlDocu>
192 pMostRecentDocu;
193 bool bIsPassedFirstDocu;
196 // DATA
197 TokenParser_Uidl * pTokenSource;
198 Documentation aDocumentation;
199 ProcessingData aProcessingData;
204 // IMPLEMENTATION
206 inline void
207 TokenDistributor::SetTokenProvider( TokenParser_Uidl & io_rTokenSource )
208 { pTokenSource = &io_rTokenSource; }
210 inline void
211 TokenDistributor::SetTopParseEnvironment( UnoIDL_PE & io_pTopParseEnvironment )
212 { aProcessingData.SetTopParseEnvironment(io_pTopParseEnvironment); }
214 inline csi::uidl::Token_Receiver &
215 TokenDistributor::CodeTokens_Receiver()
216 { return aProcessingData; }
218 inline csi::dsapi::Token_Receiver &
219 TokenDistributor::DocuTokens_Receiver()
220 { return aDocumentation; }
222 inline const csi::uidl::Token &
223 TokenDistributor::ProcessingData::CurToken() const
225 csv_assert( itCurToken != aTokenQueue.end() );
226 csv_assert( *itCurToken != 0 );
227 return *(*itCurToken);
230 inline UnoIDL_PE &
231 TokenDistributor::ProcessingData::CurEnv() const
233 csv_assert( aEnvironments.size() > 0 );
234 csv_assert( aEnvironments.back().first != 0 );
235 return *aEnvironments.back().first;
238 inline UnoIDL_PE &
239 TokenDistributor::ProcessingData::PushEnv() const
241 csv_assert( aCurResult.pEnv2Push != 0 );
242 return *aCurResult.pEnv2Push;
245 inline uintt
246 TokenDistributor::ProcessingData::CurTokenPosition() const
248 return itCurToken - aTokenQueue.begin();
251 inline uintt
252 TokenDistributor::ProcessingData::CurEnv_TriedTokenPosition() const
254 csv_assert( aEnvironments.size() > 0 );
255 return aEnvironments.back().second;
259 } // namespace uidl
260 } // namespace csi
262 #endif
264 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */