LibreOffice: rtl/bootstrap.hxx Source File

LibreOffice LibreOffice 6.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
22 #include "sal/config.h"
23
24 #include <cstddef>
25
26 #include "rtl/ustring.hxx"
27 #include "rtl/bootstrap.h"
28
29 namespace rtl
30 {
31 class Bootstrap
32 {
33 void * _handle;
34
35 Bootstrap( Bootstrap const & ) SAL_DELETED_FUNCTION;
36 Bootstrap & operator = ( Bootstrap const & ) SAL_DELETED_FUNCTION;
37
38 public:
42 static inline void SAL_CALL setIniFilename( const ::rtl::OUString &sFileUri );
43
51 static inline bool get(
52 const ::rtl::OUString &sName,
53 ::rtl::OUString &outValue );
54
64 static inline void get(
65 const ::rtl::OUString &sName,
66 ::rtl::OUString &outValue,
67 const ::rtl::OUString &aDefault );
68
78 static inline void set( ::rtl::OUString const & name, ::rtl::OUString const & value );
79
82 inline Bootstrap();
83
87 inline Bootstrap(const rtl::OUString & iniName);
88
92 inline ~Bootstrap();
93
101 inline bool getFrom(const ::rtl::OUString &sName,
102 ::rtl::OUString &outValue) const;
103
110 inline void getFrom(const ::rtl::OUString &sName,
111 ::rtl::OUString &outValue,
112 const ::rtl::OUString &aDefault) const;
113
117 inline void getIniName(::rtl::OUString & iniName) const;
118
123 void expandMacrosFrom( ::rtl::OUString & macro ) const
124 { rtl_bootstrap_expandMacros_from_handle( _handle, &macro.pData ); }
125
130 static void expandMacros( ::rtl::OUString & macro )
131 { rtl_bootstrap_expandMacros( &macro.pData ); }
132
137 rtlBootstrapHandle getHandle() const
138 { return _handle; }
139
151 static inline ::rtl::OUString encode( ::rtl::OUString const & value );
152 };
153
154
155 // IMPLEMENTATION
156
157 inline void Bootstrap::setIniFilename( const ::rtl::OUString &sFile )
158 {
159 rtl_bootstrap_setIniFileName( sFile.pData );
160 }
161
162 inline bool Bootstrap::get( const ::rtl::OUString &sName,
163 ::rtl::OUString & outValue )
164 {
165 return rtl_bootstrap_get( sName.pData , &(outValue.pData) , NULL );
166 }
167
168 inline void Bootstrap::get( const ::rtl::OUString &sName,
169 ::rtl::OUString & outValue,
170 const ::rtl::OUString & sDefault )
171 {
172 rtl_bootstrap_get( sName.pData , &(outValue.pData) , sDefault.pData );
173 }
174
175 inline void Bootstrap::set( ::rtl::OUString const & name, ::rtl::OUString const & value )
176 {
177 rtl_bootstrap_set( name.pData, value.pData );
178 }
179
180 inline Bootstrap::Bootstrap()
181 {
182 _handle = NULL;
183 }
184
185 inline Bootstrap::Bootstrap(const rtl::OUString & iniName)
186 {
187 if(!iniName.isEmpty())
188 _handle = rtl_bootstrap_args_open(iniName.pData);
189
190 else
191 _handle = NULL;
192 }
193
194 inline Bootstrap::~Bootstrap()
195 {
196 rtl_bootstrap_args_close(_handle);
197 }
198
199
200 inline bool Bootstrap::getFrom(const ::rtl::OUString &sName,
201 ::rtl::OUString &outValue) const
202 {
203 return rtl_bootstrap_get_from_handle(_handle, sName.pData, &outValue.pData, NULL);
204 }
205
206 inline void Bootstrap::getFrom(const ::rtl::OUString &sName,
207 ::rtl::OUString &outValue,
208 const ::rtl::OUString &aDefault) const
209 {
210 rtl_bootstrap_get_from_handle(_handle, sName.pData, &outValue.pData, aDefault.pData);
211 }
212
213 inline void Bootstrap::getIniName(::rtl::OUString & iniName) const
214 {
215 rtl_bootstrap_get_iniName_from_handle(_handle, &iniName.pData);
216 }
217
218 inline ::rtl::OUString Bootstrap::encode( ::rtl::OUString const & value )
219 {
220 ::rtl::OUString encoded;
221 rtl_bootstrap_encode(value.pData, &encoded.pData);
222 return encoded;
223 }
224 }
225 #endif
226
227 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
rtl::Bootstrap::getIniName
void getIniName(::rtl::OUString &iniName) const
Retrieves the name of the underlying ini-file.
Definition: bootstrap.hxx:213
ustring.hxx
rtl::OUString
This String class provides base functionality for C++ like Unicode character array handling.
Definition: ustring.hxx:126
rtl::Bootstrap::getHandle
rtlBootstrapHandle getHandle() const
Provides the bootstrap internal handle.
Definition: bootstrap.hxx:137
rtl::Bootstrap
Definition: bootstrap.hxx:31
rtl::Bootstrap::get
static bool get(const ::rtl::OUString &sName, ::rtl::OUString &outValue)
Retrieves a bootstrap parameter.
Definition: bootstrap.hxx:162
rtl::Bootstrap::~Bootstrap
~Bootstrap()
Closes a bootstrap argument container.
Definition: bootstrap.hxx:194
rtl_bootstrap_get_from_handle
SAL_DLLPUBLIC sal_Bool rtl_bootstrap_get_from_handle(rtlBootstrapHandle handle, rtl_uString *pName, rtl_uString **ppValue, rtl_uString *pDefault)
rtl::OUString::isEmpty
bool isEmpty() const
Checks if a string is empty.
Definition: ustring.hxx:692
rtl_bootstrap_setIniFileName
SAL_DLLPUBLIC void rtl_bootstrap_setIniFileName(rtl_uString *pFileUri)
may be called by an application to set an ini-filename.
rtl_bootstrap_get
SAL_DLLPUBLIC sal_Bool rtl_bootstrap_get(rtl_uString *pName, rtl_uString **ppValue, rtl_uString *pDefault)
config.h
rtl::Bootstrap::encode
static inline ::rtl::OUString encode(::rtl::OUString const &value)
Escapes special characters ("$" and "\").
Definition: bootstrap.hxx:218
rtl_bootstrap_encode
SAL_DLLPUBLIC void rtl_bootstrap_encode(rtl_uString const *value, rtl_uString **encoded)
Escapes special characters ("$" and "\").
rtl::Bootstrap::expandMacros
static void expandMacros(::rtl::OUString &macro)
Expands a macro using default bootstrap variables.
Definition: bootstrap.hxx:130
rtl::Bootstrap::set
static void set(::rtl::OUString const &name, ::rtl::OUString const &value)
Sets a bootstrap parameter.
Definition: bootstrap.hxx:175
rtl_bootstrap_expandMacros_from_handle
SAL_DLLPUBLIC void rtl_bootstrap_expandMacros_from_handle(rtlBootstrapHandle handle, rtl_uString **macro)
Expands a macro using bootstrap variables.
rtl
Definition: bootstrap.hxx:29
rtlBootstrapHandle
void * rtlBootstrapHandle
Definition: bootstrap.h:149
rtl_bootstrap_get_iniName_from_handle
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.h
rtl::Bootstrap::Bootstrap
Bootstrap()
default ctor.
Definition: bootstrap.hxx:180
rtl_bootstrap_set
SAL_DLLPUBLIC void rtl_bootstrap_set(rtl_uString *pName, rtl_uString *pValue)
Sets a bootstrap parameter.
rtl_bootstrap_args_open
SAL_DLLPUBLIC rtlBootstrapHandle rtl_bootstrap_args_open(rtl_uString *pIniName)
Opens a bootstrap argument container.
rtl_bootstrap_args_close
SAL_DLLPUBLIC void rtl_bootstrap_args_close(rtlBootstrapHandle handle) SAL_THROW_EXTERN_C()
Closes a bootstrap argument container.
rtl::Bootstrap::setIniFilename
static void setIniFilename(const ::rtl::OUString &sFileUri)
Definition: bootstrap.hxx:157
rtl_bootstrap_expandMacros
SAL_DLLPUBLIC void rtl_bootstrap_expandMacros(rtl_uString **macro)
Expands a macro using default bootstrap variables.
SAL_DELETED_FUNCTION
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:396
rtl::Bootstrap::expandMacrosFrom
void expandMacrosFrom(::rtl::OUString &macro) const
Expands a macro using bootstrap variables.
Definition: bootstrap.hxx:123
rtl::Bootstrap::getFrom
bool getFrom(const ::rtl::OUString &sName, ::rtl::OUString &outValue) const
Retrieves a bootstrap argument.
Definition: bootstrap.hxx:200