update emoji autocorrect entries from po-files
[LibreOffice.git] / include / osl / module.hxx
blob7858ad0695e56889d3605c1294929b54a2512c1c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #ifndef INCLUDED_OSL_MODULE_HXX
21 #define INCLUDED_OSL_MODULE_HXX
23 #include <rtl/ustring.hxx>
24 #include <osl/module.h>
26 namespace osl
29 class Module
31 Module( const Module&) SAL_DELETED_FUNCTION;
32 Module& operator = ( const Module&) SAL_DELETED_FUNCTION;
34 public:
35 static bool getUrlFromAddress(void * addr, ::rtl::OUString & libraryUrl) {
36 return osl_getModuleURLFromAddress(addr, &libraryUrl.pData);
39 /** Get module URL from the specified function address in the module.
41 Similar to getUrlFromAddress, but use a function address to get URL of the Module.
42 Use Function pointer as symbol address to conceal type conversion.
44 @param addr
45 [in] function address in oslGenericFunction format.
47 @param libraryUrl
48 [in|out] receives the URL of the module.
50 @return
51 <dl>
52 <dt>true</dt>
53 <dd>on success</dd>
54 <dt>false</dt>
55 <dd>can not get the URL from the specified function address or the parameter is invalid.</dd>
56 </dl>
58 @see getUrlFromAddress
60 static bool getUrlFromAddress( oslGenericFunction addr, ::rtl::OUString & libraryUrl){
61 return osl_getModuleURLFromFunctionAddress( addr, &libraryUrl.pData );
64 Module(): m_Module(0){}
66 #ifndef DISABLE_DYNLOADING
68 Module( const ::rtl::OUString& strModuleName, sal_Int32 nRtldMode = SAL_LOADMODULE_DEFAULT) : m_Module(0)
70 load( strModuleName, nRtldMode);
73 #endif
75 ~Module()
77 #ifndef DISABLE_DYNLOADING
78 osl_unloadModule(m_Module);
79 #endif
82 #ifndef DISABLE_DYNLOADING
84 bool SAL_CALL load( const ::rtl::OUString& strModuleName,
85 sal_Int32 nRtldMode = SAL_LOADMODULE_DEFAULT)
87 unload();
88 m_Module= osl_loadModule( strModuleName.pData, nRtldMode );
89 return is();
92 /// @since UDK 3.2.8
93 bool SAL_CALL loadRelative(
94 ::oslGenericFunction baseModule, ::rtl::OUString const & relativePath,
95 ::sal_Int32 mode = SAL_LOADMODULE_DEFAULT)
97 unload();
98 m_Module = osl_loadModuleRelative(baseModule, relativePath.pData, mode);
99 return is();
102 /// @since LibreOffice 3.5
103 bool SAL_CALL loadRelative(
104 oslGenericFunction baseModule, char const * relativePath,
105 sal_Int32 mode = SAL_LOADMODULE_DEFAULT)
107 unload();
108 m_Module = osl_loadModuleRelativeAscii(baseModule, relativePath, mode);
109 return is();
112 void SAL_CALL unload()
114 if (m_Module)
116 osl_unloadModule(m_Module);
117 m_Module = 0;
121 #endif
123 bool SAL_CALL is() const
125 return m_Module != NULL;
128 void* SAL_CALL getSymbol( const ::rtl::OUString& strSymbolName)
130 return ( osl_getSymbol( m_Module, strSymbolName.pData ) );
133 /** Get function address by the function name in the module.
135 getFunctionSymbol is an alternative function for getSymbol.
136 Use Function pointer as symbol address to conceal type conversion.
138 @param ustrFunctionSymbolName
139 [in] Function name to be looked up.
141 @return
142 <dl>
143 <dt>oslGenericFunction format function address</dt>
144 <dd>on success</dd>
145 <dt>NULL</dt>
146 <dd>lookup failed or parameter is somewhat invalid</dd>
147 </dl>
149 @see getSymbol
151 oslGenericFunction SAL_CALL getFunctionSymbol( const ::rtl::OUString& ustrFunctionSymbolName ) const
153 return ( osl_getFunctionSymbol( m_Module, ustrFunctionSymbolName.pData ) );
156 /// @since LibreOffice 3.5
157 oslGenericFunction SAL_CALL getFunctionSymbol(char const * name) const {
158 return osl_getAsciiFunctionSymbol(m_Module, name);
161 operator oslModule() const
163 return m_Module;
166 /** Release the module so that it will not be unloaded from the destructor.
168 This instance returns to the state of a default-constructed instance
169 again.
171 @since LibreOffice 4.3
173 void release() { m_Module = 0; }
175 private:
176 oslModule m_Module;
182 #endif
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */