16ea96550Sopenharmony_ci/*
26ea96550Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
36ea96550Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
46ea96550Sopenharmony_ci * you may not use this file except in compliance with the License.
56ea96550Sopenharmony_ci * You may obtain a copy of the License at
66ea96550Sopenharmony_ci *
76ea96550Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
86ea96550Sopenharmony_ci *
96ea96550Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
106ea96550Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
116ea96550Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
126ea96550Sopenharmony_ci * See the License for the specific language governing permissions and
136ea96550Sopenharmony_ci * limitations under the License.
146ea96550Sopenharmony_ci */
156ea96550Sopenharmony_ci
166ea96550Sopenharmony_ci#ifndef SECURITY_GUARD_EVENT_STORE_H
176ea96550Sopenharmony_ci#define SECURITY_GUARD_EVENT_STORE_H
186ea96550Sopenharmony_ci
196ea96550Sopenharmony_ci#include "rdb_open_callback.h"
206ea96550Sopenharmony_ci#include "rdb_predicates.h"
216ea96550Sopenharmony_ci#include "rdb_store.h"
226ea96550Sopenharmony_ci#include "rdb_store_config.h"
236ea96550Sopenharmony_ci
246ea96550Sopenharmony_ci#include "config_define.h"
256ea96550Sopenharmony_ci#include "store_define.h"
266ea96550Sopenharmony_ci
276ea96550Sopenharmony_cinamespace OHOS::Security::SecurityGuard {
286ea96550Sopenharmony_ciclass Database {
296ea96550Sopenharmony_cipublic:
306ea96550Sopenharmony_ci    Database() = default;
316ea96550Sopenharmony_ci    ~Database() = default;
326ea96550Sopenharmony_ci    void CreateRdbStore(const NativeRdb::RdbStoreConfig &config, int version,
336ea96550Sopenharmony_ci        NativeRdb::RdbOpenCallback &openCallback, int &errCode);
346ea96550Sopenharmony_ci    int Insert(int64_t &outRowId, const std::string &table, const NativeRdb::ValuesBucket &initialValues);
356ea96550Sopenharmony_ci    int BatchInsert(int64_t &outInsertNum, const std::string &table,
366ea96550Sopenharmony_ci        const std::vector<NativeRdb::ValuesBucket> &initialBatchValues);
376ea96550Sopenharmony_ci    int Update(int &changedRows, const NativeRdb::ValuesBucket &values, const NativeRdb::AbsRdbPredicates &predicates);
386ea96550Sopenharmony_ci    int Delete(int &deletedRows, const NativeRdb::AbsRdbPredicates &predicates);
396ea96550Sopenharmony_ci    std::shared_ptr<NativeRdb::ResultSet> Query(
406ea96550Sopenharmony_ci        const NativeRdb::AbsRdbPredicates &predicates, const std::vector<std::string> columns);
416ea96550Sopenharmony_ci    int ExecuteSql(const std::string &sql);
426ea96550Sopenharmony_ci    int ExecuteAndGetLong(int64_t &outValue, const std::string &sql,
436ea96550Sopenharmony_ci        const std::vector<NativeRdb::ValueObject> &bindArgs = std::vector<NativeRdb::ValueObject>());
446ea96550Sopenharmony_ci    int Count(int64_t &outValue, const NativeRdb::AbsRdbPredicates &predicates);
456ea96550Sopenharmony_ci    int BeginTransaction();
466ea96550Sopenharmony_ci    int RollBack();
476ea96550Sopenharmony_ci    int Commit();
486ea96550Sopenharmony_ci    int Attach(const std::string &alias, const std::string &pathName, const std::vector<uint8_t> destEncryptKey);
496ea96550Sopenharmony_ci
506ea96550Sopenharmony_ciprivate:
516ea96550Sopenharmony_ci    int IsExistStore();
526ea96550Sopenharmony_ci    std::shared_ptr<NativeRdb::RdbStore> store_;
536ea96550Sopenharmony_ci};
546ea96550Sopenharmony_ci}  // OHOS::Security::SecurityGuard
556ea96550Sopenharmony_ci
566ea96550Sopenharmony_ci#endif // SECURITY_GUARD_EVENT_STORE_H
57