diff options
author | Noel Grandin <noel@peralex.com> | 2015-10-12 14:30:06 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2015-10-13 10:07:50 +0200 |
commit | 38b4b7590d520fb53fabc40c5c95346546b2fdc3 (patch) | |
tree | 38ef6d225a9b14d1b5a40da40421f3c26ddbe997 /dbaccess | |
parent | ade2ba503f345fcbd2ac889a749db584a94a3043 (diff) |
loplugin:mergeclasses, merge OOdbcLibWrapper with OOdbcEnumeration
Change-Id: I2e564e90c11bb46022a5e258ad013aeb2fe4ca2e
Diffstat (limited to 'dbaccess')
-rw-r--r-- | dbaccess/source/ui/dlg/odbcconfig.cxx | 26 | ||||
-rw-r--r-- | dbaccess/source/ui/dlg/odbcconfig.hxx | 52 |
2 files changed, 25 insertions, 53 deletions
diff --git a/dbaccess/source/ui/dlg/odbcconfig.cxx b/dbaccess/source/ui/dlg/odbcconfig.cxx index b04aa698db60..e6308c7557a2 100644 --- a/dbaccess/source/ui/dlg/odbcconfig.cxx +++ b/dbaccess/source/ui/dlg/odbcconfig.cxx @@ -69,16 +69,8 @@ typedef SQLRETURN (SQL_API* TSQLDataSources) (SQLHENV EnvironmentHandle, SQLUSMA #endif // OOdbcLibWrapper -#ifdef HAVE_ODBC_SUPPORT -OOdbcLibWrapper::OOdbcLibWrapper() - :m_pOdbcLib(NULL) -{ - -} - -#endif -bool OOdbcLibWrapper::load(const sal_Char* _pLibPath) +bool OOdbcEnumeration::load(const sal_Char* _pLibPath) { m_sLibPath = OUString::createFromAscii(_pLibPath); #ifdef HAVE_ODBC_SUPPORT @@ -90,7 +82,7 @@ bool OOdbcLibWrapper::load(const sal_Char* _pLibPath) #endif } -void OOdbcLibWrapper::unload() +void OOdbcEnumeration::unload() { #ifdef HAVE_ODBC_SUPPORT if (isLoaded()) @@ -101,18 +93,12 @@ void OOdbcLibWrapper::unload() #endif } -oslGenericFunction OOdbcLibWrapper::loadSymbol(const sal_Char* _pFunctionName) +oslGenericFunction OOdbcEnumeration::loadSymbol(const sal_Char* _pFunctionName) { return osl_getFunctionSymbol(m_pOdbcLib, OUString::createFromAscii(_pFunctionName).pData); } -OOdbcLibWrapper::~OOdbcLibWrapper() -{ - unload(); - -} -// OOdbcEnumeration struct OdbcTypesImpl { #ifdef HAVE_ODBC_SUPPORT @@ -124,8 +110,9 @@ struct OdbcTypesImpl }; OOdbcEnumeration::OOdbcEnumeration() + :m_pOdbcLib(NULL) #ifdef HAVE_ODBC_SUPPORT - :m_pAllocHandle(NULL) + ,m_pAllocHandle(NULL) ,m_pFreeHandle(NULL) ,m_pSetEnvAttr(NULL) ,m_pDataSources(NULL) @@ -161,9 +148,10 @@ OOdbcEnumeration::~OOdbcEnumeration() { freeEnv(); delete m_pImpl; - + unload(); } +// OOdbcEnumeration bool OOdbcEnumeration::allocEnv() { OSL_ENSURE(isLoaded(), "OOdbcEnumeration::allocEnv: not loaded!"); diff --git a/dbaccess/source/ui/dlg/odbcconfig.hxx b/dbaccess/source/ui/dlg/odbcconfig.hxx index 3059b1dcf06b..3142f5cd9b8a 100644 --- a/dbaccess/source/ui/dlg/odbcconfig.hxx +++ b/dbaccess/source/ui/dlg/odbcconfig.hxx @@ -38,42 +38,13 @@ namespace dbaui { -// OOdbcLibWrapper -/** base for helper classes wrapping functionality from an ODBC library -*/ -class OOdbcLibWrapper -{ - oslModule m_pOdbcLib; // the library handle - OUString m_sLibPath; // the path to the library - -public: -#ifdef HAVE_ODBC_SUPPORT - bool isLoaded() const { return NULL != m_pOdbcLib; } -#else - sal_Bool isLoaded() const { return sal_False; } -#endif - OUString getLibraryName() const { return m_sLibPath; } - -protected: -#ifndef HAVE_ODBC_SUPPORT - OOdbcLibWrapper() : m_pOdbcLib(NULL) { } -#else - OOdbcLibWrapper(); -#endif - ~OOdbcLibWrapper(); - - oslGenericFunction loadSymbol(const sal_Char* _pFunctionName); - - /// load the lib - bool load(const sal_Char* _pLibPath); - /// unload the lib - void unload(); -}; - // OOdbcEnumeration struct OdbcTypesImpl; -class OOdbcEnumeration : public OOdbcLibWrapper +class OOdbcEnumeration { + oslModule m_pOdbcLib; // the library handle + OUString m_sLibPath; // the path to the library + #ifdef HAVE_ODBC_SUPPORT // entry points for ODBC administration oslGenericFunction m_pAllocHandle; @@ -90,11 +61,24 @@ public: OOdbcEnumeration(); ~OOdbcEnumeration(); +#ifdef HAVE_ODBC_SUPPORT + bool isLoaded() const { return NULL != m_pOdbcLib; } +#else + bool isLoaded() const { return false; } +#endif + OUString getLibraryName() const { return m_sLibPath; } + void getDatasourceNames(StringBag& _rNames); protected: + oslGenericFunction loadSymbol(const sal_Char* _pFunctionName); + + /// load the lib + bool load(const sal_Char* _pLibPath); + /// unload the lib + void unload(); /// ensure that an ODBC environment is allocated - bool allocEnv(); + bool allocEnv(); /// free any allocated ODBC environment void freeEnv(); }; |