LCOV - code coverage report
Current view: top level - rsc/inc - rscdef.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 44 0.0 %
Date: 2014-04-14 Functions: 0 28 0.0 %
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             : #ifndef _RSCDEF_HXX
      20             : #define _RSCDEF_HXX
      21             : 
      22             : #include <tools/unqidx.hxx>
      23             : #include <rsctree.hxx>
      24             : #include <rtl/strbuf.hxx>
      25             : #include <vector>
      26             : 
      27             : /****************** C L A S S E S ****************************************/
      28             : class RscExpression;
      29             : class RscFileTab;
      30             : class RscDefine;
      31             : 
      32             : /*********** R s c E x p r e s s i o n ***********************************/
      33             : #define RSCEXP_LONG     0
      34             : #define RSCEXP_EXP      1
      35             : #define RSCEXP_DEF      2
      36             : #define RSCEXP_NOTHING  3
      37             : 
      38             : class RscExpType
      39             : {
      40             : public:
      41             :     union
      42             :     {
      43             :         RscExpression * pExp;
      44             :         RscDefine     * pDef;
      45             :         struct
      46             :         {
      47             :              short           nHi;
      48             :              unsigned short  nLo;
      49             :         } aLong;
      50             :     } aExp;
      51             :     char cType;
      52             :     bool cUnused;
      53           0 :     bool IsNumber()    const { return( RSCEXP_LONG     == cType ); }
      54           0 :     bool IsExpression()const { return( RSCEXP_EXP      == cType ); }
      55           0 :     bool IsDefinition()const { return( RSCEXP_DEF      == cType ); }
      56           0 :     bool IsNothing()   const { return( RSCEXP_NOTHING  == cType ); }
      57           0 :     void SetLong( sal_Int32 lValue )
      58             :              {
      59           0 :                  aExp.aLong.nHi = (short)(lValue >> 16);
      60           0 :                  aExp.aLong.nLo = (unsigned short)lValue;
      61           0 :                  cType = RSCEXP_LONG;
      62           0 :              }
      63           0 :     sal_Int32 GetLong() const
      64             :                   {
      65           0 :                       return aExp.aLong.nLo |
      66           0 :                           ((sal_Int32)aExp.aLong.nHi << 16);
      67             :                   }
      68             :     bool Evaluate( sal_Int32 * pValue ) const;
      69             :     void AppendMacro( OStringBuffer & ) const;
      70             : };
      71             : 
      72             : /*********** R s c I d ***************************************************/
      73             : class RscId
      74             : {
      75             :     static      bool bNames;// false, bei den Namenoperation nur Zahlen
      76             : public:
      77             :     RscExpType  aExp;       // Zahl, Define oder Ausdruck
      78             :     sal_Int32   GetNumber() const;
      79             :     void    Create( const RscExpType & rExpType );
      80           0 :     void    Create(){ aExp.cType = RSCEXP_NOTHING; }
      81             : 
      82           0 :             RscId() { Create();                         }
      83             : 
      84             :             RscId( RscDefine * pEle );
      85           0 :             RscId( sal_Int32 lNumber )
      86             :             {
      87           0 :                 aExp.cUnused = false;
      88           0 :                 aExp.SetLong( lNumber );
      89           0 :             }
      90             : 
      91           0 :             RscId( const RscExpType & rExpType )
      92           0 :                     { Create( rExpType );               }
      93             : 
      94             :             void Destroy();
      95             : 
      96           0 :             ~RscId() { Destroy(); }
      97             : 
      98             :             RscId( const RscId& rRscId );
      99             : 
     100             :             RscId& operator = ( const RscId& rRscId );
     101             : 
     102             :     static void SetNames( bool bSet = true );
     103             :     operator sal_Int32() const;   // Gibt Nummer zurueck
     104             :     OString GetName()  const;   // Gibt den Namen des Defines zurueck
     105             :     bool    operator <  ( const RscId& rRscId ) const;
     106             :     bool    operator >  ( const RscId& rRscId ) const;
     107             :     bool    operator == ( const RscId& rRscId ) const;
     108           0 :     bool    operator <=  ( const RscId& rRscId ) const
     109           0 :                 { return !(operator > ( rRscId )); }
     110           0 :     bool    operator >= ( const RscId& rRscId ) const
     111           0 :                 { return !(operator < ( rRscId )); }
     112           0 :     bool    IsId() const { return !aExp.IsNothing(); }
     113             : };
     114             : 
     115             : /*********** R s c D e f i n e *******************************************/
     116             : class RscDefine : public StringNode
     117             : {
     118             : friend class RscFileTab;
     119             : friend class RscDefineList;
     120             : friend class RscDefTree;
     121             : friend class RscExpression;
     122             : friend class RscId;
     123             :     sal_uLong   lFileKey;   // zu welcher Datei gehoert das Define
     124             :     sal_uInt32  nRefCount;  // Wieviele Referenzen auf dieses Objekt
     125             :     sal_Int32   lId;        // Identifier
     126             :     RscExpression * pExp;       // Ausdruck
     127             : protected:
     128             : 
     129             :                 RscDefine( sal_uLong lFileKey, const OString& rDefName,
     130             :                            sal_Int32 lDefId );
     131             :                 RscDefine( sal_uLong lFileKey, const OString& rDefName,
     132             :                            RscExpression * pExpression );
     133             :                 virtual ~RscDefine();
     134           0 :     void        IncRef(){ nRefCount++; }
     135             :     sal_uInt32  GetRefCount() const    { return nRefCount; }
     136             :     void        DecRef();
     137             :     void        DefineToNumber();
     138           0 :     void        SetName(const OString& rNewName) { m_aName = rNewName; }
     139             : 
     140             :     using StringNode::Search;
     141             : public:
     142             :     RscDefine * Search( const char * );
     143           0 :     sal_uLong   GetFileKey() const { return lFileKey; }
     144             :     bool        Evaluate();
     145           0 :     sal_Int32   GetNumber() const  { return lId;      }
     146             :     OString     GetMacro();
     147             : };
     148             : 
     149             : typedef ::std::vector< RscDefine* > RscSubDefList;
     150             : 
     151           0 : class RscDefineList
     152             : {
     153             : friend class RscFile;
     154             : friend class RscFileTab;
     155             : private:
     156             :     RscSubDefList   maList;
     157             :                 // pExpression wird auf jedenfall Eigentum der Liste
     158             :     RscDefine * New( sal_uLong lFileKey, const OString& rDefName,
     159             :                      sal_Int32 lDefId, size_t lPos );
     160             :     RscDefine * New( sal_uLong lFileKey, const OString& rDefName,
     161             :                      RscExpression * pExpression, size_t lPos );
     162             :     bool        Remove();
     163           0 :     size_t      GetPos( RscDefine* item )
     164             :                     {
     165           0 :                         for ( size_t i = 0, n = maList.size(); i < n; ++i )
     166           0 :                             if ( maList[ i ] == item )
     167           0 :                                 return i;
     168           0 :                         return size_t(-1);
     169             :                     }
     170             : public:
     171             :     void        WriteAll( FILE * fOutput );
     172             : };
     173             : 
     174             : /*********** R s c E x p r e s s i o n ***********************************/
     175             : class RscExpression
     176             : {
     177             : friend class RscFileTab;
     178             :     char        cOperation;
     179             :     RscExpType  aLeftExp;
     180             :     RscExpType  aRightExp;
     181             : public:
     182             :                 RscExpression( RscExpType aLE, char cOp,
     183             :                                RscExpType aRE );
     184             :                 ~RscExpression();
     185             :     bool        Evaluate( sal_Int32 * pValue );
     186             :     OString     GetMacro();
     187             : };
     188             : 
     189             : /********************** R S C F I L E ************************************/
     190             : class RscDepend
     191             : {
     192             :     sal_uLong   lKey;
     193             : public:
     194           0 :                 RscDepend( sal_uLong lIncKey ){ lKey = lIncKey; };
     195           0 :     sal_uLong   GetFileKey(){ return lKey; }
     196             : };
     197             : 
     198             : typedef ::std::vector< RscDepend* > RscDependList;
     199             : 
     200             : // Tabelle die alle Dateinamen enthaelt
     201             : class RscFile
     202             : {
     203             : friend class RscFileTab;
     204             :     bool            bIncFile;   // Ist es eine Include-Datei
     205             : public:
     206             :     bool            bLoaded;    // Ist die Datei geladen
     207             :     bool            bScanned;   // Wurde Datei nach Inclide abgesucht
     208             :     bool            bDirty;     // Dirty-Flag
     209             :     OString         aFileName;  // Name der Datei
     210             :     OString         aPathName;  // Pfad und Name der Datei
     211             :     RscDefineList   aDefLst;    // Liste der Defines
     212             :     RscDependList   aDepLst;    // List of Depend
     213             : 
     214             :                     RscFile();
     215             :                     ~RscFile();
     216             :     bool            InsertDependFile( sal_uLong lDepFile, size_t lPos );
     217             :     bool            Depend( sal_uLong lDepend, sal_uLong lFree );
     218           0 :     void            SetIncFlag(){ bIncFile = true; };
     219           0 :     bool            IsIncFile(){  return bIncFile; };
     220             : };
     221             : 
     222             : typedef UniqueIndex<RscFile> RscSubFileTab;
     223             : #define NOFILE_INDEX UNIQUEINDEX_ENTRY_NOTFOUND
     224             : 
     225             : class RscDefTree
     226             : {
     227             :     RscDefine * pDefRoot;
     228             : public:
     229             :     static bool Evaluate( RscDefine * pDef );
     230           0 :                 RscDefTree(){ pDefRoot = NULL; }
     231             :                 ~RscDefTree();
     232             :     void        Remove();
     233             :     RscDefine * Search( const char * pName );
     234             :     void        Insert( RscDefine * pDef );
     235             :     void        Remove( RscDefine * pDef );
     236             : };
     237             : 
     238             : class RscFileTab : public RscSubFileTab
     239             : {
     240             :     RscDefTree aDefTree;
     241             :     sal_uLong       Find(const OString& rName);
     242             : public:
     243             :                 RscFileTab();
     244             :                 ~RscFileTab();
     245             : 
     246             :     RscDefine * FindDef( const char * );
     247           0 :     RscDefine * FindDef(const OString& rStr)
     248             :                 {
     249           0 :                     return FindDef(rStr.getStr());
     250             :                 }
     251             : 
     252             :     bool        Depend( sal_uLong lDepend, sal_uLong lFree );
     253             :     bool        TestDef( sal_uLong lFileKey, size_t lPos,
     254             :                          const RscDefine * pDefDec );
     255             :     bool        TestDef( sal_uLong lFileKey, size_t lPos,
     256             :                          const RscExpression * pExpDec );
     257             : 
     258             :     RscDefine * NewDef( sal_uLong lKey, const OString& rDefName,
     259             :                         sal_Int32 lId, sal_uLong lPos );
     260             :     RscDefine * NewDef( sal_uLong lKey, const OString& rDefName,
     261             :                         RscExpression *, sal_uLong lPos );
     262             : 
     263             :            // Alle Defines die in dieser Datei Definiert sind loeschen
     264             :     void        DeleteFileContext( sal_uLong lKey );
     265             :     sal_uLong   NewCodeFile(const OString& rName);
     266             :     sal_uLong   NewIncFile(const OString& rName, const OString& rPath);
     267           0 :     RscFile *   GetFile( sal_uLong lFileKey ){ return Get( lFileKey ); }
     268             : };
     269             : 
     270             : #endif // _RSCDEF_HXX
     271             : 
     272             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10