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_rule.h"
17
18namespace OHOS {
19namespace HiviewDFX {
20bool SysEventRule::Marshalling(Parcel& parcel) const
21{
22    if (!parcel.WriteString(domain)) {
23        return false;
24    }
25    if (!parcel.WriteString(eventName)) {
26        return false;
27    }
28    if (!parcel.WriteString(tag)) {
29        return false;
30    }
31    if (!parcel.WriteUint32(ruleType)) {
32        return false;
33    }
34    if (!parcel.WriteUint32(eventType)) {
35        return false;
36    }
37    return true;
38}
39
40SysEventRule* SysEventRule::Unmarshalling(Parcel& parcel)
41{
42    SysEventRule* ret = new(std::nothrow) SysEventRule();
43    if (ret == nullptr) {
44        return ret;
45    }
46    if (!parcel.ReadString(ret->domain)) {
47        goto error;
48    }
49    if (!parcel.ReadString(ret->eventName)) {
50        goto error;
51    }
52    if (!parcel.ReadString(ret->tag)) {
53        goto error;
54    }
55    if (!parcel.ReadUint32(ret->ruleType)) {
56        goto error;
57    }
58    if (!parcel.ReadUint32(ret->eventType)) {
59        goto error;
60    }
61    return ret;
62error:
63    delete ret;
64    ret = nullptr;
65    return nullptr;
66}
67} // namespace HiviewDFX
68} // namespace OHOS
69