1 /*
2  * Copyright (c) 2021-2024 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 "dummy_values_bucket.h"
17 #include "hilog_tag_wrapper.h"
18 #include "string_ex.h"
19 
20 namespace OHOS {
21 namespace AppExecFwk {
ValuesBucket(const std::string & testInf)22 ValuesBucket::ValuesBucket(const std::string &testInf) : testInf_(testInf)
23 {}
24 
25 /**
26  * @brief read this Sequenceable object from a Parcel.
27  *
28  * @param inParcel Indicates the Parcel object into which the Sequenceable object has been marshaled.
29  * @return Returns true if read succeeded; returns false otherwise.
30  */
ReadFromParcel(Parcel & parcel)31 bool ValuesBucket::ReadFromParcel(Parcel &parcel)
32 {
33     testInf_ = Str16ToStr8(parcel.ReadString16());
34     return true;
35 }
36 
37 /**
38  * @brief Unmarshals this Sequenceable object from a Parcel.
39  *
40  * @param inParcel Indicates the Parcel object into which the Sequenceable object has been marshaled.
41  */
Unmarshalling(Parcel & parcel)42 ValuesBucket ValuesBucket::Unmarshalling(Parcel &parcel)
43 {
44     ValuesBucket valuesBucket;
45     if (!valuesBucket.ReadFromParcel(parcel)) {
46         TAG_LOGE(AAFwkTag::DEFAULT, "ReadFromParcel failed");
47     }
48     return valuesBucket;
49 }
50 
51 /**
52  * @brief Marshals this Sequenceable object into a Parcel.
53  *
54  * @param outParcel Indicates the Parcel object to which the Sequenceable object will be marshaled.
55  */
Marshalling(Parcel & parcel) const56 bool ValuesBucket::Marshalling(Parcel &parcel) const
57 {
58     if (!parcel.WriteString16(Str8ToStr16(testInf_))) {
59         TAG_LOGE(AAFwkTag::DEFAULT, "WriteString16 failed");
60         return false;
61     }
62     return true;
63 }
64 }  // namespace AppExecFwk
65 }  // namespace OHOS
66