This commit is contained in:
jed
2011-10-27 16:59:42 -07:00
parent 7eae6e5886
commit e68b0fb8d1
23 changed files with 165 additions and 65 deletions

View File

@@ -70,6 +70,7 @@ int SqliteDatabase::getLastInsertID()
// returns false if there are no results
bool SqliteDatabase::startIterRows()
{
needs to fill out the column table
return(mMoreRows);
}
@@ -120,14 +121,15 @@ bool SqliteDatabase::getBool(int colIndex)
return(sqlite3_column_int(mCurrentStmt, colIndex));
}
bool SqliteDatabase::getBinary(int colIndex,unsigned char* buf,int maxSize)
int SqliteDatabase::getBinary(int colIndex,unsigned char* buf,int maxSize)
{
const void* blob=sqlite3_column_blob(mCurrentStmt, colIndex);
int size=sqlite3_column_bytes(mCurrentStmt, colIndex);
if(maxSize<size) size=maxSize;
memcpy(buf,blob,size);
return(true);
return(size);
}
uint64 SqliteDatabase::getBigInt(int colIndex)
{
return(sqlite3_column_int64(mCurrentStmt, colIndex));
@@ -146,7 +148,13 @@ void SqliteDatabase::escape(unsigned char* start,int size,std::string& retStr)
retStr.append("X'");
for(int n=0; n<size; n++)
{
retStr.append( itoa(*start,buf,16) );
itoa(start[n],buf,16);
if(buf[1]==0)
{
retStr.append("0");
retStr.append(buf);
}else retStr.append(buf);
}
retStr.push_back('\'');
}

View File

@@ -33,7 +33,8 @@ public:
int32 getInt(int colIndex);
float getFloat(int colIndex);
bool getBool(int colIndex);
bool getBinary(int colIndex,unsigned char* buf,int maxSize);
// returns amount stored in buf
int getBinary(int colIndex,unsigned char* buf,int maxSize);
uint64 getBigInt(int colIndex);
void escape(unsigned char* start,int size,std::string& retStr);

View File

@@ -58,7 +58,7 @@ bool Database::getBool(const char* colName)
return(0);
}
bool Database::getBinary(const char* colName,unsigned char* buf,int maxSize)
int Database::getBinary(const char* colName,unsigned char* buf,int maxSize)
{
int index;
if(getColNumber(colName,&index))

View File

@@ -50,14 +50,15 @@ public:
int32 getInt(const char* colName);
float getFloat(const char* colName);
bool getBool(const char* colName);
bool getBinary(const char* colName,unsigned char* buf,int maxSize);
// returns amount stored in buf
int 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,unsigned char* buf,int maxSize)=0;
virtual int getBinary(int colIndex,unsigned char* buf,int maxSize)=0;
virtual uint64 getBigInt(int colIndex)=0;
int getSingleDBValueInt(const char* sql);