• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 "query_argument.h"
17 
18 namespace OHOS {
19 namespace HiviewDFX {
Marshalling(Parcel & parcel) const20 bool QueryArgument::Marshalling(Parcel& parcel) const
21 {
22     if (!parcel.WriteInt64(beginTime)) {
23         return false;
24     }
25     if (!parcel.WriteInt64(endTime)) {
26         return false;
27     }
28     if (!parcel.WriteInt32(maxEvents)) {
29         return false;
30     }
31     if (!parcel.WriteInt64(fromSeq)) {
32         return false;
33     }
34     if (!parcel.WriteInt64(toSeq)) {
35         return false;
36     }
37     return true;
38 }
39 
Unmarshalling(Parcel & parcel)40 QueryArgument* QueryArgument::Unmarshalling(Parcel& parcel)
41 {
42     QueryArgument* ret = new(std::nothrow) QueryArgument();
43     if (ret == nullptr) {
44         return ret;
45     }
46     if (!parcel.ReadInt64(ret->beginTime)) {
47         goto error;
48     }
49     if (!parcel.ReadInt64(ret->endTime)) {
50         goto error;
51     }
52     if (!parcel.ReadInt32(ret->maxEvents)) {
53         goto error;
54     }
55     if (!parcel.ReadInt64(ret->fromSeq)) {
56         goto error;
57     }
58     if (!parcel.ReadInt64(ret->toSeq)) {
59         goto error;
60     }
61     return ret;
62 error:
63     delete ret;
64     ret = nullptr;
65     return nullptr;
66 }
67 } // namespace HiviewDFX
68 } // namespace OHOS
69