33 std::string doubleToString(
const double value);
38 std::string floatToString(
const float value);
44 std::string intToString(
const int value);
51 enum TransactionFlags {DEFERRED, IMMEDIATE, EXCLUSIVE};
60 enum StepValue {ROW, DONE, UNKNOWN};
67 enum OpenFlags {READONLY, READWRITE, CREATE};
101 inline void checkDatabaseOpened()
const;
114 Database(
const std::string& path,
const OpenFlags flag = CREATE);
127 void open(
const std::string& path,
const OpenFlags flag = CREATE);
154 int exec(
const std::string& sql);
201 sqlite3_stmt* statement;
211 std::map<std::string, int> columns;
216 StepValue step(
void);
221 inline void checkPrepared()
const;
242 void bindString(
const int n,
const std::string& value);
250 void bindInt(
const int n,
const int value);
258 void bindDouble(
const int n,
const double value);
274 std::string
getString(
const std::string& column)
const;
283 int getInt(
const std::string& column)
const;
292 double getDouble(
const std::string& column)
const;
300 void getString(
const int n, std::string& out)
const;
308 void getInt(
const int n,
int& out)
const;
316 void getDouble(
const int n,
double& out)
const;
323 std::string
getString(
const int n)
const ;
330 int getInt(
const int n)
const;
344 void prepare(
const std::string& sql);
385 this->error = std::string(sqlite3_errmsg(db));
394 virtual const char*
what()
const throw() {
395 return this->error.c_str();
399 extern SQLiteException DatabaseNotOpened;
400 extern SQLiteException DatabaseOpened;
401 extern SQLiteException StatementNotPrepared;
SQLiteException(sqlite3 *db)
The error message is the last sqlite error in the passed sqlite database.
void bindNull(const int n)
Binds the nth parameter with the null value.
~Database(void)
destructor
bool fetchRow(void)
fetches the next row
bool isOpen(void)
returns true, when a database has been opened, false otherwise
std::string getString(const std::string &column) const
gets a column as string
int getInt(const std::string &column) const
gets a column as integer
void bindString(const int n, const std::string &value)
Binds the nth parameter with the passed value as string.
void deactivateForeignKeys(void)
deactivates foreign keys
void exec(void)
executes the prepared statement
Statement(Database &db)
Default constructor.
void open(const std::string &path, const OpenFlags flag=CREATE)
Opens a database with the passed flag.
virtual const char * what() const
gets the error message
void endTransaction(void)
commits a transaction
void bindDouble(const int n, const double value)
Binds the nth parameter with the passed value as integer.
SQLiteException(const std::string &str)
Constructs a SQLiteException with the passed error message.
void beginTransaction(const TransactionFlags=DEFERRED)
Begins a transaction.
int getLastRowId(void)
gets the last ID, that has been inserted
void prepare(const std::string &sql)
prepares a string as statement
Database(void)
empty constructor. Does not open a database
double getDouble(const std::string &column) const
gets a column as double
void finalize(void)
releases any allocated resources. Use it, when you want to reuse a statement object.
void close(void)
closes the database
void activateForeignKeys(void)
activates foreign keys
void bindInt(const int n, const int value)
Binds the nth parameter with the passed value as integer.
int exec(const std::string &sql)
executes a single statement without return values
void rollback(void)
executes a rollback on the current transaction