11401458bSopenharmony_ci/* 21401458bSopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 31401458bSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 41401458bSopenharmony_ci * you may not use this file except in compliance with the License. 51401458bSopenharmony_ci * You may obtain a copy of the License at 61401458bSopenharmony_ci * 71401458bSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 81401458bSopenharmony_ci * 91401458bSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 101401458bSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 111401458bSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 121401458bSopenharmony_ci * See the License for the specific language governing permissions and 131401458bSopenharmony_ci * limitations under the License. 141401458bSopenharmony_ci */ 151401458bSopenharmony_ci 161401458bSopenharmony_ci#include "query_argument.h" 171401458bSopenharmony_ci 181401458bSopenharmony_cinamespace OHOS { 191401458bSopenharmony_cinamespace HiviewDFX { 201401458bSopenharmony_cibool QueryArgument::Marshalling(Parcel& parcel) const 211401458bSopenharmony_ci{ 221401458bSopenharmony_ci if (!parcel.WriteInt64(beginTime)) { 231401458bSopenharmony_ci return false; 241401458bSopenharmony_ci } 251401458bSopenharmony_ci if (!parcel.WriteInt64(endTime)) { 261401458bSopenharmony_ci return false; 271401458bSopenharmony_ci } 281401458bSopenharmony_ci if (!parcel.WriteInt32(maxEvents)) { 291401458bSopenharmony_ci return false; 301401458bSopenharmony_ci } 311401458bSopenharmony_ci if (!parcel.WriteInt64(fromSeq)) { 321401458bSopenharmony_ci return false; 331401458bSopenharmony_ci } 341401458bSopenharmony_ci if (!parcel.WriteInt64(toSeq)) { 351401458bSopenharmony_ci return false; 361401458bSopenharmony_ci } 371401458bSopenharmony_ci return true; 381401458bSopenharmony_ci} 391401458bSopenharmony_ci 401401458bSopenharmony_ciQueryArgument* QueryArgument::Unmarshalling(Parcel& parcel) 411401458bSopenharmony_ci{ 421401458bSopenharmony_ci QueryArgument* ret = new(std::nothrow) QueryArgument(); 431401458bSopenharmony_ci if (ret == nullptr) { 441401458bSopenharmony_ci return ret; 451401458bSopenharmony_ci } 461401458bSopenharmony_ci if (!parcel.ReadInt64(ret->beginTime)) { 471401458bSopenharmony_ci goto error; 481401458bSopenharmony_ci } 491401458bSopenharmony_ci if (!parcel.ReadInt64(ret->endTime)) { 501401458bSopenharmony_ci goto error; 511401458bSopenharmony_ci } 521401458bSopenharmony_ci if (!parcel.ReadInt32(ret->maxEvents)) { 531401458bSopenharmony_ci goto error; 541401458bSopenharmony_ci } 551401458bSopenharmony_ci if (!parcel.ReadInt64(ret->fromSeq)) { 561401458bSopenharmony_ci goto error; 571401458bSopenharmony_ci } 581401458bSopenharmony_ci if (!parcel.ReadInt64(ret->toSeq)) { 591401458bSopenharmony_ci goto error; 601401458bSopenharmony_ci } 611401458bSopenharmony_ci return ret; 621401458bSopenharmony_cierror: 631401458bSopenharmony_ci delete ret; 641401458bSopenharmony_ci ret = nullptr; 651401458bSopenharmony_ci return nullptr; 661401458bSopenharmony_ci} 671401458bSopenharmony_ci} // namespace HiviewDFX 681401458bSopenharmony_ci} // namespace OHOS 69