interreality.org [VOS]
[Home] [About]
[Screenshots]
[Download]
[News]
[Community]
[Documentation] [Manual]
[Bugs & Requests] [Wiki]

/home/tetron/hack/vos/libs/vos/extensions/sqlpersist/sqldb.hh

Go to the documentation of this file.
00001 #ifndef _SQLDB_HH_
00002 #define _SQLDB_HH_
00003 
00004 #include <stdexcept>
00005 #include <vector>
00006 #include <string>
00007 #include <stdarg.h>
00008 
00009 namespace VOS {
00010 
00011     class SQLPERSIST_API SQLError : public std::runtime_error
00012     {
00013     public:
00014         SQLError(const std::string& s) : runtime_error(s) { };
00015     };
00016 
00017     struct SQLPERSIST_API SQLCell
00018     {
00019         char* data;
00020         unsigned int length;
00021     };
00022 
00023     typedef std::vector<SQLCell> SQLRow;
00024 
00025     class SQLPERSIST_API SQLResult
00026     {
00027     public:
00028         virtual ~SQLResult() { }
00029         virtual int countRows() = 0;
00030         virtual SQLRow* getNextRow() = 0;
00031     };
00032 
00033     class SQLPERSIST_API SQLDatabase
00034     {
00035     public:
00036         virtual ~SQLDatabase() { }
00037 
00038         void formatQuery(const char* q, va_list ap, std::string& buffer);
00039         SQLResult* queryf(const char* q, ...);
00040 
00041         virtual SQLResult* query(const char* q);
00042         virtual SQLResult* query(const char* q, unsigned int len) = 0;
00043         virtual bool selectDatabase(const char* db) = 0;
00044         virtual std::string lastError() = 0;
00045         virtual unsigned int escapeString(char* to, const char* from, unsigned int fromlen) = 0;
00046         virtual unsigned int getAffectedRows() = 0;
00047     };
00048 }
00049 
00050 #endif