• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 "message_parcel.h"
17 #include "sane_out_param.h"
18 #include "scan_log.h"
19 
20 namespace OHOS::Scan {
SaneOutParam()21 SaneOutParam::SaneOutParam() : info_(0), valueNumber_(0), valueBool_(true) {}
Marshalling(Parcel & parcel) const22 bool SaneOutParam::Marshalling(Parcel &parcel) const
23 {
24     bool status = true;
25     status &= parcel.WriteInt32(info_);
26     status &= parcel.WriteInt32(valueNumber_);
27     status &= parcel.WriteInt32Vector(valueNumList_);
28     status &= parcel.WriteString(valueStr_);
29     status &= parcel.WriteBool(valueBool_);
30     return status;
31 }
32 
Unmarshalling(Parcel & parcel)33 SaneOutParam* SaneOutParam::Unmarshalling(Parcel &parcel)
34 {
35     SaneOutParam* obj = new (std::nothrow) SaneOutParam();
36     if (obj == nullptr) {
37         SCAN_HILOGE("obj is a nullptr.");
38         return nullptr;
39     }
40     obj->info_ = parcel.ReadInt32();
41     obj->valueNumber_ = parcel.ReadInt32();
42     std::vector<int32_t>& value = obj->valueNumList_;
43     parcel.ReadInt32Vector(&value);
44     obj->valueStr_ = parcel.ReadString();
45     obj->valueBool_ = parcel.ReadBool();
46     return obj;
47 }
48 }   // namespace OHOS::Scan