LibreOffice
LibreOffice 24.2 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 
20 /*
21  * This file is part of LibreOffice published API.
22  */
23 #ifndef INCLUDED_RTL_BOOTSTRAP_HXX
24 #define INCLUDED_RTL_BOOTSTRAP_HXX
25 
26 #include "sal/config.h"
27 
28 #include <cstddef>
29 
30 #include "rtl/ustring.hxx"
31 #include "rtl/bootstrap.h"
32 
33 namespace rtl
34 {
35  class Bootstrap
36  {
37  void * _handle;
38 
40  Bootstrap & operator = ( Bootstrap const & ) SAL_DELETED_FUNCTION;
41 
42  public:
46  static inline void SAL_CALL setIniFilename( const ::rtl::OUString &sFileUri );
47 
55  static inline 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 
86  inline Bootstrap();
87 
91  inline Bootstrap(const rtl::OUString & iniName);
92 
96  inline ~Bootstrap();
97 
105  inline bool getFrom(const ::rtl::OUString &sName,
106  ::rtl::OUString &outValue) const;
107 
114  inline void getFrom(const ::rtl::OUString &sName,
115  ::rtl::OUString &outValue,
116  const ::rtl::OUString &aDefault) const;
117 
121  inline void getIniName(::rtl::OUString & iniName) const;
122 
127  void expandMacrosFrom( ::rtl::OUString & macro ) const
128  { rtl_bootstrap_expandMacros_from_handle( _handle, &macro.pData ); }
129 
134  static void expandMacros( ::rtl::OUString & macro )
135  { rtl_bootstrap_expandMacros( &macro.pData ); }
136 
142  { return _handle; }
143 
155  static inline ::rtl::OUString encode( ::rtl::OUString const & value );
156  };
157 
158 
159  // IMPLEMENTATION
160 
161  inline void Bootstrap::setIniFilename( const ::rtl::OUString &sFile )
162  {
163  rtl_bootstrap_setIniFileName( sFile.pData );
164  }
165 
166  inline bool Bootstrap::get( const ::rtl::OUString &sName,
167  ::rtl::OUString & outValue )
168  {
169  return rtl_bootstrap_get( sName.pData , &(outValue.pData) , NULL );
170  }
171 
172  inline void Bootstrap::get( const ::rtl::OUString &sName,
173  ::rtl::OUString & outValue,
174  const ::rtl::OUString & sDefault )
175  {
176  rtl_bootstrap_get( sName.pData , &(outValue.pData) , sDefault.pData );
177  }
178 
179  inline void Bootstrap::set( ::rtl::OUString const & name, ::rtl::OUString const & value )
180  {
181  rtl_bootstrap_set( name.pData, value.pData );
182  }
183 
185  {
186  _handle = NULL;
187  }
188 
189  inline Bootstrap::Bootstrap(const rtl::OUString & iniName)
190  {
191  if(!iniName.isEmpty())
192  _handle = rtl_bootstrap_args_open(iniName.pData);
193 
194  else
195  _handle = NULL;
196  }
197 
199  {
200  rtl_bootstrap_args_close(_handle);
201  }
202 
203 
204  inline bool Bootstrap::getFrom(const ::rtl::OUString &sName,
205  ::rtl::OUString &outValue) const
206  {
207  return rtl_bootstrap_get_from_handle(_handle, sName.pData, &outValue.pData, NULL);
208  }
209 
210  inline void Bootstrap::getFrom(const ::rtl::OUString &sName,
211  ::rtl::OUString &outValue,
212  const ::rtl::OUString &aDefault) const
213  {
214  rtl_bootstrap_get_from_handle(_handle, sName.pData, &outValue.pData, aDefault.pData);
215  }
216 
217  inline void Bootstrap::getIniName(::rtl::OUString & iniName) const
218  {
219  rtl_bootstrap_get_iniName_from_handle(_handle, &iniName.pData);
220  }
221 
222  inline ::rtl::OUString Bootstrap::encode( ::rtl::OUString const & value )
223  {
224  ::rtl::OUString encoded;
225  rtl_bootstrap_encode(value.pData, &encoded.pData);
226  return encoded;
227  }
228 }
229 #endif
230 
231 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC void rtl_bootstrap_setIniFileName(rtl_uString *pFileUri)
may be called by an application to set an ini-filename.
The described concept provides a platform independent way to access minimum bootstrap settings for ev...
Definition: bootstrap.hxx:35
static bool get(const ::rtl::OUString &sName, ::rtl::OUString &outValue)
Retrieves a bootstrap parameter.
Definition: bootstrap.hxx:166
SAL_DLLPUBLIC void rtl_bootstrap_get_iniName_from_handle(rtlBootstrapHandle handle, rtl_uString **ppIniName)
Returns the name of the inifile associated with this handle.
~Bootstrap()
Closes a bootstrap argument container.
Definition: bootstrap.hxx:198
Bootstrap()
default ctor.
Definition: bootstrap.hxx:184
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:378
rtlBootstrapHandle getHandle() const
Provides the bootstrap internal handle.
Definition: bootstrap.hxx:141
SAL_DLLPUBLIC void rtl_bootstrap_expandMacros_from_handle(rtlBootstrapHandle handle, rtl_uString **macro)
Expands a macro using bootstrap variables.
void getIniName(::rtl::OUString &iniName) const
Retrieves the name of the underlying ini-file.
Definition: bootstrap.hxx:217
SAL_DLLPUBLIC sal_Bool rtl_bootstrap_get(rtl_uString *pName, rtl_uString **ppValue, rtl_uString *pDefault)
SAL_DLLPUBLIC sal_Bool rtl_bootstrap_get_from_handle(rtlBootstrapHandle handle, rtl_uString *pName, rtl_uString **ppValue, rtl_uString *pDefault)
Definition: bootstrap.hxx:33
void expandMacrosFrom(::rtl::OUString &macro) const
Expands a macro using bootstrap variables.
Definition: bootstrap.hxx:127
static void expandMacros(::rtl::OUString &macro)
Expands a macro using default bootstrap variables.
Definition: bootstrap.hxx:134
static void set(::rtl::OUString const &name, ::rtl::OUString const &value)
Sets a bootstrap parameter.
Definition: bootstrap.hxx:179
SAL_DLLPUBLIC void rtl_bootstrap_args_close(rtlBootstrapHandle handle) SAL_THROW_EXTERN_C()
Closes a bootstrap argument container.
SAL_DLLPUBLIC void rtl_bootstrap_encode(rtl_uString const *value, rtl_uString **encoded)
Escapes special characters ("$" and "\").
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:170
bool getFrom(const ::rtl::OUString &sName, ::rtl::OUString &outValue) const
Retrieves a bootstrap argument.
Definition: bootstrap.hxx:204
SAL_DLLPUBLIC void rtl_bootstrap_set(rtl_uString *pName, rtl_uString *pValue)
Sets a bootstrap parameter.
SAL_DLLPUBLIC rtlBootstrapHandle rtl_bootstrap_args_open(rtl_uString *pIniName)
Opens a bootstrap argument container.
SAL_DLLPUBLIC void rtl_bootstrap_expandMacros(rtl_uString **macro)
Expands a macro using default bootstrap variables.
bool isEmpty() const
Checks if a string is empty.
Definition: ustring.hxx:826
static inline ::rtl::OUString encode(::rtl::OUString const &value)
Escapes special characters ("$" and "\").
Definition: bootstrap.hxx:222
void * rtlBootstrapHandle
Definition: bootstrap.h:153
static void setIniFilename(const ::rtl::OUString &sFileUri)
Definition: bootstrap.hxx:161