1 /* 2 * Copyright (c) 2022 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 #ifndef DATASHARE_COMMON_ITYPES_UTIL_H 17 #define DATASHARE_COMMON_ITYPES_UTIL_H 18 19 #include "dataproxy_handle_common.h" 20 #include "datashare_operation_statement.h" 21 #include "datashare_common.h" 22 #include "datashare_predicates.h" 23 #include "datashare_template.h" 24 #include "datashare_value_object.h" 25 #include "datashare_values_bucket.h" 26 #include "itypes_util.h" 27 #include "uri.h" 28 29 namespace OHOS::ITypesUtil { 30 using Predicates = DataShare::DataSharePredicates; 31 using Operation = DataShare::OperationItem; 32 using PublishedDataItem = DataShare::PublishedDataItem; 33 using Data = DataShare::Data; 34 using TemplateId = DataShare::TemplateId; 35 using PredicateTemplateNode = DataShare::PredicateTemplateNode; 36 using RdbChangeNode = DataShare::RdbChangeNode; 37 using PublishedDataChangeNode = DataShare::PublishedDataChangeNode; 38 using OperationResult = DataShare::OperationResult; 39 using DataShareValuesBucket = DataShare::DataShareValuesBucket; 40 using AshmemNode = DataShare::AshmemNode; 41 using OperationStatement = DataShare::OperationStatement; 42 using ExecResult = DataShare::ExecResult; 43 using ExecResultSet = DataShare::ExecResultSet; 44 using UpdateOperation = DataShare::UpdateOperation; 45 using BatchUpdateResult = DataShare::BatchUpdateResult; 46 using DataShareProxyData = DataShare::DataShareProxyData; 47 using DataProxyConfig = DataShare::DataProxyConfig; 48 using DataProxyType = DataShare::DataProxyType; 49 using DataProxyResult = DataShare::DataProxyResult; 50 using DataProxyErrorCode = DataShare::DataProxyErrorCode; 51 using DataShareValueObject = DataShare::DataShareValueObject; 52 using DataProxyValue = DataShare::DataProxyValue; 53 using DataProxyGetResult = DataShare::DataProxyGetResult; 54 using DataProxyChangeInfo = DataShare::DataProxyChangeInfo; 55 using UriInfo = DataShare::UriInfo; 56 using RegisterOption = DataShare::RegisterOption; 57 58 template<> 59 bool Marshalling(const BatchUpdateResult &result, MessageParcel &parcel); 60 61 template<> 62 bool Unmarshalling(BatchUpdateResult &result, MessageParcel &parcel); 63 64 template<> 65 bool Marshalling(const UpdateOperation &operation, MessageParcel &parcel); 66 67 template<> 68 bool Unmarshalling(UpdateOperation &operation, MessageParcel &parcel); 69 70 template<> 71 bool Marshalling(const Predicates &bucket, MessageParcel &parcel); 72 73 template<> 74 bool Unmarshalling(Predicates &predicates, MessageParcel &parcel); 75 76 template<> 77 bool Marshalling(const Operation &operation, MessageParcel &parcel); 78 79 template<> 80 bool Unmarshalling(Operation &operation, MessageParcel &parcel); 81 82 template<> 83 bool Unmarshalling(PublishedDataItem &dataItem, MessageParcel &parcel); 84 85 template<> 86 bool Unmarshalling(PublishedDataItem &dataItem, MessageParcel &parcel); 87 88 template<> 89 bool Marshalling(const PublishedDataItem &templateId, MessageParcel &parcel); 90 91 template<> 92 bool Marshalling(const Data &data, MessageParcel &parcel); 93 94 template<> 95 bool Unmarshalling(Data &data, MessageParcel &parcel); 96 97 template<> 98 bool Marshalling(const DataShareValuesBucket &bucket, MessageParcel &parcel); 99 100 template<> 101 bool Unmarshalling(DataShareValuesBucket &bucket, MessageParcel &parcel); 102 103 template<> 104 bool Marshalling(const AshmemNode &node, MessageParcel &parcel); 105 106 template<> 107 bool Unmarshalling(AshmemNode &node, MessageParcel &parcel); 108 109 template<> 110 bool Marshalling(const Uri &node, MessageParcel &parcel); 111 112 template<> 113 bool Unmarshalling(Uri &node, MessageParcel &parcel); 114 115 template<> 116 bool Unmarshalling(TemplateId &templateId, MessageParcel &parcel); 117 118 template<> 119 bool Marshalling(const PredicateTemplateNode &predicateTemplateNode, MessageParcel &parcel); 120 121 template<> 122 bool Unmarshalling(PredicateTemplateNode &predicateTemplateNode, MessageParcel &parcel); 123 124 template<> 125 bool Marshalling(const RdbChangeNode &changeNode, MessageParcel &parcel); 126 127 template<> 128 bool Unmarshalling(RdbChangeNode &changeNode, MessageParcel &parcel); 129 130 template<> 131 bool Marshalling(const PublishedDataChangeNode &changeNode, MessageParcel &parcel); 132 133 template<> 134 bool Unmarshalling(PublishedDataChangeNode &changeNode, MessageParcel &parcel); 135 136 template<> 137 bool Marshalling(const OperationResult &operationResult, MessageParcel &parcel); 138 139 template<> 140 bool Unmarshalling(OperationResult &predicateTemplateNode, MessageParcel &parcel); 141 142 template<> 143 bool Marshalling(const TemplateId &changeNode, MessageParcel &parcel); 144 145 template<> 146 bool Marshalling(const OperationStatement &operationStatement, MessageParcel &parcel); 147 148 template<> 149 bool Unmarshalling(OperationStatement &operationStatement, MessageParcel &parcel); 150 151 template<> 152 bool Marshalling(const ExecResult &execResult, MessageParcel &parcel); 153 154 template<> 155 bool Unmarshalling(ExecResult &execResult, MessageParcel &parcel); 156 157 template<> 158 bool Marshalling(const ExecResultSet &execResultSet, MessageParcel &parcel); 159 160 template<> 161 bool Unmarshalling(ExecResultSet &execResultSet, MessageParcel &parcel); 162 163 /** 164 * @brief The following four functions are used for serializing and deserializing objects 165 * to and from shared memory during Query and BatchInsert operations, 166 * which has a 128M upper limit. The upper limit of other method is 200k. 167 * Other methods remain unchanged. 168 */ 169 bool MarshalPredicates(const Predicates &predicates, MessageParcel &parcel); 170 171 bool UnmarshalPredicates(Predicates &predicates, MessageParcel &parcel); 172 173 bool MarshalValuesBucketVec(const std::vector<DataShareValuesBucket> &values, MessageParcel &parcel); 174 175 bool UnmarshalValuesBucketVec(std::vector<DataShareValuesBucket> &values, MessageParcel &parcel); 176 177 template<> 178 bool Marshalling(const DataShareProxyData &proxyData, MessageParcel &parcel); 179 180 template<> 181 bool Unmarshalling(DataShareProxyData &proxyData, MessageParcel &parcel); 182 183 template<> 184 bool Marshalling(const DataProxyConfig &proxyData, MessageParcel &parcel); 185 186 template<> 187 bool Unmarshalling(DataProxyConfig &proxyData, MessageParcel &parcel); 188 189 template<> 190 bool Marshalling(const DataProxyResult &result, MessageParcel &parcel); 191 192 template<> 193 bool Unmarshalling(DataProxyResult &result, MessageParcel &parcel); 194 195 template<> 196 bool Marshalling(const DataShareValueObject &result, MessageParcel &parcel); 197 198 template<> 199 bool Unmarshalling(DataShareValueObject &result, MessageParcel &parcel); 200 201 template<> 202 bool Marshalling(const DataProxyValue &result, MessageParcel &parcel); 203 204 template<> 205 bool Unmarshalling(DataProxyValue &result, MessageParcel &parcel); 206 207 template<> 208 bool Marshalling(const DataProxyGetResult &result, MessageParcel &parcel); 209 210 template<> 211 bool Unmarshalling(DataProxyGetResult &result, MessageParcel &parcel); 212 213 template<> 214 bool Marshalling(const DataProxyChangeInfo &result, MessageParcel &parcel); 215 216 template<> 217 bool Unmarshalling(DataProxyChangeInfo &result, MessageParcel &parcel); 218 219 template<> 220 bool Marshalling(const UriInfo &result, MessageParcel &parcel); 221 222 template<> 223 bool Unmarshalling(UriInfo &result, MessageParcel &parcel); 224 225 template<> 226 bool Marshalling(const RegisterOption &option, MessageParcel &parcel); 227 228 template<> 229 bool Unmarshalling(RegisterOption &option, MessageParcel &parcel); 230 } 231 #endif 232