LCOV - code coverage report
Current view: top level - solver/unxlngi6.pro/inc/rtl - bootstrap.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 36 37 97.3 %
Date: 2012-08-25 Functions: 13 13 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 1 2 50.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : #ifndef _RTL_BOOTSTRAP_HXX_
      29                 :            : #define _RTL_BOOTSTRAP_HXX_
      30                 :            : #include <rtl/ustring.hxx>
      31                 :            : #include <rtl/bootstrap.h>
      32                 :            : 
      33                 :            : namespace rtl
      34                 :            : {
      35                 :            :     class Bootstrap
      36                 :            :     {
      37                 :            :         void * _handle;
      38                 :            : 
      39                 :            :         inline Bootstrap( Bootstrap const & ); // not impl
      40                 :            :         inline Bootstrap & operator = ( Bootstrap const & ); // not impl
      41                 :            : 
      42                 :            :     public:
      43                 :            :         /**
      44                 :            :          * @see rtl_bootstrap_setIniFileName()
      45                 :            :          */
      46                 :            :         static inline void SAL_CALL setIniFilename( const ::rtl::OUString &sFileUri );
      47                 :            : 
      48                 :            :         /** Retrieves a bootstrap parameter
      49                 :            :            @param sName name of the bootstrap value. case insensitive.
      50                 :            :            @param outValue (out parameter). On success contains the value, otherwise
      51                 :            :                   an empty string.
      52                 :            :            @return sal_False, if no value could be retrieved, otherwise sal_True
      53                 :            :            @see rtl_bootstrap_get()
      54                 :            :          */
      55                 :            :         static inline sal_Bool get(
      56                 :            :             const ::rtl::OUString &sName,
      57                 :            :             ::rtl::OUString &outValue );
      58                 :            : 
      59                 :            :         /** Retrieves a bootstrap parameter
      60                 :            : 
      61                 :            :            @param sName name of the bootstrap value. case insensitive.
      62                 :            :            @param outValue (out parameter). Contains the value associated with sName.
      63                 :            :            @param aDefault if none of the other methods retrieved a value, outValue
      64                 :            :                            is assigned to a Default.
      65                 :            : 
      66                 :            :            @see rtl_bootstrap_get()
      67                 :            :          */
      68                 :            :         static inline void get(
      69                 :            :             const ::rtl::OUString &sName,
      70                 :            :             ::rtl::OUString &outValue,
      71                 :            :             const ::rtl::OUString &aDefault );
      72                 :            : 
      73                 :            :         /** Sets a bootstrap parameter.
      74                 :            : 
      75                 :            :             @param name
      76                 :            :                    name of bootstrap parameter
      77                 :            :             @param value
      78                 :            :                    value of bootstrap parameter
      79                 :            : 
      80                 :            :             @see rtl_bootstrap_set()
      81                 :            :         */
      82                 :            :         static inline void set( ::rtl::OUString const & name, ::rtl::OUString const & value )
      83                 :            :             SAL_THROW(());
      84                 :            : 
      85                 :            :         /** default ctor.
      86                 :            :          */
      87                 :            :         inline Bootstrap();
      88                 :            : 
      89                 :            :         /** Opens a bootstrap argment container
      90                 :            :             @see rtl_bootstrap_args_open()
      91                 :            :          */
      92                 :            :         inline Bootstrap(const OUString & iniName);
      93                 :            : 
      94                 :            :         /** Closes a bootstrap argument container
      95                 :            :             @see rtl_bootstrap_args_close()
      96                 :            :         */
      97                 :            :         inline ~Bootstrap();
      98                 :            : 
      99                 :            :         /** Retrieves a bootstrap argument.
     100                 :            : 
     101                 :            :             It is first tried to retrieve the value via the global function
     102                 :            :             and second via the special bootstrap container.
     103                 :            :             @see rtl_bootstrap_get_from_handle()
     104                 :            :         */
     105                 :            : 
     106                 :            :         inline sal_Bool getFrom(const ::rtl::OUString &sName,
     107                 :            :                                 ::rtl::OUString &outValue) const;
     108                 :            : 
     109                 :            :         /** Retrieves a bootstrap argument.
     110                 :            : 
     111                 :            :             It is first tried to retrieve the value via the global function
     112                 :            :             and second via the special bootstrap container.
     113                 :            :             @see rtl_bootstrap_get_from_handle()
     114                 :            :         */
     115                 :            :         inline void getFrom(const ::rtl::OUString &sName,
     116                 :            :                             ::rtl::OUString &outValue,
     117                 :            :                             const ::rtl::OUString &aDefault) const;
     118                 :            : 
     119                 :            :         /** Retrieves the name of the underlying ini-file.
     120                 :            :             @see rtl_bootstrap_get_iniName_from_handle()
     121                 :            :          */
     122                 :            :         inline void getIniName(::rtl::OUString & iniName) const;
     123                 :            : 
     124                 :            :         /** Expands a macro using bootstrap variables.
     125                 :            : 
     126                 :            :             @param macro    [inout]  The macro to be expanded
     127                 :            :         */
     128                 :       8210 :         inline void expandMacrosFrom( ::rtl::OUString & macro ) const SAL_THROW(())
     129                 :       8210 :             { rtl_bootstrap_expandMacros_from_handle( _handle, &macro.pData ); }
     130                 :            : 
     131                 :            :         /** Expands a macro using default bootstrap variables.
     132                 :            : 
     133                 :            :             @param macro    [inout]  The macro to be expanded
     134                 :            :         */
     135                 :      12515 :         static inline void expandMacros( ::rtl::OUString & macro ) SAL_THROW(())
     136                 :      12515 :             { rtl_bootstrap_expandMacros( &macro.pData ); }
     137                 :            : 
     138                 :            :         /** Provides the bootstrap internal handle.
     139                 :            : 
     140                 :            :             @return bootstrap handle
     141                 :            :         */
     142                 :     115695 :         inline rtlBootstrapHandle getHandle() const SAL_THROW(())
     143                 :     115695 :             { return _handle; }
     144                 :            : 
     145                 :            :         /** Escapes special characters ("$" and "\").
     146                 :            : 
     147                 :            :             @param value
     148                 :            :             an arbitrary value
     149                 :            : 
     150                 :            :             @return
     151                 :            :             the given value, with all occurrences of special characters ("$" and
     152                 :            :             "\") escaped
     153                 :            : 
     154                 :            :             @since UDK 3.2.9
     155                 :            :         */
     156                 :            :         static inline ::rtl::OUString encode( ::rtl::OUString const & value )
     157                 :            :             SAL_THROW(());
     158                 :            :     };
     159                 :            : 
     160                 :            :     //----------------------------------------------------------------------------
     161                 :            :     // IMPLEMENTATION
     162                 :            :     //----------------------------------------------------------------------------
     163                 :            :     inline void Bootstrap::setIniFilename( const ::rtl::OUString &sFile )
     164                 :            :     {
     165                 :            :         rtl_bootstrap_setIniFileName( sFile.pData );
     166                 :            :     }
     167                 :            : 
     168                 :       1851 :     inline sal_Bool Bootstrap::get( const ::rtl::OUString &sName,
     169                 :            :                                     ::rtl::OUString & outValue )
     170                 :            :     {
     171                 :       1851 :         return rtl_bootstrap_get( sName.pData , &(outValue.pData) , 0 );
     172                 :            :     }
     173                 :            : 
     174                 :        158 :     inline void Bootstrap::get( const ::rtl::OUString &sName,
     175                 :            :                                 ::rtl::OUString & outValue,
     176                 :            :                                 const ::rtl::OUString & sDefault )
     177                 :            :     {
     178                 :        158 :         rtl_bootstrap_get( sName.pData , &(outValue.pData) , sDefault.pData );
     179                 :        158 :     }
     180                 :            : 
     181                 :        940 :     inline void Bootstrap::set( ::rtl::OUString const & name, ::rtl::OUString const & value )
     182                 :            :         SAL_THROW(())
     183                 :            :     {
     184                 :        940 :         rtl_bootstrap_set( name.pData, value.pData );
     185                 :        940 :     }
     186                 :            : 
     187                 :       1497 :     inline Bootstrap::Bootstrap()
     188                 :            :     {
     189                 :       1497 :         _handle = 0;
     190                 :       1497 :     }
     191                 :            : 
     192                 :      65654 :     inline Bootstrap::Bootstrap(const OUString & iniName)
     193                 :            :     {
     194         [ +  - ]:      65654 :         if(!iniName.isEmpty())
     195                 :      65654 :             _handle = rtl_bootstrap_args_open(iniName.pData);
     196                 :            : 
     197                 :            :         else
     198                 :          0 :             _handle = 0;
     199                 :      65654 :     }
     200                 :            : 
     201                 :      67046 :     inline Bootstrap::~Bootstrap()
     202                 :            :     {
     203                 :      67046 :         rtl_bootstrap_args_close(_handle);
     204                 :      67046 :     }
     205                 :            : 
     206                 :            : 
     207                 :       9438 :     inline sal_Bool Bootstrap::getFrom(const ::rtl::OUString &sName,
     208                 :            :                                        ::rtl::OUString &outValue) const
     209                 :            :     {
     210                 :       9438 :         return rtl_bootstrap_get_from_handle(_handle, sName.pData, &outValue.pData, 0);
     211                 :            :     }
     212                 :            : 
     213                 :       2182 :     inline void Bootstrap::getFrom(const ::rtl::OUString &sName,
     214                 :            :                                    ::rtl::OUString &outValue,
     215                 :            :                                    const ::rtl::OUString &aDefault) const
     216                 :            :     {
     217                 :       2182 :         rtl_bootstrap_get_from_handle(_handle, sName.pData, &outValue.pData, aDefault.pData);
     218                 :       2182 :     }
     219                 :            : 
     220                 :        583 :     inline void Bootstrap::getIniName(::rtl::OUString & iniName) const
     221                 :            :     {
     222                 :        583 :         rtl_bootstrap_get_iniName_from_handle(_handle, &iniName.pData);
     223                 :        583 :     }
     224                 :            : 
     225                 :        158 :     inline ::rtl::OUString Bootstrap::encode( ::rtl::OUString const & value )
     226                 :            :         SAL_THROW(())
     227                 :            :     {
     228                 :        158 :         ::rtl::OUString encoded;
     229                 :        158 :         rtl_bootstrap_encode(value.pData, &encoded.pData);
     230                 :        158 :         return encoded;
     231                 :            :     }
     232                 :            : }
     233                 :            : #endif
     234                 :            : 
     235                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10