1 /* 2 * Copyright (c) 2024 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 SERVICES_EDM_INCLUDE_UTILS_CLIPBOARD_POLICY_SERIALIZER_H 17 #define SERVICES_EDM_INCLUDE_UTILS_CLIPBOARD_POLICY_SERIALIZER_H 18 19 #include "clipboard_policy.h" 20 #include "ipolicy_serializer.h" 21 22 namespace OHOS { 23 namespace EDM { 24 25 const std::string TOKEN_ID = "tokenId"; 26 const std::string CLIPBOARD_POLICY_STR = "clipboardPolicy"; 27 28 /* 29 * Policy data serializer of type int. 30 */ 31 class ClipboardSerializer : public IPolicySerializer<std::map<int32_t, ClipboardPolicy>>, 32 public DelayedSingleton<ClipboardSerializer> { 33 public: 34 35 bool Deserialize(const std::string &policy, std::map<int32_t, ClipboardPolicy> &dataObj) override; 36 37 bool Serialize(const std::map<int32_t, ClipboardPolicy> &dataObj, std::string &policy) override; 38 39 bool GetPolicy(MessageParcel &data, std::map<int32_t, ClipboardPolicy> &result) override; 40 41 bool WritePolicy(MessageParcel &reply, std::map<int32_t, ClipboardPolicy> &result) override; 42 43 bool MergePolicy(std::vector<std::map<int32_t, ClipboardPolicy>> &data, 44 std::map<int32_t, ClipboardPolicy> &result) override; 45 46 private: 47 ClipboardPolicy ConvertToClipboardPolicy(int32_t policy); 48 }; 49 } // namespace EDM 50 } // namespace OHOS 51 52 #endif // SERVICES_EDM_INCLUDE_UTILS_PASSWORD_POLICY_SERIALIZER_H 53