UDK 3.2.7 C/C++ API Reference
|
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 00002 /************************************************************************* 00003 * 00004 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 00005 * 00006 * Copyright 2000, 2010 Oracle and/or its affiliates. 00007 * 00008 * OpenOffice.org - a multi-platform office productivity suite 00009 * 00010 * This file is part of OpenOffice.org. 00011 * 00012 * OpenOffice.org is free software: you can redistribute it and/or modify 00013 * it under the terms of the GNU Lesser General Public License version 3 00014 * only, as published by the Free Software Foundation. 00015 * 00016 * OpenOffice.org is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Lesser General Public License version 3 for more details 00020 * (a copy is included in the LICENSE file that accompanied this code). 00021 * 00022 * You should have received a copy of the GNU Lesser General Public License 00023 * version 3 along with OpenOffice.org. If not, see 00024 * <http://www.openoffice.org/license.html> 00025 * for a copy of the LGPLv3 License. 00026 * 00027 ************************************************************************/ 00028 #ifndef _RTL_BOOTSTRAP_HXX_ 00029 #define _RTL_BOOTSTRAP_HXX_ 00030 #include <rtl/ustring.hxx> 00031 #include <rtl/bootstrap.h> 00032 00033 namespace rtl 00034 { 00035 class Bootstrap 00036 { 00037 void * _handle; 00038 00039 inline Bootstrap( Bootstrap const & ); // not impl 00040 inline Bootstrap & operator = ( Bootstrap const & ); // not impl 00041 00042 public: 00046 static inline void SAL_CALL setIniFilename( const ::rtl::OUString &sFileUri ); 00047 00055 static inline sal_Bool get( 00056 const ::rtl::OUString &sName, 00057 ::rtl::OUString &outValue ); 00058 00068 static inline void get( 00069 const ::rtl::OUString &sName, 00070 ::rtl::OUString &outValue, 00071 const ::rtl::OUString &aDefault ); 00072 00082 static inline void set( ::rtl::OUString const & name, ::rtl::OUString const & value ) 00083 SAL_THROW(()); 00084 00087 inline Bootstrap(); 00088 00092 inline Bootstrap(const OUString & iniName); 00093 00097 inline ~Bootstrap(); 00098 00106 inline sal_Bool getFrom(const ::rtl::OUString &sName, 00107 ::rtl::OUString &outValue) const; 00108 00115 inline void getFrom(const ::rtl::OUString &sName, 00116 ::rtl::OUString &outValue, 00117 const ::rtl::OUString &aDefault) const; 00118 00122 inline void getIniName(::rtl::OUString & iniName) const; 00123 00128 inline void expandMacrosFrom( ::rtl::OUString & macro ) const SAL_THROW(()) 00129 { rtl_bootstrap_expandMacros_from_handle( _handle, ¯o.pData ); } 00130 00135 static inline void expandMacros( ::rtl::OUString & macro ) SAL_THROW(()) 00136 { rtl_bootstrap_expandMacros( ¯o.pData ); } 00137 00142 inline rtlBootstrapHandle getHandle() const SAL_THROW(()) 00143 { return _handle; } 00144 00156 static inline ::rtl::OUString encode( ::rtl::OUString const & value ) 00157 SAL_THROW(()); 00158 }; 00159 00160 //---------------------------------------------------------------------------- 00161 // IMPLEMENTATION 00162 //---------------------------------------------------------------------------- 00163 inline void Bootstrap::setIniFilename( const ::rtl::OUString &sFile ) 00164 { 00165 rtl_bootstrap_setIniFileName( sFile.pData ); 00166 } 00167 00168 inline sal_Bool Bootstrap::get( const ::rtl::OUString &sName, 00169 ::rtl::OUString & outValue ) 00170 { 00171 return rtl_bootstrap_get( sName.pData , &(outValue.pData) , 0 ); 00172 } 00173 00174 inline void Bootstrap::get( const ::rtl::OUString &sName, 00175 ::rtl::OUString & outValue, 00176 const ::rtl::OUString & sDefault ) 00177 { 00178 rtl_bootstrap_get( sName.pData , &(outValue.pData) , sDefault.pData ); 00179 } 00180 00181 inline void Bootstrap::set( ::rtl::OUString const & name, ::rtl::OUString const & value ) 00182 SAL_THROW(()) 00183 { 00184 rtl_bootstrap_set( name.pData, value.pData ); 00185 } 00186 00187 inline Bootstrap::Bootstrap() 00188 { 00189 _handle = 0; 00190 } 00191 00192 inline Bootstrap::Bootstrap(const OUString & iniName) 00193 { 00194 if(!iniName.isEmpty()) 00195 _handle = rtl_bootstrap_args_open(iniName.pData); 00196 00197 else 00198 _handle = 0; 00199 } 00200 00201 inline Bootstrap::~Bootstrap() 00202 { 00203 rtl_bootstrap_args_close(_handle); 00204 } 00205 00206 00207 inline sal_Bool Bootstrap::getFrom(const ::rtl::OUString &sName, 00208 ::rtl::OUString &outValue) const 00209 { 00210 return rtl_bootstrap_get_from_handle(_handle, sName.pData, &outValue.pData, 0); 00211 } 00212 00213 inline void Bootstrap::getFrom(const ::rtl::OUString &sName, 00214 ::rtl::OUString &outValue, 00215 const ::rtl::OUString &aDefault) const 00216 { 00217 rtl_bootstrap_get_from_handle(_handle, sName.pData, &outValue.pData, aDefault.pData); 00218 } 00219 00220 inline void Bootstrap::getIniName(::rtl::OUString & iniName) const 00221 { 00222 rtl_bootstrap_get_iniName_from_handle(_handle, &iniName.pData); 00223 } 00224 00225 inline ::rtl::OUString Bootstrap::encode( ::rtl::OUString const & value ) 00226 SAL_THROW(()) 00227 { 00228 ::rtl::OUString encoded; 00229 rtl_bootstrap_encode(value.pData, &encoded.pData); 00230 return encoded; 00231 } 00232 } 00233 #endif 00234 00235 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */