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 OHOS_DISTRIBUTED_DATA_FRAMEWORKS_KVDB_KV_TYPES_UTIL_H
17 #define OHOS_DISTRIBUTED_DATA_FRAMEWORKS_KVDB_KV_TYPES_UTIL_H
18 #include "change_notification.h"
19 #include "kvdb_service.h"
20 #include "itypes_util.h"
21 #include "types.h"
22 namespace OHOS::ITypesUtil {
23 using Blob = DistributedKv::Blob;
24 using Key = DistributedKv::Key;
25 using Value = DistributedKv::Value;
26 using Entry = DistributedKv::Entry;
27 using AppId = DistributedKv::AppId;
28 using StoreId = DistributedKv::StoreId;
29 using DeviceInfo = DistributedKv::DeviceInfo;
30 using ChangeNotification = DistributedKv::ChangeNotification;
31 using Options = DistributedKv::Options;
32 using SyncPolicy = DistributedKv::SyncPolicy;
33 using TableDetail = DistributedKv::TableDetail;
34 using Statistic = DistributedKv::Statistic;
35 using ProgressDetail = DistributedKv::ProgressDetail;
36 using SwitchData = DistributedKv::SwitchData;
37 using Status = OHOS::DistributedKv::Status;
38 using Notification = OHOS::DistributedKv::SwitchNotification;
39 using SwitchState = OHOS::DistributedKv::SwitchState;
40 using CloudConfig = OHOS::DistributedKv::CloudConfig;
41 using StoreConfig = OHOS::DistributedKv::StoreConfig;
42 using AuthType = OHOS::DistributedKv::AuthType;
43 template<>
44 API_EXPORT bool Marshalling(const Blob &input, MessageParcel &data);
45 template<>
46 API_EXPORT bool Unmarshalling(Blob &output, MessageParcel &data);
47 
48 template<>
49 API_EXPORT bool Marshalling(const AppId &input, MessageParcel &data);
50 template<>
51 API_EXPORT bool Unmarshalling(AppId &output, MessageParcel &data);
52 
53 template<>
54 API_EXPORT bool Marshalling(const StoreId &input, MessageParcel &data);
55 template<>
56 API_EXPORT bool Unmarshalling(StoreId &output, MessageParcel &data);
57 
58 template<>
59 API_EXPORT bool Marshalling(const Entry &input, MessageParcel &data);
60 template<>
61 API_EXPORT bool Unmarshalling(Entry &output, MessageParcel &data);
62 
63 template<>
64 API_EXPORT bool Marshalling(const DeviceInfo &input, MessageParcel &data);
65 template<>
66 API_EXPORT bool Unmarshalling(DeviceInfo &output, MessageParcel &data);
67 
68 template<>
69 API_EXPORT bool Marshalling(const ChangeNotification &notification, MessageParcel &parcel);
70 template<>
71 API_EXPORT bool Unmarshalling(ChangeNotification &output, MessageParcel &parcel);
72 
73 template<>
74 API_EXPORT bool Marshalling(const Options &input, MessageParcel &data);
75 template<>
76 API_EXPORT bool Unmarshalling(Options &output, MessageParcel &data);
77 
78 template<>
79 API_EXPORT bool Marshalling(const SyncPolicy &input, MessageParcel &data);
80 template<>
81 API_EXPORT bool Unmarshalling(SyncPolicy &output, MessageParcel &data);
82 
83 template<>
84 API_EXPORT bool Marshalling(const SwitchData &input, MessageParcel &data);
85 template<>
86 API_EXPORT bool Unmarshalling(SwitchData &output, MessageParcel &data);
87 
88 template<>
89 API_EXPORT bool Marshalling(const Status &input, MessageParcel &data);
90 template<>
91 API_EXPORT bool Unmarshalling(Status &output, MessageParcel &data);
92 
93 template<>
94 API_EXPORT bool Marshalling(const Notification &input, MessageParcel &data);
95 template<>
96 API_EXPORT bool Unmarshalling(Notification &output, MessageParcel &data);
97 
98 template<>
99 API_EXPORT bool Marshalling(const ProgressDetail &input, MessageParcel &data);
100 template<>
101 API_EXPORT bool Unmarshalling(ProgressDetail &output, MessageParcel &data);
102 
103 template<>
104 API_EXPORT bool Marshalling(const TableDetail &input, MessageParcel &data);
105 template<>
106 API_EXPORT bool Unmarshalling(TableDetail &output, MessageParcel &data);
107 
108 template<>
109 API_EXPORT bool Marshalling(const Statistic &input, MessageParcel &data);
110 template<>
111 API_EXPORT bool Unmarshalling(Statistic &output, MessageParcel &data);
112 
113 template<>
114 API_EXPORT bool Marshalling(const CloudConfig &input, MessageParcel &data);
115 template<>
116 API_EXPORT bool Unmarshalling(CloudConfig &output, MessageParcel &data);
117 
118 template<>
119 API_EXPORT bool Marshalling(const StoreConfig &input, MessageParcel &data);
120 template<>
121 API_EXPORT bool Unmarshalling(StoreConfig &output, MessageParcel &data);
122 
123 template<>
124 API_EXPORT bool Marshalling(const AuthType &input, MessageParcel &data);
125 template<>
126 API_EXPORT bool Unmarshalling(AuthType &output, MessageParcel &data);
127 
128 int64_t GetTotalSize(const std::vector<Entry> &entries);
129 int64_t GetTotalSize(const std::vector<Key> &entries);
130 } // namespace OHOS::ITypesUtil
131 #endif // OHOS_DISTRIBUTED_DATA_FRAMEWORKS_KVDB_KV_TYPES_UTIL_H
132