bump product version to 6.3.0.0.beta1
[LibreOffice.git] / connectivity / source / drivers / mysqlc / mysqlc_services.cxx
blobd23cf66aba0683e39bde1a9b0d0e107551e12194
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 #include "mysqlc_driver.hxx"
22 #include <cppuhelper/factory.hxx>
23 #include <rtl/ustrbuf.hxx>
24 #include <uno/lbnames.h>
25 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
27 using namespace connectivity::mysqlc;
28 using ::com::sun::star::lang::XMultiServiceFactory;
29 using ::com::sun::star::lang::XSingleServiceFactory;
30 using ::com::sun::star::uno::Reference;
31 using ::com::sun::star::uno::Sequence;
33 typedef Reference<XSingleServiceFactory> (*createFactoryFunc)(
34 const Reference<XMultiServiceFactory>& rServiceManager, const OUString& rComponentName,
35 ::cppu::ComponentInstantiation pCreateFunction, const Sequence<OUString>& rServiceNames,
36 rtl_ModuleCount*);
38 struct ProviderRequest
40 Reference<XSingleServiceFactory> xRet;
41 Reference<XMultiServiceFactory> const xServiceManager;
42 OUString const sImplementationName;
44 ProviderRequest(void* pServiceManager, sal_Char const* pImplementationName)
45 : xServiceManager(static_cast<XMultiServiceFactory*>(pServiceManager))
46 , sImplementationName(OUString::createFromAscii(pImplementationName))
50 bool CREATE_PROVIDER(const OUString& Implname, const Sequence<OUString>& Services,
51 ::cppu::ComponentInstantiation Factory, createFactoryFunc creator)
53 if (!xRet.is() && (Implname == sImplementationName))
55 try
57 xRet = creator(xServiceManager, sImplementationName, Factory, Services, nullptr);
59 catch (...)
63 return xRet.is();
66 void* getProvider() const { return xRet.get(); }
69 extern "C" SAL_DLLPUBLIC_EXPORT void* component_getFactory(const sal_Char* pImplementationName,
70 void* pServiceManager,
71 void* /* pRegistryKey */)
73 void* pRet = nullptr;
74 if (pServiceManager)
76 ProviderRequest aReq(pServiceManager, pImplementationName);
78 aReq.CREATE_PROVIDER(MysqlCDriver::getImplementationName_Static(),
79 MysqlCDriver::getSupportedServiceNames_Static(),
80 MysqlCDriver_CreateInstance, ::cppu::createSingleFactory);
82 if (aReq.xRet.is())
84 aReq.xRet->acquire();
87 pRet = aReq.getProvider();
90 return pRet;
93 extern "C" SAL_DLLPUBLIC_EXPORT void
94 component_getImplementationEnvironment(char const** ppEnvTypeName, uno_Environment**)
96 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
100 * Local variables:
101 * tab-width: 4
102 * c-basic-offset: 4
103 * End:
104 * vim600: noet sw=4 ts=4 fdm=marker
105 * vim<600: noet sw=4 ts=4
108 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */