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 #ifndef OHOS_FILEMGMT_CLOUD_PREF_IMPL_H 16 #define OHOS_FILEMGMT_CLOUD_PREF_IMPL_H 17 #include "preferences.h" 18 #include "preferences_helper.h" 19 20 namespace OHOS::FileManagement::CloudSync { 21 const static std::string START_CURSOR = "start_cursor"; 22 const static std::string NEXT_CURSOR = "next_cursor"; 23 const static std::string TEMP_START_CURSOR = "temp_start_cursor"; 24 class CloudPrefImpl { 25 public: 26 CloudPrefImpl(const std::string& fileName); 27 CloudPrefImpl(const int32_t userId, const std::string& bundleName, const std::string& tableName); 28 ~CloudPrefImpl() = default;; 29 30 void SetString(const std::string& key, const std::string& value); 31 void GetString(const std::string& key, std::string& value); 32 void SetLong(const std::string& key, const int64_t value); 33 void GetLong(const std::string& key, int64_t& value); 34 void SetInt(const std::string& key, const int value); 35 void GetInt(const std::string& key, int32_t& value); 36 void SetBool(const std::string& key, const bool& value); 37 void GetBool(const std::string& key, bool& value); 38 void Clear(); 39 void Delete(const std::string& key); 40 41 private: 42 std::string fileName_; 43 std::shared_ptr<NativePreferences::Preferences> pref_; 44 }; 45 } 46 #endif // OHOS_FILEMGMT_CLOUD_PREF_IMPL_H