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_device.h" 18 #include "scan_log.h" 19 20 namespace OHOS::Scan { Marshalling(Parcel & parcel) const21bool SaneDevice::Marshalling(Parcel &parcel) const 22 { 23 bool status = true; 24 status &= parcel.WriteString(name_); 25 status &= parcel.WriteString(vendor_); 26 status &= parcel.WriteString(model_); 27 status &= parcel.WriteString(type_); 28 return status; 29 } 30 Unmarshalling(Parcel & parcel)31SaneDevice* SaneDevice::Unmarshalling(Parcel &parcel) 32 { 33 SaneDevice* obj = new (std::nothrow) SaneDevice(); 34 if (obj == nullptr) { 35 SCAN_HILOGE("obj is a nullptr."); 36 return nullptr; 37 } 38 obj->name_ = parcel.ReadString(); 39 obj->vendor_ = parcel.ReadString(); 40 obj->model_ = parcel.ReadString(); 41 obj->type_ = parcel.ReadString(); 42 return obj; 43 } 44 Dump()45void SaneDevice::Dump() 46 { 47 SCAN_HILOGD("SaneDevice:[%{private}s] [%{private}s] [%{private}s] [%{private}s]", 48 name_.c_str(), vendor_.c_str(), model_.c_str(), type_.c_str()); 49 } 50 } // namespace OHOS::Scan