LibreOffice
LibreOffice 4.3 SDK C/C++ API Reference
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  * 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 INCLUDED_RTL_BOOTSTRAP_HXX
20 #define INCLUDED_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:
37  static inline void SAL_CALL setIniFilename( const ::rtl::OUString &sFileUri );
38 
46  static inline bool get(
47  const ::rtl::OUString &sName,
48  ::rtl::OUString &outValue );
49 
59  static inline void get(
60  const ::rtl::OUString &sName,
61  ::rtl::OUString &outValue,
62  const ::rtl::OUString &aDefault );
63 
73  static inline void set( ::rtl::OUString const & name, ::rtl::OUString const & value )
74  SAL_THROW(());
75 
78  inline Bootstrap();
79 
83  inline Bootstrap(const rtl::OUString & iniName);
84 
88  inline ~Bootstrap();
89 
97  inline bool getFrom(const ::rtl::OUString &sName,
98  ::rtl::OUString &outValue) const;
99 
106  inline void getFrom(const ::rtl::OUString &sName,
107  ::rtl::OUString &outValue,
108  const ::rtl::OUString &aDefault) const;
109 
113  inline void getIniName(::rtl::OUString & iniName) const;
114 
119  inline void expandMacrosFrom( ::rtl::OUString & macro ) const SAL_THROW(())
120  { rtl_bootstrap_expandMacros_from_handle( _handle, &macro.pData ); }
121 
126  static inline void expandMacros( ::rtl::OUString & macro ) SAL_THROW(())
127  { rtl_bootstrap_expandMacros( &macro.pData ); }
128 
133  inline rtlBootstrapHandle getHandle() const SAL_THROW(())
134  { return _handle; }
135 
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  inline bool Bootstrap::get( const ::rtl::OUString &sName,
160  ::rtl::OUString & outValue )
161  {
162  return rtl_bootstrap_get( sName.pData , &(outValue.pData) , 0 );
163  }
164 
165  inline void Bootstrap::get( const ::rtl::OUString &sName,
166  ::rtl::OUString & outValue,
167  const ::rtl::OUString & sDefault )
168  {
169  rtl_bootstrap_get( sName.pData , &(outValue.pData) , sDefault.pData );
170  }
171 
172  inline void Bootstrap::set( ::rtl::OUString const & name, ::rtl::OUString const & value )
173  SAL_THROW(())
174  {
175  rtl_bootstrap_set( name.pData, value.pData );
176  }
177 
179  {
180  _handle = 0;
181  }
182 
183  inline Bootstrap::Bootstrap(const rtl::OUString & iniName)
184  {
185  if(!iniName.isEmpty())
186  _handle = rtl_bootstrap_args_open(iniName.pData);
187 
188  else
189  _handle = 0;
190  }
191 
193  {
194  rtl_bootstrap_args_close(_handle);
195  }
196 
197 
198  inline bool Bootstrap::getFrom(const ::rtl::OUString &sName,
199  ::rtl::OUString &outValue) const
200  {
201  return rtl_bootstrap_get_from_handle(_handle, sName.pData, &outValue.pData, 0);
202  }
203 
204  inline void Bootstrap::getFrom(const ::rtl::OUString &sName,
205  ::rtl::OUString &outValue,
206  const ::rtl::OUString &aDefault) const
207  {
208  rtl_bootstrap_get_from_handle(_handle, sName.pData, &outValue.pData, aDefault.pData);
209  }
210 
211  inline void Bootstrap::getIniName(::rtl::OUString & iniName) const
212  {
213  rtl_bootstrap_get_iniName_from_handle(_handle, &iniName.pData);
214  }
215 
216  inline ::rtl::OUString Bootstrap::encode( ::rtl::OUString const & value )
217  SAL_THROW(())
218  {
219  ::rtl::OUString encoded;
220  rtl_bootstrap_encode(value.pData, &encoded.pData);
221  return encoded;
222  }
223 }
224 #endif
225 
226 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
rtlBootstrapHandle getHandle() const SAL_THROW(())
Provides the bootstrap internal handle.
Definition: bootstrap.hxx:133
static void set(::rtl::OUString const &name,::rtl::OUString const &value) SAL_THROW(())
Sets a bootstrap parameter.
Definition: bootstrap.hxx:172
SAL_DLLPUBLIC sal_Bool rtl_bootstrap_get(rtl_uString *pName, rtl_uString **ppValue, rtl_uString *pDefault) SAL_THROW_EXTERN_C()
SAL_DLLPUBLIC void rtl_bootstrap_args_close(rtlBootstrapHandle handle) SAL_THROW_EXTERN_C()
Closes a boostrap agument container.
static void setIniFilename(const ::rtl::OUString &sFileUri)
Definition: bootstrap.hxx:154
SAL_DLLPUBLIC void rtl_bootstrap_get_iniName_from_handle(rtlBootstrapHandle handle, rtl_uString **ppIniName) SAL_THROW_EXTERN_C()
Returns the name of the inifile associated with this handle.
Definition: bootstrap.hxx:24
~Bootstrap()
Closes a bootstrap argument container.
Definition: bootstrap.hxx:192
SAL_DLLPUBLIC sal_Bool rtl_bootstrap_get_from_handle(rtlBootstrapHandle handle, rtl_uString *pName, rtl_uString **ppValue, rtl_uString *pDefault) SAL_THROW_EXTERN_C()
static inline::rtl::OUString encode(::rtl::OUString const &value) SAL_THROW(())
Escapes special characters ("$" and "\").
Definition: bootstrap.hxx:216
void getIniName(::rtl::OUString &iniName) const
Retrieves the name of the underlying ini-file.
Definition: bootstrap.hxx:211
static bool get(const ::rtl::OUString &sName,::rtl::OUString &outValue)
Retrieves a bootstrap parameter.
Definition: bootstrap.hxx:159
Bootstrap()
default ctor.
Definition: bootstrap.hxx:178
void * rtlBootstrapHandle
Definition: bootstrap.h:157
static void expandMacros(::rtl::OUString &macro) SAL_THROW(())
Expands a macro using default bootstrap variables.
Definition: bootstrap.hxx:126
bool getFrom(const ::rtl::OUString &sName,::rtl::OUString &outValue) const
Retrieves a bootstrap argument.
Definition: bootstrap.hxx:198
SAL_DLLPUBLIC void rtl_bootstrap_expandMacros(rtl_uString **macro) SAL_THROW_EXTERN_C()
Expands a macro using default bootstrap variables.
#define SAL_THROW(x)
Exception specification documentation.
Definition: types.h:361
SAL_DLLPUBLIC void rtl_bootstrap_setIniFileName(rtl_uString *pFileUri) SAL_THROW_EXTERN_C()
may be called by an application to set an ini-filename.
SAL_DLLPUBLIC void rtl_bootstrap_encode(rtl_uString const *value, rtl_uString **encoded) SAL_THROW_EXTERN_C()
Escapes special characters ("$" and "\").
The described concept provides a platform independent way to access minimum bootstrap settings for ev...
bool isEmpty() const SAL_THROW(())
Checks if a string is empty.
Definition: ustring.hxx:396
SAL_DLLPUBLIC void rtl_bootstrap_set(rtl_uString *pName, rtl_uString *pValue) SAL_THROW_EXTERN_C()
Sets a bootstrap parameter.
void expandMacrosFrom(::rtl::OUString &macro) const SAL_THROW(())
Expands a macro using bootstrap variables.
Definition: bootstrap.hxx:119
SAL_DLLPUBLIC void rtl_bootstrap_expandMacros_from_handle(rtlBootstrapHandle handle, rtl_uString **macro) SAL_THROW_EXTERN_C()
Expands a macro using bootstrap variables.
Definition: bootstrap.hxx:26
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:82
SAL_DLLPUBLIC rtlBootstrapHandle rtl_bootstrap_args_open(rtl_uString *pIniName) SAL_THROW_EXTERN_C()
Opens a bootstrap argument container.