mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
Merge pull request #2060 from Bloodknight/add_sqlite
SQLite Integration
This commit is contained in:
commit
ad612e218b
911
Engine/source/sqlite/SQLiteObject.cc
Normal file
911
Engine/source/sqlite/SQLiteObject.cc
Normal file
|
|
@ -0,0 +1,911 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//
|
||||
// Additional Copyrights
|
||||
// Copyright 2004 John Vanderbeck
|
||||
// Copyright 2016 Chris Calef
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// This code implements support for SQLite into Torque and TorqueScript
|
||||
//
|
||||
// Essentially this creates a scriptable object that interfaces with SQLite.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "SQLiteObject.h"
|
||||
|
||||
#include "console/simBase.h"
|
||||
#include "console/engineAPI.h"
|
||||
|
||||
#include "console/consoleInternal.h"
|
||||
#include <STDLIB.H>
|
||||
|
||||
IMPLEMENT_CONOBJECT(SQLiteObject);
|
||||
|
||||
|
||||
SQLiteObject::SQLiteObject()
|
||||
{
|
||||
m_pDatabase = NULL;
|
||||
m_szErrorString = NULL;
|
||||
m_iLastResultSet = 0;
|
||||
m_iNextResultSet = 1;
|
||||
}
|
||||
|
||||
SQLiteObject::~SQLiteObject()
|
||||
{
|
||||
S32 index;
|
||||
// if we still have a database open, close it
|
||||
CloseDatabase();
|
||||
// Clear out any error string we may have left
|
||||
ClearErrorString();
|
||||
// Clean up result sets
|
||||
//
|
||||
// Boy oh boy this is such a crazy hack!
|
||||
// I can't seem to iterate through a vector and clean it up without screwing the vector.
|
||||
// So (HACK HACK HACK) what i'm doing for now is making a temporary vector that
|
||||
// contains a list of the result sets that the user hasn't cleaned up.
|
||||
// Clean up all those result sets, then delete the temp vector.
|
||||
Vector<int> vTemp;
|
||||
Vector<int>::iterator iTemp;
|
||||
|
||||
VectorPtr<sqlite_resultset*>::iterator i;
|
||||
for (i = m_vResultSets.begin(); i != m_vResultSets.end(); i++)
|
||||
{
|
||||
vTemp.push_back((*i)->iResultSet);
|
||||
}
|
||||
index = 0;
|
||||
for (iTemp = vTemp.begin(); iTemp != vTemp.end(); iTemp++)
|
||||
{
|
||||
Con::warnf("SQLiteObject Warning: Result set #%i was not cleared by script. Clearing it now.", vTemp[index]);
|
||||
ClearResultSet(vTemp[index]);
|
||||
index++;
|
||||
}
|
||||
|
||||
m_vResultSets.clear();
|
||||
|
||||
}
|
||||
|
||||
bool SQLiteObject::processArguments(S32 argc, const char **argv)
|
||||
{
|
||||
if (argc == 0)
|
||||
return true;
|
||||
else
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SQLiteObject::onAdd()
|
||||
{
|
||||
if (!Parent::onAdd())
|
||||
return false;
|
||||
|
||||
const char *name = getName();
|
||||
if (name && name[0] && getClassRep())
|
||||
{
|
||||
Namespace *parent = getClassRep()->getNameSpace();
|
||||
Con::linkNamespaces(parent->mName, name);
|
||||
mNameSpace = Con::lookupNamespace(name);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// This is the function that gets called when an instance
|
||||
// of your object is being removed from the system and being
|
||||
// destroyed. Use this to do your clean up and what not.
|
||||
void SQLiteObject::onRemove()
|
||||
{
|
||||
CloseDatabase();
|
||||
Parent::onRemove();
|
||||
}
|
||||
|
||||
// To be honest i'm not 100% sure on when this is called yet.
|
||||
// Basically its used to set the values of any persistant fields
|
||||
// the object has. Similiar to the way datablocks work. I'm
|
||||
// just not sure how and when this gets called.
|
||||
void SQLiteObject::initPersistFields()
|
||||
{
|
||||
Parent::initPersistFields();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// These functions below are our custom functions that we will tie into
|
||||
// script.
|
||||
|
||||
int Callback(void *pArg, int argc, char **argv, char **columnNames)
|
||||
{
|
||||
// basically this callback is called for each row in the SQL query result.
|
||||
// for each row, argc indicates how many columns are returned.
|
||||
// columnNames[i] is the name of the column
|
||||
// argv[i] is the value of the column
|
||||
|
||||
sqlite_resultrow* pRow;
|
||||
sqlite_resultset* pResultSet;
|
||||
char* name;
|
||||
char* value;
|
||||
int i;
|
||||
|
||||
if (argc == 0)
|
||||
return 0;
|
||||
|
||||
pResultSet = (sqlite_resultset*)pArg;
|
||||
if (!pResultSet)
|
||||
return -1;
|
||||
|
||||
// create a new result row
|
||||
pRow = new sqlite_resultrow;
|
||||
pResultSet->iNumCols = argc;
|
||||
// loop through all the columns and stuff them into our row
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
// DBEUG CODE
|
||||
// Con::printf("%s = %s\n", columnNames[i], argv[i] ? argv[i] : "NULL");
|
||||
name = new char[dStrlen(columnNames[i]) + 1];
|
||||
dStrcpy(name, columnNames[i]);
|
||||
pRow->vColumnNames.push_back(name);
|
||||
if (argv[i])
|
||||
{
|
||||
value = new char[dStrlen(argv[i]) + 1];
|
||||
dStrcpy(value, argv[i]);
|
||||
pRow->vColumnValues.push_back(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = new char[10];
|
||||
dStrcpy(value, "NULL");
|
||||
pRow->vColumnValues.push_back(value);
|
||||
}
|
||||
}
|
||||
pResultSet->iNumRows++;
|
||||
pResultSet->vRows.push_back(pRow);
|
||||
|
||||
// return 0 or else the sqlexec will be aborted.
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool SQLiteObject::OpenDatabase(const char* filename)
|
||||
{
|
||||
// check to see if we already have an open database, and
|
||||
// if so, close it.
|
||||
CloseDatabase();
|
||||
|
||||
Con::printf("CALLING THE OLD OPEN DATABASE FUNCTION!!!!!!!!!!!!!!!!!!");
|
||||
|
||||
// We persist the error string so that the script may make a
|
||||
// GetLastError() call at any time. However when we get
|
||||
// ready to make a call which could result in a new error,
|
||||
// we need to clear what we have to avoid a memory leak.
|
||||
ClearErrorString();
|
||||
|
||||
int isOpen = sqlite3_open(filename, &m_pDatabase);
|
||||
if (isOpen == SQLITE_ERROR)
|
||||
{
|
||||
// there was an error and the database could not
|
||||
// be opened.
|
||||
m_szErrorString = (char *)sqlite3_errmsg(m_pDatabase);
|
||||
Con::executef(this, "2", "onOpenFailed()", m_szErrorString);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// database was opened without error
|
||||
Con::executef(this, "1", "onOpened()");
|
||||
|
||||
//Now, for OpenSimEarth, load spatialite dll, so we can have GIS functions.
|
||||
//int canLoadExt = sqlite3_load_extension(m_pDatabase,"mod_spatialite.dll",0,0);
|
||||
//Con::printf("opened spatialite extension: %d",canLoadExt);
|
||||
//Sigh, no luck yet. Cannot find function GeomFromText().
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int SQLiteObject::ExecuteSQL(const char* sql)
|
||||
{
|
||||
int iResult;
|
||||
sqlite_resultset* pResultSet;
|
||||
|
||||
// create a new resultset
|
||||
pResultSet = new sqlite_resultset;
|
||||
|
||||
if (pResultSet)
|
||||
{
|
||||
pResultSet->bValid = false;
|
||||
pResultSet->iCurrentColumn = 0;
|
||||
pResultSet->iCurrentRow = 0;
|
||||
pResultSet->iNumCols = 0;
|
||||
pResultSet->iNumRows = 0;
|
||||
pResultSet->iResultSet = m_iNextResultSet;
|
||||
pResultSet->vRows.clear();
|
||||
m_iLastResultSet = m_iNextResultSet;
|
||||
m_iNextResultSet++;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
|
||||
iResult = sqlite3_exec(m_pDatabase, sql, Callback, (void*)pResultSet, &m_szErrorString);
|
||||
if (iResult == 0)
|
||||
{
|
||||
//SQLITE_OK
|
||||
SaveResultSet(pResultSet);
|
||||
Con::executef(this, "1", "onQueryFinished()");
|
||||
return pResultSet->iResultSet;
|
||||
}
|
||||
else
|
||||
{
|
||||
// error occured
|
||||
Con::executef(this, "2", "onQueryFailed", m_szErrorString);
|
||||
Con::errorf("SQLite failed to execute query, error %s", m_szErrorString);
|
||||
delete pResultSet;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SQLiteObject::CloseDatabase()
|
||||
{
|
||||
if (m_pDatabase)
|
||||
sqlite3_close(m_pDatabase);
|
||||
|
||||
m_pDatabase = NULL;
|
||||
}
|
||||
|
||||
//(The following function is courtesy of sqlite.org, minus changes to use m_pDatabase instead of pInMemory.)
|
||||
/*
|
||||
** This function is used to load the contents of a database file on disk
|
||||
** into the "main" database of open database connection pInMemory, or
|
||||
** to save the current contents of the database opened by pInMemory into
|
||||
** a database file on disk. pInMemory is probably an in-memory database,
|
||||
** but this function will also work fine if it is not.
|
||||
**
|
||||
** Parameter zFilename points to a null-terminated string containing the
|
||||
** name of the database file on disk to load from or save to. If parameter
|
||||
** isSave is non-zero, then the contents of the file zFilename are
|
||||
** overwritten with the contents of the database opened by pInMemory. If
|
||||
** parameter isSave is zero, then the contents of the database opened by
|
||||
** pInMemory are replaced by data loaded from the file zFilename.
|
||||
**
|
||||
** If the operation is successful, SQLITE_OK is returned. Otherwise, if
|
||||
** an error occurs, an SQLite error code is returned.
|
||||
*/
|
||||
int SQLiteObject::loadOrSaveDb(const char *zFilename, bool isSave) {
|
||||
int rc; /* Function return code */
|
||||
sqlite3 *pFile; /* Database connection opened on zFilename */
|
||||
sqlite3_backup *pBackup; /* Backup object used to copy data */
|
||||
sqlite3 *pTo; /* Database to copy to (pFile or pInMemory) */
|
||||
sqlite3 *pFrom; /* Database to copy from (pFile or pInMemory) */
|
||||
|
||||
/* Open the database file identified by zFilename. Exit early if this fails
|
||||
** for any reason. */
|
||||
|
||||
Con::printf("calling loadOrSaveDb, isSave = %d", isSave);
|
||||
|
||||
if (isSave == false)
|
||||
{//If we're loading, have to create the memory database.
|
||||
if (!(SQLITE_OK == sqlite3_open(":memory:", &m_pDatabase)))
|
||||
{
|
||||
Con::printf("Unable to open a memory database!");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
rc = sqlite3_open(zFilename, &pFile);
|
||||
if (rc == SQLITE_OK) {
|
||||
|
||||
/* If this is a 'load' operation (isSave==0), then data is copied
|
||||
** from the database file just opened to database pInMemory.
|
||||
** Otherwise, if this is a 'save' operation (isSave==1), then data
|
||||
** is copied from pInMemory to pFile. Set the variables pFrom and
|
||||
** pTo accordingly. */
|
||||
pFrom = (isSave ? m_pDatabase : pFile);
|
||||
pTo = (isSave ? pFile : m_pDatabase);
|
||||
|
||||
/* Set up the backup procedure to copy from the "main" database of
|
||||
** connection pFile to the main database of connection pInMemory.
|
||||
** If something goes wrong, pBackup will be set to NULL and an error
|
||||
** code and message left in connection pTo.
|
||||
**
|
||||
** If the backup object is successfully created, call backup_step()
|
||||
** to copy data from pFile to pInMemory. Then call backup_finish()
|
||||
** to release resources associated with the pBackup object. If an
|
||||
** error occurred, then an error code and message will be left in
|
||||
** connection pTo. If no error occurred, then the error code belonging
|
||||
** to pTo is set to SQLITE_OK.
|
||||
*/
|
||||
pBackup = sqlite3_backup_init(pTo, "main", pFrom, "main");
|
||||
if (pBackup) {
|
||||
(void)sqlite3_backup_step(pBackup, -1);
|
||||
(void)sqlite3_backup_finish(pBackup);
|
||||
}
|
||||
rc = sqlite3_errcode(pTo);
|
||||
}
|
||||
|
||||
/* Close the database connection opened on database file zFilename
|
||||
** and return the result of this function. */
|
||||
(void)sqlite3_close(pFile);
|
||||
|
||||
//if (isSave == true) // Actually, cancel this, I'm sure it will happen automatically and if we don't do it here, we can also use
|
||||
//{ // this function for periodic saves, such as after saving mission.
|
||||
// sqlite3_close(m_pDatabase);
|
||||
//}
|
||||
|
||||
Con::printf("finished loadOrSaveDb, rc = %d", rc);
|
||||
|
||||
if (rc == 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void SQLiteObject::NextRow(int resultSet)
|
||||
{
|
||||
sqlite_resultset* pResultSet;
|
||||
|
||||
pResultSet = GetResultSet(resultSet);
|
||||
if (!pResultSet)
|
||||
return;
|
||||
|
||||
pResultSet->iCurrentRow++;
|
||||
}
|
||||
|
||||
bool SQLiteObject::EndOfResult(int resultSet)
|
||||
{
|
||||
sqlite_resultset* pResultSet;
|
||||
|
||||
pResultSet = GetResultSet(resultSet);
|
||||
if (!pResultSet)
|
||||
return true;
|
||||
|
||||
if (pResultSet->iCurrentRow >= pResultSet->iNumRows)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void SQLiteObject::ClearErrorString()
|
||||
{
|
||||
if (m_szErrorString)
|
||||
sqlite3_free(m_szErrorString);
|
||||
|
||||
m_szErrorString = NULL;
|
||||
}
|
||||
|
||||
void SQLiteObject::ClearResultSet(int index)
|
||||
{
|
||||
if (index <= 0)
|
||||
return;
|
||||
|
||||
sqlite_resultset* resultSet;
|
||||
sqlite_resultrow* resultRow;
|
||||
S32 rows, cols, iResultSet;
|
||||
|
||||
// Get the result set specified by index
|
||||
resultSet = GetResultSet(index);
|
||||
iResultSet = GetResultSetIndex(index);
|
||||
if ((!resultSet) || (!resultSet->bValid))
|
||||
{
|
||||
Con::warnf("Warning SQLiteObject::ClearResultSet(%i) failed to retrieve specified result set. Result set was NOT cleared.", index);
|
||||
return;
|
||||
}
|
||||
// Now we have the specific result set to be cleared.
|
||||
// What we need to do now is iterate through each "Column" in each "Row"
|
||||
// and free the strings, then delete the entries.
|
||||
VectorPtr<sqlite_resultrow*>::iterator iRow;
|
||||
VectorPtr<char*>::iterator iColumnName;
|
||||
VectorPtr<char*>::iterator iColumnValue;
|
||||
|
||||
for (iRow = resultSet->vRows.begin(); iRow != resultSet->vRows.end(); iRow++)
|
||||
{
|
||||
// Iterate through rows
|
||||
// for each row iterate through all the column values and names
|
||||
for (iColumnName = (*iRow)->vColumnNames.begin(); iColumnName != (*iRow)->vColumnNames.end(); iColumnName++)
|
||||
{
|
||||
// Iterate through column names. Free the memory.
|
||||
delete[](*iColumnName);
|
||||
}
|
||||
for (iColumnValue = (*iRow)->vColumnValues.begin(); iColumnValue != (*iRow)->vColumnValues.end(); iColumnValue++)
|
||||
{
|
||||
// Iterate through column values. Free the memory.
|
||||
delete[](*iColumnValue);
|
||||
}
|
||||
// free memory used by the row
|
||||
delete (*iRow);
|
||||
}
|
||||
// empty the resultset
|
||||
resultSet->vRows.clear();
|
||||
resultSet->bValid = false;
|
||||
delete resultSet;
|
||||
m_vResultSets.erase_fast(iResultSet);
|
||||
}
|
||||
|
||||
sqlite_resultset* SQLiteObject::GetResultSet(int iResultSet)
|
||||
{
|
||||
// Get the result set specified by iResultSet
|
||||
VectorPtr<sqlite_resultset*>::iterator i;
|
||||
for (i = m_vResultSets.begin(); i != m_vResultSets.end(); i++)
|
||||
{
|
||||
if ((*i)->iResultSet == iResultSet)
|
||||
break;
|
||||
}
|
||||
|
||||
return *i;
|
||||
}
|
||||
|
||||
int SQLiteObject::GetResultSetIndex(int iResultSet)
|
||||
{
|
||||
int iIndex;
|
||||
// Get the result set specified by iResultSet
|
||||
VectorPtr<sqlite_resultset*>::iterator i;
|
||||
iIndex = 0;
|
||||
for (i = m_vResultSets.begin(); i != m_vResultSets.end(); i++)
|
||||
{
|
||||
if ((*i)->iResultSet == iResultSet)
|
||||
break;
|
||||
iIndex++;
|
||||
}
|
||||
|
||||
return iIndex;
|
||||
}
|
||||
|
||||
bool SQLiteObject::SaveResultSet(sqlite_resultset* pResultSet)
|
||||
{
|
||||
// Basically just add this to our vector. It should already be filled up.
|
||||
pResultSet->bValid = true;
|
||||
m_vResultSets.push_back(pResultSet);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int SQLiteObject::GetColumnIndex(int iResult, const char* columnName)
|
||||
{
|
||||
int iIndex;
|
||||
VectorPtr<char*>::iterator i;
|
||||
sqlite_resultset* pResultSet;
|
||||
sqlite_resultrow* pRow;
|
||||
|
||||
pResultSet = GetResultSet(iResult);
|
||||
if (!pResultSet)
|
||||
return 0;
|
||||
|
||||
pRow = pResultSet->vRows[0];
|
||||
if (!pRow)
|
||||
return 0;
|
||||
|
||||
iIndex = 0;
|
||||
for (i = pRow->vColumnNames.begin(); i != pRow->vColumnNames.end(); i++)
|
||||
{
|
||||
if (dStricmp((*i), columnName) == 0)
|
||||
return iIndex + 1;
|
||||
iIndex++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SQLiteObject::numResultSets()
|
||||
{
|
||||
return m_vResultSets.size();
|
||||
}
|
||||
|
||||
void SQLiteObject::escapeSingleQuotes(const char* source, char *dest)
|
||||
{
|
||||
//To Do: This function needs to step through the source string and insert another single quote
|
||||
//immediately after every single quote it finds.
|
||||
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// These functions are the code that actually tie our object into the scripting
|
||||
// language. As you can see each one of these is called by script and in turn
|
||||
// calls the C++ class function.
|
||||
// FIX: change all these to DefineEngineMethod!
|
||||
|
||||
ConsoleMethod(SQLiteObject, openDatabase, bool, 3, 3, "(const char* filename) Opens the database specifed by filename. Returns true or false.")
|
||||
{
|
||||
return object->OpenDatabase(argv[2]);
|
||||
}
|
||||
|
||||
DefineEngineMethod(SQLiteObject, loadOrSaveDb, bool, (const char* filename, bool isSave), ,
|
||||
"Loads or saves a cached database from the disk db specifed by filename. Second argument determines loading (false) or saving (true). Returns true or false.")
|
||||
{
|
||||
return object->loadOrSaveDb(filename, isSave);
|
||||
}
|
||||
|
||||
ConsoleMethod(SQLiteObject, closeDatabase, void, 2, 2, "Closes the active database.")
|
||||
{
|
||||
object->CloseDatabase();
|
||||
}
|
||||
|
||||
ConsoleMethod(SQLiteObject, query, S32, 4, 0, "(const char* sql, int mode) Performs an SQL query on the open database and returns an identifier to a valid result set. mode is currently unused, and is reserved for future use.")
|
||||
{
|
||||
S32 iCount;
|
||||
S32 iIndex, iLen, iNewIndex, iArg, iArgLen, i;
|
||||
char* szNew;
|
||||
|
||||
if (argc == 4)
|
||||
return object->ExecuteSQL(argv[2]);
|
||||
else if (argc > 4)
|
||||
{
|
||||
// Support for printf type querys, as per Ben Garney's suggestion
|
||||
// Basically what this does is allow the user to insert question marks into their query that will
|
||||
// be replaced with actual data. For example:
|
||||
// "SELECT * FROM data WHERE id=? AND age<7 AND name LIKE ?"
|
||||
|
||||
// scan the query and count the question marks
|
||||
iCount = 0;
|
||||
iLen = dStrlen(argv[2]);
|
||||
for (iIndex = 0; iIndex < iLen; iIndex++)
|
||||
{
|
||||
if (argv[2][iIndex] == '?')
|
||||
iCount++;
|
||||
}
|
||||
|
||||
// now that we know how many replacements we have, we need to make sure we
|
||||
// have enough arguments to replace them all. All arguments above 4 should be our data
|
||||
if (argc - 4 == iCount)
|
||||
{
|
||||
// ok we have the correct number of arguments
|
||||
// so now we need to calc the length of the new query string. This is easily achieved.
|
||||
// We simply take our base string length, subtract the question marks, then add in
|
||||
// the number of total characters used by our arguments.
|
||||
iLen = dStrlen(argv[2]) - iCount;
|
||||
for (iIndex = 1; iIndex <= iCount; iIndex++)
|
||||
{
|
||||
iLen = iLen + dStrlen(argv[iIndex + 3]);
|
||||
}
|
||||
// iLen should now be the length of our new string
|
||||
szNew = new char[iLen];
|
||||
|
||||
// now we need to replace all the question marks with the actual arguments
|
||||
iLen = dStrlen(argv[2]);
|
||||
iNewIndex = 0;
|
||||
iArg = 1;
|
||||
for (iIndex = 0; iIndex <= iLen; iIndex++)
|
||||
{
|
||||
if (argv[2][iIndex] == '?')
|
||||
{
|
||||
// ok we need to replace this question mark with the actual argument
|
||||
// and iterate our pointers and everything as needed. This is no doubt
|
||||
// not the best way to do this, but it works for me for now.
|
||||
// My god this is really a mess.
|
||||
iArgLen = dStrlen(argv[iArg + 3]);
|
||||
// copy first character
|
||||
szNew[iNewIndex] = argv[iArg + 3][0];
|
||||
// copy rest of characters, and increment iNewIndex
|
||||
for (i = 1; i < iArgLen; i++)
|
||||
{
|
||||
iNewIndex++;
|
||||
szNew[iNewIndex] = argv[iArg + 3][i];
|
||||
}
|
||||
iArg++;
|
||||
|
||||
}
|
||||
else
|
||||
szNew[iNewIndex] = argv[2][iIndex];
|
||||
|
||||
iNewIndex++;
|
||||
}
|
||||
}
|
||||
else
|
||||
return 0; // incorrect number of question marks vs arguments
|
||||
Con::printf("Old SQL: %s\nNew SQL: %s", argv[2], szNew);
|
||||
return object->ExecuteSQL(szNew);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
ConsoleMethod(SQLiteObject, clearResult, void, 3, 3, "(int resultSet) Clears memory used by the specified result set, and deletes the result set.")
|
||||
{
|
||||
object->ClearResultSet(dAtoi(argv[2]));
|
||||
}
|
||||
|
||||
ConsoleMethod(SQLiteObject, nextRow, void, 3, 3, "(int resultSet) Moves the result set's row pointer to the next row.")
|
||||
{
|
||||
sqlite_resultset* pResultSet;
|
||||
pResultSet = object->GetResultSet(dAtoi(argv[2]));
|
||||
if (pResultSet)
|
||||
{
|
||||
pResultSet->iCurrentRow++;
|
||||
}
|
||||
}
|
||||
|
||||
ConsoleMethod(SQLiteObject, previousRow, void, 3, 3, "(int resultSet) Moves the result set's row pointer to the previous row")
|
||||
{
|
||||
sqlite_resultset* pResultSet;
|
||||
pResultSet = object->GetResultSet(dAtoi(argv[2]));
|
||||
if (pResultSet)
|
||||
{
|
||||
pResultSet->iCurrentRow--;
|
||||
}
|
||||
}
|
||||
|
||||
ConsoleMethod(SQLiteObject, firstRow, void, 3, 3, "(int resultSet) Moves the result set's row pointer to the very first row in the result set.")
|
||||
{
|
||||
sqlite_resultset* pResultSet;
|
||||
pResultSet = object->GetResultSet(dAtoi(argv[2]));
|
||||
if (pResultSet)
|
||||
{
|
||||
pResultSet->iCurrentRow = 0;
|
||||
}
|
||||
}
|
||||
|
||||
ConsoleMethod(SQLiteObject, lastRow, void, 3, 3, "(int resultSet) Moves the result set's row pointer to the very last row in the result set.")
|
||||
{
|
||||
sqlite_resultset* pResultSet;
|
||||
pResultSet = object->GetResultSet(dAtoi(argv[2]));
|
||||
if (pResultSet)
|
||||
{
|
||||
pResultSet->iCurrentRow = pResultSet->iNumRows - 1;
|
||||
}
|
||||
}
|
||||
|
||||
ConsoleMethod(SQLiteObject, setRow, void, 4, 4, "(int resultSet int row) Moves the result set's row pointer to the row specified. Row indices start at 1 not 0.")
|
||||
{
|
||||
sqlite_resultset* pResultSet;
|
||||
pResultSet = object->GetResultSet(dAtoi(argv[2]));
|
||||
if (pResultSet)
|
||||
{
|
||||
pResultSet->iCurrentRow = dAtoi(argv[3]) - 1;
|
||||
}
|
||||
}
|
||||
|
||||
ConsoleMethod(SQLiteObject, getRow, S32, 3, 3, "(int resultSet) Returns what row the result set's row pointer is currently on.")
|
||||
{
|
||||
sqlite_resultset* pResultSet;
|
||||
pResultSet = object->GetResultSet(dAtoi(argv[2]));
|
||||
if (pResultSet)
|
||||
{
|
||||
return pResultSet->iCurrentRow + 1;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
ConsoleMethod(SQLiteObject, numRows, S32, 3, 3, "(int resultSet) Returns the number of rows in the result set.")
|
||||
{
|
||||
sqlite_resultset* pResultSet;
|
||||
pResultSet = object->GetResultSet(dAtoi(argv[2]));
|
||||
if (pResultSet)
|
||||
{
|
||||
return pResultSet->iNumRows;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
ConsoleMethod(SQLiteObject, numColumns, S32, 3, 3, "(int resultSet) Returns the number of columns in the result set.")
|
||||
{
|
||||
sqlite_resultset* pResultSet;
|
||||
pResultSet = object->GetResultSet(dAtoi(argv[2]));
|
||||
if (pResultSet)
|
||||
{
|
||||
return pResultSet->iNumCols;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
ConsoleMethod(SQLiteObject, endOfResult, bool, 3, 3, "(int resultSet) Checks to see if the internal pointer for the specified result set is at the end, indicating there are no more rows left to read.")
|
||||
{
|
||||
return object->EndOfResult(dAtoi(argv[2]));
|
||||
}
|
||||
|
||||
ConsoleMethod(SQLiteObject, EOR, bool, 3, 3, "(int resultSet) Same as endOfResult().")
|
||||
{
|
||||
return object->EndOfResult(dAtoi(argv[2]));
|
||||
}
|
||||
|
||||
ConsoleMethod(SQLiteObject, EOF, bool, 3, 3, "(int resultSet) Same as endOfResult().")
|
||||
{
|
||||
return object->EndOfResult(dAtoi(argv[2]));
|
||||
}
|
||||
|
||||
ConsoleMethod(SQLiteObject, getColumnIndex, S32, 4, 4, "(resultSet columnName) Looks up the specified column name in the specified result set, and returns the columns index number. A return value of 0 indicates the lookup failed for some reason (usually this indicates you specified a column name that doesn't exist or is spelled wrong).")
|
||||
{
|
||||
return object->GetColumnIndex(dAtoi(argv[2]), argv[3]);
|
||||
}
|
||||
|
||||
ConsoleMethod(SQLiteObject, getColumnName, const char *, 4, 4, "(resultSet columnIndex) Looks up the specified column index in the specified result set, and returns the column's name. A return value of an empty string indicates the lookup failed for some reason (usually this indicates you specified a column index that is invalid or exceeds the number of columns in the result set). Columns are index starting with 1 not 0")
|
||||
{
|
||||
sqlite_resultset* pResultSet;
|
||||
sqlite_resultrow* pRow;
|
||||
VectorPtr<char*>::iterator iName;
|
||||
VectorPtr<char*>::iterator iValue;
|
||||
S32 iColumn;
|
||||
|
||||
pResultSet = object->GetResultSet(dAtoi(argv[2]));
|
||||
if (pResultSet)
|
||||
{
|
||||
pRow = pResultSet->vRows[pResultSet->iCurrentRow];
|
||||
if (!pRow)
|
||||
return "";
|
||||
|
||||
// We assume they specified column by index. If they know the column name they wouldn't be calling this function :)
|
||||
iColumn = dAtoi(argv[3]);
|
||||
if (iColumn == 0)
|
||||
return ""; // column indices start at 1, not 0
|
||||
|
||||
// now we should have an index for our column name
|
||||
if (pRow->vColumnNames[iColumn])
|
||||
return pRow->vColumnNames[iColumn];
|
||||
else
|
||||
return "";
|
||||
}
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
ConsoleMethod(SQLiteObject, getColumn, const char *, 4, 4, "(resultSet column) Returns the value of the specified column (Column can be specified by name or index) in the current row of the specified result set. If the call fails, the returned string will indicate the error.")
|
||||
{
|
||||
sqlite_resultset* pResultSet;
|
||||
sqlite_resultrow* pRow;
|
||||
VectorPtr<char*>::iterator iName;
|
||||
VectorPtr<char*>::iterator iValue;
|
||||
S32 iColumn;
|
||||
|
||||
pResultSet = object->GetResultSet(dAtoi(argv[2]));
|
||||
if (pResultSet)
|
||||
{
|
||||
if (pResultSet->vRows.size() == 0)
|
||||
return "NULL";
|
||||
|
||||
pRow = pResultSet->vRows[pResultSet->iCurrentRow];
|
||||
if (!pRow)
|
||||
return "invalid_row";
|
||||
|
||||
// Is column specified by a name or an index?
|
||||
iColumn = dAtoi(argv[3]);
|
||||
if (iColumn == 0)
|
||||
{
|
||||
// column was specified by a name
|
||||
iColumn = object->GetColumnIndex(dAtoi(argv[2]), argv[3]);
|
||||
// if this is still 0 then we have some error
|
||||
if (iColumn == 0)
|
||||
return "invalid_column";
|
||||
}
|
||||
|
||||
// We temporarily padded the index in GetColumnIndex() so we could return a
|
||||
// 0 for error. So now we need to drop it back down.
|
||||
iColumn--;
|
||||
|
||||
// now we should have an index for our column data
|
||||
if (pRow->vColumnValues[iColumn])
|
||||
return pRow->vColumnValues[iColumn];
|
||||
else
|
||||
return "NULL";
|
||||
}
|
||||
else
|
||||
return "invalid_result_set";
|
||||
}
|
||||
|
||||
ConsoleMethod(SQLiteObject, getColumnNumeric, F32, 4, 4, "(resultSet column) Returns the value of the specified column (Column can be specified by name or index) in the current row of the specified result set. If the call fails, the returned string will indicate the error.")
|
||||
{
|
||||
sqlite_resultset* pResultSet;
|
||||
sqlite_resultrow* pRow;
|
||||
VectorPtr<char*>::iterator iName;
|
||||
VectorPtr<char*>::iterator iValue;
|
||||
S32 iColumn;
|
||||
|
||||
pResultSet = object->GetResultSet(dAtoi(argv[2]));
|
||||
if (pResultSet)
|
||||
{
|
||||
|
||||
if (pResultSet->vRows.size() == 0)
|
||||
return -1;
|
||||
|
||||
pRow = pResultSet->vRows[pResultSet->iCurrentRow];
|
||||
if (!pRow)
|
||||
return -1;//"invalid_row";
|
||||
|
||||
// Is column specified by a name or an index?
|
||||
iColumn = dAtoi(argv[3]);
|
||||
if (iColumn == 0)
|
||||
{
|
||||
// column was specified by a name
|
||||
iColumn = object->GetColumnIndex(dAtoi(argv[2]), argv[3]);
|
||||
// if this is still 0 then we have some error
|
||||
if (iColumn == 0)
|
||||
return -1;//"invalid_column";
|
||||
}
|
||||
|
||||
// We temporarily padded the index in GetColumnIndex() so we could return a
|
||||
// 0 for error. So now we need to drop it back down.
|
||||
iColumn--;
|
||||
|
||||
// now we should have an index for our column data
|
||||
if (pRow->vColumnValues[iColumn])
|
||||
return dAtof(pRow->vColumnValues[iColumn]);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return -1;//"invalid_result_set";
|
||||
}
|
||||
|
||||
ConsoleMethod(SQLiteObject, escapeString, const char *, 3, 3, "(string) Escapes the given string, making it safer to pass into a query.")
|
||||
{
|
||||
// essentially what we need to do here is scan the string for any occurrences of: ', ", and \
|
||||
// and prepend them with a slash: \', \", \\
|
||||
|
||||
// to do this we first need to know how many characters we are replacing so we can calculate
|
||||
// the size of the new string
|
||||
S32 iCount;
|
||||
S32 iIndex, iLen, iNewIndex;
|
||||
char* szNew;
|
||||
|
||||
iCount = 0;
|
||||
iLen = dStrlen(argv[2]);
|
||||
for (iIndex = 0; iIndex < iLen; iIndex++)
|
||||
{
|
||||
if (argv[2][iIndex] == '\'')
|
||||
iCount++;
|
||||
else if (argv[2][iIndex] == '\"')
|
||||
iCount++;
|
||||
else if (argv[2][iIndex] == '\\')
|
||||
iCount++;
|
||||
|
||||
}
|
||||
// Con::printf("escapeString counts %i instances of characters to be escaped. New string will be %i characters longer for a total of %i characters.", iCount, iCount, iLen+iCount);
|
||||
szNew = new char[iLen + iCount];
|
||||
iNewIndex = 0;
|
||||
for (iIndex = 0; iIndex <= iLen; iIndex++)
|
||||
{
|
||||
if (argv[2][iIndex] == '\'')
|
||||
{
|
||||
szNew[iNewIndex] = '\\';
|
||||
iNewIndex++;
|
||||
szNew[iNewIndex] = '\'';
|
||||
}
|
||||
else if (argv[2][iIndex] == '\"')
|
||||
{
|
||||
szNew[iNewIndex] = '\\';
|
||||
iNewIndex++;
|
||||
szNew[iNewIndex] = '\"';
|
||||
}
|
||||
else if (argv[2][iIndex] == '\\')
|
||||
{
|
||||
szNew[iNewIndex] = '\\';
|
||||
iNewIndex++;
|
||||
szNew[iNewIndex] = '\\';
|
||||
}
|
||||
else
|
||||
szNew[iNewIndex] = argv[2][iIndex];
|
||||
|
||||
iNewIndex++;
|
||||
}
|
||||
// Con::printf("Last characters of each string (new, old): %s, %s", argv[2][iIndex-1], szNew[iNewIndex-1]);
|
||||
// Con::printf("Old String: %s\nNew String: %s", argv[2], szNew);
|
||||
|
||||
return szNew;
|
||||
}
|
||||
|
||||
|
||||
ConsoleMethod(SQLiteObject, numResultSets, S32, 2, 2, "numResultSets()")
|
||||
{
|
||||
return object->numResultSets();
|
||||
}
|
||||
|
||||
ConsoleMethod(SQLiteObject, getLastRowId, S32, 2, 2, "getLastRowId()")
|
||||
{
|
||||
return object->getLastRowId();
|
||||
}
|
||||
134
Engine/source/sqlite/SQLiteObject.h
Normal file
134
Engine/source/sqlite/SQLiteObject.h
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//
|
||||
// Additional Copyrights
|
||||
// Copyright 2004 John Vanderbeck
|
||||
// Copyright 2016 Chris Calef
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// This code implements support for SQLite into Torque and TorqueScript
|
||||
//
|
||||
// Essentially this creates a scriptable object that interfaces with SQLite.
|
||||
//
|
||||
// The supported SQL subset of SQLite can be found here:
|
||||
// http://www.sqlite.org/lang.html
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef _SQLITEOBJECT_H_
|
||||
#define _SQLITEOBJECT_H_
|
||||
|
||||
#ifndef _SIMBASE_H_
|
||||
#include "console/simBase.h"
|
||||
#endif
|
||||
|
||||
#include "sqlite3.h"
|
||||
#include "core/util/tVector.h"
|
||||
|
||||
struct sqlite_resultrow
|
||||
{
|
||||
VectorPtr<char*> vColumnNames;
|
||||
VectorPtr<char*> vColumnValues;
|
||||
};
|
||||
|
||||
struct sqlite_resultset
|
||||
{
|
||||
int iResultSet;
|
||||
int iCurrentRow;
|
||||
int iCurrentColumn;
|
||||
int iNumRows;
|
||||
int iNumCols;
|
||||
bool bValid;
|
||||
VectorPtr<sqlite_resultrow*> vRows;
|
||||
};
|
||||
|
||||
|
||||
class SQLiteObject : public SimObject
|
||||
{
|
||||
// This typedef is required for tie ins with the script language.
|
||||
//--------------------------------------------------------------------------
|
||||
protected:
|
||||
typedef SimObject Parent;
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
public:
|
||||
SQLiteObject();
|
||||
~SQLiteObject();
|
||||
|
||||
// These are overloaded functions from SimObject that we handle for
|
||||
// tie in to the script language. The .cc file has more in depth
|
||||
// comments on these.
|
||||
//-----------------------------------------------------------------------
|
||||
bool processArguments(S32 argc, const char **argv);
|
||||
bool onAdd();
|
||||
void onRemove();
|
||||
static void initPersistFields();
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// Called to open a database using the sqlite_open() function.
|
||||
// If the open fails, the function returns false, and sets the
|
||||
// global error string. The script interface will automatically
|
||||
// call the onOpenFailed() script callback and pass this string
|
||||
// in if it fails. If it succeeds the script interface will call
|
||||
// the onOpened() script callback.
|
||||
bool OpenDatabase(const char* filename);
|
||||
void CloseDatabase();
|
||||
int loadOrSaveDb(const char *zFilename, bool isSave);//This code courtesy of sqlite.org.
|
||||
int ExecuteSQL(const char* sql);
|
||||
void NextRow(int resultSet);
|
||||
bool EndOfResult(int resultSet);
|
||||
void escapeSingleQuotes(const char* source, char *dest);
|
||||
|
||||
// support functions
|
||||
void ClearErrorString();
|
||||
void ClearResultSet(int index);
|
||||
sqlite_resultset* GetResultSet(int iResultSet);
|
||||
bool SaveResultSet(sqlite_resultset* pResultSet);
|
||||
int GetResultSetIndex(int iResultSet);
|
||||
int GetColumnIndex(int iResult, const char* columnName);
|
||||
int numResultSets();
|
||||
|
||||
//Prepared Statements! We need a way to make them and extend them to script.
|
||||
//void prepareStatement(sqlite3_stmt*,);
|
||||
//void finalizeStatement();
|
||||
//void bindInteger();
|
||||
//...
|
||||
|
||||
sqlite3* m_pDatabase;
|
||||
private:
|
||||
char* m_szErrorString;
|
||||
VectorPtr<sqlite_resultset*> m_vResultSets;
|
||||
int m_iLastResultSet;
|
||||
int m_iNextResultSet;
|
||||
|
||||
|
||||
// This macro ties us into the script engine, and MUST MUST MUST be declared
|
||||
// in a public section of the class definition. If it isn't you WILL get
|
||||
// errors that will confuse you.
|
||||
//--------------------------------------------------------------------------
|
||||
public:
|
||||
DECLARE_CONOBJECT(SQLiteObject);
|
||||
int getLastRowId() { return sqlite3_last_insert_rowid(m_pDatabase); };
|
||||
//--------------------------------------------------------------------------
|
||||
};
|
||||
|
||||
#endif // _SQLITEOBJECT_H_
|
||||
199527
Engine/source/sqlite/sqlite3.c
Normal file
199527
Engine/source/sqlite/sqlite3.c
Normal file
File diff suppressed because it is too large
Load diff
10371
Engine/source/sqlite/sqlite3.h
Normal file
10371
Engine/source/sqlite/sqlite3.h
Normal file
File diff suppressed because it is too large
Load diff
560
Engine/source/sqlite/sqlite3ext.h
Normal file
560
Engine/source/sqlite/sqlite3ext.h
Normal file
|
|
@ -0,0 +1,560 @@
|
|||
/*
|
||||
** 2006 June 7
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** This header file defines the SQLite interface for use by
|
||||
** shared libraries that want to be imported as extensions into
|
||||
** an SQLite instance. Shared libraries that intend to be loaded
|
||||
** as extensions by SQLite should #include this file instead of
|
||||
** sqlite3.h.
|
||||
*/
|
||||
#ifndef SQLITE3EXT_H
|
||||
#define SQLITE3EXT_H
|
||||
#include "sqlite3.h"
|
||||
|
||||
/*
|
||||
** The following structure holds pointers to all of the SQLite API
|
||||
** routines.
|
||||
**
|
||||
** WARNING: In order to maintain backwards compatibility, add new
|
||||
** interfaces to the end of this structure only. If you insert new
|
||||
** interfaces in the middle of this structure, then older different
|
||||
** versions of SQLite will not be able to load each other's shared
|
||||
** libraries!
|
||||
*/
|
||||
struct sqlite3_api_routines {
|
||||
void * (*aggregate_context)(sqlite3_context*,int nBytes);
|
||||
int (*aggregate_count)(sqlite3_context*);
|
||||
int (*bind_blob)(sqlite3_stmt*,int,const void*,int n,void(*)(void*));
|
||||
int (*bind_double)(sqlite3_stmt*,int,double);
|
||||
int (*bind_int)(sqlite3_stmt*,int,int);
|
||||
int (*bind_int64)(sqlite3_stmt*,int,sqlite_int64);
|
||||
int (*bind_null)(sqlite3_stmt*,int);
|
||||
int (*bind_parameter_count)(sqlite3_stmt*);
|
||||
int (*bind_parameter_index)(sqlite3_stmt*,const char*zName);
|
||||
const char * (*bind_parameter_name)(sqlite3_stmt*,int);
|
||||
int (*bind_text)(sqlite3_stmt*,int,const char*,int n,void(*)(void*));
|
||||
int (*bind_text16)(sqlite3_stmt*,int,const void*,int,void(*)(void*));
|
||||
int (*bind_value)(sqlite3_stmt*,int,const sqlite3_value*);
|
||||
int (*busy_handler)(sqlite3*,int(*)(void*,int),void*);
|
||||
int (*busy_timeout)(sqlite3*,int ms);
|
||||
int (*changes)(sqlite3*);
|
||||
int (*close)(sqlite3*);
|
||||
int (*collation_needed)(sqlite3*,void*,void(*)(void*,sqlite3*,
|
||||
int eTextRep,const char*));
|
||||
int (*collation_needed16)(sqlite3*,void*,void(*)(void*,sqlite3*,
|
||||
int eTextRep,const void*));
|
||||
const void * (*column_blob)(sqlite3_stmt*,int iCol);
|
||||
int (*column_bytes)(sqlite3_stmt*,int iCol);
|
||||
int (*column_bytes16)(sqlite3_stmt*,int iCol);
|
||||
int (*column_count)(sqlite3_stmt*pStmt);
|
||||
const char * (*column_database_name)(sqlite3_stmt*,int);
|
||||
const void * (*column_database_name16)(sqlite3_stmt*,int);
|
||||
const char * (*column_decltype)(sqlite3_stmt*,int i);
|
||||
const void * (*column_decltype16)(sqlite3_stmt*,int);
|
||||
double (*column_double)(sqlite3_stmt*,int iCol);
|
||||
int (*column_int)(sqlite3_stmt*,int iCol);
|
||||
sqlite_int64 (*column_int64)(sqlite3_stmt*,int iCol);
|
||||
const char * (*column_name)(sqlite3_stmt*,int);
|
||||
const void * (*column_name16)(sqlite3_stmt*,int);
|
||||
const char * (*column_origin_name)(sqlite3_stmt*,int);
|
||||
const void * (*column_origin_name16)(sqlite3_stmt*,int);
|
||||
const char * (*column_table_name)(sqlite3_stmt*,int);
|
||||
const void * (*column_table_name16)(sqlite3_stmt*,int);
|
||||
const unsigned char * (*column_text)(sqlite3_stmt*,int iCol);
|
||||
const void * (*column_text16)(sqlite3_stmt*,int iCol);
|
||||
int (*column_type)(sqlite3_stmt*,int iCol);
|
||||
sqlite3_value* (*column_value)(sqlite3_stmt*,int iCol);
|
||||
void * (*commit_hook)(sqlite3*,int(*)(void*),void*);
|
||||
int (*complete)(const char*sql);
|
||||
int (*complete16)(const void*sql);
|
||||
int (*create_collation)(sqlite3*,const char*,int,void*,
|
||||
int(*)(void*,int,const void*,int,const void*));
|
||||
int (*create_collation16)(sqlite3*,const void*,int,void*,
|
||||
int(*)(void*,int,const void*,int,const void*));
|
||||
int (*create_function)(sqlite3*,const char*,int,int,void*,
|
||||
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
|
||||
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
|
||||
void (*xFinal)(sqlite3_context*));
|
||||
int (*create_function16)(sqlite3*,const void*,int,int,void*,
|
||||
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
|
||||
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
|
||||
void (*xFinal)(sqlite3_context*));
|
||||
int (*create_module)(sqlite3*,const char*,const sqlite3_module*,void*);
|
||||
int (*data_count)(sqlite3_stmt*pStmt);
|
||||
sqlite3 * (*db_handle)(sqlite3_stmt*);
|
||||
int (*declare_vtab)(sqlite3*,const char*);
|
||||
int (*enable_shared_cache)(int);
|
||||
int (*errcode)(sqlite3*db);
|
||||
const char * (*errmsg)(sqlite3*);
|
||||
const void * (*errmsg16)(sqlite3*);
|
||||
int (*exec)(sqlite3*,const char*,sqlite3_callback,void*,char**);
|
||||
int (*expired)(sqlite3_stmt*);
|
||||
int (*finalize)(sqlite3_stmt*pStmt);
|
||||
void (*free)(void*);
|
||||
void (*free_table)(char**result);
|
||||
int (*get_autocommit)(sqlite3*);
|
||||
void * (*get_auxdata)(sqlite3_context*,int);
|
||||
int (*get_table)(sqlite3*,const char*,char***,int*,int*,char**);
|
||||
int (*global_recover)(void);
|
||||
void (*interruptx)(sqlite3*);
|
||||
sqlite_int64 (*last_insert_rowid)(sqlite3*);
|
||||
const char * (*libversion)(void);
|
||||
int (*libversion_number)(void);
|
||||
void *(*malloc)(int);
|
||||
char * (*mprintf)(const char*,...);
|
||||
int (*open)(const char*,sqlite3**);
|
||||
int (*open16)(const void*,sqlite3**);
|
||||
int (*prepare)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);
|
||||
int (*prepare16)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);
|
||||
void * (*profile)(sqlite3*,void(*)(void*,const char*,sqlite_uint64),void*);
|
||||
void (*progress_handler)(sqlite3*,int,int(*)(void*),void*);
|
||||
void *(*realloc)(void*,int);
|
||||
int (*reset)(sqlite3_stmt*pStmt);
|
||||
void (*result_blob)(sqlite3_context*,const void*,int,void(*)(void*));
|
||||
void (*result_double)(sqlite3_context*,double);
|
||||
void (*result_error)(sqlite3_context*,const char*,int);
|
||||
void (*result_error16)(sqlite3_context*,const void*,int);
|
||||
void (*result_int)(sqlite3_context*,int);
|
||||
void (*result_int64)(sqlite3_context*,sqlite_int64);
|
||||
void (*result_null)(sqlite3_context*);
|
||||
void (*result_text)(sqlite3_context*,const char*,int,void(*)(void*));
|
||||
void (*result_text16)(sqlite3_context*,const void*,int,void(*)(void*));
|
||||
void (*result_text16be)(sqlite3_context*,const void*,int,void(*)(void*));
|
||||
void (*result_text16le)(sqlite3_context*,const void*,int,void(*)(void*));
|
||||
void (*result_value)(sqlite3_context*,sqlite3_value*);
|
||||
void * (*rollback_hook)(sqlite3*,void(*)(void*),void*);
|
||||
int (*set_authorizer)(sqlite3*,int(*)(void*,int,const char*,const char*,
|
||||
const char*,const char*),void*);
|
||||
void (*set_auxdata)(sqlite3_context*,int,void*,void (*)(void*));
|
||||
char * (*snprintf)(int,char*,const char*,...);
|
||||
int (*step)(sqlite3_stmt*);
|
||||
int (*table_column_metadata)(sqlite3*,const char*,const char*,const char*,
|
||||
char const**,char const**,int*,int*,int*);
|
||||
void (*thread_cleanup)(void);
|
||||
int (*total_changes)(sqlite3*);
|
||||
void * (*trace)(sqlite3*,void(*xTrace)(void*,const char*),void*);
|
||||
int (*transfer_bindings)(sqlite3_stmt*,sqlite3_stmt*);
|
||||
void * (*update_hook)(sqlite3*,void(*)(void*,int ,char const*,char const*,
|
||||
sqlite_int64),void*);
|
||||
void * (*user_data)(sqlite3_context*);
|
||||
const void * (*value_blob)(sqlite3_value*);
|
||||
int (*value_bytes)(sqlite3_value*);
|
||||
int (*value_bytes16)(sqlite3_value*);
|
||||
double (*value_double)(sqlite3_value*);
|
||||
int (*value_int)(sqlite3_value*);
|
||||
sqlite_int64 (*value_int64)(sqlite3_value*);
|
||||
int (*value_numeric_type)(sqlite3_value*);
|
||||
const unsigned char * (*value_text)(sqlite3_value*);
|
||||
const void * (*value_text16)(sqlite3_value*);
|
||||
const void * (*value_text16be)(sqlite3_value*);
|
||||
const void * (*value_text16le)(sqlite3_value*);
|
||||
int (*value_type)(sqlite3_value*);
|
||||
char *(*vmprintf)(const char*,va_list);
|
||||
/* Added ??? */
|
||||
int (*overload_function)(sqlite3*, const char *zFuncName, int nArg);
|
||||
/* Added by 3.3.13 */
|
||||
int (*prepare_v2)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);
|
||||
int (*prepare16_v2)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);
|
||||
int (*clear_bindings)(sqlite3_stmt*);
|
||||
/* Added by 3.4.1 */
|
||||
int (*create_module_v2)(sqlite3*,const char*,const sqlite3_module*,void*,
|
||||
void (*xDestroy)(void *));
|
||||
/* Added by 3.5.0 */
|
||||
int (*bind_zeroblob)(sqlite3_stmt*,int,int);
|
||||
int (*blob_bytes)(sqlite3_blob*);
|
||||
int (*blob_close)(sqlite3_blob*);
|
||||
int (*blob_open)(sqlite3*,const char*,const char*,const char*,sqlite3_int64,
|
||||
int,sqlite3_blob**);
|
||||
int (*blob_read)(sqlite3_blob*,void*,int,int);
|
||||
int (*blob_write)(sqlite3_blob*,const void*,int,int);
|
||||
int (*create_collation_v2)(sqlite3*,const char*,int,void*,
|
||||
int(*)(void*,int,const void*,int,const void*),
|
||||
void(*)(void*));
|
||||
int (*file_control)(sqlite3*,const char*,int,void*);
|
||||
sqlite3_int64 (*memory_highwater)(int);
|
||||
sqlite3_int64 (*memory_used)(void);
|
||||
sqlite3_mutex *(*mutex_alloc)(int);
|
||||
void (*mutex_enter)(sqlite3_mutex*);
|
||||
void (*mutex_free)(sqlite3_mutex*);
|
||||
void (*mutex_leave)(sqlite3_mutex*);
|
||||
int (*mutex_try)(sqlite3_mutex*);
|
||||
int (*open_v2)(const char*,sqlite3**,int,const char*);
|
||||
int (*release_memory)(int);
|
||||
void (*result_error_nomem)(sqlite3_context*);
|
||||
void (*result_error_toobig)(sqlite3_context*);
|
||||
int (*sleep)(int);
|
||||
void (*soft_heap_limit)(int);
|
||||
sqlite3_vfs *(*vfs_find)(const char*);
|
||||
int (*vfs_register)(sqlite3_vfs*,int);
|
||||
int (*vfs_unregister)(sqlite3_vfs*);
|
||||
int (*xthreadsafe)(void);
|
||||
void (*result_zeroblob)(sqlite3_context*,int);
|
||||
void (*result_error_code)(sqlite3_context*,int);
|
||||
int (*test_control)(int, ...);
|
||||
void (*randomness)(int,void*);
|
||||
sqlite3 *(*context_db_handle)(sqlite3_context*);
|
||||
int (*extended_result_codes)(sqlite3*,int);
|
||||
int (*limit)(sqlite3*,int,int);
|
||||
sqlite3_stmt *(*next_stmt)(sqlite3*,sqlite3_stmt*);
|
||||
const char *(*sql)(sqlite3_stmt*);
|
||||
int (*status)(int,int*,int*,int);
|
||||
int (*backup_finish)(sqlite3_backup*);
|
||||
sqlite3_backup *(*backup_init)(sqlite3*,const char*,sqlite3*,const char*);
|
||||
int (*backup_pagecount)(sqlite3_backup*);
|
||||
int (*backup_remaining)(sqlite3_backup*);
|
||||
int (*backup_step)(sqlite3_backup*,int);
|
||||
const char *(*compileoption_get)(int);
|
||||
int (*compileoption_used)(const char*);
|
||||
int (*create_function_v2)(sqlite3*,const char*,int,int,void*,
|
||||
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
|
||||
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
|
||||
void (*xFinal)(sqlite3_context*),
|
||||
void(*xDestroy)(void*));
|
||||
int (*db_config)(sqlite3*,int,...);
|
||||
sqlite3_mutex *(*db_mutex)(sqlite3*);
|
||||
int (*db_status)(sqlite3*,int,int*,int*,int);
|
||||
int (*extended_errcode)(sqlite3*);
|
||||
void (*log)(int,const char*,...);
|
||||
sqlite3_int64 (*soft_heap_limit64)(sqlite3_int64);
|
||||
const char *(*sourceid)(void);
|
||||
int (*stmt_status)(sqlite3_stmt*,int,int);
|
||||
int (*strnicmp)(const char*,const char*,int);
|
||||
int (*unlock_notify)(sqlite3*,void(*)(void**,int),void*);
|
||||
int (*wal_autocheckpoint)(sqlite3*,int);
|
||||
int (*wal_checkpoint)(sqlite3*,const char*);
|
||||
void *(*wal_hook)(sqlite3*,int(*)(void*,sqlite3*,const char*,int),void*);
|
||||
int (*blob_reopen)(sqlite3_blob*,sqlite3_int64);
|
||||
int (*vtab_config)(sqlite3*,int op,...);
|
||||
int (*vtab_on_conflict)(sqlite3*);
|
||||
/* Version 3.7.16 and later */
|
||||
int (*close_v2)(sqlite3*);
|
||||
const char *(*db_filename)(sqlite3*,const char*);
|
||||
int (*db_readonly)(sqlite3*,const char*);
|
||||
int (*db_release_memory)(sqlite3*);
|
||||
const char *(*errstr)(int);
|
||||
int (*stmt_busy)(sqlite3_stmt*);
|
||||
int (*stmt_readonly)(sqlite3_stmt*);
|
||||
int (*stricmp)(const char*,const char*);
|
||||
int (*uri_boolean)(const char*,const char*,int);
|
||||
sqlite3_int64 (*uri_int64)(const char*,const char*,sqlite3_int64);
|
||||
const char *(*uri_parameter)(const char*,const char*);
|
||||
char *(*vsnprintf)(int,char*,const char*,va_list);
|
||||
int (*wal_checkpoint_v2)(sqlite3*,const char*,int,int*,int*);
|
||||
/* Version 3.8.7 and later */
|
||||
int (*auto_extension)(void(*)(void));
|
||||
int (*bind_blob64)(sqlite3_stmt*,int,const void*,sqlite3_uint64,
|
||||
void(*)(void*));
|
||||
int (*bind_text64)(sqlite3_stmt*,int,const char*,sqlite3_uint64,
|
||||
void(*)(void*),unsigned char);
|
||||
int (*cancel_auto_extension)(void(*)(void));
|
||||
int (*load_extension)(sqlite3*,const char*,const char*,char**);
|
||||
void *(*malloc64)(sqlite3_uint64);
|
||||
sqlite3_uint64 (*msize)(void*);
|
||||
void *(*realloc64)(void*,sqlite3_uint64);
|
||||
void (*reset_auto_extension)(void);
|
||||
void (*result_blob64)(sqlite3_context*,const void*,sqlite3_uint64,
|
||||
void(*)(void*));
|
||||
void (*result_text64)(sqlite3_context*,const char*,sqlite3_uint64,
|
||||
void(*)(void*), unsigned char);
|
||||
int (*strglob)(const char*,const char*);
|
||||
/* Version 3.8.11 and later */
|
||||
sqlite3_value *(*value_dup)(const sqlite3_value*);
|
||||
void (*value_free)(sqlite3_value*);
|
||||
int (*result_zeroblob64)(sqlite3_context*,sqlite3_uint64);
|
||||
int (*bind_zeroblob64)(sqlite3_stmt*, int, sqlite3_uint64);
|
||||
/* Version 3.9.0 and later */
|
||||
unsigned int (*value_subtype)(sqlite3_value*);
|
||||
void (*result_subtype)(sqlite3_context*,unsigned int);
|
||||
/* Version 3.10.0 and later */
|
||||
int (*status64)(int,sqlite3_int64*,sqlite3_int64*,int);
|
||||
int (*strlike)(const char*,const char*,unsigned int);
|
||||
int (*db_cacheflush)(sqlite3*);
|
||||
/* Version 3.12.0 and later */
|
||||
int (*system_errno)(sqlite3*);
|
||||
/* Version 3.14.0 and later */
|
||||
int (*trace_v2)(sqlite3*,unsigned,int(*)(unsigned,void*,void*,void*),void*);
|
||||
char *(*expanded_sql)(sqlite3_stmt*);
|
||||
};
|
||||
|
||||
/*
|
||||
** This is the function signature used for all extension entry points. It
|
||||
** is also defined in the file "loadext.c".
|
||||
*/
|
||||
typedef int (*sqlite3_loadext_entry)(
|
||||
sqlite3 *db, /* Handle to the database. */
|
||||
char **pzErrMsg, /* Used to set error string on failure. */
|
||||
const sqlite3_api_routines *pThunk /* Extension API function pointers. */
|
||||
);
|
||||
|
||||
/*
|
||||
** The following macros redefine the API routines so that they are
|
||||
** redirected through the global sqlite3_api structure.
|
||||
**
|
||||
** This header file is also used by the loadext.c source file
|
||||
** (part of the main SQLite library - not an extension) so that
|
||||
** it can get access to the sqlite3_api_routines structure
|
||||
** definition. But the main library does not want to redefine
|
||||
** the API. So the redefinition macros are only valid if the
|
||||
** SQLITE_CORE macros is undefined.
|
||||
*/
|
||||
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
|
||||
#define sqlite3_aggregate_context sqlite3_api->aggregate_context
|
||||
#ifndef SQLITE_OMIT_DEPRECATED
|
||||
#define sqlite3_aggregate_count sqlite3_api->aggregate_count
|
||||
#endif
|
||||
#define sqlite3_bind_blob sqlite3_api->bind_blob
|
||||
#define sqlite3_bind_double sqlite3_api->bind_double
|
||||
#define sqlite3_bind_int sqlite3_api->bind_int
|
||||
#define sqlite3_bind_int64 sqlite3_api->bind_int64
|
||||
#define sqlite3_bind_null sqlite3_api->bind_null
|
||||
#define sqlite3_bind_parameter_count sqlite3_api->bind_parameter_count
|
||||
#define sqlite3_bind_parameter_index sqlite3_api->bind_parameter_index
|
||||
#define sqlite3_bind_parameter_name sqlite3_api->bind_parameter_name
|
||||
#define sqlite3_bind_text sqlite3_api->bind_text
|
||||
#define sqlite3_bind_text16 sqlite3_api->bind_text16
|
||||
#define sqlite3_bind_value sqlite3_api->bind_value
|
||||
#define sqlite3_busy_handler sqlite3_api->busy_handler
|
||||
#define sqlite3_busy_timeout sqlite3_api->busy_timeout
|
||||
#define sqlite3_changes sqlite3_api->changes
|
||||
#define sqlite3_close sqlite3_api->close
|
||||
#define sqlite3_collation_needed sqlite3_api->collation_needed
|
||||
#define sqlite3_collation_needed16 sqlite3_api->collation_needed16
|
||||
#define sqlite3_column_blob sqlite3_api->column_blob
|
||||
#define sqlite3_column_bytes sqlite3_api->column_bytes
|
||||
#define sqlite3_column_bytes16 sqlite3_api->column_bytes16
|
||||
#define sqlite3_column_count sqlite3_api->column_count
|
||||
#define sqlite3_column_database_name sqlite3_api->column_database_name
|
||||
#define sqlite3_column_database_name16 sqlite3_api->column_database_name16
|
||||
#define sqlite3_column_decltype sqlite3_api->column_decltype
|
||||
#define sqlite3_column_decltype16 sqlite3_api->column_decltype16
|
||||
#define sqlite3_column_double sqlite3_api->column_double
|
||||
#define sqlite3_column_int sqlite3_api->column_int
|
||||
#define sqlite3_column_int64 sqlite3_api->column_int64
|
||||
#define sqlite3_column_name sqlite3_api->column_name
|
||||
#define sqlite3_column_name16 sqlite3_api->column_name16
|
||||
#define sqlite3_column_origin_name sqlite3_api->column_origin_name
|
||||
#define sqlite3_column_origin_name16 sqlite3_api->column_origin_name16
|
||||
#define sqlite3_column_table_name sqlite3_api->column_table_name
|
||||
#define sqlite3_column_table_name16 sqlite3_api->column_table_name16
|
||||
#define sqlite3_column_text sqlite3_api->column_text
|
||||
#define sqlite3_column_text16 sqlite3_api->column_text16
|
||||
#define sqlite3_column_type sqlite3_api->column_type
|
||||
#define sqlite3_column_value sqlite3_api->column_value
|
||||
#define sqlite3_commit_hook sqlite3_api->commit_hook
|
||||
#define sqlite3_complete sqlite3_api->complete
|
||||
#define sqlite3_complete16 sqlite3_api->complete16
|
||||
#define sqlite3_create_collation sqlite3_api->create_collation
|
||||
#define sqlite3_create_collation16 sqlite3_api->create_collation16
|
||||
#define sqlite3_create_function sqlite3_api->create_function
|
||||
#define sqlite3_create_function16 sqlite3_api->create_function16
|
||||
#define sqlite3_create_module sqlite3_api->create_module
|
||||
#define sqlite3_create_module_v2 sqlite3_api->create_module_v2
|
||||
#define sqlite3_data_count sqlite3_api->data_count
|
||||
#define sqlite3_db_handle sqlite3_api->db_handle
|
||||
#define sqlite3_declare_vtab sqlite3_api->declare_vtab
|
||||
#define sqlite3_enable_shared_cache sqlite3_api->enable_shared_cache
|
||||
#define sqlite3_errcode sqlite3_api->errcode
|
||||
#define sqlite3_errmsg sqlite3_api->errmsg
|
||||
#define sqlite3_errmsg16 sqlite3_api->errmsg16
|
||||
#define sqlite3_exec sqlite3_api->exec
|
||||
#ifndef SQLITE_OMIT_DEPRECATED
|
||||
#define sqlite3_expired sqlite3_api->expired
|
||||
#endif
|
||||
#define sqlite3_finalize sqlite3_api->finalize
|
||||
#define sqlite3_free sqlite3_api->free
|
||||
#define sqlite3_free_table sqlite3_api->free_table
|
||||
#define sqlite3_get_autocommit sqlite3_api->get_autocommit
|
||||
#define sqlite3_get_auxdata sqlite3_api->get_auxdata
|
||||
#define sqlite3_get_table sqlite3_api->get_table
|
||||
#ifndef SQLITE_OMIT_DEPRECATED
|
||||
#define sqlite3_global_recover sqlite3_api->global_recover
|
||||
#endif
|
||||
#define sqlite3_interrupt sqlite3_api->interruptx
|
||||
#define sqlite3_last_insert_rowid sqlite3_api->last_insert_rowid
|
||||
#define sqlite3_libversion sqlite3_api->libversion
|
||||
#define sqlite3_libversion_number sqlite3_api->libversion_number
|
||||
#define sqlite3_malloc sqlite3_api->malloc
|
||||
#define sqlite3_mprintf sqlite3_api->mprintf
|
||||
#define sqlite3_open sqlite3_api->open
|
||||
#define sqlite3_open16 sqlite3_api->open16
|
||||
#define sqlite3_prepare sqlite3_api->prepare
|
||||
#define sqlite3_prepare16 sqlite3_api->prepare16
|
||||
#define sqlite3_prepare_v2 sqlite3_api->prepare_v2
|
||||
#define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2
|
||||
#define sqlite3_profile sqlite3_api->profile
|
||||
#define sqlite3_progress_handler sqlite3_api->progress_handler
|
||||
#define sqlite3_realloc sqlite3_api->realloc
|
||||
#define sqlite3_reset sqlite3_api->reset
|
||||
#define sqlite3_result_blob sqlite3_api->result_blob
|
||||
#define sqlite3_result_double sqlite3_api->result_double
|
||||
#define sqlite3_result_error sqlite3_api->result_error
|
||||
#define sqlite3_result_error16 sqlite3_api->result_error16
|
||||
#define sqlite3_result_int sqlite3_api->result_int
|
||||
#define sqlite3_result_int64 sqlite3_api->result_int64
|
||||
#define sqlite3_result_null sqlite3_api->result_null
|
||||
#define sqlite3_result_text sqlite3_api->result_text
|
||||
#define sqlite3_result_text16 sqlite3_api->result_text16
|
||||
#define sqlite3_result_text16be sqlite3_api->result_text16be
|
||||
#define sqlite3_result_text16le sqlite3_api->result_text16le
|
||||
#define sqlite3_result_value sqlite3_api->result_value
|
||||
#define sqlite3_rollback_hook sqlite3_api->rollback_hook
|
||||
#define sqlite3_set_authorizer sqlite3_api->set_authorizer
|
||||
#define sqlite3_set_auxdata sqlite3_api->set_auxdata
|
||||
#define sqlite3_snprintf sqlite3_api->snprintf
|
||||
#define sqlite3_step sqlite3_api->step
|
||||
#define sqlite3_table_column_metadata sqlite3_api->table_column_metadata
|
||||
#define sqlite3_thread_cleanup sqlite3_api->thread_cleanup
|
||||
#define sqlite3_total_changes sqlite3_api->total_changes
|
||||
#define sqlite3_trace sqlite3_api->trace
|
||||
#ifndef SQLITE_OMIT_DEPRECATED
|
||||
#define sqlite3_transfer_bindings sqlite3_api->transfer_bindings
|
||||
#endif
|
||||
#define sqlite3_update_hook sqlite3_api->update_hook
|
||||
#define sqlite3_user_data sqlite3_api->user_data
|
||||
#define sqlite3_value_blob sqlite3_api->value_blob
|
||||
#define sqlite3_value_bytes sqlite3_api->value_bytes
|
||||
#define sqlite3_value_bytes16 sqlite3_api->value_bytes16
|
||||
#define sqlite3_value_double sqlite3_api->value_double
|
||||
#define sqlite3_value_int sqlite3_api->value_int
|
||||
#define sqlite3_value_int64 sqlite3_api->value_int64
|
||||
#define sqlite3_value_numeric_type sqlite3_api->value_numeric_type
|
||||
#define sqlite3_value_text sqlite3_api->value_text
|
||||
#define sqlite3_value_text16 sqlite3_api->value_text16
|
||||
#define sqlite3_value_text16be sqlite3_api->value_text16be
|
||||
#define sqlite3_value_text16le sqlite3_api->value_text16le
|
||||
#define sqlite3_value_type sqlite3_api->value_type
|
||||
#define sqlite3_vmprintf sqlite3_api->vmprintf
|
||||
#define sqlite3_vsnprintf sqlite3_api->vsnprintf
|
||||
#define sqlite3_overload_function sqlite3_api->overload_function
|
||||
#define sqlite3_prepare_v2 sqlite3_api->prepare_v2
|
||||
#define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2
|
||||
#define sqlite3_clear_bindings sqlite3_api->clear_bindings
|
||||
#define sqlite3_bind_zeroblob sqlite3_api->bind_zeroblob
|
||||
#define sqlite3_blob_bytes sqlite3_api->blob_bytes
|
||||
#define sqlite3_blob_close sqlite3_api->blob_close
|
||||
#define sqlite3_blob_open sqlite3_api->blob_open
|
||||
#define sqlite3_blob_read sqlite3_api->blob_read
|
||||
#define sqlite3_blob_write sqlite3_api->blob_write
|
||||
#define sqlite3_create_collation_v2 sqlite3_api->create_collation_v2
|
||||
#define sqlite3_file_control sqlite3_api->file_control
|
||||
#define sqlite3_memory_highwater sqlite3_api->memory_highwater
|
||||
#define sqlite3_memory_used sqlite3_api->memory_used
|
||||
#define sqlite3_mutex_alloc sqlite3_api->mutex_alloc
|
||||
#define sqlite3_mutex_enter sqlite3_api->mutex_enter
|
||||
#define sqlite3_mutex_free sqlite3_api->mutex_free
|
||||
#define sqlite3_mutex_leave sqlite3_api->mutex_leave
|
||||
#define sqlite3_mutex_try sqlite3_api->mutex_try
|
||||
#define sqlite3_open_v2 sqlite3_api->open_v2
|
||||
#define sqlite3_release_memory sqlite3_api->release_memory
|
||||
#define sqlite3_result_error_nomem sqlite3_api->result_error_nomem
|
||||
#define sqlite3_result_error_toobig sqlite3_api->result_error_toobig
|
||||
#define sqlite3_sleep sqlite3_api->sleep
|
||||
#define sqlite3_soft_heap_limit sqlite3_api->soft_heap_limit
|
||||
#define sqlite3_vfs_find sqlite3_api->vfs_find
|
||||
#define sqlite3_vfs_register sqlite3_api->vfs_register
|
||||
#define sqlite3_vfs_unregister sqlite3_api->vfs_unregister
|
||||
#define sqlite3_threadsafe sqlite3_api->xthreadsafe
|
||||
#define sqlite3_result_zeroblob sqlite3_api->result_zeroblob
|
||||
#define sqlite3_result_error_code sqlite3_api->result_error_code
|
||||
#define sqlite3_test_control sqlite3_api->test_control
|
||||
#define sqlite3_randomness sqlite3_api->randomness
|
||||
#define sqlite3_context_db_handle sqlite3_api->context_db_handle
|
||||
#define sqlite3_extended_result_codes sqlite3_api->extended_result_codes
|
||||
#define sqlite3_limit sqlite3_api->limit
|
||||
#define sqlite3_next_stmt sqlite3_api->next_stmt
|
||||
#define sqlite3_sql sqlite3_api->sql
|
||||
#define sqlite3_status sqlite3_api->status
|
||||
#define sqlite3_backup_finish sqlite3_api->backup_finish
|
||||
#define sqlite3_backup_init sqlite3_api->backup_init
|
||||
#define sqlite3_backup_pagecount sqlite3_api->backup_pagecount
|
||||
#define sqlite3_backup_remaining sqlite3_api->backup_remaining
|
||||
#define sqlite3_backup_step sqlite3_api->backup_step
|
||||
#define sqlite3_compileoption_get sqlite3_api->compileoption_get
|
||||
#define sqlite3_compileoption_used sqlite3_api->compileoption_used
|
||||
#define sqlite3_create_function_v2 sqlite3_api->create_function_v2
|
||||
#define sqlite3_db_config sqlite3_api->db_config
|
||||
#define sqlite3_db_mutex sqlite3_api->db_mutex
|
||||
#define sqlite3_db_status sqlite3_api->db_status
|
||||
#define sqlite3_extended_errcode sqlite3_api->extended_errcode
|
||||
#define sqlite3_log sqlite3_api->log
|
||||
#define sqlite3_soft_heap_limit64 sqlite3_api->soft_heap_limit64
|
||||
#define sqlite3_sourceid sqlite3_api->sourceid
|
||||
#define sqlite3_stmt_status sqlite3_api->stmt_status
|
||||
#define sqlite3_strnicmp sqlite3_api->strnicmp
|
||||
#define sqlite3_unlock_notify sqlite3_api->unlock_notify
|
||||
#define sqlite3_wal_autocheckpoint sqlite3_api->wal_autocheckpoint
|
||||
#define sqlite3_wal_checkpoint sqlite3_api->wal_checkpoint
|
||||
#define sqlite3_wal_hook sqlite3_api->wal_hook
|
||||
#define sqlite3_blob_reopen sqlite3_api->blob_reopen
|
||||
#define sqlite3_vtab_config sqlite3_api->vtab_config
|
||||
#define sqlite3_vtab_on_conflict sqlite3_api->vtab_on_conflict
|
||||
/* Version 3.7.16 and later */
|
||||
#define sqlite3_close_v2 sqlite3_api->close_v2
|
||||
#define sqlite3_db_filename sqlite3_api->db_filename
|
||||
#define sqlite3_db_readonly sqlite3_api->db_readonly
|
||||
#define sqlite3_db_release_memory sqlite3_api->db_release_memory
|
||||
#define sqlite3_errstr sqlite3_api->errstr
|
||||
#define sqlite3_stmt_busy sqlite3_api->stmt_busy
|
||||
#define sqlite3_stmt_readonly sqlite3_api->stmt_readonly
|
||||
#define sqlite3_stricmp sqlite3_api->stricmp
|
||||
#define sqlite3_uri_boolean sqlite3_api->uri_boolean
|
||||
#define sqlite3_uri_int64 sqlite3_api->uri_int64
|
||||
#define sqlite3_uri_parameter sqlite3_api->uri_parameter
|
||||
#define sqlite3_uri_vsnprintf sqlite3_api->vsnprintf
|
||||
#define sqlite3_wal_checkpoint_v2 sqlite3_api->wal_checkpoint_v2
|
||||
/* Version 3.8.7 and later */
|
||||
#define sqlite3_auto_extension sqlite3_api->auto_extension
|
||||
#define sqlite3_bind_blob64 sqlite3_api->bind_blob64
|
||||
#define sqlite3_bind_text64 sqlite3_api->bind_text64
|
||||
#define sqlite3_cancel_auto_extension sqlite3_api->cancel_auto_extension
|
||||
#define sqlite3_load_extension sqlite3_api->load_extension
|
||||
#define sqlite3_malloc64 sqlite3_api->malloc64
|
||||
#define sqlite3_msize sqlite3_api->msize
|
||||
#define sqlite3_realloc64 sqlite3_api->realloc64
|
||||
#define sqlite3_reset_auto_extension sqlite3_api->reset_auto_extension
|
||||
#define sqlite3_result_blob64 sqlite3_api->result_blob64
|
||||
#define sqlite3_result_text64 sqlite3_api->result_text64
|
||||
#define sqlite3_strglob sqlite3_api->strglob
|
||||
/* Version 3.8.11 and later */
|
||||
#define sqlite3_value_dup sqlite3_api->value_dup
|
||||
#define sqlite3_value_free sqlite3_api->value_free
|
||||
#define sqlite3_result_zeroblob64 sqlite3_api->result_zeroblob64
|
||||
#define sqlite3_bind_zeroblob64 sqlite3_api->bind_zeroblob64
|
||||
/* Version 3.9.0 and later */
|
||||
#define sqlite3_value_subtype sqlite3_api->value_subtype
|
||||
#define sqlite3_result_subtype sqlite3_api->result_subtype
|
||||
/* Version 3.10.0 and later */
|
||||
#define sqlite3_status64 sqlite3_api->status64
|
||||
#define sqlite3_strlike sqlite3_api->strlike
|
||||
#define sqlite3_db_cacheflush sqlite3_api->db_cacheflush
|
||||
/* Version 3.12.0 and later */
|
||||
#define sqlite3_system_errno sqlite3_api->system_errno
|
||||
/* Version 3.14.0 and later */
|
||||
#define sqlite3_trace_v2 sqlite3_api->trace_v2
|
||||
#define sqlite3_expanded_sql sqlite3_api->expanded_sql
|
||||
#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
|
||||
|
||||
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
|
||||
/* This case when the file really is being compiled as a loadable
|
||||
** extension */
|
||||
# define SQLITE_EXTENSION_INIT1 const sqlite3_api_routines *sqlite3_api=0;
|
||||
# define SQLITE_EXTENSION_INIT2(v) sqlite3_api=v;
|
||||
# define SQLITE_EXTENSION_INIT3 \
|
||||
extern const sqlite3_api_routines *sqlite3_api;
|
||||
#else
|
||||
/* This case when the file is being statically linked into the
|
||||
** application */
|
||||
# define SQLITE_EXTENSION_INIT1 /*no-op*/
|
||||
# define SQLITE_EXTENSION_INIT2(v) (void)v; /* unused parameter */
|
||||
# define SQLITE_EXTENSION_INIT3 /*no-op*/
|
||||
#endif
|
||||
|
||||
#endif /* SQLITE3EXT_H */
|
||||
27
Tools/CMake/modules/module_sqlite.cmake
Normal file
27
Tools/CMake/modules/module_sqlite.cmake
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
# -----------------------------------------------------------------------------
|
||||
# Copyright (c) 2014 GarageGames, LLC
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to
|
||||
# deal in the Software without restriction, including without limitation the
|
||||
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
# sell copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
# IN THE SOFTWARE.
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
option(TORQUE_sqlite "Enable sqlite module" ON)
|
||||
if(TORQUE_sqlite)
|
||||
# files
|
||||
addPathRec( "${srcDir}/sqlite" )
|
||||
endif()
|
||||
Loading…
Reference in a new issue