1 /*
2  * Copyright (C) 2021-2022 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 "bluetooth_log.h"
17 #include "bluetooth_raw_address.h"
18 
19 namespace OHOS {
20 namespace Bluetooth {
Marshalling(Parcel & parcel) const21 bool BluetoothRawAddress::Marshalling(Parcel &parcel) const
22 {
23     if (!parcel.WriteString(address_)) {
24         return false;
25     }
26     return true;
27 }
28 
Unmarshalling(Parcel & parcel)29 BluetoothRawAddress *BluetoothRawAddress::Unmarshalling(Parcel &parcel)
30 {
31     BluetoothRawAddress *rawAddress = new BluetoothRawAddress();
32     if (rawAddress != nullptr && !rawAddress->ReadFromParcel(parcel)) {
33         delete rawAddress;
34         rawAddress = nullptr;
35     }
36     return rawAddress;
37 }
38 
WriteToParcel(Parcel & parcel)39 bool BluetoothRawAddress::WriteToParcel(Parcel &parcel)
40 {
41     return Marshalling(parcel);
42 }
43 
ReadFromParcel(Parcel & parcel)44 bool BluetoothRawAddress::ReadFromParcel(Parcel &parcel)
45 {
46     if (!parcel.ReadString(address_)) {
47         return false;
48     }
49     return true;
50 }
51 }  // namespace Bluetooth
52 }  // namespace OHOS
53