LibreOffice
LibreOffice 4.4 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 
77  inline Bootstrap();
78 
82  inline Bootstrap(const rtl::OUString & iniName);
83 
87  inline ~Bootstrap();
88 
96  inline bool getFrom(const ::rtl::OUString &sName,
97  ::rtl::OUString &outValue) const;
98 
105  inline void getFrom(const ::rtl::OUString &sName,
106  ::rtl::OUString &outValue,
107  const ::rtl::OUString &aDefault) const;
108 
112  inline void getIniName(::rtl::OUString & iniName) const;
113 
118  inline void expandMacrosFrom( ::rtl::OUString & macro ) const
119  { rtl_bootstrap_expandMacros_from_handle( _handle, &macro.pData ); }
120 
125  static inline void expandMacros( ::rtl::OUString & macro )
126  { rtl_bootstrap_expandMacros( &macro.pData ); }
127 
133  { return _handle; }
134 
146  static inline ::rtl::OUString encode( ::rtl::OUString const & value );
147  };
148 
149 
150  // IMPLEMENTATION
151 
152  inline void Bootstrap::setIniFilename( const ::rtl::OUString &sFile )
153  {
154  rtl_bootstrap_setIniFileName( sFile.pData );
155  }
156 
157  inline bool Bootstrap::get( const ::rtl::OUString &sName,
158  ::rtl::OUString & outValue )
159  {
160  return rtl_bootstrap_get( sName.pData , &(outValue.pData) , 0 );
161  }
162 
163  inline void Bootstrap::get( const ::rtl::OUString &sName,
164  ::rtl::OUString & outValue,
165  const ::rtl::OUString & sDefault )
166  {
167  rtl_bootstrap_get( sName.pData , &(outValue.pData) , sDefault.pData );
168  }
169 
170  inline void Bootstrap::set( ::rtl::OUString const & name, ::rtl::OUString const & value )
171  {
172  rtl_bootstrap_set( name.pData, value.pData );
173  }
174 
176  {
177  _handle = 0;
178  }
179 
180  inline Bootstrap::Bootstrap(const rtl::OUString & iniName)
181  {
182  if(!iniName.isEmpty())
183  _handle = rtl_bootstrap_args_open(iniName.pData);
184 
185  else
186  _handle = 0;
187  }
188 
190  {
191  rtl_bootstrap_args_close(_handle);
192  }
193 
194 
195  inline bool Bootstrap::getFrom(const ::rtl::OUString &sName,
196  ::rtl::OUString &outValue) const
197  {
198  return rtl_bootstrap_get_from_handle(_handle, sName.pData, &outValue.pData, 0);
199  }
200 
201  inline void Bootstrap::getFrom(const ::rtl::OUString &sName,
202  ::rtl::OUString &outValue,
203  const ::rtl::OUString &aDefault) const
204  {
205  rtl_bootstrap_get_from_handle(_handle, sName.pData, &outValue.pData, aDefault.pData);
206  }
207 
208  inline void Bootstrap::getIniName(::rtl::OUString & iniName) const
209  {
210  rtl_bootstrap_get_iniName_from_handle(_handle, &iniName.pData);
211  }
212 
213  inline ::rtl::OUString Bootstrap::encode( ::rtl::OUString const & value )
214  {
215  ::rtl::OUString encoded;
216  rtl_bootstrap_encode(value.pData, &encoded.pData);
217  return encoded;
218  }
219 }
220 #endif
221 
222 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC void rtl_bootstrap_encode(rtl_uString const *value, rtl_uString **encoded) SAL_THROW_EXTERN_C()
Escapes special characters ("$" and "\").
static void setIniFilename(const ::rtl::OUString &sFileUri)
Definition: bootstrap.hxx:152
static inline::rtl::OUString encode(::rtl::OUString const &value)
Escapes special characters ("$" and "\").
Definition: bootstrap.hxx:213
static void set(::rtl::OUString const &name,::rtl::OUString const &value)
Sets a bootstrap parameter.
Definition: bootstrap.hxx:170
~Bootstrap()
Closes a bootstrap argument container.
Definition: bootstrap.hxx:189
SAL_DLLPUBLIC void rtl_bootstrap_expandMacros(rtl_uString **macro)
Expands a macro using default bootstrap variables.
SAL_DLLPUBLIC void rtl_bootstrap_setIniFileName(rtl_uString *pFileUri) SAL_THROW_EXTERN_C()
may be called by an application to set an ini-filename.
Definition: bootstrap.hxx:24
void getIniName(::rtl::OUString &iniName) const
Retrieves the name of the underlying ini-file.
Definition: bootstrap.hxx:208
static bool get(const ::rtl::OUString &sName,::rtl::OUString &outValue)
Retrieves a bootstrap parameter.
Definition: bootstrap.hxx:157
Bootstrap()
default ctor.
Definition: bootstrap.hxx:175
SAL_DLLPUBLIC void rtl_bootstrap_set(rtl_uString *pName, rtl_uString *pValue) SAL_THROW_EXTERN_C()
Sets a bootstrap parameter.
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.
bool isEmpty() const
Checks if a string is empty.
Definition: ustring.hxx:404
bool getFrom(const ::rtl::OUString &sName,::rtl::OUString &outValue) const
Retrieves a bootstrap argument.
Definition: bootstrap.hxx:195
void expandMacrosFrom(::rtl::OUString &macro) const
Expands a macro using bootstrap variables.
Definition: bootstrap.hxx:118
SAL_DLLPUBLIC rtlBootstrapHandle rtl_bootstrap_args_open(rtl_uString *pIniName) SAL_THROW_EXTERN_C()
Opens a bootstrap argument container.
SAL_DLLPUBLIC sal_Bool rtl_bootstrap_get_from_handle(rtlBootstrapHandle handle, rtl_uString *pName, rtl_uString **ppValue, rtl_uString *pDefault) SAL_THROW_EXTERN_C()
rtlBootstrapHandle getHandle() const
Provides the bootstrap internal handle.
Definition: bootstrap.hxx:132
SAL_DLLPUBLIC void rtl_bootstrap_expandMacros_from_handle(rtlBootstrapHandle handle, rtl_uString **macro)
Expands a macro using bootstrap variables.
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:81
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 bootstrap agument container.
void * rtlBootstrapHandle
Definition: bootstrap.h:157
static void expandMacros(::rtl::OUString &macro)
Expands a macro using default bootstrap variables.
Definition: bootstrap.hxx:125
The described concept provides a platform independent way to access minimum bootstrap settings for ev...
Definition: bootstrap.hxx:26