LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/rsc/inc - rsctools.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 58 64 90.6 %
Date: 2013-07-09 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             : OString GetTmpFileName();
      44             : bool Append(const OString &rDestFile, const OString &rSourceFile);
      45             : bool Append(FILE * fDest, OString &raSourceFile);
      46             : OString OutputFile(const 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< 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       71575 :     sal_uInt32  Append( char * pStr ){
      78       71575 :                         return( Append( (void *)pStr ) );
      79             :                     };
      80       90334 :     sal_uInt32  GetCount(){ return( nCount ); };
      81             :     void *          GetEntry( sal_uInt32 nEle );
      82        2445 :     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             :     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        9505 :     void *      GetBuffer()
      98             :                 {
      99        9505 :                     return GetPointer( 0 );
     100             :                 }
     101       24424 :     sal_uInt16  GetShort( sal_uInt32 nPos )
     102             :                 {
     103       24424 :                     sal_uInt16 nVal = 0;
     104       24424 :                     char* pFrom = GetPointer(nPos);
     105       24424 :                     char* pTo = (char*)&nVal;
     106       24424 :                     *pTo++ = *pFrom++;
     107       24424 :                     *pTo++ = *pFrom++;
     108       24424 :                     return bSwap ? OSL_SWAPWORD( nVal ) : nVal;
     109             :                 }
     110       77787 :     sal_uInt32  GetLong( sal_uInt32 nPos )
     111             :                 {
     112       77787 :                     sal_uInt32 nVal = 0;
     113       77787 :                     char* pFrom = GetPointer(nPos);
     114       77787 :                     char* pTo = (char*)&nVal;
     115       77787 :                     *pTo++ = *pFrom++;
     116       77787 :                     *pTo++ = *pFrom++;
     117       77787 :                     *pTo++ = *pFrom++;
     118       77787 :                     *pTo++ = *pFrom++;
     119       77787 :                     return bSwap ? OSL_SWAPDWORD( nVal ) : nVal;
     120             :                 }
     121        2252 :     char *      GetUTF8( sal_uInt32 nPos )
     122             :                 {
     123        2252 :                     return GetPointer( nPos );
     124             :                 }
     125             : 
     126             : 
     127             :     RSCBYTEORDER_TYPE GetByteOrder() const { return nByteOrder; }
     128       88914 :     sal_uInt32      Size(){ return( nLen ); };
     129        9505 :     void        Put( sal_uInt64 lVal )
     130             :                 {
     131             :                     union
     132             :                     {
     133             :                         sal_uInt64 lVal64;
     134             :                         sal_uInt32 aVal32[2];
     135             :                     };
     136        9505 :                     lVal64 = lVal;
     137        9505 :                     if( bSwap )
     138             :                     {
     139        9505 :                         Put( aVal32[1] );
     140        9505 :                         Put( aVal32[0] );
     141             :                     }
     142             :                     else
     143             :                     {
     144           0 :                         Put( aVal32[0] );
     145           0 :                         Put( aVal32[1] );
     146             :                     }
     147        9505 :                 }
     148      104008 :     void        Put( sal_Int32 lVal )
     149             :                 {
     150             :                     union
     151             :                     {
     152             :                         sal_uInt32 lVal32;
     153             :                         sal_uInt16 aVal16[2];
     154             :                     };
     155      104008 :                     lVal32 = lVal;
     156             : 
     157      104008 :                     if( bSwap )
     158             :                     {
     159      104008 :                         Put( aVal16[1] );
     160      104008 :                         Put( aVal16[0] );
     161             :                     }
     162             :                     else
     163             :                     {
     164           0 :                         Put( aVal16[0] );
     165           0 :                         Put( aVal16[1] );
     166             :                     }
     167      104008 :                 }
     168       35922 :     void        Put( sal_uInt32 nValue )
     169       35922 :                 { Put( (sal_Int32)nValue ); }
     170             :     void        Put( sal_uInt16 nValue );
     171       99559 :     void        Put( sal_Int16 nValue )
     172       99559 :                 { Put( (sal_uInt16)nValue ); }
     173             :     void        PutUTF8( char * pData );
     174             : 
     175      169857 :     void        PutAt( sal_uInt32 nPos, sal_Int32 lVal )
     176             :                 {
     177             :                     union
     178             :                     {
     179             :                         sal_uInt32 lVal32;
     180             :                         sal_uInt16 aVal16[2];
     181             :                     };
     182      169857 :                     lVal32 = lVal;
     183             : 
     184      169857 :                     if( bSwap )
     185             :                     {
     186      169857 :                         PutAt( nPos, aVal16[1] );
     187      169857 :                         PutAt( nPos + 2, aVal16[0] );
     188             :                     }
     189             :                     else
     190             :                     {
     191           0 :                         PutAt( nPos, aVal16[0] );
     192           0 :                         PutAt( nPos + 2, aVal16[1] );
     193             :                     }
     194      169857 :                 }
     195      169857 :     void        PutAt( sal_uInt32 nPos, sal_uInt32 lVal )
     196             :                 {
     197      169857 :                     PutAt( nPos, (sal_Int32)lVal);
     198      169857 :                 }
     199             :     void        PutAt( sal_uInt32 nPos, short nVal )
     200             :                 {
     201             :                     PutAt( nPos, (sal_uInt16)nVal );
     202             :                 }
     203      651675 :     void        PutAt( sal_uInt32 nPos, sal_uInt16 nVal )
     204             :                 {
     205      651675 :                     if( bSwap )
     206      553979 :                         nVal = OSL_SWAPWORD( nVal );
     207      651675 :                     char* pTo = GetPointer( nPos );
     208      651675 :                     char* pFrom = (char*)&nVal;
     209      651675 :                     *pTo++ = *pFrom++;
     210      651675 :                     *pTo++ = *pFrom++;
     211      651675 :                 }
     212             : };
     213             : 
     214             : #endif // _RSCTOOLS_HXX
     215             : 
     216             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10