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 16 #ifndef DRAG_DATA_PACKER_H 17 #define DRAG_DATA_PACKER_H 18 19 #include <map> 20 #include <string> 21 #include <vector> 22 23 #include "parcel.h" 24 25 #include "drag_data.h" 26 27 namespace OHOS { 28 namespace Msdp { 29 namespace DeviceStatus { 30 31 using SummaryMap = std::map<std::string, int64_t>; 32 class DragDataPacker { 33 public: 34 static int32_t Marshalling(const DragData &dragData, Parcel &data, bool isCross = false); 35 static int32_t UnMarshalling(Parcel &data, DragData &dragData, bool isCross = false); 36 static int32_t CheckDragData(const DragData &dragData); 37 }; 38 39 class ShadowPacker { 40 public: 41 static int32_t Marshalling(const std::vector<ShadowInfo> &shadowInfos, Parcel &data, bool isCross = false); 42 static int32_t UnMarshalling(Parcel &data, std::vector<ShadowInfo> &shadowInfos, bool isCross = false); 43 static int32_t PackUpShadowInfo(const ShadowInfo &shadowInfo, Parcel &data, bool isCross = false); 44 static int32_t UnPackShadowInfo(Parcel &data, ShadowInfo &shadowInfo, bool isCross = false); 45 static int32_t CheckShadowInfo(const ShadowInfo &shadowInfo); 46 }; 47 48 class SummaryPacker { 49 public: 50 static int32_t Marshalling(const SummaryMap &val, Parcel &parcel); 51 static int32_t UnMarshalling(Parcel &parcel, SummaryMap &val); 52 }; 53 54 class ShadowOffsetPacker { 55 public: 56 static int32_t Marshalling(const ShadowOffset &shadowOffset, Parcel &parcel); 57 static int32_t UnMarshalling(Parcel &parcel, ShadowOffset &shadowOffset); 58 }; 59 } // namespace DeviceStatus 60 } // namespace Msdp 61 } // namespace OHOS 62 #endif // DRAG_DATA_PACKER_H 63