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 #include "parcel_sample.h"
16 
17 #include "parcel.h"
18 
19 namespace OHOS {
20 namespace HiviewDFX {
Marshalling(Parcel & parcel) const21 bool ParcelSample::Marshalling(Parcel& parcel) const
22 {
23     if (!parcel.WriteInt64(member0)) {
24         return false;
25     }
26 
27     if (!parcel.WriteInt32(member1)) {
28         return false;
29     }
30 
31     if (!parcel.WriteInt32(member2)) {
32         return false;
33     }
34 
35     if (!parcel.WriteString(member3)) {
36         return false;
37     }
38 
39     return true;
40 }
41 
Unmarshalling(Parcel & parcel)42 ParcelSample* ParcelSample::Unmarshalling(Parcel& parcel)
43 {
44     ParcelSample* ret = new ParcelSample();
45     if (!parcel.ReadInt64(ret->member0)) {
46         goto error;
47     }
48 
49     if (!parcel.ReadInt32(ret->member1)) {
50         goto error;
51     }
52 
53     if (!parcel.ReadInt32(ret->member2)) {
54         goto error;
55     }
56 
57     if (!parcel.ReadString(ret->member3)) {
58         goto error;
59     }
60     return ret;
61 
62 error:
63     delete ret;
64     ret = nullptr;
65     return nullptr;
66 }
67 }  // namespace hiview
68 }  // namespace OHOS
69