1 /* 2 * Copyright (c) 2024 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 ACCOUNT_STATEMENT_H 17 #define ACCOUNT_STATEMENT_H 18 19 #include <string> 20 21 #include "variant_value.h" 22 23 #include "sqlite3sym.h" 24 25 namespace OHOS { 26 namespace AccountSA { 27 class Statement final { 28 public: 29 enum State { BUSY, ROW, DONE, MISUSE, UNKNOWN }; 30 31 Statement(sqlite3* db, const std::string& sql); 32 virtual ~Statement(); 33 34 void Bind(const int32_t index, const std::string& text); 35 void Bind(const int32_t index, int32_t value); 36 void Bind(const int32_t index, int64_t value); 37 void Bind(const std::string& tableColumnName, const VariantValue& value); 38 39 State Step(); 40 int32_t Reset(); 41 42 std::string GetColumnString(const int32_t column) const; 43 int32_t GetColumnInt(const int32_t column) const; 44 int64_t GetColumnInt64(const int32_t column) const; 45 std::string GetColumnName(const int32_t column) const; 46 int32_t GetParameterIndex(const std::string& name) const; 47 int32_t GetColumnCount() const; 48 VariantValue GetValue(const int32_t column, const bool flagInt64) const; 49 50 private: 51 sqlite3* db_; 52 sqlite3_stmt* statement_; 53 const std::string sql_; 54 }; 55 } // namespace AccountSA 56 } // namespace OHOS 57 #endif // ACCOUNT_STATEMENT_H 58