• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 UDMF_TLV_UTIL_H
17 #define UDMF_TLV_UTIL_H
18 
19 #include <type_traits>
20 
21 #include "application_defined_record.h"
22 #include "audio.h"
23 #include "file.h"
24 #include "folder.h"
25 #include "html.h"
26 #include "image.h"
27 #include "link.h"
28 #include "plain_text.h"
29 #include "system_defined_appitem.h"
30 #include "system_defined_form.h"
31 #include "system_defined_pixelmap.h"
32 #include "system_defined_record.h"
33 #include "text.h"
34 #include "tlv_object.h"
35 #include "unified_data.h"
36 #include "unified_key.h"
37 #include "unified_meta.h"
38 #include "unified_record.h"
39 #include "unified_types.h"
40 #include "video.h"
41 
42 namespace OHOS {
43 namespace TLVUtil {
44 using namespace OHOS::UDMF;
45 template<typename T>
46 bool CountBufferSize(const T &input, TLVObject &data);
47 
48 template<>
49 bool CountBufferSize(const std::shared_ptr<UnifiedRecord> &input, TLVObject &data);
50 
51 template<>
52 bool CountBufferSize(const Runtime &input, TLVObject &data);
53 
54 template<>
55 bool CountBufferSize(const UnifiedData &input, TLVObject &data);
56 
57 template<>
58 bool CountBufferSize(const std::vector<UnifiedData> &input, TLVObject &data);
59 
60 template<typename T>
61 bool Writing(const T &input, TLVObject &data);
62 template<typename T>
63 bool Reading(T &output, TLVObject &data);
64 
65 template<>
66 bool Writing(const int32_t &input, TLVObject &data);
67 template<>
68 bool Reading(int32_t &output, TLVObject &data);
69 
70 template<>
71 bool Writing(const int64_t &input, TLVObject &data);
72 template<>
73 bool Reading(int64_t &output, TLVObject &data);
74 
75 template<>
76 bool Writing(const bool &input, TLVObject &data);
77 template<>
78 bool Reading(bool &output, TLVObject &data);
79 
80 template<>
81 bool Reading(uint32_t &output, TLVObject &data);
82 
83 template<>
84 bool Writing(const uint32_t &input, TLVObject &data);
85 
86 template<>
87 bool Reading(uint64_t &output, TLVObject &data);
88 
89 template<>
90 bool Writing(const uint64_t &input, TLVObject &data);
91 
92 template<>
93 bool Writing(const std::string &input, TLVObject &data);
94 template<>
95 bool Reading(std::string &output, TLVObject &data);
96 
97 template<>
98 bool Writing(const std::vector<uint8_t> &input, TLVObject &data);
99 template<>
100 bool Reading(std::vector<uint8_t> &output, TLVObject &data);
101 
102 template<>
103 bool Writing(const UDVariant &input, TLVObject &data);
104 template<>
105 bool Reading(UDVariant &output, TLVObject &data);
106 
107 template<>
108 bool Writing(const UDDetails &input, TLVObject &data);
109 template<>
110 bool Reading(UDDetails &output, TLVObject &data);
111 
112 template<>
113 bool Writing(const UDType &input, TLVObject &data);
114 template<>
115 bool Reading(UDType &output, TLVObject &data);
116 
117 template<>
118 bool Writing(const Text &input, TLVObject &data);
119 template<>
120 bool Reading(Text &output, TLVObject &data);
121 
122 template<>
123 bool Writing(const PlainText &input, TLVObject &data);
124 template<>
125 bool Reading(PlainText &output, TLVObject &data);
126 
127 template<>
128 bool Writing(const Html &input, TLVObject &data);
129 template<>
130 bool Reading(Html &output, TLVObject &data);
131 
132 template<>
133 bool Writing(const Link &input, TLVObject &data);
134 template<>
135 bool Reading(Link &output, TLVObject &data);
136 
137 template<>
138 bool Writing(const File &input, TLVObject &data);
139 template<>
140 bool Reading(File &output, TLVObject &data);
141 
142 template<>
143 bool Writing(const Image &input, TLVObject &data);
144 template<>
145 bool Reading(Image &output, TLVObject &data);
146 
147 template<>
148 bool Writing(const Video &input, TLVObject &data);
149 template<>
150 bool Reading(Video &output, TLVObject &data);
151 
152 template<>
153 bool Writing(const Audio &input, TLVObject &data);
154 template<>
155 bool Reading(Audio &output, TLVObject &data);
156 
157 template<>
158 bool Writing(const Folder &input, TLVObject &data);
159 template<>
160 bool Reading(Folder &output, TLVObject &data);
161 
162 template<>
163 bool Writing(const SystemDefinedRecord &input, TLVObject &data);
164 template<>
165 bool Reading(SystemDefinedRecord &output, TLVObject &data);
166 
167 template<>
168 bool Writing(const SystemDefinedForm &input, TLVObject &data);
169 template<>
170 bool Reading(SystemDefinedForm &output, TLVObject &data);
171 
172 template<>
173 bool Writing(const SystemDefinedAppItem &input, TLVObject &data);
174 template<>
175 bool Reading(SystemDefinedAppItem &output, TLVObject &data);
176 
177 template<>
178 bool Writing(const SystemDefinedPixelMap &input, TLVObject &data);
179 template<>
180 bool Reading(SystemDefinedPixelMap &output, TLVObject &data);
181 
182 template<>
183 bool Writing(const ApplicationDefinedRecord &input, TLVObject &data);
184 template<>
185 bool Reading(ApplicationDefinedRecord &output, TLVObject &data);
186 
187 template<>
188 bool Writing(const std::shared_ptr<UnifiedRecord> &input, TLVObject &data);
189 template<>
190 bool Reading(std::shared_ptr<UnifiedRecord> &output, TLVObject &data);
191 
192 template<>
193 bool Writing(const UnifiedData &input, TLVObject &data);
194 template<>
195 bool Reading(UnifiedData &output, TLVObject &data);
196 
197 template<>
198 bool Writing(const std::vector<UnifiedData> &input, TLVObject &data);
199 template<>
200 bool Reading(std::vector<UnifiedData> &output, TLVObject &data);
201 
202 template<>
203 bool Writing(const UnifiedKey &input, TLVObject &data);
204 template<>
205 bool Reading(UnifiedKey &output, TLVObject &data);
206 
207 template<>
208 bool Writing(const Privilege &input, TLVObject &data);
209 template<>
210 bool Reading(Privilege &output, TLVObject &data);
211 
212 template<>
213 bool Writing(const DataStatus &input, TLVObject &data);
214 template<>
215 bool Reading(DataStatus &output, TLVObject &data);
216 
217 template<>
218 bool Writing(const Runtime &input, TLVObject &data);
219 template<>
220 bool Reading(Runtime &output, TLVObject &data);
221 } // namespace TLVUtil
222 } // namespace OHOS
223 #endif // UDMF_TLV_UTIL_H