/src/connectedhomeip/zzz_generated/app-common/clusters/UnitTesting/Structs.ipp
Line | Count | Source |
1 | | /* |
2 | | * |
3 | | * Copyright (c) 2022 Project CHIP Authors |
4 | | * |
5 | | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | | * you may not use this file except in compliance with the License. |
7 | | * You may obtain a copy of the License at |
8 | | * |
9 | | * http://www.apache.org/licenses/LICENSE-2.0 |
10 | | * |
11 | | * Unless required by applicable law or agreed to in writing, software |
12 | | * distributed under the License is distributed on an "AS IS" BASIS, |
13 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14 | | * See the License for the specific language governing permissions and |
15 | | * limitations under the License. |
16 | | */ |
17 | | |
18 | | // THIS FILE IS GENERATED BY ZAP |
19 | | // This file is generated from clusters-Structs.ipp.zapt |
20 | | |
21 | | #include <clusters/UnitTesting/Structs.h> |
22 | | |
23 | | #include <app/data-model/StructDecodeIterator.h> |
24 | | #include <app/data-model/WrappedStructEncoder.h> |
25 | | |
26 | | namespace chip { |
27 | | namespace app { |
28 | | namespace Clusters { |
29 | | namespace UnitTesting { |
30 | | namespace Structs { |
31 | | |
32 | | namespace SimpleStruct { |
33 | | CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const |
34 | 0 | { |
35 | 0 | DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
36 | 0 | encoder.Encode(to_underlying(Fields::kA), a); |
37 | 0 | encoder.Encode(to_underlying(Fields::kB), b); |
38 | 0 | encoder.Encode(to_underlying(Fields::kC), c); |
39 | 0 | encoder.Encode(to_underlying(Fields::kD), d); |
40 | 0 | encoder.Encode(to_underlying(Fields::kE), e); |
41 | 0 | encoder.Encode(to_underlying(Fields::kF), f); |
42 | 0 | encoder.Encode(to_underlying(Fields::kG), g); |
43 | 0 | encoder.Encode(to_underlying(Fields::kH), h); |
44 | 0 | encoder.Encode(to_underlying(Fields::kI), i); |
45 | 0 | return encoder.Finalize(); |
46 | 0 | } |
47 | | |
48 | | CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) |
49 | 0 | { |
50 | 0 | detail::StructDecodeIterator __iterator(reader); |
51 | 0 | while (true) |
52 | 0 | { |
53 | 0 | uint8_t __context_tag = 0; |
54 | 0 | CHIP_ERROR err = __iterator.Next(__context_tag); |
55 | 0 | VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
56 | 0 | ReturnErrorOnFailure(err); |
57 | | |
58 | 0 | if (__context_tag == to_underlying(Fields::kA)) |
59 | 0 | { |
60 | 0 | err = DataModel::Decode(reader, a); |
61 | 0 | } |
62 | 0 | else if (__context_tag == to_underlying(Fields::kB)) |
63 | 0 | { |
64 | 0 | err = DataModel::Decode(reader, b); |
65 | 0 | } |
66 | 0 | else if (__context_tag == to_underlying(Fields::kC)) |
67 | 0 | { |
68 | 0 | err = DataModel::Decode(reader, c); |
69 | 0 | } |
70 | 0 | else if (__context_tag == to_underlying(Fields::kD)) |
71 | 0 | { |
72 | 0 | err = DataModel::Decode(reader, d); |
73 | 0 | } |
74 | 0 | else if (__context_tag == to_underlying(Fields::kE)) |
75 | 0 | { |
76 | 0 | err = DataModel::Decode(reader, e); |
77 | 0 | } |
78 | 0 | else if (__context_tag == to_underlying(Fields::kF)) |
79 | 0 | { |
80 | 0 | err = DataModel::Decode(reader, f); |
81 | 0 | } |
82 | 0 | else if (__context_tag == to_underlying(Fields::kG)) |
83 | 0 | { |
84 | 0 | err = DataModel::Decode(reader, g); |
85 | 0 | } |
86 | 0 | else if (__context_tag == to_underlying(Fields::kH)) |
87 | 0 | { |
88 | 0 | err = DataModel::Decode(reader, h); |
89 | 0 | } |
90 | 0 | else if (__context_tag == to_underlying(Fields::kI)) |
91 | 0 | { |
92 | 0 | err = DataModel::Decode(reader, i); |
93 | 0 | } |
94 | |
|
95 | 0 | ReturnErrorOnFailure(err); |
96 | 0 | } |
97 | 0 | } |
98 | | |
99 | | } // namespace SimpleStruct |
100 | | |
101 | | namespace TestFabricScoped { |
102 | | CHIP_ERROR Type::EncodeForWrite(TLV::TLVWriter & aWriter, TLV::Tag aTag) const |
103 | 0 | { |
104 | 0 | return DoEncode(aWriter, aTag, NullOptional); |
105 | 0 | } |
106 | | |
107 | | CHIP_ERROR Type::EncodeForRead(TLV::TLVWriter & aWriter, TLV::Tag aTag, FabricIndex aAccessingFabricIndex) const |
108 | 0 | { |
109 | 0 | return DoEncode(aWriter, aTag, MakeOptional(aAccessingFabricIndex)); |
110 | 0 | } |
111 | | |
112 | | CHIP_ERROR Type::DoEncode(TLV::TLVWriter & aWriter, TLV::Tag aTag, const Optional<FabricIndex> & aAccessingFabricIndex) const |
113 | 0 | { |
114 | 0 | bool includeSensitive = !aAccessingFabricIndex.HasValue() || (aAccessingFabricIndex.Value() == fabricIndex); |
115 | |
|
116 | 0 | DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
117 | |
|
118 | 0 | if (includeSensitive) |
119 | 0 | { |
120 | 0 | encoder.Encode(to_underlying(Fields::kFabricSensitiveInt8u), fabricSensitiveInt8u); |
121 | 0 | } |
122 | 0 | if (includeSensitive) |
123 | 0 | { |
124 | 0 | encoder.Encode(to_underlying(Fields::kOptionalFabricSensitiveInt8u), optionalFabricSensitiveInt8u); |
125 | 0 | } |
126 | 0 | if (includeSensitive) |
127 | 0 | { |
128 | 0 | encoder.Encode(to_underlying(Fields::kNullableFabricSensitiveInt8u), nullableFabricSensitiveInt8u); |
129 | 0 | } |
130 | 0 | if (includeSensitive) |
131 | 0 | { |
132 | 0 | encoder.Encode(to_underlying(Fields::kNullableOptionalFabricSensitiveInt8u), nullableOptionalFabricSensitiveInt8u); |
133 | 0 | } |
134 | 0 | if (includeSensitive) |
135 | 0 | { |
136 | 0 | encoder.Encode(to_underlying(Fields::kFabricSensitiveCharString), fabricSensitiveCharString); |
137 | 0 | } |
138 | 0 | if (includeSensitive) |
139 | 0 | { |
140 | 0 | encoder.Encode(to_underlying(Fields::kFabricSensitiveStruct), fabricSensitiveStruct); |
141 | 0 | } |
142 | 0 | if (includeSensitive) |
143 | 0 | { |
144 | 0 | encoder.Encode(to_underlying(Fields::kFabricSensitiveInt8uList), fabricSensitiveInt8uList); |
145 | 0 | } |
146 | 0 | if (aAccessingFabricIndex.HasValue()) |
147 | 0 | { |
148 | 0 | encoder.Encode(to_underlying(Fields::kFabricIndex), fabricIndex); |
149 | 0 | } |
150 | |
|
151 | 0 | return encoder.Finalize(); |
152 | 0 | } |
153 | | |
154 | | CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) |
155 | 0 | { |
156 | 0 | detail::StructDecodeIterator __iterator(reader); |
157 | 0 | while (true) |
158 | 0 | { |
159 | 0 | uint8_t __context_tag = 0; |
160 | 0 | CHIP_ERROR err = __iterator.Next(__context_tag); |
161 | 0 | VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
162 | 0 | ReturnErrorOnFailure(err); |
163 | | |
164 | 0 | if (__context_tag == to_underlying(Fields::kFabricSensitiveInt8u)) |
165 | 0 | { |
166 | 0 | err = DataModel::Decode(reader, fabricSensitiveInt8u); |
167 | 0 | } |
168 | 0 | else if (__context_tag == to_underlying(Fields::kOptionalFabricSensitiveInt8u)) |
169 | 0 | { |
170 | 0 | err = DataModel::Decode(reader, optionalFabricSensitiveInt8u); |
171 | 0 | } |
172 | 0 | else if (__context_tag == to_underlying(Fields::kNullableFabricSensitiveInt8u)) |
173 | 0 | { |
174 | 0 | err = DataModel::Decode(reader, nullableFabricSensitiveInt8u); |
175 | 0 | } |
176 | 0 | else if (__context_tag == to_underlying(Fields::kNullableOptionalFabricSensitiveInt8u)) |
177 | 0 | { |
178 | 0 | err = DataModel::Decode(reader, nullableOptionalFabricSensitiveInt8u); |
179 | 0 | } |
180 | 0 | else if (__context_tag == to_underlying(Fields::kFabricSensitiveCharString)) |
181 | 0 | { |
182 | 0 | err = DataModel::Decode(reader, fabricSensitiveCharString); |
183 | 0 | } |
184 | 0 | else if (__context_tag == to_underlying(Fields::kFabricSensitiveStruct)) |
185 | 0 | { |
186 | 0 | err = DataModel::Decode(reader, fabricSensitiveStruct); |
187 | 0 | } |
188 | 0 | else if (__context_tag == to_underlying(Fields::kFabricSensitiveInt8uList)) |
189 | 0 | { |
190 | 0 | err = DataModel::Decode(reader, fabricSensitiveInt8uList); |
191 | 0 | } |
192 | 0 | else if (__context_tag == to_underlying(Fields::kFabricIndex)) |
193 | 0 | { |
194 | 0 | err = DataModel::Decode(reader, fabricIndex); |
195 | 0 | } |
196 | |
|
197 | 0 | ReturnErrorOnFailure(err); |
198 | 0 | } |
199 | 0 | } |
200 | | |
201 | | } // namespace TestFabricScoped |
202 | | |
203 | | namespace NullablesAndOptionalsStruct { |
204 | | CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const |
205 | 0 | { |
206 | 0 | DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
207 | 0 | encoder.Encode(to_underlying(Fields::kNullableInt), nullableInt); |
208 | 0 | encoder.Encode(to_underlying(Fields::kOptionalInt), optionalInt); |
209 | 0 | encoder.Encode(to_underlying(Fields::kNullableOptionalInt), nullableOptionalInt); |
210 | 0 | encoder.Encode(to_underlying(Fields::kNullableString), nullableString); |
211 | 0 | encoder.Encode(to_underlying(Fields::kOptionalString), optionalString); |
212 | 0 | encoder.Encode(to_underlying(Fields::kNullableOptionalString), nullableOptionalString); |
213 | 0 | encoder.Encode(to_underlying(Fields::kNullableStruct), nullableStruct); |
214 | 0 | encoder.Encode(to_underlying(Fields::kOptionalStruct), optionalStruct); |
215 | 0 | encoder.Encode(to_underlying(Fields::kNullableOptionalStruct), nullableOptionalStruct); |
216 | 0 | encoder.Encode(to_underlying(Fields::kNullableList), nullableList); |
217 | 0 | encoder.Encode(to_underlying(Fields::kOptionalList), optionalList); |
218 | 0 | encoder.Encode(to_underlying(Fields::kNullableOptionalList), nullableOptionalList); |
219 | 0 | return encoder.Finalize(); |
220 | 0 | } |
221 | | |
222 | | CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) |
223 | 0 | { |
224 | 0 | detail::StructDecodeIterator __iterator(reader); |
225 | 0 | while (true) |
226 | 0 | { |
227 | 0 | uint8_t __context_tag = 0; |
228 | 0 | CHIP_ERROR err = __iterator.Next(__context_tag); |
229 | 0 | VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
230 | 0 | ReturnErrorOnFailure(err); |
231 | | |
232 | 0 | if (__context_tag == to_underlying(Fields::kNullableInt)) |
233 | 0 | { |
234 | 0 | err = DataModel::Decode(reader, nullableInt); |
235 | 0 | } |
236 | 0 | else if (__context_tag == to_underlying(Fields::kOptionalInt)) |
237 | 0 | { |
238 | 0 | err = DataModel::Decode(reader, optionalInt); |
239 | 0 | } |
240 | 0 | else if (__context_tag == to_underlying(Fields::kNullableOptionalInt)) |
241 | 0 | { |
242 | 0 | err = DataModel::Decode(reader, nullableOptionalInt); |
243 | 0 | } |
244 | 0 | else if (__context_tag == to_underlying(Fields::kNullableString)) |
245 | 0 | { |
246 | 0 | err = DataModel::Decode(reader, nullableString); |
247 | 0 | } |
248 | 0 | else if (__context_tag == to_underlying(Fields::kOptionalString)) |
249 | 0 | { |
250 | 0 | err = DataModel::Decode(reader, optionalString); |
251 | 0 | } |
252 | 0 | else if (__context_tag == to_underlying(Fields::kNullableOptionalString)) |
253 | 0 | { |
254 | 0 | err = DataModel::Decode(reader, nullableOptionalString); |
255 | 0 | } |
256 | 0 | else if (__context_tag == to_underlying(Fields::kNullableStruct)) |
257 | 0 | { |
258 | 0 | err = DataModel::Decode(reader, nullableStruct); |
259 | 0 | } |
260 | 0 | else if (__context_tag == to_underlying(Fields::kOptionalStruct)) |
261 | 0 | { |
262 | 0 | err = DataModel::Decode(reader, optionalStruct); |
263 | 0 | } |
264 | 0 | else if (__context_tag == to_underlying(Fields::kNullableOptionalStruct)) |
265 | 0 | { |
266 | 0 | err = DataModel::Decode(reader, nullableOptionalStruct); |
267 | 0 | } |
268 | 0 | else if (__context_tag == to_underlying(Fields::kNullableList)) |
269 | 0 | { |
270 | 0 | err = DataModel::Decode(reader, nullableList); |
271 | 0 | } |
272 | 0 | else if (__context_tag == to_underlying(Fields::kOptionalList)) |
273 | 0 | { |
274 | 0 | err = DataModel::Decode(reader, optionalList); |
275 | 0 | } |
276 | 0 | else if (__context_tag == to_underlying(Fields::kNullableOptionalList)) |
277 | 0 | { |
278 | 0 | err = DataModel::Decode(reader, nullableOptionalList); |
279 | 0 | } |
280 | |
|
281 | 0 | ReturnErrorOnFailure(err); |
282 | 0 | } |
283 | 0 | } |
284 | | |
285 | | } // namespace NullablesAndOptionalsStruct |
286 | | |
287 | | namespace NestedStruct { |
288 | | CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const |
289 | 0 | { |
290 | 0 | DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
291 | 0 | encoder.Encode(to_underlying(Fields::kA), a); |
292 | 0 | encoder.Encode(to_underlying(Fields::kB), b); |
293 | 0 | encoder.Encode(to_underlying(Fields::kC), c); |
294 | 0 | encoder.Encode(to_underlying(Fields::kD), d); |
295 | 0 | return encoder.Finalize(); |
296 | 0 | } |
297 | | |
298 | | CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) |
299 | 0 | { |
300 | 0 | detail::StructDecodeIterator __iterator(reader); |
301 | 0 | while (true) |
302 | 0 | { |
303 | 0 | uint8_t __context_tag = 0; |
304 | 0 | CHIP_ERROR err = __iterator.Next(__context_tag); |
305 | 0 | VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
306 | 0 | ReturnErrorOnFailure(err); |
307 | | |
308 | 0 | if (__context_tag == to_underlying(Fields::kA)) |
309 | 0 | { |
310 | 0 | err = DataModel::Decode(reader, a); |
311 | 0 | } |
312 | 0 | else if (__context_tag == to_underlying(Fields::kB)) |
313 | 0 | { |
314 | 0 | err = DataModel::Decode(reader, b); |
315 | 0 | } |
316 | 0 | else if (__context_tag == to_underlying(Fields::kC)) |
317 | 0 | { |
318 | 0 | err = DataModel::Decode(reader, c); |
319 | 0 | } |
320 | 0 | else if (__context_tag == to_underlying(Fields::kD)) |
321 | 0 | { |
322 | 0 | err = DataModel::Decode(reader, d); |
323 | 0 | } |
324 | |
|
325 | 0 | ReturnErrorOnFailure(err); |
326 | 0 | } |
327 | 0 | } |
328 | | |
329 | | } // namespace NestedStruct |
330 | | |
331 | | namespace NestedStructList { |
332 | | CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const |
333 | 0 | { |
334 | 0 | DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
335 | 0 | encoder.Encode(to_underlying(Fields::kA), a); |
336 | 0 | encoder.Encode(to_underlying(Fields::kB), b); |
337 | 0 | encoder.Encode(to_underlying(Fields::kC), c); |
338 | 0 | encoder.Encode(to_underlying(Fields::kD), d); |
339 | 0 | encoder.Encode(to_underlying(Fields::kE), e); |
340 | 0 | encoder.Encode(to_underlying(Fields::kF), f); |
341 | 0 | encoder.Encode(to_underlying(Fields::kG), g); |
342 | 0 | return encoder.Finalize(); |
343 | 0 | } |
344 | | |
345 | | CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) |
346 | 0 | { |
347 | 0 | detail::StructDecodeIterator __iterator(reader); |
348 | 0 | while (true) |
349 | 0 | { |
350 | 0 | uint8_t __context_tag = 0; |
351 | 0 | CHIP_ERROR err = __iterator.Next(__context_tag); |
352 | 0 | VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
353 | 0 | ReturnErrorOnFailure(err); |
354 | | |
355 | 0 | if (__context_tag == to_underlying(Fields::kA)) |
356 | 0 | { |
357 | 0 | err = DataModel::Decode(reader, a); |
358 | 0 | } |
359 | 0 | else if (__context_tag == to_underlying(Fields::kB)) |
360 | 0 | { |
361 | 0 | err = DataModel::Decode(reader, b); |
362 | 0 | } |
363 | 0 | else if (__context_tag == to_underlying(Fields::kC)) |
364 | 0 | { |
365 | 0 | err = DataModel::Decode(reader, c); |
366 | 0 | } |
367 | 0 | else if (__context_tag == to_underlying(Fields::kD)) |
368 | 0 | { |
369 | 0 | err = DataModel::Decode(reader, d); |
370 | 0 | } |
371 | 0 | else if (__context_tag == to_underlying(Fields::kE)) |
372 | 0 | { |
373 | 0 | err = DataModel::Decode(reader, e); |
374 | 0 | } |
375 | 0 | else if (__context_tag == to_underlying(Fields::kF)) |
376 | 0 | { |
377 | 0 | err = DataModel::Decode(reader, f); |
378 | 0 | } |
379 | 0 | else if (__context_tag == to_underlying(Fields::kG)) |
380 | 0 | { |
381 | 0 | err = DataModel::Decode(reader, g); |
382 | 0 | } |
383 | |
|
384 | 0 | ReturnErrorOnFailure(err); |
385 | 0 | } |
386 | 0 | } |
387 | | |
388 | | } // namespace NestedStructList |
389 | | |
390 | | namespace DoubleNestedStructList { |
391 | | CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const |
392 | 0 | { |
393 | 0 | DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
394 | 0 | encoder.Encode(to_underlying(Fields::kA), a); |
395 | 0 | return encoder.Finalize(); |
396 | 0 | } |
397 | | |
398 | | CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) |
399 | 0 | { |
400 | 0 | detail::StructDecodeIterator __iterator(reader); |
401 | 0 | while (true) |
402 | 0 | { |
403 | 0 | uint8_t __context_tag = 0; |
404 | 0 | CHIP_ERROR err = __iterator.Next(__context_tag); |
405 | 0 | VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
406 | 0 | ReturnErrorOnFailure(err); |
407 | | |
408 | 0 | if (__context_tag == to_underlying(Fields::kA)) |
409 | 0 | { |
410 | 0 | err = DataModel::Decode(reader, a); |
411 | 0 | } |
412 | |
|
413 | 0 | ReturnErrorOnFailure(err); |
414 | 0 | } |
415 | 0 | } |
416 | | |
417 | | } // namespace DoubleNestedStructList |
418 | | |
419 | | namespace TestListStructOctet { |
420 | | CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const |
421 | 0 | { |
422 | 0 | DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
423 | 0 | encoder.Encode(to_underlying(Fields::kMember1), member1); |
424 | 0 | encoder.Encode(to_underlying(Fields::kMember2), member2); |
425 | 0 | return encoder.Finalize(); |
426 | 0 | } |
427 | | |
428 | | CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) |
429 | 0 | { |
430 | 0 | detail::StructDecodeIterator __iterator(reader); |
431 | 0 | while (true) |
432 | 0 | { |
433 | 0 | uint8_t __context_tag = 0; |
434 | 0 | CHIP_ERROR err = __iterator.Next(__context_tag); |
435 | 0 | VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
436 | 0 | ReturnErrorOnFailure(err); |
437 | | |
438 | 0 | if (__context_tag == to_underlying(Fields::kMember1)) |
439 | 0 | { |
440 | 0 | err = DataModel::Decode(reader, member1); |
441 | 0 | } |
442 | 0 | else if (__context_tag == to_underlying(Fields::kMember2)) |
443 | 0 | { |
444 | 0 | err = DataModel::Decode(reader, member2); |
445 | 0 | } |
446 | |
|
447 | 0 | ReturnErrorOnFailure(err); |
448 | 0 | } |
449 | 0 | } |
450 | | |
451 | | } // namespace TestListStructOctet |
452 | | } // namespace Structs |
453 | | } // namespace UnitTesting |
454 | | } // namespace Clusters |
455 | | } // namespace app |
456 | | } // namespace chip |