LCOV - code coverage report
Current view: top level - libreoffice/solver/unxlngi6.pro/inc/rtl - bootstrap.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 27 37 73.0 %
Date: 2012-12-27 Functions: 10 13 76.9 %
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 _RTL_BOOTSTRAP_HXX_
      20             : #define _RTL_BOOTSTRAP_HXX_
      21             : #include <rtl/ustring.hxx>
      22             : #include <rtl/bootstrap.h>
      23             : 
      24             : namespace rtl
      25             : {
      26             :     class Bootstrap
      27             :     {
      28             :         void * _handle;
      29             : 
      30             :         inline Bootstrap( Bootstrap const & ); // not impl
      31             :         inline Bootstrap & operator = ( Bootstrap const & ); // not impl
      32             : 
      33             :     public:
      34             :         /**
      35             :          * @see rtl_bootstrap_setIniFileName()
      36             :          */
      37             :         static inline void SAL_CALL setIniFilename( const ::rtl::OUString &sFileUri );
      38             : 
      39             :         /** Retrieves a bootstrap parameter
      40             :            @param sName name of the bootstrap value. case insensitive.
      41             :            @param outValue (out parameter). On success contains the value, otherwise
      42             :                   an empty string.
      43             :            @return sal_False, if no value could be retrieved, otherwise sal_True
      44             :            @see rtl_bootstrap_get()
      45             :          */
      46             :         static inline sal_Bool get(
      47             :             const ::rtl::OUString &sName,
      48             :             ::rtl::OUString &outValue );
      49             : 
      50             :         /** Retrieves a bootstrap parameter
      51             : 
      52             :            @param sName name of the bootstrap value. case insensitive.
      53             :            @param outValue (out parameter). Contains the value associated with sName.
      54             :            @param aDefault if none of the other methods retrieved a value, outValue
      55             :                            is assigned to a Default.
      56             : 
      57             :            @see rtl_bootstrap_get()
      58             :          */
      59             :         static inline void get(
      60             :             const ::rtl::OUString &sName,
      61             :             ::rtl::OUString &outValue,
      62             :             const ::rtl::OUString &aDefault );
      63             : 
      64             :         /** Sets a bootstrap parameter.
      65             : 
      66             :             @param name
      67             :                    name of bootstrap parameter
      68             :             @param value
      69             :                    value of bootstrap parameter
      70             : 
      71             :             @see rtl_bootstrap_set()
      72             :         */
      73             :         static inline void set( ::rtl::OUString const & name, ::rtl::OUString const & value )
      74             :             SAL_THROW(());
      75             : 
      76             :         /** default ctor.
      77             :          */
      78             :         inline Bootstrap();
      79             : 
      80             :         /** Opens a bootstrap argment container
      81             :             @see rtl_bootstrap_args_open()
      82             :          */
      83             :         inline Bootstrap(const OUString & iniName);
      84             : 
      85             :         /** Closes a bootstrap argument container
      86             :             @see rtl_bootstrap_args_close()
      87             :         */
      88             :         inline ~Bootstrap();
      89             : 
      90             :         /** Retrieves a bootstrap argument.
      91             : 
      92             :             It is first tried to retrieve the value via the global function
      93             :             and second via the special bootstrap container.
      94             :             @see rtl_bootstrap_get_from_handle()
      95             :         */
      96             : 
      97             :         inline sal_Bool getFrom(const ::rtl::OUString &sName,
      98             :                                 ::rtl::OUString &outValue) const;
      99             : 
     100             :         /** Retrieves a bootstrap argument.
     101             : 
     102             :             It is first tried to retrieve the value via the global function
     103             :             and second via the special bootstrap container.
     104             :             @see rtl_bootstrap_get_from_handle()
     105             :         */
     106             :         inline void getFrom(const ::rtl::OUString &sName,
     107             :                             ::rtl::OUString &outValue,
     108             :                             const ::rtl::OUString &aDefault) const;
     109             : 
     110             :         /** Retrieves the name of the underlying ini-file.
     111             :             @see rtl_bootstrap_get_iniName_from_handle()
     112             :          */
     113             :         inline void getIniName(::rtl::OUString & iniName) const;
     114             : 
     115             :         /** Expands a macro using bootstrap variables.
     116             : 
     117             :             @param macro    [inout]  The macro to be expanded
     118             :         */
     119           0 :         inline void expandMacrosFrom( ::rtl::OUString & macro ) const SAL_THROW(())
     120           0 :             { rtl_bootstrap_expandMacros_from_handle( _handle, &macro.pData ); }
     121             : 
     122             :         /** Expands a macro using default bootstrap variables.
     123             : 
     124             :             @param macro    [inout]  The macro to be expanded
     125             :         */
     126        1165 :         static inline void expandMacros( ::rtl::OUString & macro ) SAL_THROW(())
     127        1165 :             { rtl_bootstrap_expandMacros( &macro.pData ); }
     128             : 
     129             :         /** Provides the bootstrap internal handle.
     130             : 
     131             :             @return bootstrap handle
     132             :         */
     133        2599 :         inline rtlBootstrapHandle getHandle() const SAL_THROW(())
     134        2599 :             { return _handle; }
     135             : 
     136             :         /** Escapes special characters ("$" and "\").
     137             : 
     138             :             @param value
     139             :             an arbitrary value
     140             : 
     141             :             @return
     142             :             the given value, with all occurrences of special characters ("$" and
     143             :             "\") escaped
     144             : 
     145             :             @since UDK 3.2.9
     146             :         */
     147             :         static inline ::rtl::OUString encode( ::rtl::OUString const & value )
     148             :             SAL_THROW(());
     149             :     };
     150             : 
     151             :     //----------------------------------------------------------------------------
     152             :     // IMPLEMENTATION
     153             :     //----------------------------------------------------------------------------
     154             :     inline void Bootstrap::setIniFilename( const ::rtl::OUString &sFile )
     155             :     {
     156             :         rtl_bootstrap_setIniFileName( sFile.pData );
     157             :     }
     158             : 
     159         334 :     inline sal_Bool Bootstrap::get( const ::rtl::OUString &sName,
     160             :                                     ::rtl::OUString & outValue )
     161             :     {
     162         334 :         return rtl_bootstrap_get( sName.pData , &(outValue.pData) , 0 );
     163             :     }
     164             : 
     165           0 :     inline void Bootstrap::get( const ::rtl::OUString &sName,
     166             :                                 ::rtl::OUString & outValue,
     167             :                                 const ::rtl::OUString & sDefault )
     168             :     {
     169           0 :         rtl_bootstrap_get( sName.pData , &(outValue.pData) , sDefault.pData );
     170           0 :     }
     171             : 
     172         204 :     inline void Bootstrap::set( ::rtl::OUString const & name, ::rtl::OUString const & value )
     173             :         SAL_THROW(())
     174             :     {
     175         204 :         rtl_bootstrap_set( name.pData, value.pData );
     176         204 :     }
     177             : 
     178         198 :     inline Bootstrap::Bootstrap()
     179             :     {
     180         198 :         _handle = 0;
     181         198 :     }
     182             : 
     183         933 :     inline Bootstrap::Bootstrap(const OUString & iniName)
     184             :     {
     185         933 :         if(!iniName.isEmpty())
     186         933 :             _handle = rtl_bootstrap_args_open(iniName.pData);
     187             : 
     188             :         else
     189           0 :             _handle = 0;
     190         933 :     }
     191             : 
     192        1131 :     inline Bootstrap::~Bootstrap()
     193             :     {
     194        1131 :         rtl_bootstrap_args_close(_handle);
     195        1131 :     }
     196             : 
     197             : 
     198        2431 :     inline sal_Bool Bootstrap::getFrom(const ::rtl::OUString &sName,
     199             :                                        ::rtl::OUString &outValue) const
     200             :     {
     201        2431 :         return rtl_bootstrap_get_from_handle(_handle, sName.pData, &outValue.pData, 0);
     202             :     }
     203             : 
     204         330 :     inline void Bootstrap::getFrom(const ::rtl::OUString &sName,
     205             :                                    ::rtl::OUString &outValue,
     206             :                                    const ::rtl::OUString &aDefault) const
     207             :     {
     208         330 :         rtl_bootstrap_get_from_handle(_handle, sName.pData, &outValue.pData, aDefault.pData);
     209         330 :     }
     210             : 
     211          19 :     inline void Bootstrap::getIniName(::rtl::OUString & iniName) const
     212             :     {
     213          19 :         rtl_bootstrap_get_iniName_from_handle(_handle, &iniName.pData);
     214          19 :     }
     215             : 
     216           0 :     inline ::rtl::OUString Bootstrap::encode( ::rtl::OUString const & value )
     217             :         SAL_THROW(())
     218             :     {
     219           0 :         ::rtl::OUString encoded;
     220           0 :         rtl_bootstrap_encode(value.pData, &encoded.pData);
     221           0 :         return encoded;
     222             :     }
     223             : }
     224             : #endif
     225             : 
     226             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10