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 #define MLOG_TAG "Media_Cloud_Vo"
17
18 #include "media_operate_result_vo.h"
19
20 #include <sstream>
21
22 #include "media_itypes_utils.h"
23
24 namespace OHOS::Media::CloudSync {
25
Unmarshalling(MessageParcel & parcel)26 bool MediaOperateResultRespBodyResultNode::Unmarshalling(MessageParcel &parcel)
27 {
28 parcel.ReadString(this->cloudId);
29 parcel.ReadInt32(this->errorCode);
30 parcel.ReadString(this->errorMsg);
31 return true;
32 }
Marshalling(MessageParcel & parcel) const33 bool MediaOperateResultRespBodyResultNode::Marshalling(MessageParcel &parcel) const
34 {
35 parcel.WriteString(this->cloudId);
36 parcel.WriteInt32(this->errorCode);
37 parcel.WriteString(this->errorMsg);
38 return true;
39 }
40
ToString() const41 std::string MediaOperateResultRespBodyResultNode::ToString() const
42 {
43 std::stringstream ss;
44 ss << "{";
45 ss << "cloudId:" << this->cloudId << ",";
46 ss << "errorCode:" << this->errorCode << ",";
47 ss << "errorMsg:" << this->errorMsg;
48 ss << "}";
49 return ss.str();
50 }
51
Unmarshalling(MessageParcel & parcel)52 bool MediaOperateResultRespBody::Unmarshalling(MessageParcel &parcel)
53 {
54 IPC::ITypeMediaUtil::UnmarshallingParcelable<MediaOperateResultRespBodyResultNode>(this->result, parcel);
55 return true;
56 }
57
Marshalling(MessageParcel & parcel) const58 bool MediaOperateResultRespBody::Marshalling(MessageParcel &parcel) const
59 {
60 IPC::ITypeMediaUtil::MarshallingParcelable<MediaOperateResultRespBodyResultNode>(this->result, parcel);
61 return true;
62 }
63
GetFailSize() const64 int32_t MediaOperateResultRespBody::GetFailSize() const
65 {
66 int32_t failSize = 0;
67 for (auto &item : this->result) {
68 failSize += item.errorCode != 0 ? 1 : 0;
69 }
70 return failSize;
71 }
72
ToString() const73 std::string MediaOperateResultRespBody::ToString() const
74 {
75 std::stringstream ss;
76 ss << "[";
77 for (uint32_t i = 0; i < result.size(); ++i) {
78 ss << this->result[i].ToString();
79 if (i != result.size() - 1) {
80 ss << ",";
81 }
82 }
83 ss << "]";
84 return ss.str();
85 }
86 } // namespace OHOS::Media::CloudSync