14faa1673Sopenharmony_ci/*
24faa1673Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
34faa1673Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
44faa1673Sopenharmony_ci * you may not use this file except in compliance with the License.
54faa1673Sopenharmony_ci * You may obtain a copy of the License at
64faa1673Sopenharmony_ci *
74faa1673Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
84faa1673Sopenharmony_ci *
94faa1673Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
104faa1673Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
114faa1673Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
124faa1673Sopenharmony_ci * See the License for the specific language governing permissions and
134faa1673Sopenharmony_ci * limitations under the License.
144faa1673Sopenharmony_ci */
154faa1673Sopenharmony_ci
164faa1673Sopenharmony_ci#ifndef STATEMENT_H
174faa1673Sopenharmony_ci#define STATEMENT_H
184faa1673Sopenharmony_ci
194faa1673Sopenharmony_ci#include "sqlite3sym.h"
204faa1673Sopenharmony_ci#include <string>
214faa1673Sopenharmony_ci#include "variant_value.h"
224faa1673Sopenharmony_ci
234faa1673Sopenharmony_cinamespace OHOS {
244faa1673Sopenharmony_cinamespace AccessControl {
254faa1673Sopenharmony_cinamespace SandboxManager {
264faa1673Sopenharmony_ciclass Statement final {
274faa1673Sopenharmony_cipublic:
284faa1673Sopenharmony_ci    enum State { BUSY, ROW, DONE, MISUSE, UNKNOWN };
294faa1673Sopenharmony_ci
304faa1673Sopenharmony_ci    Statement(sqlite3* db, const std::string &sql);
314faa1673Sopenharmony_ci    virtual ~Statement();
324faa1673Sopenharmony_ci
334faa1673Sopenharmony_ci    void Bind(const int32_t index, const std::string &text);
344faa1673Sopenharmony_ci    void Bind(const int32_t index, int32_t value);
354faa1673Sopenharmony_ci    void Bind(const int32_t index, int64_t value);
364faa1673Sopenharmony_ci    void Bind(const std::string &tableColumnName, const VariantValue &value);
374faa1673Sopenharmony_ci
384faa1673Sopenharmony_ci    State Step();
394faa1673Sopenharmony_ci    int32_t Reset();
404faa1673Sopenharmony_ci
414faa1673Sopenharmony_ci    std::string GetColumnString(const int32_t column) const;
424faa1673Sopenharmony_ci    int32_t GetColumnInt(const int32_t column) const;
434faa1673Sopenharmony_ci    int64_t GetColumnInt64(const int32_t column) const;
444faa1673Sopenharmony_ci    std::string GetColumnName(const int32_t column) const;
454faa1673Sopenharmony_ci    int32_t GetParameterIndex(const std::string &name) const;
464faa1673Sopenharmony_ci    int32_t GetColumnCount() const;
474faa1673Sopenharmony_ci    VariantValue GetValue(const int32_t column, const bool flagInt64) const;
484faa1673Sopenharmony_ci
494faa1673Sopenharmony_ciprivate:
504faa1673Sopenharmony_ci    sqlite3* db_;
514faa1673Sopenharmony_ci    sqlite3_stmt* statement_;
524faa1673Sopenharmony_ci    const std::string sql_;
534faa1673Sopenharmony_ci};
544faa1673Sopenharmony_ci} // namespace SandboxManager
554faa1673Sopenharmony_ci} // namespace AccessControl
564faa1673Sopenharmony_ci} // namespace OHOS
574faa1673Sopenharmony_ci#endif // STATEMENT_H
58