1 /* 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef STATEMENT_H 17 #define STATEMENT_H 18 19 #include "sqlite3sym.h" 20 #include <string> 21 #include "variant_value.h" 22 23 namespace OHOS { 24 namespace Security::SecurityGuard { 25 class Statement final { 26 public: 27 enum State { BUSY, ROW, DONE, MISUSE, UNKNOWN }; 28 29 Statement(sqlite3* db, const std::string &sql); 30 virtual ~Statement(); 31 32 void Bind(const int32_t index, const std::string &text); 33 void Bind(const int32_t index, int32_t value); 34 void Bind(const int32_t index, int64_t value); 35 void Bind(const std::string &tableColumnName, const VariantValue &value); 36 37 State Step(); 38 int32_t Reset(); 39 40 std::string GetColumnString(const int32_t column) const; 41 int32_t GetColumnInt(const int32_t column) const; 42 int64_t GetColumnInt64(const int32_t column) const; 43 std::string GetColumnName(const int32_t column) const; 44 int32_t GetParameterIndex(const std::string &name) const; 45 int32_t GetColumnCount() const; 46 VariantValue GetValue(const int32_t column, const bool flagInt64) const; 47 48 private: 49 sqlite3* db_; 50 sqlite3_stmt* statement_; 51 const std::string sql_; 52 }; 53 } // namespace Security::SecurityGuard 54 } // namespace OHOS 55 #endif // STATEMENT_H 56