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_result_set.h" 17 #include "app_log_wrapper.h" 18 #include "string_ex.h" 19 20 namespace OHOS { 21 namespace AppExecFwk { ResultSet(const std::string & testInf)22ResultSet::ResultSet(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)31bool ResultSet::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)42ResultSet *ResultSet::Unmarshalling(Parcel &parcel) 43 { 44 ResultSet *resultSet = new (std::nothrow) ResultSet(); 45 if (resultSet && !resultSet->ReadFromParcel(parcel)) { 46 APP_LOGE("ResultSet::Unmarshalling ReadFromParcel failed"); 47 delete resultSet; 48 resultSet = nullptr; 49 } 50 return resultSet; 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) const58bool ResultSet::Marshalling(Parcel &parcel) const 59 { 60 if (!parcel.WriteString16(Str8ToStr16(testInf_))) { 61 APP_LOGE("ResultSet::Marshalling WriteString16 failed"); 62 return false; 63 } 64 return true; 65 } 66 } // namespace AppExecFwk 67 } // namespace OHOS