1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 * This file is part of LibreOffice published API.
23 #ifndef INCLUDED_RTL_BOOTSTRAP_HXX
24 #define INCLUDED_RTL_BOOTSTRAP_HXX
26 #include "sal/config.h"
30 #include "rtl/ustring.hxx"
31 #include "rtl/bootstrap.h"
39 Bootstrap( Bootstrap
const & ) SAL_DELETED_FUNCTION
;
40 Bootstrap
& operator = ( Bootstrap
const & ) SAL_DELETED_FUNCTION
;
44 * @see rtl_bootstrap_setIniFileName()
46 static inline void SAL_CALL
setIniFilename( const ::rtl::OUString
&sFileUri
);
48 /** Retrieves a bootstrap parameter
49 @param sName name of the bootstrap value. case insensitive.
50 @param[out] outValue On success contains the value, otherwise
52 @return false, if no value could be retrieved, otherwise true
53 @see rtl_bootstrap_get()
55 static inline bool get(
56 const ::rtl::OUString
&sName
,
57 ::rtl::OUString
&outValue
);
59 /** Retrieves a bootstrap parameter
61 @param sName name of the bootstrap value. case insensitive.
62 @param[out] outValue Contains the value associated with <code>sName</code>.
63 @param aDefault if none of the other methods retrieved a value,
64 <code>outValue</code> is assigned to <code>aDefault</code>.
66 @see rtl_bootstrap_get()
68 static inline void get(
69 const ::rtl::OUString
&sName
,
70 ::rtl::OUString
&outValue
,
71 const ::rtl::OUString
&aDefault
);
73 /** Sets a bootstrap parameter.
76 name of bootstrap parameter
78 value of bootstrap parameter
80 @see rtl_bootstrap_set()
82 static inline void set( ::rtl::OUString
const & name
, ::rtl::OUString
const & value
);
88 /** Opens a bootstrap argument container
89 @see rtl_bootstrap_args_open()
91 inline Bootstrap(const rtl::OUString
& iniName
);
93 /** Closes a bootstrap argument container
94 @see rtl_bootstrap_args_close()
98 /** Retrieves a bootstrap argument.
100 It is first tried to retrieve the value via the global function
101 and second via the special bootstrap container.
102 @see rtl_bootstrap_get_from_handle()
105 inline bool getFrom(const ::rtl::OUString
&sName
,
106 ::rtl::OUString
&outValue
) const;
108 /** Retrieves a bootstrap argument.
110 It is first tried to retrieve the value via the global function
111 and second via the special bootstrap container.
112 @see rtl_bootstrap_get_from_handle()
114 inline void getFrom(const ::rtl::OUString
&sName
,
115 ::rtl::OUString
&outValue
,
116 const ::rtl::OUString
&aDefault
) const;
118 /** Retrieves the name of the underlying ini-file.
119 @see rtl_bootstrap_get_iniName_from_handle()
121 inline void getIniName(::rtl::OUString
& iniName
) const;
123 /** Expands a macro using bootstrap variables.
125 @param[in,out] macro The macro to be expanded
127 void expandMacrosFrom( ::rtl::OUString
& macro
) const
128 { rtl_bootstrap_expandMacros_from_handle( _handle
, ¯o
.pData
); }
130 /** Expands a macro using default bootstrap variables.
132 @param[in,out] macro The macro to be expanded
134 static void expandMacros( ::rtl::OUString
& macro
)
135 { rtl_bootstrap_expandMacros( ¯o
.pData
); }
137 /** Provides the bootstrap internal handle.
139 @return bootstrap handle
141 rtlBootstrapHandle
getHandle() const
144 /** Escapes special characters ("$" and "\").
150 the given value, with all occurrences of special characters ("$" and
155 static inline ::rtl::OUString
encode( ::rtl::OUString
const & value
);
161 inline void Bootstrap::setIniFilename( const ::rtl::OUString
&sFile
)
163 rtl_bootstrap_setIniFileName( sFile
.pData
);
166 inline bool Bootstrap::get( const ::rtl::OUString
&sName
,
167 ::rtl::OUString
& outValue
)
169 return rtl_bootstrap_get( sName
.pData
, &(outValue
.pData
) , NULL
);
172 inline void Bootstrap::get( const ::rtl::OUString
&sName
,
173 ::rtl::OUString
& outValue
,
174 const ::rtl::OUString
& sDefault
)
176 rtl_bootstrap_get( sName
.pData
, &(outValue
.pData
) , sDefault
.pData
);
179 inline void Bootstrap::set( ::rtl::OUString
const & name
, ::rtl::OUString
const & value
)
181 rtl_bootstrap_set( name
.pData
, value
.pData
);
184 inline Bootstrap::Bootstrap()
189 inline Bootstrap::Bootstrap(const rtl::OUString
& iniName
)
191 if(!iniName
.isEmpty())
192 _handle
= rtl_bootstrap_args_open(iniName
.pData
);
198 inline Bootstrap::~Bootstrap()
200 rtl_bootstrap_args_close(_handle
);
204 inline bool Bootstrap::getFrom(const ::rtl::OUString
&sName
,
205 ::rtl::OUString
&outValue
) const
207 return rtl_bootstrap_get_from_handle(_handle
, sName
.pData
, &outValue
.pData
, NULL
);
210 inline void Bootstrap::getFrom(const ::rtl::OUString
&sName
,
211 ::rtl::OUString
&outValue
,
212 const ::rtl::OUString
&aDefault
) const
214 rtl_bootstrap_get_from_handle(_handle
, sName
.pData
, &outValue
.pData
, aDefault
.pData
);
217 inline void Bootstrap::getIniName(::rtl::OUString
& iniName
) const
219 rtl_bootstrap_get_iniName_from_handle(_handle
, &iniName
.pData
);
222 inline ::rtl::OUString
Bootstrap::encode( ::rtl::OUString
const & value
)
224 ::rtl::OUString encoded
;
225 rtl_bootstrap_encode(value
.pData
, &encoded
.pData
);
231 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */