1 /* 2 * Copyright (c) 2022-2023 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 "parcel.h" 17 18 namespace OHOS { 19 using namespace std; WriteInt32(int32_t value)20bool Parcel::WriteInt32(int32_t value) 21 { 22 if (value == 0) { 23 return false; 24 } 25 return true; 26 } 27 WriteUint32(uint32_t value)28bool Parcel::WriteUint32(uint32_t value) 29 { 30 if (value == 0) { 31 return false; 32 } 33 return true; 34 } 35 WriteInt64(int64_t value)36bool Parcel::WriteInt64(int64_t value) 37 { 38 if (value == 0) { 39 return false; 40 } 41 return true; 42 } 43 WriteString(const std::string & value)44bool Parcel::WriteString(const std::string &value) 45 { 46 if (value == "continue") { 47 return true; 48 } 49 return false; 50 } 51 WriteBool(bool value)52bool Parcel::WriteBool(bool value) 53 { 54 if (value == false) { 55 return false; 56 } 57 return true; 58 } 59 WriteParcelable(const Parcelable *)60bool Parcel::WriteParcelable(const Parcelable *) 61 { 62 return true; 63 } 64 ReadInt32(int32_t & value)65bool Parcel::ReadInt32(int32_t &value) 66 { 67 value = Parcel::readCursor_; 68 if (Parcel::readCursor_ == 0) { 69 return false; 70 } 71 return true; 72 } 73 ReadUint32(uint32_t & value)74bool Parcel::ReadUint32(uint32_t &value) 75 { 76 value = Parcel::dataSize_; 77 if (Parcel::dataSize_ == 0) { 78 return false; 79 } 80 return true; 81 } 82 ReadInt64(int64_t & value)83bool Parcel::ReadInt64(int64_t &value) 84 { 85 if (value == 0) { 86 return false; 87 } 88 return true; 89 } 90 ReadString(string & value)91bool Parcel::ReadString(string &value) 92 { 93 if (Parcel::data_ == nullptr) { 94 return false; 95 } 96 return true; 97 } 98 ReadBool(bool & value)99bool Parcel::ReadBool(bool &value) 100 { 101 value = Parcel::writable_; 102 if (value == false) { 103 return false; 104 } 105 return true; 106 } 107 } // namespace OHOS::FileManagement::Backup 108