summaryrefslogtreecommitdiff
path: root/include/db/statement.h
blob: 8c2ade2b0d152178e70c0c942ed34b30c9f86080 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
 * statement.h
 *
 *  Created on: 28.10.2012
 *      Author: savop
 */

#ifndef STATEMENT_H_
#define STATEMENT_H_

#include <sqlite3.h>

namespace db {

class Statement {
private:

  boost::shared_ptr<sqlite3_stmt> m_statement;
  boost::shared_ptr<sqlite3> m_connection;

public:

  Statement() {}

  Statement(boost::shared_ptr<sqlite3>& conn, boost::shared_ptr<sqlite3_stmt>& stmt)
  : m_connection(conn)
  , m_statement(stmt)
  {}

  virtual ~Statement(){}

  Statement& execute(){
    if(sqlite3_step(m_statement.get()) != SQLITE_OK)
      throw SQLiteException(sqlite3_errmsg(m_connection.get()));

    return *this;
  }

};

}  // namespace db

#endif /* STATEMENT_H_ */