LCOV - code coverage report
Current view: top level - tools/inc/tools - solar.h (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 3 3 100.0 %
Date: 2012-08-25 Functions: 6 7 85.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 4 4 100.0 %

           Branch data     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 _SOLAR_H
      21                 :            : #define _SOLAR_H
      22                 :            : 
      23                 :            : #include <sal/types.h>
      24                 :            : #include <osl/endian.h>
      25                 :            : #include <comphelper/fileformat.h>
      26                 :            : 
      27                 :            : #ifdef _SOLAR__PRIVATE
      28                 :            : #undef _SOLAR__PRIVATE
      29                 :            : #endif
      30                 :            : #define _SOLAR__PRIVATE 1
      31                 :            : 
      32                 :            : /** Intermediate type to solve type clash with Windows headers.
      33                 :            :  Should be removed as soon as all code parts have been reviewed
      34                 :            :  and the correct type is known. Most of the times ULONG is meant
      35                 :            :  to be a 32-Bit unsigned integer type as sal_uInt32 is often
      36                 :            :  used for data exchange or for similiar method args. */
      37                 :            : typedef sal_uIntPtr    sal_uLong; /* Replaces type ULONG */
      38                 :            : 
      39                 :            : // misc. macros to leverage platform and compiler differences
      40                 :            : 
      41                 :            : #define DELETEZ( p )    ( delete p,p = 0 )
      42                 :            : 
      43                 :            : #ifdef WNT
      44                 :            : #if defined (_MSC_VER) && ( _MSC_VER < 1200 )
      45                 :            : #define __LOADONCALLAPI _cdecl
      46                 :            : #else
      47                 :            : #define __LOADONCALLAPI __cdecl
      48                 :            : #endif
      49                 :            : #else
      50                 :            : #define __LOADONCALLAPI
      51                 :            : #endif
      52                 :            : 
      53                 :            : #if defined UNX
      54                 :            : #define ILLEGAL_POINTER ((void*)1)
      55                 :            : #else
      56                 :            : #define ILLEGAL_POINTER NULL
      57                 :            : #endif
      58                 :            : 
      59                 :            : // solar binary types
      60                 :            : 
      61                 :            : /* Solar (portable) Binary (exchange) Type; OSI 6 subset
      62                 :            :    always little endian;
      63                 :            :    not necessarily aligned */
      64                 :            : 
      65                 :            : typedef sal_uInt8   SVBT8[1];
      66                 :            : typedef sal_uInt8   SVBT16[2];
      67                 :            : typedef sal_uInt8   SVBT32[4];
      68                 :            : typedef sal_uInt8   SVBT64[8];
      69                 :            : 
      70                 :            : #ifdef __cplusplus
      71                 :            : 
      72                 :            : inline sal_uInt8  SVBT8ToByte  ( const SVBT8  p ) { return p[0]; }
      73                 :            : inline sal_uInt16 SVBT16ToShort( const SVBT16 p ) { return (sal_uInt16)p[0]
      74                 :            :                                                    + ((sal_uInt16)p[1] <<  8); }
      75                 :            : inline sal_uInt32 SVBT32ToUInt32 ( const SVBT32 p ) { return (sal_uInt32)p[0]
      76                 :            :                                                    + ((sal_uInt32)p[1] <<  8)
      77                 :            :                                                    + ((sal_uInt32)p[2] << 16)
      78                 :            :                                                    + ((sal_uInt32)p[3] << 24); }
      79                 :            : #if defined OSL_LITENDIAN
      80                 :            : inline double   SVBT64ToDouble( const SVBT64 p ) { double n;
      81                 :            :                                                     ((sal_uInt8*)&n)[0] = p[0];
      82                 :            :                                                     ((sal_uInt8*)&n)[1] = p[1];
      83                 :            :                                                     ((sal_uInt8*)&n)[2] = p[2];
      84                 :            :                                                     ((sal_uInt8*)&n)[3] = p[3];
      85                 :            :                                                     ((sal_uInt8*)&n)[4] = p[4];
      86                 :            :                                                     ((sal_uInt8*)&n)[5] = p[5];
      87                 :            :                                                     ((sal_uInt8*)&n)[6] = p[6];
      88                 :            :                                                     ((sal_uInt8*)&n)[7] = p[7];
      89                 :            :                                                     return n; }
      90                 :            : #else
      91                 :            : inline double   SVBT64ToDouble( const SVBT64 p ) { double n;
      92                 :            :                                                     ((sal_uInt8*)&n)[0] = p[7];
      93                 :            :                                                     ((sal_uInt8*)&n)[1] = p[6];
      94                 :            :                                                     ((sal_uInt8*)&n)[2] = p[5];
      95                 :            :                                                     ((sal_uInt8*)&n)[3] = p[4];
      96                 :            :                                                     ((sal_uInt8*)&n)[4] = p[3];
      97                 :            :                                                     ((sal_uInt8*)&n)[5] = p[2];
      98                 :            :                                                     ((sal_uInt8*)&n)[6] = p[1];
      99                 :            :                                                     ((sal_uInt8*)&n)[7] = p[0];
     100                 :            :                                                     return n; }
     101                 :            : #endif
     102                 :            : 
     103                 :            : inline void     ByteToSVBT8  ( sal_uInt8   n, SVBT8 p ) { p[0] = n; }
     104                 :            : inline void     ShortToSVBT16( sal_uInt16 n, SVBT16 p ) { p[0] = (sal_uInt8) n;
     105                 :            :                                                       p[1] = (sal_uInt8)(n >>  8); }
     106                 :            : inline void     UInt32ToSVBT32 ( sal_uInt32  n, SVBT32 p ) { p[0] = (sal_uInt8) n;
     107                 :            :                                                       p[1] = (sal_uInt8)(n >>  8);
     108                 :            :                                                       p[2] = (sal_uInt8)(n >> 16);
     109                 :            :                                                       p[3] = (sal_uInt8)(n >> 24); }
     110                 :            : #if defined OSL_LITENDIAN
     111                 :            : inline void     DoubleToSVBT64( double n, SVBT64 p ) { p[0] = ((sal_uInt8*)&n)[0];
     112                 :            :                                                        p[1] = ((sal_uInt8*)&n)[1];
     113                 :            :                                                        p[2] = ((sal_uInt8*)&n)[2];
     114                 :            :                                                        p[3] = ((sal_uInt8*)&n)[3];
     115                 :            :                                                        p[4] = ((sal_uInt8*)&n)[4];
     116                 :            :                                                        p[5] = ((sal_uInt8*)&n)[5];
     117                 :            :                                                        p[6] = ((sal_uInt8*)&n)[6];
     118                 :            :                                                        p[7] = ((sal_uInt8*)&n)[7]; }
     119                 :            : #else
     120                 :            : inline void     DoubleToSVBT64( double n, SVBT64 p ) { p[0] = ((sal_uInt8*)&n)[7];
     121                 :            :                                                        p[1] = ((sal_uInt8*)&n)[6];
     122                 :            :                                                        p[2] = ((sal_uInt8*)&n)[5];
     123                 :            :                                                        p[3] = ((sal_uInt8*)&n)[4];
     124                 :            :                                                        p[4] = ((sal_uInt8*)&n)[3];
     125                 :            :                                                        p[5] = ((sal_uInt8*)&n)[2];
     126                 :            :                                                        p[6] = ((sal_uInt8*)&n)[1];
     127                 :            :                                                        p[7] = ((sal_uInt8*)&n)[0]; }
     128                 :            : #endif
     129                 :            : #endif
     130                 :            : 
     131                 :            : #ifndef __cplusplus
     132                 :            : #ifndef min
     133                 :            : #define min(a,b)    (((a) < (b)) ? (a) : (b))
     134                 :            : #endif
     135                 :            : #ifndef max
     136                 :            : #define max(a,b)    (((a) > (b)) ? (a) : (b))
     137                 :            : #endif
     138                 :            : #endif
     139                 :            : 
     140                 :            : #ifdef __cplusplus
     141         [ +  + ]:    4526498 : template<typename T> inline T Min(T a, T b) { return (a<b?a:b); }
     142         [ +  + ]:    4520296 : template<typename T> inline T Max(T a, T b) { return (a>b?a:b); }
     143                 :   14186679 : template<typename T> inline T Abs(T a) { return (a>=0?a:-a); }
     144                 :            : #endif
     145                 :            : 
     146                 :            : #ifdef __cplusplus
     147                 :            : #define EXTERN_C    extern "C"
     148                 :            : #else
     149                 :            : #define EXTERN_C
     150                 :            : #endif
     151                 :            : 
     152                 :            : #ifdef NOHACKS
     153                 :            : #define HACK( comment ) #error hack: comment
     154                 :            : #else
     155                 :            : #define HACK( comment )
     156                 :            : #endif
     157                 :            : 
     158                 :            : #define _LF     ((char)0x0A)
     159                 :            : #define _CR     ((char)0x0D)
     160                 :            : 
     161                 :            : // pragmas
     162                 :            : 
     163                 :            : #if defined _MSC_VER
     164                 :            : /* deletion of pointer to incomplete type '...'; no destructor called
     165                 :            :  serious error, memory deleted without call of dtor */
     166                 :            : #pragma warning( error: 4150 )
     167                 :            : // warning C4002: too many actual parameters for macro
     168                 :            : // warning C4003: not enough actual parameters for macro
     169                 :            : #pragma warning(error : 4002 4003)
     170                 :            : #endif
     171                 :            : 
     172                 :            : // dll file extensions
     173                 :            : 
     174                 :            : #if defined WNT
     175                 :            :   #define __DLLEXTENSION "lo"
     176                 :            : #elif defined MACOSX
     177                 :            :   #define __DLLEXTENSION "lo.dylib"
     178                 :            : #elif defined UNX
     179                 :            :   #define __DLLEXTENSION "lo.so"
     180                 :            : #else
     181                 :            :   #error unknown platform
     182                 :            : #endif
     183                 :            : 
     184                 :            : #define UniString       String
     185                 :            : #define XubString       String
     186                 :            : #define xub_Unicode     sal_Unicode
     187                 :            : #define xub_StrLen      sal_uInt16
     188                 :            : 
     189                 :            : #define LIBRARY_CONCAT3( s1, s2, s3 ) \
     190                 :            :     s1 s2 s3
     191                 :            : #define LIBRARY_CONCAT4( s1, s2, s3, s4 ) \
     192                 :            :     s1 s2 s3 s4
     193                 :            : 
     194                 :            : #if defined WNT
     195                 :            : #define SVLIBRARY( Base ) \
     196                 :            :     LIBRARY_CONCAT3( Base, __DLLEXTENSION, ".DLL" )
     197                 :            : #elif defined UNX
     198                 :            : #define SVLIBRARY( Base ) \
     199                 :            :     LIBRARY_CONCAT3( "lib", Base, __DLLEXTENSION )
     200                 :            : #else
     201                 :            : #define SVLIBRARY( Base ) \
     202                 :            :     LIBRARY_CONCAT2( Base, __DLLEXTENSION )
     203                 :            : #endif
     204                 :            : 
     205                 :            : #endif
     206                 :            : 
     207                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10