⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main_so.cpp

📁 C++连接一写常用数据库的接口
💻 CPP
字号:
/* * PostgreSQL Driver Implementation * Exports the public methods used to create and instance of the driver. * Copyright (C) 2003 Johnathan Ingram, jingram@rogueware.org * * This library is free software; you can redistribute it and/or *   modify it under the terms of the GNU Lesser General Public *   License as published by the Free Software Foundation; either *   version 2.1 of the License, or (at your option) any later version. * *   This library is distributed in the hope that it will be useful, *   but WITHOUT ANY WARRANTY; without even the implied warranty of *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU *   Lesser General Public License for more details. * *   You should have received a copy of the GNU Lesser General Public *   License along with this library; if not, write to the Free Software *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  US * */#include <string.h>#include <string>#include "baseConnection.h"#include "pgsqlConnection.h"#include <iostream>

using namespace std;

//Stop the C++ name mangling
extern "C"
{

#ifdef WIN32
   // Windows
   // DLL Exports
   __declspec( dllexport ) void* createDriverInstance(int argc, const char** argv);
   __declspec( dllexport ) void* destroyDriverInstance(void* driver);
   __declspec( dllexport ) const char* getAuthor();
   __declspec( dllexport ) const char* getVendor();
   __declspec( dllexport ) const char* getDriverName();
   __declspec( dllexport ) const char* getDriverDesc();
   __declspec( dllexport ) const char* getDbConnectVersion();
   __declspec( dllexport ) const char* getCopyright();   __declspec( dllexport ) const char* getDriverType();#endif


/* Create an instance of the driver.  * @param  argc     Number of parameters and values. * @param  argv     Parameters that can be used to instantiate the driver with. * * @return          Return the instance or NULL if an error occured. */
void*createDriverInstance(int argc, const char** argv){   try   {
      PostgresqlConnection *pgsqlConnection = NULL;      pgsqlConnection = new PostgresqlConnection(argc, argv);      return (void*)pgsqlConnection;   }   catch(...)   {      return NULL;   }}/* Destroy an instance of the driver. * * @return        Return NULL for success or the the pointer to the instance for failure. * * @param  driver The pointer to the driver instance. */
void*destroyDriverInstance(   void* driver){   PostgresqlConnection *pgsqlConnection = (PostgresqlConnection*)driver;      if (pgsqlConnection)   {      // Make sure we have the correct driver.           if (strcmp( pgsqlConnection->driverName.c_str(), PGSQL_DRIVERNAME) != 0)         return driver;      // Free the driver.      delete pgsqlConnection;   }   return NULL;}   /* Get the author of the driver. * * @return          Return the author. */
const char*getAuthor(){   return "Johnathan Ingram, jingram@rogueware.org";}/* Get the vendor information of the driver. * * @return          Return the vendor. */
const char*getVendor(){   return "Rogueware, www.rogueware.org, GNU";}  /* Get the copyright information of the driver. * * @return          Return the copyright information. */const char*getCopyright(){   return "Copyright (C) 2003 Johnathan Ingram, jingram@rogueware.org";}  /* Get the driver type * * @return          Return the driver type. */const char*getDriverType(){   return "RDMS";}  /* Get the name of the driver. * * @return          Return the driver name. */
const char*getDriverName(){     return PGSQL_DRIVERNAME;}/* Get the description of the driver. * * @return          Return the driver description. */
const char*getDriverDesc(){     return "PostgreSQL Version 7 Database Driver";}/* Returns the version of DbConnect this driver was compiled with. * * @return          Return the DbConnect version. */
const char*getDbConnectVersion(){   return DBCONNECTVER;}} // extern "C"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -