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 #ifndef NFC_PREFERENCES_H 16 #define NFC_PREFERENCES_H 17 #include "preferences.h" 18 #include "preferences_helper.h" 19 20 namespace OHOS { 21 namespace NFC { 22 constexpr const char* ABORT_RETRY_TIME = "abort_retry_time"; 23 24 class NfcPreferences { 25 public: 26 static NfcPreferences& GetInstance(); 27 28 void SetString(const std::string& key, const std::string& value); 29 std::string GetString(const std::string& key); 30 void SetInt(const std::string& key, const int value); 31 int GetInt(const std::string& key); 32 void SetBool(const std::string& key, const bool value); 33 bool GetBool(const std::string& key); 34 void Clear(); 35 void Delete(const std::string& key); 36 37 private: 38 NfcPreferences(); 39 ~NfcPreferences(); 40 41 std::shared_ptr<NativePreferences::Preferences> GetPreference(const std::string& fileName); 42 int errCode_; 43 std::string fileName_; 44 }; 45 } // NFC 46 } // OHOS 47 #endif // NFC_PREFERENCES_H