Fix crash when invalid parameter given
[platform/core/api/capability-manager.git] / src / sqlite_statement.h
1 // Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by a apache 2.0 license that can be
3 // found in the LICENSE file.
4
5 #ifndef SQLITE_STATEMENT_H_
6 #define SQLITE_STATEMENT_H_
7
8 #include <sqlite3.h>
9
10 #include <string>
11
12 #include "src/sql_statement.h"
13
14 namespace capmgr {
15
16 class SQLConnection;
17
18 class SQLiteStatement final : public SQLStatement {
19  public:
20   SQLiteStatement(SQLConnection* sql_conn, sqlite3_stmt* stmt);
21   virtual ~SQLiteStatement();
22
23   // non-copyable
24   SQLiteStatement(const SQLiteStatement&) = delete;
25   SQLiteStatement& operator=(const SQLiteStatement&) = delete;
26
27   SQLStatement::StepResult Step() override;
28
29   bool BindInt(int pos, int val) override;
30   bool BindString(int pos, const std::string& val) override;
31
32   int GetColumnInt(int pos) const override;
33   std::string GetColumnString(int pos) const override;
34
35   bool Reset() override;
36   void Clear() override;
37
38  private:
39   std::string GetErrorMessage() const;
40
41   sqlite3_stmt* stmt_;
42 };
43
44 }  // namespace capmgr
45
46 #endif  // SQLITE_STATEMENT_H_