Fix crash when invalid parameter given
[platform/core/api/capability-manager.git] / src / sql_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 SQL_STATEMENT_H_
6 #define SQL_STATEMENT_H_
7
8 #include <string>
9
10 namespace capmgr {
11
12 class SQLConnection;
13
14 class SQLStatement {
15  public:
16   enum class StepResult : int {
17     DONE,
18     ROW,
19     ERROR,
20   };
21
22   explicit SQLStatement(SQLConnection* sql_conn) : sql_conn_(sql_conn) {}
23   virtual ~SQLStatement() = default;
24
25   virtual StepResult Step() = 0;
26
27   virtual bool BindInt(int pos, int val) = 0;
28   virtual bool BindString(int pos, const std::string& val) = 0;
29
30   virtual int GetColumnInt(int pos) const = 0;
31   virtual std::string GetColumnString(int pos) const = 0;
32
33   virtual bool Reset() = 0;
34   virtual void Clear() = 0;
35
36  protected:
37   SQLConnection* sql_conn_;
38 };
39
40 }  // namespace capmgr
41
42 #endif  // SQL_STATEMENT_H_