diff options
author | megamage <none@none> | 2009-04-25 11:31:57 -0500 |
---|---|---|
committer | megamage <none@none> | 2009-04-25 11:31:57 -0500 |
commit | f89cd6318daba66d9761c1cdbf012210ca31f918 (patch) | |
tree | 7cee580403f4ee9f06352d61a835da08f44b2f46 /src/shared/Database | |
parent | 8644c48db870b2f33e2b64a62ab8ec1030188067 (diff) |
*Fix build.
--HG--
branch : trunk
Diffstat (limited to 'src/shared/Database')
-rw-r--r-- | src/shared/Database/CMakeLists.txt | 5 | ||||
-rw-r--r-- | src/shared/Database/DatabaseEnv.h | 56 | ||||
-rw-r--r-- | src/shared/Database/DatabaseSqlite.cpp | 104 | ||||
-rw-r--r-- | src/shared/Database/DatabaseSqlite.h | 46 | ||||
-rw-r--r-- | src/shared/Database/QueryResultSqlite.cpp | 99 | ||||
-rw-r--r-- | src/shared/Database/QueryResultSqlite.h | 46 |
6 files changed, 0 insertions, 356 deletions
diff --git a/src/shared/Database/CMakeLists.txt b/src/shared/Database/CMakeLists.txt index 617cc0fdb38..429dc118c6c 100644 --- a/src/shared/Database/CMakeLists.txt +++ b/src/shared/Database/CMakeLists.txt @@ -4,14 +4,11 @@ SET(trinitydatabase_STAT_SRCS DBCStore.h Database.cpp Database.h - DatabaseEnv.h DatabaseImpl.h DatabaseMysql.cpp DatabasePostgre.cpp DatabaseMysql.h DatabasePostgre.h - DatabaseSqlite.cpp - DatabaseSqlite.h Field.cpp Field.h MySQLDelayThread.h @@ -21,8 +18,6 @@ SET(trinitydatabase_STAT_SRCS QueryResultMysql.h QueryResultPostgre.cpp QueryResultPostgre.h - QueryResultSqlite.cpp - QueryResultSqlite.h SQLStorage.cpp SQLStorage.h SqlDelayThread.cpp diff --git a/src/shared/Database/DatabaseEnv.h b/src/shared/Database/DatabaseEnv.h deleted file mode 100644 index 1d3d735881c..00000000000 --- a/src/shared/Database/DatabaseEnv.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> - * - * Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#if !defined(DATABASEENV_H) -#define DATABASEENV_H - -#include "Common.h" -#include "Log.h" -#include "Errors.h" - -#include "Database/Field.h" -#include "Database/QueryResult.h" - -#ifdef DO_POSTGRESQL -#include "Database/QueryResultPostgre.h" -#include "Database/Database.h" -#include "Database/DatabasePostgre.h" -typedef DatabasePostgre DatabaseType; -#define _LIKE_ "ILIKE" -#define _TABLE_SIM_ "\"" -#define _CONCAT3_(A,B,C) "( " A " || " B " || " C " )" -#define _OFFSET_ "LIMIT 1 OFFSET %d" -#else -#include "Database/QueryResultMysql.h" -#include "Database/Database.h" -#include "Database/DatabaseMysql.h" -typedef DatabaseMysql DatabaseType; -#define _LIKE_ "LIKE" -#define _TABLE_SIM_ "`" -#define _CONCAT3_(A,B,C) "CONCAT( " A " , " B " , " C " )" -#define _OFFSET_ "LIMIT %d,1" -#endif - -extern DatabaseType WorldDatabase; -extern DatabaseType CharacterDatabase; -extern DatabaseType LoginDatabase; - -#endif - diff --git a/src/shared/Database/DatabaseSqlite.cpp b/src/shared/Database/DatabaseSqlite.cpp deleted file mode 100644 index b5def933723..00000000000 --- a/src/shared/Database/DatabaseSqlite.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> - * - * Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef DO_POSTGRESQL - -#include "DatabaseEnv.h" - -DatabaseSqlite::DatabaseSqlite() : Database(), mSqlite(0) -{ -} - -DatabaseSqlite::~DatabaseSqlite() -{ - if (mSqlite) - sqlite_close(mSqlite); -} - -bool DatabaseSqlite::Initialize(const char *infoString) -{ - if(!Database::Initialize(infoString)) - return false; - - char *errmsg; - - mSqlite = sqlite_open(infoString, 0, &errmsg); - - if (!mSqlite) - { - - if (errmsg) - sqlite_freemem(errmsg); - return false; - } - - return true; -} - -QueryResult* DatabaseSqlite::Query(const char *sql) -{ - char *errmsg; - - if (!mSqlite) - return 0; - - char **tableData; - int rowCount; - int fieldCount; - - sqlite_get_table(mSqlite, sql, &tableData, &rowCount, &fieldCount, &errmsg); - - if (!rowCount) - return 0; - - if (!tableData) - { - - if (errmsg) - sqlite_freemem(errmsg); - return 0; - } - - QueryResultSqlite *queryResult = new QueryResultSqlite(tableData, rowCount, fieldCount); - if(!queryResult) - { - - return 0; - } - - queryResult->NextRow(); - - return queryResult; -} - -bool DatabaseSqlite::Execute(const char *sql) -{ - char *errmsg; - - if (!mSqlite) - return false; - - if(sqlite_exec(mSqlite, sql, NULL, NULL, &errmsg) != SQLITE_OK) - return false; - - return true; -} -#endif - diff --git a/src/shared/Database/DatabaseSqlite.h b/src/shared/Database/DatabaseSqlite.h deleted file mode 100644 index c84b59eea80..00000000000 --- a/src/shared/Database/DatabaseSqlite.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> - * - * Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef DO_POSTGRESQL - -#ifndef _DATABASESQLITE_H -#define _DATABASESQLITE_H - -#include <sqlite/sqlite.h> - -class DatabaseSqlite : public Database -{ - public: - DatabaseSqlite(); - ~DatabaseSqlite(); - - bool Initialize(const char *infoString); - - QueryResult* Query(const char *sql); - bool Execute(const char *sql); - - operator bool () const { return mSqlite != NULL; } - - private: - sqlite *mSqlite; -}; -#endif -#endif - diff --git a/src/shared/Database/QueryResultSqlite.cpp b/src/shared/Database/QueryResultSqlite.cpp deleted file mode 100644 index 06a02d1db59..00000000000 --- a/src/shared/Database/QueryResultSqlite.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> - * - * Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef DO_POSTGRESQL - -#include "DatabaseEnv.h" - -QueryResultSqlite::QueryResultSqlite(char **tableData, uint32 rowCount, uint32 fieldCount) : -QueryResult(rowCount, fieldCount), mTableData(tableData), mTableIndex(0) -{ - mCurrentRow = new Field[mFieldCount]; - - for (uint32 i = 0; i < mFieldCount; i++) - { - mFieldNames[i] = mTableData[i]; - mCurrentRow[i].SetType(Field::DB_TYPE_UNKNOWN); - } -} - -QueryResultSqlite::~QueryResultSqlite() -{ - EndQuery(); -} - -bool QueryResultSqlite::NextRow() -{ - int startIndex; - uint32 i; - - if (!mTableData) - return false; - - if (mTableIndex >= mRowCount) - { - EndQuery(); - return false; - } - - startIndex = (mTableIndex + 1) * mFieldCount; - for (i = 0; i < mFieldCount; i++) - { - mCurrentRow[i].SetValue(mTableData[startIndex + i]); - } - - ++mTableIndex; - return true; -} - -void QueryResultSqlite::EndQuery() -{ - if (mCurrentRow) - { - delete [] mCurrentRow; - mCurrentRow = NULL; - } - if (mTableData) - { - sqlite_free_table(mTableData); - mTableData = NULL; - } -} - -enum Field::DataTypes QueryResultSqlite::ConvertNativeType(const char* sqliteType) const -{ - if (sqliteType) - { - switch (*sqliteType) - { - case 'S': - return Field::DB_TYPE_STRING; - case 'I': - return Field::DB_TYPE_INTEGER; - case 'F': - return Field::DB_TYPE_FLOAT; - default: - return Field::DB_TYPE_UNKNOWN; - }; - } - return Field::DB_TYPE_UNKNOWN; -} -#endif - diff --git a/src/shared/Database/QueryResultSqlite.h b/src/shared/Database/QueryResultSqlite.h deleted file mode 100644 index 5dc3287b385..00000000000 --- a/src/shared/Database/QueryResultSqlite.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> - * - * Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef DO_POSTGRESQL - -#if !defined(QUERYRESULTSQLITE_H) -#define QUERYRESULTSQLITE_H - -#include <sqlite/sqlite.h> - -class QueryResultSqlite : public QueryResult -{ - public: - QueryResultSqlite(char **tableData, uint32 rowCount, uint32 fieldCount); - - ~QueryResultSqlite(); - - bool NextRow(); - - private: - enum Field::DataTypes ConvertNativeType(const char* sqliteType) const; - void EndQuery(); - - char **mTableData; - uint32 mTableIndex; -}; -#endif -#endif - |