|
/**
bridge.h
Purpose: provide interfaces to DSQLM kernel
These interfaces are used directly by
client applications
Author: Vijay Mathew Pandyalakal
Date: 16/11/2003
Copyright: logicmatrix
**/
#ifndef BRIDGE_H_
#define BRIDGE_H_
namespace dsqlm{
class ResultSet;
class Table;
class MyDate;
class MyTime;
class Column;
class DBIni {
private:
float version;
char cr[20];
openutils::MyDate date;
public:
DBIni() {
version = 1.0;
strcpy(cr,"");
}
void operator = (DBIni dbini) {
version = dbini.version;
strcpy(cr,dbini.cr);
date = dbini.date;
}
float getVersion() {
return version;
}
void setVersion(float ver) {
version = ver;
}
string getCr() {
return cr;
}
void setCr(const char* cr) {
strcpy(this->cr,cr);
}
string getDate() {
return date.getDate();
}
void setDate(const char* dt) {
date.setDate(dt);
}
};
class Database {
private:
bool inited;
DBIni db_ini;
string db_name;
public:
Database() {
db_name = "data";
}
Database(const char* db) {
db_name = db;
init();
}
long execute(const char* sql);
ResultSet executeQuery(const char* sql);
void useDatabase(const char* db) {
db_name = db;
init();
}
void dropDatabase() {
char buff[101];
sprintf(buff,"rd /S /Q %s",db_name.c_str());
system(buff);
}
bool isInited() {
return inited;
}
DBIni getDBInfo() {
return db_ini;
}
string getDBName() {
return db_name;
}
private:
void init();
};
class ResultSet {
private:
vector<Column> vct_cols;
vector<long> vct_cursor;
Table table;
Database* m_db;
long cur_pos;
public:
ResultSet();
ResultSet(Table table,Database* db);
void setColumns(vector<Column> vct);
void setCursor(vector<long> vct);
void setDb(Database* db);
bool next();
bool prev();
bool first();
bool last();
string getString(int col_num);
string getString(const char* col_name);
int getInt(int col_num);
int getInt(const char* col_name);
float getFloat(int col_num);
float getFloat(const char* col_name);
double getDouble(int col_num);
double getDouble(const char* col_name);
long getLong(int col_num);
long getLong(const char* col_name);
openutils::MyDate getDate(int col_num);
openutils::MyDate getDate(const char* col_name);
//openutils::MyTime getTime(int col_num);
//openutils::MyTime getTime(const char* col_name);
bool getBool(int col_num);
bool getBool(const char* col_name);
int getColumnCount() {
return vct_cols.size();
}
void operator = (ResultSet rslt);
};
}
#endif
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.