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 FRAMEWORKS_INPUTMETHOD_CONTROLLER_INCLUDE_ITYPES_UTIL_H
17 #define FRAMEWORKS_INPUTMETHOD_CONTROLLER_INCLUDE_ITYPES_UTIL_H
18
19 #include <climits>
20 #include <map>
21 #include <memory>
22
23 #include "element_name.h"
24 #include "global.h"
25 #include "input_client_info.h"
26 #include "input_window_info.h"
27 #include "message_parcel.h"
28 #include "panel_info.h"
29 #include "sys_panel_status.h"
30
31 namespace OHOS {
32 namespace MiscServices {
33 class ITypesUtil final {
34 public:
35 static bool Marshal(MessageParcel &data);
36 static bool Unmarshal(MessageParcel &data);
37
38 static bool Marshalling(int32_t input, MessageParcel &data);
39 static bool Unmarshalling(int32_t &output, MessageParcel &data);
40
41 static bool Marshalling(const std::string &input, MessageParcel &data);
42 static bool Unmarshalling(std::string &output, MessageParcel &data);
43
44 template<typename T, typename... Types>
45 static bool Marshal(MessageParcel &parcel, const T &first, const Types &...others);
46 template<typename T, typename... Types>
47 static bool Unmarshal(MessageParcel &parcel, T &first, Types &...others);
48 };
49
50 template<typename T, typename... Types>
Marshal(MessageParcel & parcel,const T & first,const Types &...others)51 bool ITypesUtil::Marshal(MessageParcel &parcel, const T &first, const Types &...others)
52 {
53 if (!Marshalling(first, parcel)) {
54 return false;
55 }
56 return Marshal(parcel, others...);
57 }
58
59 template<typename T, typename... Types>
Unmarshal(MessageParcel & parcel,T & first,Types &...others)60 bool ITypesUtil::Unmarshal(MessageParcel &parcel, T &first, Types &...others)
61 {
62 if (!Unmarshalling(first, parcel)) {
63 return false;
64 }
65 return Unmarshal(parcel, others...);
66 }
67 } // namespace MiscServices
68 } // namespace OHOS
69 #endif
70