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 .
19 #ifndef INCLUDED_RTL_BOOTSTRAP_HXX
20 #define INCLUDED_RTL_BOOTSTRAP_HXX
22 #include "sal/config.h"
26 #include "rtl/ustring.hxx"
27 #include "rtl/bootstrap.h"
35 Bootstrap( Bootstrap
const & ) SAL_DELETED_FUNCTION
;
36 Bootstrap
& operator = ( Bootstrap
const & ) SAL_DELETED_FUNCTION
;
40 * @see rtl_bootstrap_setIniFileName()
42 static inline void SAL_CALL
setIniFilename( const ::rtl::OUString
&sFileUri
);
44 /** Retrieves a bootstrap parameter
45 @param sName name of the bootstrap value. case insensitive.
46 @param[out] outValue On success contains the value, otherwise
48 @return false, if no value could be retrieved, otherwise true
49 @see rtl_bootstrap_get()
51 static inline bool get(
52 const ::rtl::OUString
&sName
,
53 ::rtl::OUString
&outValue
);
55 /** Retrieves a bootstrap parameter
57 @param sName name of the bootstrap value. case insensitive.
58 @param[out] outValue Contains the value associated with <code>sName</code>.
59 @param aDefault if none of the other methods retrieved a value,
60 <code>outValue</code> is assigned to <code>aDefault</code>.
62 @see rtl_bootstrap_get()
64 static inline void get(
65 const ::rtl::OUString
&sName
,
66 ::rtl::OUString
&outValue
,
67 const ::rtl::OUString
&aDefault
);
69 /** Sets a bootstrap parameter.
72 name of bootstrap parameter
74 value of bootstrap parameter
76 @see rtl_bootstrap_set()
78 static inline void set( ::rtl::OUString
const & name
, ::rtl::OUString
const & value
);
84 /** Opens a bootstrap argument container
85 @see rtl_bootstrap_args_open()
87 inline Bootstrap(const rtl::OUString
& iniName
);
89 /** Closes a bootstrap argument container
90 @see rtl_bootstrap_args_close()
94 /** Retrieves a bootstrap argument.
96 It is first tried to retrieve the value via the global function
97 and second via the special bootstrap container.
98 @see rtl_bootstrap_get_from_handle()
101 inline bool getFrom(const ::rtl::OUString
&sName
,
102 ::rtl::OUString
&outValue
) const;
104 /** Retrieves a bootstrap argument.
106 It is first tried to retrieve the value via the global function
107 and second via the special bootstrap container.
108 @see rtl_bootstrap_get_from_handle()
110 inline void getFrom(const ::rtl::OUString
&sName
,
111 ::rtl::OUString
&outValue
,
112 const ::rtl::OUString
&aDefault
) const;
114 /** Retrieves the name of the underlying ini-file.
115 @see rtl_bootstrap_get_iniName_from_handle()
117 inline void getIniName(::rtl::OUString
& iniName
) const;
119 /** Expands a macro using bootstrap variables.
121 @param[in,out] macro The macro to be expanded
123 void expandMacrosFrom( ::rtl::OUString
& macro
) const
124 { rtl_bootstrap_expandMacros_from_handle( _handle
, ¯o
.pData
); }
126 /** Expands a macro using default bootstrap variables.
128 @param[in,out] macro The macro to be expanded
130 static void expandMacros( ::rtl::OUString
& macro
)
131 { rtl_bootstrap_expandMacros( ¯o
.pData
); }
133 /** Provides the bootstrap internal handle.
135 @return bootstrap handle
137 rtlBootstrapHandle
getHandle() const
140 /** Escapes special characters ("$" and "\").
146 the given value, with all occurrences of special characters ("$" and
151 static inline ::rtl::OUString
encode( ::rtl::OUString
const & value
);
157 inline void Bootstrap::setIniFilename( const ::rtl::OUString
&sFile
)
159 rtl_bootstrap_setIniFileName( sFile
.pData
);
162 inline bool Bootstrap::get( const ::rtl::OUString
&sName
,
163 ::rtl::OUString
& outValue
)
165 return rtl_bootstrap_get( sName
.pData
, &(outValue
.pData
) , NULL
);
168 inline void Bootstrap::get( const ::rtl::OUString
&sName
,
169 ::rtl::OUString
& outValue
,
170 const ::rtl::OUString
& sDefault
)
172 rtl_bootstrap_get( sName
.pData
, &(outValue
.pData
) , sDefault
.pData
);
175 inline void Bootstrap::set( ::rtl::OUString
const & name
, ::rtl::OUString
const & value
)
177 rtl_bootstrap_set( name
.pData
, value
.pData
);
180 inline Bootstrap::Bootstrap()
185 inline Bootstrap::Bootstrap(const rtl::OUString
& iniName
)
187 if(!iniName
.isEmpty())
188 _handle
= rtl_bootstrap_args_open(iniName
.pData
);
194 inline Bootstrap::~Bootstrap()
196 rtl_bootstrap_args_close(_handle
);
200 inline bool Bootstrap::getFrom(const ::rtl::OUString
&sName
,
201 ::rtl::OUString
&outValue
) const
203 return rtl_bootstrap_get_from_handle(_handle
, sName
.pData
, &outValue
.pData
, NULL
);
206 inline void Bootstrap::getFrom(const ::rtl::OUString
&sName
,
207 ::rtl::OUString
&outValue
,
208 const ::rtl::OUString
&aDefault
) const
210 rtl_bootstrap_get_from_handle(_handle
, sName
.pData
, &outValue
.pData
, aDefault
.pData
);
213 inline void Bootstrap::getIniName(::rtl::OUString
& iniName
) const
215 rtl_bootstrap_get_iniName_from_handle(_handle
, &iniName
.pData
);
218 inline ::rtl::OUString
Bootstrap::encode( ::rtl::OUString
const & value
)
220 ::rtl::OUString encoded
;
221 rtl_bootstrap_encode(value
.pData
, &encoded
.pData
);
227 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */