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 .
20 #include "mysqlc_driver.hxx"
22 #include <cppuhelper/factory.hxx>
23 #include <uno/lbnames.h>
24 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
26 using namespace connectivity::mysqlc
;
27 using ::com::sun::star::lang::XMultiServiceFactory
;
28 using ::com::sun::star::lang::XSingleServiceFactory
;
29 using ::com::sun::star::uno::Reference
;
30 using ::com::sun::star::uno::Sequence
;
32 typedef Reference
<XSingleServiceFactory
> (*createFactoryFunc
)(
33 const Reference
<XMultiServiceFactory
>& rServiceManager
, const OUString
& rComponentName
,
34 ::cppu::ComponentInstantiation pCreateFunction
, const Sequence
<OUString
>& rServiceNames
,
39 struct ProviderRequest
41 Reference
<XSingleServiceFactory
> xRet
;
42 Reference
<XMultiServiceFactory
> const xServiceManager
;
43 OUString
const sImplementationName
;
45 ProviderRequest(void* pServiceManager
, char const* pImplementationName
)
46 : xServiceManager(static_cast<XMultiServiceFactory
*>(pServiceManager
))
47 , sImplementationName(OUString::createFromAscii(pImplementationName
))
51 bool CREATE_PROVIDER(std::u16string_view Implname
, const Sequence
<OUString
>& Services
,
52 ::cppu::ComponentInstantiation Factory
, createFactoryFunc creator
)
54 if (!xRet
.is() && (Implname
== sImplementationName
))
58 xRet
= creator(xServiceManager
, sImplementationName
, Factory
, Services
, nullptr);
67 void* getProvider() const { return xRet
.get(); }
71 extern "C" SAL_DLLPUBLIC_EXPORT
void* component_getFactory(const char* pImplementationName
,
72 void* pServiceManager
,
73 void* /* pRegistryKey */)
78 ProviderRequest
aReq(pServiceManager
, pImplementationName
);
80 aReq
.CREATE_PROVIDER(MysqlCDriver::getImplementationName_Static(),
81 MysqlCDriver::getSupportedServiceNames_Static(),
82 MysqlCDriver_CreateInstance
, ::cppu::createSingleFactory
);
89 pRet
= aReq
.getProvider();
95 extern "C" SAL_DLLPUBLIC_EXPORT
void
96 component_getImplementationEnvironment(char const** ppEnvTypeName
, uno_Environment
**)
98 *ppEnvTypeName
= CPPU_CURRENT_LANGUAGE_BINDING_NAME
;
106 * vim600: noet sw=4 ts=4 fdm=marker
107 * vim<600: noet sw=4 ts=4
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */