1 /*
2  * Copyright (c) 2023 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 DATA_STORAGE_RDB_GLOBAL_PARAMS_HELPER_H
17 #define DATA_STORAGE_RDB_GLOBAL_PARAMS_HELPER_H
18 
19 #include "iosfwd"
20 #include "rdb_base_helper.h"
21 #include "string"
22 #include "vector"
23 
24 namespace OHOS {
25 namespace Telephony {
26 class RdbGlobalParamsHelper : public RdbBaseHelper {
27 public:
28     RdbGlobalParamsHelper();
29     ~RdbGlobalParamsHelper() = default;
30 
31     /**
32      * Init dataBase
33      *
34      * @return 0 is succeed else failed
35      */
36     int Init();
37 
38     /**
39      * Update dataBase path
40      *
41      * @param path path
42      */
43     void UpdateDbPath(const std::string &path);
44 
45 private:
46     void CreateGlobalParamsTableStr(std::string &createTableStr, const std::string &tableName);
47     /**
48      * Create number_match table
49      *
50      * @param createTableStr Create table statement
51      */
52     void CreateNumMatchTableStr(std::string &createTableStr);
53 
54     /**
55      * Create number_match index
56      *
57      * @param createIndexStr Create index statement
58      */
59     void CreateNumMatchIndexStr(std::string &createIndexStr);
60 
61     /**
62      * Create ecc_data table
63      *
64      * @param createTableStr Create table statement
65      */
66     void CreateEccDataTableStr(std::string &createTableStr);
67     int CommitTransactionAction();
68 
69 private:
70     const std::string DB_NAME = "globalparams.db";
71     std::string dbPath_ = FOLDER_PATH + DB_NAME;
72     const int VERSION = 1;
73 };
74 } // namespace Telephony
75 } // namespace OHOS
76 #endif // DATA_STORAGE_RDB_GLOBAL_PARAMS_HELPER_H
77