UDK 3.2.7 C/C++ API Reference

rtl/bootstrap.hxx

Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /*
00003  * This file is part of the LibreOffice project.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  *
00009  * This file incorporates work covered by the following license notice:
00010  *
00011  *   Licensed to the Apache Software Foundation (ASF) under one or more
00012  *   contributor license agreements. See the NOTICE file distributed
00013  *   with this work for additional information regarding copyright
00014  *   ownership. The ASF licenses this file to you under the Apache
00015  *   License, Version 2.0 (the "License"); you may not use this file
00016  *   except in compliance with the License. You may obtain a copy of
00017  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
00018  */
00019 #ifndef _RTL_BOOTSTRAP_HXX_
00020 #define _RTL_BOOTSTRAP_HXX_
00021 #include <rtl/ustring.hxx>
00022 #include <rtl/bootstrap.h>
00023 
00024 namespace rtl
00025 {
00026     class Bootstrap
00027     {
00028         void * _handle;
00029 
00030         inline Bootstrap( Bootstrap const & ); // not impl
00031         inline Bootstrap & operator = ( Bootstrap const & ); // not impl
00032 
00033     public:
00037         static inline void SAL_CALL setIniFilename( const ::rtl::OUString &sFileUri );
00038 
00046         static inline sal_Bool get(
00047             const ::rtl::OUString &sName,
00048             ::rtl::OUString &outValue );
00049 
00059         static inline void get(
00060             const ::rtl::OUString &sName,
00061             ::rtl::OUString &outValue,
00062             const ::rtl::OUString &aDefault );
00063 
00073         static inline void set( ::rtl::OUString const & name, ::rtl::OUString const & value )
00074             SAL_THROW(());
00075 
00078         inline Bootstrap();
00079 
00083         inline Bootstrap(const OUString & iniName);
00084 
00088         inline ~Bootstrap();
00089 
00097         inline sal_Bool getFrom(const ::rtl::OUString &sName,
00098                                 ::rtl::OUString &outValue) const;
00099 
00106         inline void getFrom(const ::rtl::OUString &sName,
00107                             ::rtl::OUString &outValue,
00108                             const ::rtl::OUString &aDefault) const;
00109 
00113         inline void getIniName(::rtl::OUString & iniName) const;
00114 
00119         inline void expandMacrosFrom( ::rtl::OUString & macro ) const SAL_THROW(())
00120             { rtl_bootstrap_expandMacros_from_handle( _handle, &macro.pData ); }
00121 
00126         static inline void expandMacros( ::rtl::OUString & macro ) SAL_THROW(())
00127             { rtl_bootstrap_expandMacros( &macro.pData ); }
00128 
00133         inline rtlBootstrapHandle getHandle() const SAL_THROW(())
00134             { return _handle; }
00135 
00147         static inline ::rtl::OUString encode( ::rtl::OUString const & value )
00148             SAL_THROW(());
00149     };
00150 
00151     //----------------------------------------------------------------------------
00152     // IMPLEMENTATION
00153     //----------------------------------------------------------------------------
00154     inline void Bootstrap::setIniFilename( const ::rtl::OUString &sFile )
00155     {
00156         rtl_bootstrap_setIniFileName( sFile.pData );
00157     }
00158 
00159     inline sal_Bool Bootstrap::get( const ::rtl::OUString &sName,
00160                                     ::rtl::OUString & outValue )
00161     {
00162         return rtl_bootstrap_get( sName.pData , &(outValue.pData) , 0 );
00163     }
00164 
00165     inline void Bootstrap::get( const ::rtl::OUString &sName,
00166                                 ::rtl::OUString & outValue,
00167                                 const ::rtl::OUString & sDefault )
00168     {
00169         rtl_bootstrap_get( sName.pData , &(outValue.pData) , sDefault.pData );
00170     }
00171 
00172     inline void Bootstrap::set( ::rtl::OUString const & name, ::rtl::OUString const & value )
00173         SAL_THROW(())
00174     {
00175         rtl_bootstrap_set( name.pData, value.pData );
00176     }
00177 
00178     inline Bootstrap::Bootstrap()
00179     {
00180         _handle = 0;
00181     }
00182 
00183     inline Bootstrap::Bootstrap(const OUString & iniName)
00184     {
00185         if(!iniName.isEmpty())
00186             _handle = rtl_bootstrap_args_open(iniName.pData);
00187 
00188         else
00189             _handle = 0;
00190     }
00191 
00192     inline Bootstrap::~Bootstrap()
00193     {
00194         rtl_bootstrap_args_close(_handle);
00195     }
00196 
00197 
00198     inline sal_Bool Bootstrap::getFrom(const ::rtl::OUString &sName,
00199                                        ::rtl::OUString &outValue) const
00200     {
00201         return rtl_bootstrap_get_from_handle(_handle, sName.pData, &outValue.pData, 0);
00202     }
00203 
00204     inline void Bootstrap::getFrom(const ::rtl::OUString &sName,
00205                                    ::rtl::OUString &outValue,
00206                                    const ::rtl::OUString &aDefault) const
00207     {
00208         rtl_bootstrap_get_from_handle(_handle, sName.pData, &outValue.pData, aDefault.pData);
00209     }
00210 
00211     inline void Bootstrap::getIniName(::rtl::OUString & iniName) const
00212     {
00213         rtl_bootstrap_get_iniName_from_handle(_handle, &iniName.pData);
00214     }
00215 
00216     inline ::rtl::OUString Bootstrap::encode( ::rtl::OUString const & value )
00217         SAL_THROW(())
00218     {
00219         ::rtl::OUString encoded;
00220         rtl_bootstrap_encode(value.pData, &encoded.pData);
00221         return encoded;
00222     }
00223 }
00224 #endif
00225 
00226 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines