• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_RDB_DATA_MANAGER_H
17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_RDB_DATA_MANAGER_H
18 
19 #include "bms_rdb_config.h"
20 #include "bms_rdb_open_callback.h"
21 #include "rdb_helper.h"
22 
23 namespace OHOS {
24 namespace AppExecFwk {
25 class RdbDataManager {
26 public:
27     RdbDataManager(const BmsRdbConfig &bmsRdbConfig);
28     ~RdbDataManager();
29 
30     static void ClearCache();
31     bool InsertData(const std::string &key, const std::string &value);
32     bool InsertData(const NativeRdb::ValuesBucket &valuesBucket);
33     bool UpdateData(const std::string &key, const std::string &value);
34     bool DeleteData(const std::string &key);
35     bool QueryData(const std::string &key, std::string &value);
36     bool QueryAllData(std::map<std::string, std::string> &datas);
37 
38     bool BatchInsert(int64_t &outInsertNum, const std::vector<NativeRdb::ValuesBucket> &valuesBuckets);
39     bool UpdateData(const NativeRdb::ValuesBucket &valuesBucket,
40         const NativeRdb::AbsRdbPredicates &absRdbPredicates);
41     bool DeleteData(const NativeRdb::AbsRdbPredicates &absRdbPredicates);
42     std::shared_ptr<NativeRdb::AbsSharedResultSet> QueryData(
43         const NativeRdb::AbsRdbPredicates &absRdbPredicates);
44     bool CreateTable();
45 
46 private:
47     std::shared_ptr<NativeRdb::RdbStore> GetRdbStore();
48 
49     BmsRdbConfig bmsRdbConfig_;
50 };
51 }  // namespace AppExecFwk
52 }  // namespace OHOS
53 #endif  // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_RDB_DATA_MANAGER_H
54