AlterOffice
AlterOffice 3.4 SDK C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 #ifndef INCLUDED_RTL_BOOTSTRAP_HXX
4 #define INCLUDED_RTL_BOOTSTRAP_HXX
5 
6 #include "sal/config.h"
7 
8 #include <cstddef>
9 
10 #include "rtl/ustring.hxx"
11 #include "rtl/bootstrap.h"
12 
13 namespace rtl
14 {
15  class Bootstrap
16  {
17  void * _handle;
18 
20  Bootstrap & operator = ( Bootstrap const & ) SAL_DELETED_FUNCTION;
21 
22  public:
26  static inline void SAL_CALL setIniFilename( const ::rtl::OUString &sFileUri );
27 
35  static inline bool get(
36  const ::rtl::OUString &sName,
37  ::rtl::OUString &outValue );
38 
48  static inline void get(
49  const ::rtl::OUString &sName,
50  ::rtl::OUString &outValue,
51  const ::rtl::OUString &aDefault );
52 
62  static inline void set( ::rtl::OUString const & name, ::rtl::OUString const & value );
63 
66  inline Bootstrap();
67 
71  inline Bootstrap(const rtl::OUString & iniName);
72 
76  inline ~Bootstrap();
77 
85  inline bool getFrom(const ::rtl::OUString &sName,
86  ::rtl::OUString &outValue) const;
87 
94  inline void getFrom(const ::rtl::OUString &sName,
95  ::rtl::OUString &outValue,
96  const ::rtl::OUString &aDefault) const;
97 
101  inline void getIniName(::rtl::OUString & iniName) const;
102 
107  void expandMacrosFrom( ::rtl::OUString & macro ) const
108  { rtl_bootstrap_expandMacros_from_handle( _handle, &macro.pData ); }
109 
114  static void expandMacros( ::rtl::OUString & macro )
115  { rtl_bootstrap_expandMacros( &macro.pData ); }
116 
122  { return _handle; }
123 
135  static inline ::rtl::OUString encode( ::rtl::OUString const & value );
136  };
137 
138 
139  // IMPLEMENTATION
140 
141  inline void Bootstrap::setIniFilename( const ::rtl::OUString &sFile )
142  {
143  rtl_bootstrap_setIniFileName( sFile.pData );
144  }
145 
146  inline bool Bootstrap::get( const ::rtl::OUString &sName,
147  ::rtl::OUString & outValue )
148  {
149  return rtl_bootstrap_get( sName.pData , &(outValue.pData) , NULL );
150  }
151 
152  inline void Bootstrap::get( const ::rtl::OUString &sName,
153  ::rtl::OUString & outValue,
154  const ::rtl::OUString & sDefault )
155  {
156  rtl_bootstrap_get( sName.pData , &(outValue.pData) , sDefault.pData );
157  }
158 
159  inline void Bootstrap::set( ::rtl::OUString const & name, ::rtl::OUString const & value )
160  {
161  rtl_bootstrap_set( name.pData, value.pData );
162  }
163 
165  {
166  _handle = NULL;
167  }
168 
169  inline Bootstrap::Bootstrap(const rtl::OUString & iniName)
170  {
171  if(!iniName.isEmpty())
172  _handle = rtl_bootstrap_args_open(iniName.pData);
173 
174  else
175  _handle = NULL;
176  }
177 
179  {
180  rtl_bootstrap_args_close(_handle);
181  }
182 
183 
184  inline bool Bootstrap::getFrom(const ::rtl::OUString &sName,
185  ::rtl::OUString &outValue) const
186  {
187  return rtl_bootstrap_get_from_handle(_handle, sName.pData, &outValue.pData, NULL);
188  }
189 
190  inline void Bootstrap::getFrom(const ::rtl::OUString &sName,
191  ::rtl::OUString &outValue,
192  const ::rtl::OUString &aDefault) const
193  {
194  rtl_bootstrap_get_from_handle(_handle, sName.pData, &outValue.pData, aDefault.pData);
195  }
196 
197  inline void Bootstrap::getIniName(::rtl::OUString & iniName) const
198  {
199  rtl_bootstrap_get_iniName_from_handle(_handle, &iniName.pData);
200  }
201 
202  inline ::rtl::OUString Bootstrap::encode( ::rtl::OUString const & value )
203  {
204  ::rtl::OUString encoded;
205  rtl_bootstrap_encode(value.pData, &encoded.pData);
206  return encoded;
207  }
208 }
209 #endif
210 
211 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC void rtl_bootstrap_set(rtl_uString *pName, rtl_uString *pValue)
Sets a bootstrap parameter.
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:182
SAL_DLLPUBLIC rtlBootstrapHandle rtl_bootstrap_args_open(rtl_uString *pIniName)
Opens a bootstrap argument container.
static void set(::rtl::OUString const &name,::rtl::OUString const &value)
Sets a bootstrap parameter.
Definition: bootstrap.hxx:159
SAL_DLLPUBLIC void rtl_bootstrap_expandMacros_from_handle(rtlBootstrapHandle handle, rtl_uString **macro)
Expands a macro using bootstrap variables.
static inline::rtl::OUString encode(::rtl::OUString const &value)
Escapes special characters (&quot;$&quot; and &quot;\&quot;).
Definition: bootstrap.hxx:202
SAL_DLLPUBLIC void rtl_bootstrap_expandMacros(rtl_uString **macro)
Expands a macro using default bootstrap variables.
static bool get(const ::rtl::OUString &sName,::rtl::OUString &outValue)
Retrieves a bootstrap parameter.
Definition: bootstrap.hxx:146
pData
Definition: ustring.hxx:334
rtlBootstrapHandle getHandle() const
Provides the bootstrap internal handle.
Definition: bootstrap.hxx:121
~Bootstrap()
Closes a bootstrap argument container.
Definition: bootstrap.hxx:178
SAL_DLLPUBLIC void rtl_bootstrap_args_close(rtlBootstrapHandle handle) SAL_THROW_EXTERN_C()
Closes a bootstrap argument container.
void * rtlBootstrapHandle
Definition: bootstrap.h:133
SAL_DLLPUBLIC sal_Bool rtl_bootstrap_get(rtl_uString *pName, rtl_uString **ppValue, rtl_uString *pDefault)
static void setIniFilename(const ::rtl::OUString &sFileUri)
Definition: bootstrap.hxx:141
Definition: bootstrap.hxx:15
void expandMacrosFrom(::rtl::OUString &macro) const
Expands a macro using bootstrap variables.
Definition: bootstrap.hxx:107
static void expandMacros(::rtl::OUString &macro)
Expands a macro using default bootstrap variables.
Definition: bootstrap.hxx:114
SAL_DLLPUBLIC void rtl_bootstrap_encode(rtl_uString const *value, rtl_uString **encoded)
Escapes special characters (&quot;$&quot; and &quot;\&quot;).
bool getFrom(const ::rtl::OUString &sName,::rtl::OUString &outValue) const
Retrieves a bootstrap argument.
Definition: bootstrap.hxx:184
The described concept provides a platform independent way to access minimum bootstrap settings for ev...
SAL_DLLPUBLIC void rtl_bootstrap_setIniFileName(rtl_uString *pFileUri)
may be called by an application to set an ini-filename.
Bootstrap()
default ctor.
Definition: bootstrap.hxx:164
SAL_DLLPUBLIC void rtl_bootstrap_get_iniName_from_handle(rtlBootstrapHandle handle, rtl_uString **ppIniName)
Returns the name of the inifile associated with this handle.
SAL_DLLPUBLIC sal_Bool rtl_bootstrap_get_from_handle(rtlBootstrapHandle handle, rtl_uString *pName, rtl_uString **ppValue, rtl_uString *pDefault)
bool isEmpty() const
Checks if a string is empty.
Definition: ustring.hxx:794
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:358
void getIniName(::rtl::OUString &iniName) const
Retrieves the name of the underlying ini-file.
Definition: bootstrap.hxx:197