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 #include "cloud_types_util.h"
17
18 namespace OHOS::ITypesUtil {
19 template<>
Marshalling(const Participant & input,MessageParcel & data)20 bool Marshalling(const Participant &input, MessageParcel &data)
21 {
22 return ITypesUtil::Marshal(
23 data, input.identity, input.role, input.state, input.privilege, input.attachInfo);
24 }
25
26 template<>
Unmarshalling(Participant & output,MessageParcel & data)27 bool Unmarshalling(Participant &output, MessageParcel &data)
28 {
29 return ITypesUtil::Unmarshal(
30 data, output.identity, output.role, output.state, output.privilege, output.attachInfo);
31 }
32
33 template<>
Marshalling(const Privilege & input,MessageParcel & data)34 bool Marshalling(const Privilege &input, MessageParcel &data)
35 {
36 return ITypesUtil::Marshal(data, input.writable, input.readable,
37 input.creatable, input.deletable, input.shareable);
38 }
39
40 template<>
Unmarshalling(Privilege & output,MessageParcel & data)41 bool Unmarshalling(Privilege &output, MessageParcel &data)
42 {
43 return ITypesUtil::Unmarshal(data, output.writable, output.readable,
44 output.creatable, output.deletable, output.shareable);
45 }
46
47 template<>
Marshalling(const Asset & input,MessageParcel & data)48 bool Marshalling(const Asset &input, MessageParcel &data)
49 {
50 return Marshal(data, input.version, input.name, input.size, input.modifyTime, input.uri);
51 }
52 template<>
Unmarshalling(Asset & output,MessageParcel & data)53 bool Unmarshalling(Asset &output, MessageParcel &data)
54 {
55 return Unmarshal(data, output.version, output.name, output.size, output.modifyTime, output.uri);
56 }
57 template<>
Marshalling(const ValueObject & input,MessageParcel & data)58 bool Marshalling(const ValueObject &input, MessageParcel &data)
59 {
60 return Marshal(data, input.value);
61 }
62 template<>
Unmarshalling(ValueObject & output,MessageParcel & data)63 bool Unmarshalling(ValueObject &output, MessageParcel &data)
64 {
65 return Unmarshal(data, output.value);
66 }
67 template<>
Marshalling(const ValuesBucket & input,MessageParcel & data)68 bool Marshalling(const ValuesBucket &input, MessageParcel &data)
69 {
70 return Marshal(data, input.values_);
71 }
72 template<>
Unmarshalling(ValuesBucket & output,MessageParcel & data)73 bool Unmarshalling(ValuesBucket &output, MessageParcel &data)
74 {
75 return Unmarshal(data, output.values_);
76 }
77
78 template<>
Marshalling(const StatisticInfo & input,MessageParcel & data)79 bool Marshalling(const StatisticInfo &input, MessageParcel &data)
80 {
81 return ITypesUtil::Marshal(data, input.table, input.inserted, input.updated, input.normal);
82 }
83
84 template<>
Unmarshalling(StatisticInfo & output,MessageParcel & data)85 bool Unmarshalling(StatisticInfo &output, MessageParcel &data)
86 {
87 return ITypesUtil::Unmarshal(data, output.table, output.inserted, output.updated, output.normal);
88 }
89
90 template<>
Unmarshalling(Strategy & output,MessageParcel & data)91 bool Unmarshalling(Strategy &output, MessageParcel &data)
92 {
93 uint32_t result;
94 if (!data.ReadUint32(result) || result < Strategy::STRATEGY_HEAD || result >= Strategy::STRATEGY_BUTT) {
95 return false;
96 }
97 output = static_cast<Strategy>(result);
98 return true;
99 }
100
101 template<>
Marshalling(const CloudSyncInfo & input,MessageParcel & data)102 bool Marshalling(const CloudSyncInfo &input, MessageParcel &data)
103 {
104 return Marshal(data, input.startTime, input.finishTime, input.code);
105 }
106
107 template<>
Unmarshalling(CloudSyncInfo & output,MessageParcel & data)108 bool Unmarshalling(CloudSyncInfo &output, MessageParcel &data)
109 {
110 return Unmarshal(data, output.startTime, output.finishTime, output.code);
111 }
112 } // namespace OHOS::ITypesUtil