mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-19 18:45:52 +00:00
.
This commit is contained in:
@@ -1,10 +1,74 @@
|
||||
#include "SqliteDatabase.h"
|
||||
|
||||
SqliteDatabase::SqliteDatabase()
|
||||
SqliteDatabase::SqliteDatabase() : Database
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SqliteDatabase::connect()
|
||||
{
|
||||
|
||||
}
|
||||
void SqliteDatabase::disconnect()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// returns true if the query went ok
|
||||
bool SqliteDatabase::executeSQL(const char* sql)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// tells you how many rows were changed by an update or insert
|
||||
int SqliteDatabase::getNumRowsAffected()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// returns false if there are no results
|
||||
bool SqliteDatabase::startIterRows()
|
||||
{
|
||||
|
||||
}
|
||||
void SqliteDatabase::endIterRows()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// call this after you executeSQL
|
||||
// will return false if there are no more rows
|
||||
bool SqliteDatabase::getNextRow()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
char* SqliteDatabase::getStr(int colIndex,std::string& retStr)
|
||||
{
|
||||
|
||||
}
|
||||
int32 SqliteDatabase::getInt(int colIndex)
|
||||
{
|
||||
|
||||
}
|
||||
float SqliteDatabase::getFloat(int colIndex)
|
||||
{
|
||||
|
||||
}
|
||||
bool SqliteDatabase::getBool(int colIndex)
|
||||
{
|
||||
|
||||
}
|
||||
bool SqliteDatabase::getBinary(int colIndex,unsigned char* buf,int maxSize)
|
||||
{
|
||||
|
||||
}
|
||||
uint64 SqliteDatabase::getBigInt(int colIndex)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* http://www.sqlite.org/lang_expr.html
|
||||
BLOB literals are string literals containing hexadecimal data and preceded by a single "x" or "X" character. For example:
|
||||
X'53514C697465'
|
||||
|
||||
@@ -5,6 +5,29 @@ class SqliteDatabase : public Database
|
||||
public:
|
||||
SqliteDatabase();
|
||||
|
||||
void connect();
|
||||
void disconnect();
|
||||
|
||||
// returns true if the query went ok
|
||||
bool executeSQL(const char* sql);
|
||||
|
||||
// tells you how many rows were changed by an update or insert
|
||||
int getNumRowsAffected();
|
||||
|
||||
// returns false if there are no results
|
||||
bool startIterRows();
|
||||
void endIterRows();
|
||||
|
||||
// call this after you executeSQL
|
||||
// will return false if there are no more rows
|
||||
bool getNextRow();
|
||||
|
||||
char* getStr(int colIndex,std::string& retStr);
|
||||
int32 getInt(int colIndex);
|
||||
float getFloat(int colIndex);
|
||||
bool getBool(int colIndex);
|
||||
bool getBinary(int colIndex,unsigned char* buf,int maxSize);
|
||||
uint64 getBigInt(int colIndex);
|
||||
|
||||
void escape(unsigned char* start,int size,std::string& retStr);
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
#include "database.h"
|
||||
#include "../utillib/reportingmechanism.h"
|
||||
#include "string/i4string.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
@@ -26,7 +24,7 @@ char* Database::getStr(const char* colName,std::string& retStr)
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
w32 Database::getInt(const char* colName)
|
||||
int32 Database::getInt(const char* colName)
|
||||
{
|
||||
int index;
|
||||
if(getColNumber(colName,&index))
|
||||
@@ -56,6 +54,26 @@ bool Database::getBool(const char* colName)
|
||||
return(0);
|
||||
}
|
||||
|
||||
bool Database::getBinary(const char* colName,unsigned char* buf,int maxSize)
|
||||
{
|
||||
int index;
|
||||
if(getColNumber(colName,&index))
|
||||
{
|
||||
return(getBinary(index,buf,maxSize));
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
uint64 Database::getBigInt(const char* colName)
|
||||
{
|
||||
int index;
|
||||
if(getColNumber(colName,&index))
|
||||
{
|
||||
return(getBigInt(index));
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// returns false if can't find col
|
||||
@@ -63,7 +81,7 @@ bool Database::getColNumber(const char* colName,int* retIndex)
|
||||
{
|
||||
for(int n=0; n<mNumCol; n++)
|
||||
{
|
||||
if(i4_stricmp(colName,mColNameTable[n])==0)
|
||||
if(stricmp(colName,mColNameTable[n].c_str())==0)
|
||||
{
|
||||
*retIndex=n;
|
||||
return(true);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define __DATABASE__
|
||||
|
||||
#include <string>
|
||||
#include "../types.h"
|
||||
|
||||
/*
|
||||
this maintains the connection to the database
|
||||
@@ -10,10 +11,10 @@ class Database
|
||||
{
|
||||
protected:
|
||||
int mNumCol;
|
||||
std:string mUser;
|
||||
std:string mHost;
|
||||
std:string mDBPass;
|
||||
std:string* mColNameTable;
|
||||
std::string mUser;
|
||||
std::string mHost;
|
||||
std::string mDBPass;
|
||||
std::string* mColNameTable;
|
||||
|
||||
bool getColNumber(const char* colName, int* retIndex);
|
||||
|
||||
@@ -48,13 +49,15 @@ public:
|
||||
int32 getInt(const char* colName);
|
||||
float getFloat(const char* colName);
|
||||
bool getBool(const char* colName);
|
||||
bool getBinary(const char* colName,char* buf,int maxSize);
|
||||
bool getBinary(const char* colName,unsigned char* buf,int maxSize);
|
||||
uint64 getBigInt(const char* colName);
|
||||
|
||||
virtual char* getStr(int colIndex,std::string& retStr)=0;
|
||||
virtual int32 getInt(int colIndex)=0;
|
||||
virtual float getFloat(int colIndex)=0;
|
||||
virtual bool getBool(int colIndex)=0;
|
||||
virtual bool getBinary(int colIndex,char* buf,int maxSize)=0;
|
||||
virtual bool getBinary(int colIndex,unsigned char* buf,int maxSize)=0;
|
||||
virtual uint64 getBigInt(int colIndex)=0;
|
||||
|
||||
int getSingleDBValueInt(const char* sql);
|
||||
float getSingleDBValueFloat(const char* sql);
|
||||
@@ -63,11 +66,5 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class MsqlDatabase
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user