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 DATA_STORAGE_RDB_OPKEY_HELPER_H 17 #define DATA_STORAGE_RDB_OPKEY_HELPER_H 18 19 #include "iosfwd" 20 #include "rdb_base_helper.h" 21 #include "string" 22 23 namespace OHOS { 24 namespace Telephony { 25 class RdbOpKeyHelper : public RdbBaseHelper { 26 public: 27 RdbOpKeyHelper(); 28 ~RdbOpKeyHelper() = default; 29 30 /** 31 * Update dataBase path 32 * 33 * @param path path 34 */ 35 void UpdateDbPath(const std::string &path); 36 37 /** 38 * Init dataBase 39 * 40 * @return 0 is succeed else failed 41 */ 42 int Init(); 43 44 /** 45 * Init InitOpKeyDatabase 46 * 47 * @return Greater than 0 is succeed else failed 48 */ 49 int64_t InitOpKeyDatabase(); 50 51 private: 52 /** 53 * Create OpKeyInfo table 54 * 55 * @param createTableStr Create table statement 56 */ 57 void CreateOpKeyInfoTableStr(std::string &createTableStr); 58 59 /** 60 * Create OpKeyInfo index 61 * 62 * @param createIndexStr Create index statement 63 */ 64 void CreateOpKeyInfoIndexStr(std::string &createIndexStr); 65 66 /** 67 * Commit the transaction action 68 * 69 * @return 0 is succeed else failed 70 */ 71 int CommitTransactionAction(); 72 73 private: 74 const std::string DB_NAME = "opkey.db"; 75 std::string dbPath_ = FOLDER_PATH + DB_NAME; 76 }; 77 } // namespace Telephony 78 } // namespace OHOS 79 #endif // DATA_STORAGE_RDB_OPKEY_HELPER_H