1 /* 2 * Copyright (c) 2021 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 NATIVE_RDB_RDB_HELPER_H 17 #define NATIVE_RDB_RDB_HELPER_H 18 19 #include <memory> 20 #include <mutex> 21 #include <string> 22 23 #include "rdb_open_callback.h" 24 #include "rdb_store.h" 25 #include "rdb_store_config.h" 26 27 namespace OHOS { 28 namespace NativeRdb { 29 class API_EXPORT RdbHelper final { 30 public: 31 /** 32 * @brief Obtains an RDB store. 33 * 34 * You can set parameters of the RDB store as required. In general, this method is recommended 35 * to obtain a rdb store. 36 * 37 * @param config Indicates the {@link RdbStoreConfig} configuration of the database related to this RDB store. 38 * @param version Indicates the database version for upgrade or downgrade. 39 * @param openCallback version the database version for upgrade or downgrade. 40 * @param errCode Indicates the {@link RdbOpenCallback} callback of the store. 41 * 42 * @return Returns the RDB store {@link RdbStore}. 43 */ 44 API_EXPORT static std::shared_ptr<RdbStore> GetRdbStore( 45 const RdbStoreConfig &config, int version, RdbOpenCallback &openCallback, int &errCode); 46 47 /** 48 * @brief Deletes the database with a specified name. 49 * 50 * @param path Indicates the database path. 51 */ 52 API_EXPORT static int DeleteRdbStore(const std::string &path); 53 54 API_EXPORT static int DeleteRdbStore(const RdbStoreConfig &config); 55 56 /** 57 * @brief Clear Cache. 58 */ 59 API_EXPORT static void ClearCache(); 60 61 }; 62 } // namespace NativeRdb 63 } // namespace OHOS 64 #endif 65