1 /* 2 * Copyright (c) 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 #ifndef FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_UTILS_IPC_UTIL_H 17 #define FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_UTILS_IPC_UTIL_H 18 19 #include <iremote_object.h> 20 #include <iservice_registry.h> 21 #include <string_ex.h> 22 23 namespace OHOS { 24 namespace DevStandbyMgr { 25 #define READ_PARCEL(in, type, data) \ 26 do { \ 27 if (!(in).Read##type(data)) { \ 28 STANDBYSERVICE_LOGE("Failed to read "#data); \ 29 return; \ 30 } \ 31 } while (0) 32 33 #define READ_PARCEL_WITH_RET(in, type, data, ret) \ 34 do { \ 35 if (!(in).Read##type(data)) { \ 36 STANDBYSERVICE_LOGE("Failed to read "#data); \ 37 return (ret); \ 38 } \ 39 } while (0) 40 41 #define WRITE_PARCEL(out, type, data) \ 42 do { \ 43 if (!(out).Write##type(data)) { \ 44 STANDBYSERVICE_LOGE("Failed to write "#data); \ 45 return; \ 46 } \ 47 } while (0) 48 49 #define WRITE_PARCEL_WITH_RET(out, type, data, ret) \ 50 do { \ 51 if (!(out).Write##type(data)) { \ 52 STANDBYSERVICE_LOGE("Failed to write "#data); \ 53 return (ret); \ 54 } \ 55 } while (0) 56 57 }; // namespace DevStandbyMgr 58 }; // namespace OHOS 59 #endif // FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_UTILS_IPC_UTIL_H 60