• 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 "sane_control_param.h"
17 #include "scan_log.h"
18 #include "message_parcel.h"
19 
20 namespace OHOS::Scan {
SaneControlParam()21 SaneControlParam::SaneControlParam() : option_(0), action_(SANE_ACTION_GET_VALUE),
22     valueType_(0), valueSize_(0), valueNumber_(0) {}
Marshalling(Parcel & parcel) const23 bool SaneControlParam::Marshalling(Parcel &parcel) const
24 {
25     bool status = true;
26     status &= parcel.WriteInt32(option_);
27     status &= parcel.WriteInt32(static_cast<int32_t>(action_));
28     status &= parcel.WriteInt32(valueType_);
29     status &= parcel.WriteInt32(valueSize_);
30     status &= parcel.WriteInt32(valueNumber_);
31     status &= parcel.WriteString(valueStr_);
32     return status;
33 }
34 
Unmarshalling(Parcel & parcel)35 SaneControlParam* SaneControlParam::Unmarshalling(Parcel &parcel)
36 {
37     SaneControlParam* obj = new (std::nothrow) SaneControlParam();
38     if (obj == nullptr) {
39         SCAN_HILOGE("obj is a nullptr.");
40         return nullptr;
41     }
42     obj->option_ = parcel.ReadInt32();
43     obj->action_ = static_cast<SaneAction>(parcel.ReadInt32());
44     obj->valueType_ = parcel.ReadInt32();
45     obj->valueSize_ = parcel.ReadInt32();
46     obj->valueNumber_ = parcel.ReadInt32();
47     obj->valueStr_ = parcel.ReadString();
48     return obj;
49 }
50 }   // namespace OHOS::Scan