LCOV - code coverage report
Current view: top level - libreoffice/rsc/inc - rsctools.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 58 64 90.6 %
Date: 2012-12-27 Functions: 15 15 100.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             : struct RSHEADER_TYPE;
      20             : class  RscPtrPtr;
      21             : 
      22             : #ifndef _RSCTOOLS_HXX
      23             : #define _RSCTOOLS_HXX
      24             : 
      25             : #ifdef UNX
      26             : #include <stdlib.h>
      27             : #endif
      28             : #include <stdio.h>
      29             : #include <vector>
      30             : #include <tools/solar.h>
      31             : #include <rtl/ustring.hxx>
      32             : 
      33             : /******************* T y p e s *******************************************/
      34             : // Zeichensatz
      35             : enum COMPARE { LESS = -1, EQUAL = 0, GREATER = 1 };
      36             : 
      37             : enum RSCBYTEORDER_TYPE { RSC_BIGENDIAN, RSC_LITTLEENDIAN, RSC_SYSTEMENDIAN };
      38             : 
      39             : /******************* M A K R O S *****************************************/
      40             : #define ALIGNED_SIZE( nSize )                               \
      41             :             (nSize + sizeof( void * ) -1) / sizeof( void * ) * sizeof( void * )
      42             : /******************* F u n c t i o n   F o r w a r d s *******************/
      43             : rtl::OString GetTmpFileName();
      44             : sal_Bool Append(const rtl::OString &rDestFile, const rtl::OString &rSourceFile);
      45             : sal_Bool Append(FILE * fDest, rtl::OString &raSourceFile);
      46             : rtl::OString OutputFile(const rtl::OString &rInput, const char * ext);
      47             : char * ResponseFile( RscPtrPtr * ppCmd, char ** ppArgv,
      48             :                      sal_uInt32 nArgc );
      49             : void RscExit( sal_uInt32 nExit );
      50             : 
      51             : /********* A n s i - F u n c t i o n   F o r w a r d s *******************/
      52             : int rsc_strnicmp( const char *string1, const char *string2, size_t count );
      53             : int rsc_stricmp( const char *string1, const char *string2 );
      54             : char* rsc_strdup( const char* );
      55             : 
      56             : /****************** C L A S S E S ****************************************/
      57             : 
      58             : typedef ::std::vector< rtl::OString* > RscStrList;
      59             : 
      60             : /*********** R s c C h a r ***********************************************/
      61             : class RscChar
      62             : {
      63             : public:
      64             :     static char * MakeUTF8( char * pStr, sal_uInt16 nTextEncoding );
      65             : };
      66             : 
      67             : /****************** R s c P t r P t r ************************************/
      68             : class RscPtrPtr
      69             : {
      70             :     sal_uInt32  nCount;
      71             :     void **         pMem;
      72             : public:
      73             :                     RscPtrPtr();
      74             :                     ~RscPtrPtr();
      75             :     void            Reset();
      76             :     sal_uInt32  Append( void * );
      77       88916 :     sal_uInt32  Append( char * pStr ){
      78       88916 :                         return( Append( (void *)pStr ) );
      79             :                     };
      80      112160 :     sal_uInt32  GetCount(){ return( nCount ); };
      81             :     void *          GetEntry( sal_uInt32 nEle );
      82        2703 :     void **         GetBlock(){ return( pMem ); };
      83             : };
      84             : 
      85             : /****************** R s c W r i t e R c **********************************/
      86             : class RscWriteRc
      87             : {
      88             :     sal_uInt32              nLen;
      89             :     sal_Bool                bSwap;
      90             :     RSCBYTEORDER_TYPE   nByteOrder;
      91             :     char *              pMem;
      92             :     char *              GetPointer( sal_uInt32 nSize );
      93             : public:
      94             :                 RscWriteRc( RSCBYTEORDER_TYPE nOrder = RSC_SYSTEMENDIAN );
      95             :                 ~RscWriteRc();
      96             :     sal_uInt32      IncSize( sal_uInt32 nSize );// gibt die vorherige Groesse
      97        9489 :     void *      GetBuffer()
      98             :                 {
      99        9489 :                     return GetPointer( 0 );
     100             :                 }
     101       34204 :     sal_uInt16  GetShort( sal_uInt32 nPos )
     102             :                 {
     103       34204 :                     sal_uInt16 nVal = 0;
     104       34204 :                     char* pFrom = GetPointer(nPos);
     105       34204 :                     char* pTo = (char*)&nVal;
     106       34204 :                     *pTo++ = *pFrom++;
     107       34204 :                     *pTo++ = *pFrom++;
     108       34204 :                     return bSwap ? OSL_SWAPWORD( nVal ) : nVal;
     109             :                 }
     110       96339 :     sal_uInt32  GetLong( sal_uInt32 nPos )
     111             :                 {
     112       96339 :                     sal_uInt32 nVal = 0;
     113       96339 :                     char* pFrom = GetPointer(nPos);
     114       96339 :                     char* pTo = (char*)&nVal;
     115       96339 :                     *pTo++ = *pFrom++;
     116       96339 :                     *pTo++ = *pFrom++;
     117       96339 :                     *pTo++ = *pFrom++;
     118       96339 :                     *pTo++ = *pFrom++;
     119       96339 :                     return bSwap ? OSL_SWAPDWORD( nVal ) : nVal;
     120             :                 }
     121        1982 :     char *      GetUTF8( sal_uInt32 nPos )
     122             :                 {
     123        1982 :                     return GetPointer( nPos );
     124             :                 }
     125             : 
     126             : 
     127             :     RSCBYTEORDER_TYPE GetByteOrder() const { return nByteOrder; }
     128       96537 :     sal_uInt32      Size(){ return( nLen ); };
     129        9489 :     void        Put( sal_uInt64 lVal )
     130             :                 {
     131             :                     union
     132             :                     {
     133             :                         sal_uInt64 lVal64;
     134             :                         sal_uInt32 aVal32[2];
     135             :                     };
     136        9489 :                     lVal64 = lVal;
     137        9489 :                     if( bSwap )
     138             :                     {
     139        9489 :                         Put( aVal32[1] );
     140        9489 :                         Put( aVal32[0] );
     141             :                     }
     142             :                     else
     143             :                     {
     144           0 :                         Put( aVal32[0] );
     145           0 :                         Put( aVal32[1] );
     146             :                     }
     147        9489 :                 }
     148      127866 :     void        Put( sal_Int32 lVal )
     149             :                 {
     150             :                     union
     151             :                     {
     152             :                         sal_uInt32 lVal32;
     153             :                         sal_uInt16 aVal16[2];
     154             :                     };
     155      127866 :                     lVal32 = lVal;
     156             : 
     157      127866 :                     if( bSwap )
     158             :                     {
     159      127866 :                         Put( aVal16[1] );
     160      127866 :                         Put( aVal16[0] );
     161             :                     }
     162             :                     else
     163             :                     {
     164           0 :                         Put( aVal16[0] );
     165           0 :                         Put( aVal16[1] );
     166             :                     }
     167      127866 :                 }
     168       38921 :     void        Put( sal_uInt32 nValue )
     169       38921 :                 { Put( (sal_Int32)nValue ); }
     170             :     void        Put( sal_uInt16 nValue );
     171      138658 :     void        Put( sal_Int16 nValue )
     172      138658 :                 { Put( (sal_uInt16)nValue ); }
     173             :     void        PutUTF8( char * pData );
     174             : 
     175      197917 :     void        PutAt( sal_uInt32 nPos, sal_Int32 lVal )
     176             :                 {
     177             :                     union
     178             :                     {
     179             :                         sal_uInt32 lVal32;
     180             :                         sal_uInt16 aVal16[2];
     181             :                     };
     182      197917 :                     lVal32 = lVal;
     183             : 
     184      197917 :                     if( bSwap )
     185             :                     {
     186      197917 :                         PutAt( nPos, aVal16[1] );
     187      197917 :                         PutAt( nPos + 2, aVal16[0] );
     188             :                     }
     189             :                     else
     190             :                     {
     191           0 :                         PutAt( nPos, aVal16[0] );
     192           0 :                         PutAt( nPos + 2, aVal16[1] );
     193             :                     }
     194      197917 :                 }
     195      197917 :     void        PutAt( sal_uInt32 nPos, sal_uInt32 lVal )
     196             :                 {
     197      197917 :                     PutAt( nPos, (sal_Int32)lVal);
     198      197917 :                 }
     199             :     void        PutAt( sal_uInt32 nPos, short nVal )
     200             :                 {
     201             :                     PutAt( nPos, (sal_uInt16)nVal );
     202             :                 }
     203      795908 :     void        PutAt( sal_uInt32 nPos, sal_uInt16 nVal )
     204             :                 {
     205      795908 :                     if( bSwap )
     206      659092 :                         nVal = OSL_SWAPWORD( nVal );
     207      795908 :                     char* pTo = GetPointer( nPos );
     208      795908 :                     char* pFrom = (char*)&nVal;
     209      795908 :                     *pTo++ = *pFrom++;
     210      795908 :                     *pTo++ = *pFrom++;
     211      795908 :                 }
     212             : };
     213             : 
     214             : #endif // _RSCTOOLS_HXX
     215             : 
     216             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10