LCOV - code coverage report
Current view: top level - libreoffice/autodoc/source/parser_i/inc/s2_luidl - distrib.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 26 28 92.9 %
Date: 2012-12-27 Functions: 14 15 93.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #ifndef LUIDL_DISTRIB_HXX
      21             : #define LUIDL_DISTRIB_HXX
      22             : 
      23             : 
      24             : 
      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
      32             : 
      33             : 
      34             : class ParserInfo;
      35             : 
      36             : namespace ary
      37             : {
      38             :     class Repository;
      39             : 
      40             : namespace doc
      41             : {
      42             :     class OldIdlDocu;
      43             : }   // namespace inf
      44             : }   // namespace ary)
      45             : 
      46             : 
      47             : 
      48             : namespace csi
      49             : {
      50             : namespace dsapi
      51             : {
      52             :     class Token_Receiver;
      53             :     class SapiDocu_PE;
      54             : }
      55             : 
      56             : 
      57             : 
      58             : namespace uidl
      59             : {
      60             : 
      61             : 
      62             : typedef std::vector< DYN Token * >  TokenQueue;
      63             : typedef TokenQueue::iterator        TokenIterator;
      64             : 
      65             : class TokenParser_Uidl;
      66             : class UnoIDL_PE;
      67             : class Token;
      68             : 
      69             : 
      70             : class TokenDistributor : private TokenProcessing_Types
      71             : 
      72             : {
      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();
      82             : 
      83             : 
      84        4137 :     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;
      88             :     */
      89             :     void                TradeToken();
      90             : 
      91             :     csi::uidl::Token_Receiver &
      92             :                         CodeTokens_Receiver();
      93             :     csi::dsapi::Token_Receiver &
      94             :                         DocuTokens_Receiver();
      95             : 
      96             :     /** Used from PE_File, if there is a docu to get without
      97             :         an environment to push (this is the case for modules).
      98             :     */
      99             :     DYN ary::doc::OldIdlDocu *
     100       17717 :                         ReleaseLastParsedDocu()
     101       17717 :                             { return aDocumentation.ReleaseLastParsedDocu(); }
     102             : 
     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()).
     106             :     */
     107        3018 :     void                Set_PublishedOn()
     108        3018 :                             { aProcessingData.Set_PublishedOn(); }
     109             : 
     110             : 
     111             :   private:
     112             :     class Documentation;
     113             :     class ProcessingData;
     114             :     friend class ProcessingData;
     115             : 
     116             :     class  ProcessingData : public  csi::uidl::Token_Receiver,
     117             :                             private TokenProcessing_Types
     118             :     {
     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 );
     127             : 
     128             : 
     129             :         /** is called from pTokenSource before finishing a ::TokenParse2::GetNextToken()
     130             :             call and passes the just parsed token to this class.
     131             :         */
     132             :         virtual void        Receive(
     133             :                                 DYN csi::uidl::Token &
     134             :                                                 let_drToken );
     135             :         virtual void        Increment_CurLine();
     136             : 
     137             :         void                ProcessCurToken();
     138             : 
     139             :         UnoIDL_PE &         CurEnvironment() const;
     140             :         bool                NextTokenExists() const;
     141        3018 :         void                Set_PublishedOn()
     142        3018 :                                 { bPublishedRecentlyOn = true; }
     143             : 
     144             :       private:
     145             :         typedef uintt   TokenQ_Position;
     146             :         typedef std::pair< UnoIDL_PE *, TokenQ_Position >   EnvironmentInfo;
     147             :         typedef std::vector< EnvironmentInfo >              EnvironmentStack;
     148             : 
     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();
     157             : 
     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;
     169             :     };
     170             : 
     171             :     class Documentation : public csi::dsapi::Token_Receiver
     172             :     {
     173             :       public:
     174             :                             Documentation(
     175             :                                 ParserInfo &    io_rParserInfo);
     176             :                             ~Documentation();
     177             : 
     178        4137 :         void                Reset()             { bIsPassedFirstDocu = false; }
     179             : 
     180             :         virtual void        Receive(
     181             :                                 DYN csi::dsapi::Token &
     182             :                                                 let_drToken );
     183             :         virtual void        Increment_CurLine();
     184             :         DYN ary::doc::OldIdlDocu *
     185       74537 :                             ReleaseLastParsedDocu()
     186       74537 :                                                 { 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;
     194             :     };
     195             : 
     196             :     // DATA
     197             :     TokenParser_Uidl *  pTokenSource;
     198             :     Documentation       aDocumentation;
     199             :     ProcessingData      aProcessingData;
     200             : };
     201             : 
     202             : 
     203             : 
     204             : // IMPLEMENTATION
     205             : 
     206             : inline void
     207           3 : TokenDistributor::SetTokenProvider( TokenParser_Uidl &  io_rTokenSource )
     208           3 :     { pTokenSource = &io_rTokenSource; }
     209             : 
     210             : inline void
     211           3 : TokenDistributor::SetTopParseEnvironment( UnoIDL_PE & io_pTopParseEnvironment )
     212           3 :     { aProcessingData.SetTopParseEnvironment(io_pTopParseEnvironment); }
     213             : 
     214             : inline csi::uidl::Token_Receiver &
     215           3 : TokenDistributor::CodeTokens_Receiver()
     216           3 :     { return aProcessingData; }
     217             : 
     218             : inline csi::dsapi::Token_Receiver &
     219           3 : TokenDistributor::DocuTokens_Receiver()
     220           3 :     { return aDocumentation; }
     221             : 
     222             : inline const csi::uidl::Token &
     223      526996 : TokenDistributor::ProcessingData::CurToken() const
     224             : {
     225             :     csv_assert( itCurToken != aTokenQueue.end() );
     226             :     csv_assert( *itCurToken != 0 );
     227      526996 :     return *(*itCurToken);
     228             : }
     229             : 
     230             : inline UnoIDL_PE &
     231      170457 : TokenDistributor::ProcessingData::CurEnv() const
     232             : {
     233             :     csv_assert( aEnvironments.size() > 0 );
     234             :     csv_assert( aEnvironments.back().first != 0 );
     235      170457 :     return *aEnvironments.back().first;
     236             : }
     237             : 
     238             : inline UnoIDL_PE &
     239      173478 : TokenDistributor::ProcessingData::PushEnv() const
     240             : {
     241             :     csv_assert( aCurResult.pEnv2Push != 0 );
     242      173478 :     return *aCurResult.pEnv2Push;
     243             : }
     244             : 
     245             : inline uintt
     246           0 : TokenDistributor::ProcessingData::CurTokenPosition() const
     247             : {
     248           0 :     return itCurToken - aTokenQueue.begin();
     249             : }
     250             : 
     251             : inline uintt
     252       56818 : TokenDistributor::ProcessingData::CurEnv_TriedTokenPosition() const
     253             : {
     254             :     csv_assert( aEnvironments.size() > 0 );
     255       56818 :     return aEnvironments.back().second;
     256             : }
     257             : 
     258             : 
     259             : }   // namespace uidl
     260             : }   // namespace csi
     261             : 
     262             : #endif
     263             : 
     264             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10