• 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 #include "tlv_util.h"
16 
17 #include "logger.h"
18 
19 namespace OHOS {
20 namespace TLVUtil {
CountBufferSize(const std::nullptr_t & input,TLVObject & data)21 template <> size_t CountBufferSize(const std::nullptr_t &input, TLVObject &data)
22 {
23     return sizeof(TLVHead);
24 }
25 
Writing(const std::nullptr_t & input,TLVObject & data,TAG tag)26 template <> bool Writing(const std::nullptr_t &input, TLVObject &data, TAG tag)
27 {
28     return true;
29 }
30 
Reading(std::nullptr_t & output,TLVObject & data,const TLVHead & head)31 template <> bool Reading(std::nullptr_t &output, TLVObject &data, const TLVHead &head)
32 {
33     return true;
34 }
35 
CountBufferSize(const std::monostate & input,TLVObject & data)36 template <> size_t CountBufferSize(const std::monostate &input, TLVObject &data)
37 {
38     return sizeof(TLVHead);
39 }
40 
Writing(const std::monostate & input,TLVObject & data,TAG tag)41 template <> bool Writing(const std::monostate &input, TLVObject &data, TAG tag)
42 {
43     return true;
44 }
45 
Reading(std::monostate & output,TLVObject & data,const TLVHead & head)46 template <> bool Reading(std::monostate &output, TLVObject &data, const TLVHead &head)
47 {
48     return true;
49 }
50 
CountBufferSize(const std::string & input,TLVObject & data)51 template <> size_t CountBufferSize(const std::string &input, TLVObject &data)
52 {
53     return sizeof(TLVHead);
54 }
55 
Writing(const std::string & input,TLVObject & data,TAG tag)56 template <> bool Writing(const std::string &input, TLVObject &data, TAG tag)
57 {
58     return true;
59 }
60 
Reading(std::string & output,TLVObject & data,const TLVHead & head)61 template <> bool Reading(std::string &output, TLVObject &data, const TLVHead &head)
62 {
63     return true;
64 }
65 
CountBufferSize(const std::vector<uint8_t> & input,TLVObject & data)66 template <> size_t CountBufferSize(const std::vector<uint8_t> &input, TLVObject &data)
67 {
68     return sizeof(TLVHead);
69 }
70 
Writing(const std::vector<uint8_t> & input,TLVObject & data,TAG tag)71 template <> bool Writing(const std::vector<uint8_t> &input, TLVObject &data, TAG tag)
72 {
73     return true;
74 }
75 
Reading(std::vector<uint8_t> & output,TLVObject & data,const TLVHead & head)76 template <> bool Reading(std::vector<uint8_t> &output, TLVObject &data, const TLVHead &head)
77 {
78     return true;
79 }
80 
CountBufferSize(const UDType & input,TLVObject & data)81 template <> size_t CountBufferSize(const UDType &input, TLVObject &data)
82 {
83     return sizeof(TLVHead);
84 }
85 
Writing(const UDType & input,TLVObject & data,TAG tag)86 template <> bool Writing(const UDType &input, TLVObject &data, TAG tag)
87 {
88     return true;
89 }
90 
Reading(UDType & output,TLVObject & data,const TLVHead & head)91 template <> bool Reading(UDType &output, TLVObject &data, const TLVHead &head)
92 {
93     return true;
94 }
95 
CountBufferSize(const DataStatus & input,TLVObject & data)96 template <> size_t CountBufferSize(const DataStatus &input, TLVObject &data)
97 {
98     return sizeof(TLVHead);
99 }
100 
Writing(const DataStatus & input,TLVObject & data,TAG tag)101 template <> bool Writing(const DataStatus &input, TLVObject &data, TAG tag)
102 {
103     return true;
104 }
105 
Reading(DataStatus & output,TLVObject & data,const TLVHead & head)106 template <> bool Reading(DataStatus &output, TLVObject &data, const TLVHead &head)
107 {
108     return true;
109 }
110 
CountBufferSize(const Object & input,TLVObject & data)111 template <> size_t CountBufferSize(const Object &input, TLVObject &data)
112 {
113     return sizeof(TLVHead);
114 }
115 
Writing(const Object & input,TLVObject & data,TAG tag)116 template <> bool Writing(const Object &input, TLVObject &data, TAG tag)
117 {
118     return true;
119 }
Reading(Object & output,TLVObject & data,const TLVHead & head)120 template <> bool Reading(Object &output, TLVObject &data, const TLVHead &head)
121 {
122     return true;
123 }
124 
CountBufferSize(const UnifiedKey & input,TLVObject & data)125 template <> size_t CountBufferSize(const UnifiedKey &input, TLVObject &data)
126 {
127     return sizeof(TLVHead);
128 }
Writing(const UnifiedKey & input,TLVObject & data,TAG tag)129 template <> bool Writing(const UnifiedKey &input, TLVObject &data, TAG tag)
130 {
131     return true;
132 }
133 
Reading(UnifiedKey & output,TLVObject & data,const TLVHead & head)134 template <> bool Reading(UnifiedKey &output, TLVObject &data, const TLVHead &head)
135 {
136     return true;
137 }
138 
CountBufferSize(const UnifiedData & input,TLVObject & data)139 template <> size_t CountBufferSize(const UnifiedData &input, TLVObject &data)
140 {
141     return sizeof(TLVHead);
142 }
143 
Writing(const UnifiedData & input,TLVObject & data,TAG tag)144 template <> bool Writing(const UnifiedData &input, TLVObject &data, TAG tag)
145 {
146     return false;
147 }
148 
Reading(UnifiedData & output,TLVObject & data,const TLVHead & head)149 template <> bool Reading(UnifiedData &output, TLVObject &data, const TLVHead &head)
150 {
151     return false;
152 }
153 
CountBufferSize(const UnifiedRecord & input,TLVObject & data)154 template <> size_t CountBufferSize(const UnifiedRecord &input, TLVObject &data)
155 {
156     return sizeof(TLVHead);
157 }
158 
Writing(const UnifiedRecord & input,TLVObject & data,TAG tag)159 template <> bool Writing(const UnifiedRecord &input, TLVObject &data, TAG tag)
160 {
161     return true;
162 }
163 
Reading(UnifiedRecord & output,TLVObject & data,const TLVHead & head)164 template <> bool Reading(UnifiedRecord &output, TLVObject &data, const TLVHead &head)
165 {
166     return true;
167 }
168 
CountBufferSize(const Runtime & input,TLVObject & data)169 template <> size_t CountBufferSize(const Runtime &input, TLVObject &data)
170 {
171     return sizeof(TLVHead);
172 }
173 
Writing(const Runtime & input,TLVObject & data,TAG tag)174 template <> bool Writing(const Runtime &input, TLVObject &data, TAG tag)
175 {
176     return true;
177 }
178 
Reading(Runtime & output,TLVObject & data,const TLVHead & head)179 template <> bool Reading(Runtime &output, TLVObject &data, const TLVHead &head)
180 {
181     return true;
182 }
183 
CountBufferSize(const Privilege & input,TLVObject & data)184 template <> size_t CountBufferSize(const Privilege &input, TLVObject &data)
185 {
186     return sizeof(TLVHead);
187 }
188 
Writing(const Privilege & input,TLVObject & data,TAG tag)189 template <> bool Writing(const Privilege &input, TLVObject &data, TAG tag)
190 {
191     return true;
192 }
193 
Reading(Privilege & output,TLVObject & data,const TLVHead & head)194 template <> bool Reading(Privilege &output, TLVObject &data, const TLVHead &head)
195 {
196     return true;
197 }
198 
CountBufferSize(const std::shared_ptr<OHOS::Media::PixelMap> & input,TLVObject & data)199 template <> size_t CountBufferSize(const std::shared_ptr<OHOS::Media::PixelMap> &input, TLVObject &data)
200 {
201     return sizeof(TLVHead);
202 }
203 
Writing(const std::shared_ptr<OHOS::Media::PixelMap> & input,TLVObject & data,TAG tag)204 template <> bool Writing(const std::shared_ptr<OHOS::Media::PixelMap> &input, TLVObject &data, TAG tag)
205 {
206     return true;
207 }
208 
Reading(std::shared_ptr<OHOS::Media::PixelMap> & output,TLVObject & data,const TLVHead & head)209 template <> bool Reading(std::shared_ptr<OHOS::Media::PixelMap> &output, TLVObject &data, const TLVHead &head)
210 {
211     return true;
212 }
213 
CountBufferSize(const std::shared_ptr<OHOS::AAFwk::Want> & input,TLVObject & data)214 template <> size_t CountBufferSize(const std::shared_ptr<OHOS::AAFwk::Want> &input, TLVObject &data)
215 {
216     return sizeof(TLVHead);
217 }
218 
Writing(const std::shared_ptr<OHOS::AAFwk::Want> & input,TLVObject & data,TAG tag)219 template <> bool Writing(const std::shared_ptr<OHOS::AAFwk::Want> &input, TLVObject &data, TAG tag)
220 {
221     return true;
222 }
223 
224 
Reading(std::shared_ptr<OHOS::AAFwk::Want> & output,TLVObject & data,const TLVHead & head)225 template <> bool Reading(std::shared_ptr<OHOS::AAFwk::Want> &output, TLVObject &data, const TLVHead &head)
226 {
227     return true;
228 }
229 
230 
231 } // namespace TLVUtil
232 } // namespace OHOS
233