1 /*
2  * Copyright (c) 2021 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 "sys_event_query_rule.h"
17 
18 namespace OHOS {
19 namespace HiviewDFX {
Marshalling(Parcel & parcel) const20 bool SysEventQueryRule::Marshalling(Parcel& parcel) const
21 {
22     if (!parcel.WriteUint32(eventType)) {
23         return false;
24     }
25     if (!parcel.WriteUint32(ruleType)) {
26         return false;
27     }
28     if (!parcel.WriteString(domain)) {
29         return false;
30     }
31     if (!parcel.WriteString(condition)) {
32         return false;
33     }
34     if (!parcel.WriteStringVector(eventList)) {
35         return false;
36     }
37     return true;
38 }
39 
Unmarshalling(Parcel & parcel)40 SysEventQueryRule* SysEventQueryRule::Unmarshalling(Parcel& parcel)
41 {
42     SysEventQueryRule* ret = new SysEventQueryRule();
43     if (ret == nullptr) {
44         return ret;
45     }
46     if (!parcel.ReadUint32(ret->eventType)) {
47         goto error;
48     }
49     if (!parcel.ReadUint32(ret->ruleType)) {
50         goto error;
51     }
52     if (!parcel.ReadString(ret->domain)) {
53         goto error;
54     }
55     if (!parcel.ReadString(ret->condition)) {
56         goto error;
57     }
58     if (!parcel.ReadStringVector(&(ret->eventList))) {
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