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