My Project
UDK 3.2.7 C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
bootstrap.hxx
Go to the documentation of this file.
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:
46  static inline void SAL_CALL setIniFilename( const ::rtl::OUString &sFileUri );
47 
55  static inline sal_Bool get(
56  const ::rtl::OUString &sName,
57  ::rtl::OUString &outValue );
58 
68  static inline void get(
69  const ::rtl::OUString &sName,
70  ::rtl::OUString &outValue,
71  const ::rtl::OUString &aDefault );
72 
82  static inline void set( ::rtl::OUString const & name, ::rtl::OUString const & value )
83  SAL_THROW(());
84 
87  inline Bootstrap();
88 
92  inline Bootstrap(const OUString & iniName);
93 
97  inline ~Bootstrap();
98 
106  inline sal_Bool getFrom(const ::rtl::OUString &sName,
107  ::rtl::OUString &outValue) const;
108 
115  inline void getFrom(const ::rtl::OUString &sName,
116  ::rtl::OUString &outValue,
117  const ::rtl::OUString &aDefault) const;
118 
122  inline void getIniName(::rtl::OUString & iniName) const;
123 
128  inline void expandMacrosFrom( ::rtl::OUString & macro ) const SAL_THROW(())
129  { rtl_bootstrap_expandMacros_from_handle( _handle, &macro.pData ); }
130 
135  static inline void expandMacros( ::rtl::OUString & macro ) SAL_THROW(())
136  { rtl_bootstrap_expandMacros( &macro.pData ); }
137 
143  { return _handle; }
144 
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  inline sal_Bool Bootstrap::get( const ::rtl::OUString &sName,
169  ::rtl::OUString & outValue )
170  {
171  return rtl_bootstrap_get( sName.pData , &(outValue.pData) , 0 );
172  }
173 
174  inline void Bootstrap::get( const ::rtl::OUString &sName,
175  ::rtl::OUString & outValue,
176  const ::rtl::OUString & sDefault )
177  {
178  rtl_bootstrap_get( sName.pData , &(outValue.pData) , sDefault.pData );
179  }
180 
181  inline void Bootstrap::set( ::rtl::OUString const & name, ::rtl::OUString const & value )
182  SAL_THROW(())
183  {
184  rtl_bootstrap_set( name.pData, value.pData );
185  }
186 
188  {
189  _handle = 0;
190  }
191 
192  inline Bootstrap::Bootstrap(const OUString & iniName)
193  {
194  if(!iniName.isEmpty())
195  _handle = rtl_bootstrap_args_open(iniName.pData);
196 
197  else
198  _handle = 0;
199  }
200 
202  {
203  rtl_bootstrap_args_close(_handle);
204  }
205 
206 
207  inline sal_Bool Bootstrap::getFrom(const ::rtl::OUString &sName,
208  ::rtl::OUString &outValue) const
209  {
210  return rtl_bootstrap_get_from_handle(_handle, sName.pData, &outValue.pData, 0);
211  }
212 
213  inline void Bootstrap::getFrom(const ::rtl::OUString &sName,
214  ::rtl::OUString &outValue,
215  const ::rtl::OUString &aDefault) const
216  {
217  rtl_bootstrap_get_from_handle(_handle, sName.pData, &outValue.pData, aDefault.pData);
218  }
219 
220  inline void Bootstrap::getIniName(::rtl::OUString & iniName) const
221  {
222  rtl_bootstrap_get_iniName_from_handle(_handle, &iniName.pData);
223  }
224 
225  inline ::rtl::OUString Bootstrap::encode( ::rtl::OUString const & value )
226  SAL_THROW(())
227  {
228  ::rtl::OUString encoded;
229  rtl_bootstrap_encode(value.pData, &encoded.pData);
230  return encoded;
231  }
232 }
233 #endif
234 
235 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */