• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 "app_log_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 = new (std::nothrow) ValuesBucket();
45     if (valuesBucket && !valuesBucket->ReadFromParcel(parcel)) {
46         APP_LOGE("ValuesBucket::Unmarshalling ReadFromParcel failed");
47         delete valuesBucket;
48         valuesBucket = nullptr;
49     }
50     return valuesBucket;
51 }
52 
53 /**
54  * @brief Marshals this Sequenceable object into a Parcel.
55  *
56  * @param outParcel Indicates the Parcel object to which the Sequenceable object will be marshaled.
57  */
Marshalling(Parcel & parcel) const58 bool ValuesBucket::Marshalling(Parcel &parcel) const
59 {
60     if (!parcel.WriteString16(Str8ToStr16(testInf_))) {
61         APP_LOGE("valuesBucket::Marshalling WriteString16 failed");
62         return false;
63     }
64     return true;
65 }
66 }  // namespace AppExecFwk
67 }  // namespace OHOS