• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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. BundleName is mandatory and must be the same for different RDB stores
36      * of the same application.
37      *
38      * @param config Indicates the {@link RdbStoreConfig} configuration of the database related to this RDB store.
39      * @param version Indicates the database version for upgrade or downgrade.
40      * @param openCallback version the database version for upgrade or downgrade.
41      * @param errCode Indicates the {@link RdbOpenCallback} callback of the store.
42      *
43      * @return Returns the RDB store {@link RdbStore}.
44      */
45     API_EXPORT static std::shared_ptr<RdbStore> GetRdbStore(
46         const RdbStoreConfig &config, int version, RdbOpenCallback &openCallback, int &errCode);
47 
48     /**
49      * @brief Deletes the database with a specified name.
50      *
51      * @param path Indicates the database path.
52      */
53     API_EXPORT static int DeleteRdbStore(const std::string &path, bool shouldClose = true);
54 
55     API_EXPORT static int DeleteRdbStore(const RdbStoreConfig &config, bool shouldClose = true);
56 
57     /**
58      * @brief Clear Cache.
59      */
60     API_EXPORT static void ClearCache();
61 
62     /**
63      * @brief Checks whether the vector database is supported.
64      *
65      * @return Returns {@code true} if the vector database is supported; returns {@code false} otherwise.
66      */
67     API_EXPORT static bool IsSupportArkDataDb();
68 
69 	/**
70      * @brief Checks whether the custom tokenizer is supported.
71      *
72      * @return Returns {@code true} if the custom tokenizer is supported; returns {@code false} otherwise.
73      */
74     API_EXPORT static bool IsSupportedTokenizer(Tokenizer tokenizer);
75 };
76 } // namespace NativeRdb
77 } // namespace OHOS
78 #endif
79