Line | Count | Source |
1 | | #ifndef ZSERIO_TYPE_INFO_INC_H |
2 | | #define ZSERIO_TYPE_INFO_INC_H |
3 | | |
4 | | #include <algorithm> |
5 | | #include <memory> |
6 | | #include <string> |
7 | | |
8 | | #include "zserio/AnyHolder.h" |
9 | | #include "zserio/BitBuffer.h" |
10 | | #include "zserio/CppRuntimeException.h" |
11 | | #include "zserio/ITypeInfo.h" |
12 | | |
13 | | namespace zserio |
14 | | { |
15 | | |
16 | | /** |
17 | | * Type information abstract base class. |
18 | | * |
19 | | * This base class implements fully the methods getSchemaName(), getSchemaName() and getCppType(). All other |
20 | | * interface methods just throw an exception. |
21 | | */ |
22 | | template <typename ALLOC> |
23 | | class TypeInfoBase : public IBasicTypeInfo<ALLOC> |
24 | | { |
25 | | public: |
26 | | /** |
27 | | * Constructor. |
28 | | * |
29 | | * \param schemaName The schema name to be stored in type information. |
30 | | * \param schemaType The schema type to be stored in type information. |
31 | | * \param cppType The C++ type to be stored in type information. |
32 | | */ |
33 | | TypeInfoBase(StringView schemaName, SchemaType schemaType, CppType cppType); |
34 | | |
35 | | /** |
36 | | * Copying and moving is disallowed! |
37 | | * \{ |
38 | | */ |
39 | | TypeInfoBase(const TypeInfoBase&) = delete; |
40 | | TypeInfoBase& operator=(const TypeInfoBase&) = delete; |
41 | | |
42 | | TypeInfoBase(const TypeInfoBase&&) = delete; |
43 | | TypeInfoBase& operator=(const TypeInfoBase&&) = delete; |
44 | | /** |
45 | | * \} |
46 | | */ |
47 | | |
48 | 315 | ~TypeInfoBase() override = 0; |
49 | | |
50 | | StringView getSchemaName() const override; |
51 | | SchemaType getSchemaType() const override; |
52 | | CppType getCppType() const override; |
53 | | uint8_t getBitSize() const override; |
54 | | |
55 | | Span<const BasicFieldInfo<ALLOC>> getFields() const override; |
56 | | Span<const BasicParameterInfo<ALLOC>> getParameters() const override; |
57 | | Span<const BasicFunctionInfo<ALLOC>> getFunctions() const override; |
58 | | |
59 | | StringView getSelector() const override; |
60 | | Span<const BasicCaseInfo<ALLOC>> getCases() const override; |
61 | | |
62 | | const IBasicTypeInfo<ALLOC>& getUnderlyingType() const override; |
63 | | Span<const StringView> getUnderlyingTypeArguments() const override; |
64 | | Span<const ItemInfo> getEnumItems() const override; |
65 | | Span<const ItemInfo> getBitmaskValues() const override; |
66 | | |
67 | | Span<const BasicColumnInfo<ALLOC>> getColumns() const override; |
68 | | StringView getSqlConstraint() const override; |
69 | | StringView getVirtualTableUsing() const override; |
70 | | bool isWithoutRowId() const override; |
71 | | |
72 | | Span<const BasicTableInfo<ALLOC>> getTables() const override; |
73 | | |
74 | | StringView getTemplateName() const override; |
75 | | Span<const BasicTemplateArgumentInfo<ALLOC>> getTemplateArguments() const override; |
76 | | |
77 | | Span<const BasicMessageInfo<ALLOC>> getMessages() const override; |
78 | | Span<const BasicMethodInfo<ALLOC>> getMethods() const override; |
79 | | |
80 | | IBasicReflectablePtr<ALLOC> createInstance(const ALLOC& allocator) const override; |
81 | | IBasicReflectablePtr<ALLOC> createInstance() const override; |
82 | | |
83 | | private: |
84 | | StringView m_schemaName; |
85 | | SchemaType m_schemaType; |
86 | | CppType m_cppType; |
87 | | }; |
88 | | |
89 | | /** |
90 | | * Type information abstract base class for builtin types. |
91 | | */ |
92 | | template <typename ALLOC = std::allocator<uint8_t>> |
93 | | class BuiltinTypeInfo : public TypeInfoBase<ALLOC> |
94 | | { |
95 | | protected: |
96 | | /** |
97 | | * Constructor. |
98 | | * |
99 | | * \param schemaName The schema name to be stored in type information. |
100 | | * \param schemaType The schema type to be stored in type information. |
101 | | * \param cppType The C++ type to be stored in type information. |
102 | | */ |
103 | | BuiltinTypeInfo(StringView schemaName, SchemaType schemaType, CppType cppType); |
104 | | |
105 | | public: |
106 | | /** |
107 | | * Gets the type information of bool schema type. |
108 | | * |
109 | | * \return Reference to the type information of bool schema type. |
110 | | */ |
111 | | static const IBasicTypeInfo<ALLOC>& getBool(); |
112 | | |
113 | | /** |
114 | | * Gets the type information of int8 schema type. |
115 | | * |
116 | | * \return Reference to the type information of int8 schema type. |
117 | | */ |
118 | | static const IBasicTypeInfo<ALLOC>& getInt8(); |
119 | | |
120 | | /** |
121 | | * Gets the type information of int16 schema type. |
122 | | * |
123 | | * \return Reference to the type information of int16 schema type. |
124 | | */ |
125 | | static const IBasicTypeInfo<ALLOC>& getInt16(); |
126 | | |
127 | | /** |
128 | | * Gets the type information of int32 schema type. |
129 | | * |
130 | | * \return Reference to the type information of int32 schema type. |
131 | | */ |
132 | | static const IBasicTypeInfo<ALLOC>& getInt32(); |
133 | | |
134 | | /** |
135 | | * Gets the type information of int64 schema type. |
136 | | * |
137 | | * \return Reference to the type information of int64 schema type. |
138 | | */ |
139 | | static const IBasicTypeInfo<ALLOC>& getInt64(); |
140 | | |
141 | | /** |
142 | | * Gets the type information of uint8 schema type. |
143 | | * |
144 | | * \return Reference to the type information of uint8 schema type. |
145 | | */ |
146 | | static const IBasicTypeInfo<ALLOC>& getUInt8(); |
147 | | |
148 | | /** |
149 | | * Gets the type information of uint16 schema type. |
150 | | * |
151 | | * \return Reference to the type information of uint16 schema type. |
152 | | */ |
153 | | static const IBasicTypeInfo<ALLOC>& getUInt16(); |
154 | | |
155 | | /** |
156 | | * Gets the type information of uint32 schema type. |
157 | | * |
158 | | * \return Reference to the type information of uint32 schema type. |
159 | | */ |
160 | | static const IBasicTypeInfo<ALLOC>& getUInt32(); |
161 | | |
162 | | /** |
163 | | * Gets the type information of uint64 schema type. |
164 | | * |
165 | | * \return Reference to the type information of uint64 schema type. |
166 | | */ |
167 | | static const IBasicTypeInfo<ALLOC>& getUInt64(); |
168 | | |
169 | | /** |
170 | | * Gets the type information of varint16 schema type. |
171 | | * |
172 | | * \return Reference to the type information of varint16 schema type. |
173 | | */ |
174 | | static const IBasicTypeInfo<ALLOC>& getVarInt16(); |
175 | | |
176 | | /** |
177 | | * Gets the type information of varint32 schema type. |
178 | | * |
179 | | * \return Reference to the type information of varint32 schema type. |
180 | | */ |
181 | | static const IBasicTypeInfo<ALLOC>& getVarInt32(); |
182 | | |
183 | | /** |
184 | | * Gets the type information of varint64 schema type. |
185 | | * |
186 | | * \return Reference to the type information of varint64 schema type. |
187 | | */ |
188 | | static const IBasicTypeInfo<ALLOC>& getVarInt64(); |
189 | | |
190 | | /** |
191 | | * Gets the type information of varint schema type. |
192 | | * |
193 | | * \return Reference to the type information of varint schema type. |
194 | | */ |
195 | | static const IBasicTypeInfo<ALLOC>& getVarInt(); |
196 | | |
197 | | /** |
198 | | * Gets the type information of varuint16 schema type. |
199 | | * |
200 | | * \return Reference to the type information of varuint16 schema type. |
201 | | */ |
202 | | static const IBasicTypeInfo<ALLOC>& getVarUInt16(); |
203 | | |
204 | | /** |
205 | | * Gets the type information of varuint32 schema type. |
206 | | * |
207 | | * \return Reference to the type information of varuint32 schema type. |
208 | | */ |
209 | | static const IBasicTypeInfo<ALLOC>& getVarUInt32(); |
210 | | |
211 | | /** |
212 | | * Gets the type information of varuint64 schema type. |
213 | | * |
214 | | * \return Reference to the type information of varuint64 schema type. |
215 | | */ |
216 | | static const IBasicTypeInfo<ALLOC>& getVarUInt64(); |
217 | | |
218 | | /** |
219 | | * Gets the type information of varuint schema type. |
220 | | * |
221 | | * \return Reference to the type information of varuint schema type. |
222 | | */ |
223 | | static const IBasicTypeInfo<ALLOC>& getVarUInt(); |
224 | | |
225 | | /** |
226 | | * Gets the type information of varsize schema type. |
227 | | * |
228 | | * \return Reference to the type information of varsize schema type. |
229 | | */ |
230 | | static const IBasicTypeInfo<ALLOC>& getVarSize(); |
231 | | |
232 | | /** |
233 | | * Gets the type information of float16 schema type. |
234 | | * |
235 | | * \return Reference to the type information of float16 schema type. |
236 | | */ |
237 | | static const IBasicTypeInfo<ALLOC>& getFloat16(); |
238 | | |
239 | | /** |
240 | | * Gets the type information of float32 schema type. |
241 | | * |
242 | | * \return Reference to the type information of float32 schema type. |
243 | | */ |
244 | | static const IBasicTypeInfo<ALLOC>& getFloat32(); |
245 | | |
246 | | /** |
247 | | * Gets the type information of float64 schema type. |
248 | | * |
249 | | * \return Reference to the type information of float64 schema type. |
250 | | */ |
251 | | static const IBasicTypeInfo<ALLOC>& getFloat64(); |
252 | | |
253 | | /** |
254 | | * Gets the type information of bytes schema type. |
255 | | * |
256 | | * \return Reference to the type information of bytes schema type. |
257 | | */ |
258 | | static const IBasicTypeInfo<ALLOC>& getBytes(); |
259 | | |
260 | | /** |
261 | | * Gets the type information of string schema type. |
262 | | * |
263 | | * \return Reference to the type information of string schema type. |
264 | | */ |
265 | | static const IBasicTypeInfo<ALLOC>& getString(); |
266 | | |
267 | | /** |
268 | | * Gets the type information of extern schema type. |
269 | | * |
270 | | * \return Reference to the type information of extern schema type. |
271 | | */ |
272 | | static const IBasicTypeInfo<ALLOC>& getBitBuffer(); |
273 | | |
274 | | /** |
275 | | * Gets the type information of fixed signed bit field schema type. |
276 | | * |
277 | | * \param bitSize The bit size of the bit field. |
278 | | * |
279 | | * \return Reference to the type information of fixed signed bit field schema type. |
280 | | */ |
281 | | static const IBasicTypeInfo<ALLOC>& getFixedSignedBitField(uint8_t bitSize); |
282 | | |
283 | | /** |
284 | | * Gets the type information of fixed unsigned bit field schema type. |
285 | | * |
286 | | * \param bitSize The bit size of the bit field. |
287 | | * |
288 | | * \return Reference to the type information of fixed unsigned bit field schema type. |
289 | | */ |
290 | | static const IBasicTypeInfo<ALLOC>& getFixedUnsignedBitField(uint8_t bitSize); |
291 | | |
292 | | /** |
293 | | * Gets the type information of dynamic signed bit field schema type. |
294 | | * |
295 | | * \param maxBitSize The maximum bit size of the dynamic bit field. |
296 | | * |
297 | | * \return Reference to the type information of dynamic signed bit field schema type. |
298 | | */ |
299 | | static const IBasicTypeInfo<ALLOC>& getDynamicSignedBitField(uint8_t maxBitSize); |
300 | | |
301 | | /** |
302 | | * Gets the type information of dynamic unsigned bit field schema type. |
303 | | * |
304 | | * \param maxBitSize The maximum bit size of the dynamic bit field. |
305 | | * |
306 | | * \return Reference to the type information of dynamic unsigned bit field schema type. |
307 | | */ |
308 | | static const IBasicTypeInfo<ALLOC>& getDynamicUnsignedBitField(uint8_t maxBitSize); |
309 | | }; |
310 | | |
311 | | /** |
312 | | * Type information abstract base class for fixed size builtin types. |
313 | | */ |
314 | | template <typename ALLOC> |
315 | | class FixedSizeBuiltinTypeInfo : public BuiltinTypeInfo<ALLOC> |
316 | | { |
317 | | protected: |
318 | | /** |
319 | | * Constructor. |
320 | | * |
321 | | * \param schemaName The schema name to be stored in type information. |
322 | | * \param schemaType The schema type to be stored in type information. |
323 | | * \param cppType The C++ type to be stored in type information. |
324 | | * \param bitSize The bit size of the fixed size integral schema type. |
325 | | */ |
326 | | FixedSizeBuiltinTypeInfo(StringView schemaName, SchemaType schemaType, CppType cppType, |
327 | | uint8_t bitSize); |
328 | | |
329 | | public: |
330 | | uint8_t getBitSize() const override; |
331 | | |
332 | | /** |
333 | | * Gets the type information of bool schema type. |
334 | | * |
335 | | * \return Reference to the type information of bool schema type. |
336 | | */ |
337 | | static const IBasicTypeInfo<ALLOC>& getBool(); |
338 | | |
339 | | /** |
340 | | * Gets the type information of int8 schema type. |
341 | | * |
342 | | * \return Reference to the type information of int8 schema type. |
343 | | */ |
344 | | static const IBasicTypeInfo<ALLOC>& getInt8(); |
345 | | |
346 | | /** |
347 | | * Gets the type information of int16 schema type. |
348 | | * |
349 | | * \return Reference to the type information of int16 schema type. |
350 | | */ |
351 | | static const IBasicTypeInfo<ALLOC>& getInt16(); |
352 | | |
353 | | /** |
354 | | * Gets the type information of int32 schema type. |
355 | | * |
356 | | * \return Reference to the type information of int32 schema type. |
357 | | */ |
358 | | static const IBasicTypeInfo<ALLOC>& getInt32(); |
359 | | |
360 | | /** |
361 | | * Gets the type information of int64 schema type. |
362 | | * |
363 | | * \return Reference to the type information of int64 schema type. |
364 | | */ |
365 | | static const IBasicTypeInfo<ALLOC>& getInt64(); |
366 | | |
367 | | /** |
368 | | * Gets the type information of uint8 schema type. |
369 | | * |
370 | | * \return Reference to the type information of uint8 schema type. |
371 | | */ |
372 | | static const IBasicTypeInfo<ALLOC>& getUInt8(); |
373 | | |
374 | | /** |
375 | | * Gets the type information of uint16 schema type. |
376 | | * |
377 | | * \return Reference to the type information of uint16 schema type. |
378 | | */ |
379 | | static const IBasicTypeInfo<ALLOC>& getUInt16(); |
380 | | |
381 | | /** |
382 | | * Gets the type information of uint32 schema type. |
383 | | * |
384 | | * \return Reference to the type information of uint32 schema type. |
385 | | */ |
386 | | static const IBasicTypeInfo<ALLOC>& getUInt32(); |
387 | | |
388 | | /** |
389 | | * Gets the type information of uint64 schema type. |
390 | | * |
391 | | * \return Reference to the type information of uint64 schema type. |
392 | | */ |
393 | | static const IBasicTypeInfo<ALLOC>& getUInt64(); |
394 | | |
395 | | /** |
396 | | * Gets the type information of float16 schema type. |
397 | | * |
398 | | * \return Reference to the type information of float16 schema type. |
399 | | */ |
400 | | static const IBasicTypeInfo<ALLOC>& getFloat16(); |
401 | | |
402 | | /** |
403 | | * Gets the type information of float32 schema type. |
404 | | * |
405 | | * \return Reference to the type information of float32 schema type. |
406 | | */ |
407 | | static const IBasicTypeInfo<ALLOC>& getFloat32(); |
408 | | |
409 | | /** |
410 | | * Gets the type information of float64 schema type. |
411 | | * |
412 | | * \return Reference to the type information of float64 schema type. |
413 | | */ |
414 | | static const IBasicTypeInfo<ALLOC>& getFloat64(); |
415 | | |
416 | | /** |
417 | | * Gets the type information of fixed signed bit field schema type. |
418 | | * |
419 | | * \param bitSize The bit size of the bit field. |
420 | | * |
421 | | * \return Reference to the type information of fixed signed bit field schema type. |
422 | | */ |
423 | | static const IBasicTypeInfo<ALLOC>& getFixedSignedBitField(uint8_t bitSize); |
424 | | |
425 | | /** |
426 | | * Gets the type information of fixed unsigned bit field schema type. |
427 | | * |
428 | | * \param bitSize The bit size of the bit field. |
429 | | * |
430 | | * \return Reference to the type information of fixed unsigned bit field schema type. |
431 | | */ |
432 | | static const IBasicTypeInfo<ALLOC>& getFixedUnsignedBitField(uint8_t bitSize); |
433 | | |
434 | | private: |
435 | | uint8_t m_bitSize; |
436 | | }; |
437 | | |
438 | | /** |
439 | | * Type information abstract base class for templatable types. |
440 | | */ |
441 | | template <typename ALLOC> |
442 | | class TemplatableTypeInfoBase : public TypeInfoBase<ALLOC> |
443 | | { |
444 | | public: |
445 | | /** |
446 | | * Constructor. |
447 | | * |
448 | | * \param schemaName The schema name to be stored in type information. |
449 | | * \param schemaType The schema type to be stored in type information. |
450 | | * \param cppType The C++ type to be stored in type information. |
451 | | * \param templateName The full schema template name. |
452 | | * \param templateArguments The sequence of type informations for template arguments. |
453 | | */ |
454 | | TemplatableTypeInfoBase(StringView schemaName, SchemaType schemaType, CppType cppType, |
455 | | StringView templateName, Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments); |
456 | | |
457 | 50 | ~TemplatableTypeInfoBase() override = 0; |
458 | | |
459 | | TemplatableTypeInfoBase(const TemplatableTypeInfoBase&) = default; |
460 | | TemplatableTypeInfoBase& operator=(const TemplatableTypeInfoBase&) = default; |
461 | | |
462 | | TemplatableTypeInfoBase(TemplatableTypeInfoBase&&) = default; |
463 | | TemplatableTypeInfoBase& operator=(TemplatableTypeInfoBase&&) = default; |
464 | | |
465 | | StringView getTemplateName() const override; |
466 | | Span<const BasicTemplateArgumentInfo<ALLOC>> getTemplateArguments() const override; |
467 | | |
468 | | private: |
469 | | StringView m_templateName; |
470 | | Span<const BasicTemplateArgumentInfo<ALLOC>> m_templateArguments; |
471 | | }; |
472 | | |
473 | | /** |
474 | | * Type information abstract base class for compound types. |
475 | | */ |
476 | | template <typename ALLOC> |
477 | | class CompoundTypeInfoBase : public TemplatableTypeInfoBase<ALLOC> |
478 | | { |
479 | | public: |
480 | | using TypeInfoBase<ALLOC>::getSchemaName; |
481 | | using CreateInstanceFunc = IBasicReflectablePtr<ALLOC> (*)(const ALLOC&); |
482 | | |
483 | | /** |
484 | | * Constructor. |
485 | | * |
486 | | * \param schemaName The schema name to be stored in type information. |
487 | | * \param schemaType The schema type to be stored in type information. |
488 | | * \param cppType The C++ type to be stored in type information. |
489 | | * \param templateName The full schema template name. |
490 | | * \param templateArguments The sequence of type informations for template arguments. |
491 | | * \param fields The sequence of type informations for fields. |
492 | | * \param parameters The sequence of type informations for parameters. |
493 | | * \param functions The sequence of type informations for functions. |
494 | | */ |
495 | | CompoundTypeInfoBase(StringView schemaName, CreateInstanceFunc createInstanceFunc, |
496 | | SchemaType schemaType, CppType cppType, |
497 | | StringView templateName, Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments, |
498 | | Span<const BasicFieldInfo<ALLOC>> fields, Span<const BasicParameterInfo<ALLOC>> parameters, |
499 | | Span<const BasicFunctionInfo<ALLOC>> functions); |
500 | | |
501 | 49 | ~CompoundTypeInfoBase() override = 0; |
502 | | |
503 | | CompoundTypeInfoBase(const CompoundTypeInfoBase&) = default; |
504 | | CompoundTypeInfoBase& operator=(const CompoundTypeInfoBase&) = default; |
505 | | |
506 | | CompoundTypeInfoBase(CompoundTypeInfoBase&&) = default; |
507 | | CompoundTypeInfoBase& operator=(CompoundTypeInfoBase&&) = default; |
508 | | |
509 | | Span<const BasicFieldInfo<ALLOC>> getFields() const override; |
510 | | Span<const BasicParameterInfo<ALLOC>> getParameters() const override; |
511 | | Span<const BasicFunctionInfo<ALLOC>> getFunctions() const override; |
512 | | |
513 | | IBasicReflectablePtr<ALLOC> createInstance(const ALLOC& allocator) const override; |
514 | | |
515 | | private: |
516 | | CreateInstanceFunc m_createInstanceFunc; |
517 | | Span<const BasicFieldInfo<ALLOC>> m_fields; |
518 | | Span<const BasicParameterInfo<ALLOC>> m_parameters; |
519 | | Span<const BasicFunctionInfo<ALLOC>> m_functions; |
520 | | }; |
521 | | |
522 | | /** |
523 | | * Type information class for structure types. |
524 | | */ |
525 | | template <typename ALLOC> |
526 | | class StructTypeInfo : public CompoundTypeInfoBase<ALLOC> |
527 | | { |
528 | | public: |
529 | | using CreateInstanceFunc = typename CompoundTypeInfoBase<ALLOC>::CreateInstanceFunc; |
530 | | |
531 | | /** |
532 | | * Constructor. |
533 | | * |
534 | | * \param schemaName The schema name to be stored in type information. |
535 | | * \param templateName The full schema template name. |
536 | | * \param templateArguments The sequence of type informations for template arguments. |
537 | | * \param fields The sequence of type informations for fields. |
538 | | * \param parameters The sequence of type informations for parameters. |
539 | | * \param functions The sequence of type informations for functions. |
540 | | */ |
541 | | StructTypeInfo(StringView schemaName, CreateInstanceFunc createInstanceFunc, |
542 | | StringView templateName, Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments, |
543 | | Span<const BasicFieldInfo<ALLOC>> fields, Span<const BasicParameterInfo<ALLOC>> parameters, |
544 | | Span<const BasicFunctionInfo<ALLOC>> functions); |
545 | | }; |
546 | | |
547 | | /** |
548 | | * Type information class for union types. |
549 | | */ |
550 | | template <typename ALLOC> |
551 | | class UnionTypeInfo : public CompoundTypeInfoBase<ALLOC> |
552 | | { |
553 | | public: |
554 | | using CreateInstanceFunc = typename CompoundTypeInfoBase<ALLOC>::CreateInstanceFunc; |
555 | | |
556 | | /** |
557 | | * Constructor. |
558 | | * |
559 | | * \param schemaName The schema name to be stored in type information. |
560 | | * \param templateName The full schema template name. |
561 | | * \param templateArguments The sequence of type informations for template arguments. |
562 | | * \param fields The sequence of type informations for fields. |
563 | | * \param parameters The sequence of type informations for parameters. |
564 | | * \param functions The sequence of type informations for functions. |
565 | | */ |
566 | | UnionTypeInfo(StringView schemaName, CreateInstanceFunc createInstanceFunc, |
567 | | StringView templateName, Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments, |
568 | | Span<const BasicFieldInfo<ALLOC>> fields, Span<const BasicParameterInfo<ALLOC>> parameters, |
569 | | Span<const BasicFunctionInfo<ALLOC>> functions); |
570 | | }; |
571 | | |
572 | | /** |
573 | | * Type information class for choice types. |
574 | | */ |
575 | | template <typename ALLOC> |
576 | | class ChoiceTypeInfo : public CompoundTypeInfoBase<ALLOC> |
577 | | { |
578 | | public: |
579 | | using CreateInstanceFunc = typename CompoundTypeInfoBase<ALLOC>::CreateInstanceFunc; |
580 | | |
581 | | /** |
582 | | * Constructor. |
583 | | * |
584 | | * \param schemaName The schema name to be stored in type information. |
585 | | * \param templateName The full schema template name. |
586 | | * \param templateArguments The sequence of type informations for template arguments. |
587 | | * \param fields The sequence of type informations for fields. |
588 | | * \param parameters The sequence of type informations for parameters. |
589 | | * \param functions The sequence of type informations for functions. |
590 | | * \param selector The selector expression. |
591 | | * \param cases The sequence of type informations for cases. |
592 | | */ |
593 | | ChoiceTypeInfo(StringView schemaName, CreateInstanceFunc createInstanceFunc, |
594 | | StringView templateName, Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments, |
595 | | Span<const BasicFieldInfo<ALLOC>> fields, Span<const BasicParameterInfo<ALLOC>> parameters, |
596 | | Span<const BasicFunctionInfo<ALLOC>> functions, StringView selector, |
597 | | Span<const BasicCaseInfo<ALLOC>> cases); |
598 | | |
599 | | StringView getSelector() const override; |
600 | | Span<const BasicCaseInfo<ALLOC>> getCases() const override; |
601 | | |
602 | | private: |
603 | | StringView m_selector; |
604 | | Span<const BasicCaseInfo<ALLOC>> m_cases; |
605 | | }; |
606 | | |
607 | | /** |
608 | | * Type information abstract base class for enumeration and bitmask types. |
609 | | */ |
610 | | template <typename ALLOC> |
611 | | class TypeInfoWithUnderlyingTypeBase : public TypeInfoBase<ALLOC> |
612 | | { |
613 | | public: |
614 | | /** |
615 | | * Constructor. |
616 | | * |
617 | | * \param schemaName The schema name to be stored in type information. |
618 | | * \param schemaType The schema type to be stored in type information. |
619 | | * \param cppType The C++ type to be stored in type information. |
620 | | * \param underlyingType The reference to type information of underlying zserio type. |
621 | | * \param underlyingTypeArguments The underlying zserio type arguments. |
622 | | */ |
623 | | TypeInfoWithUnderlyingTypeBase(StringView schemaName, SchemaType schemaType, CppType cppType, |
624 | | const IBasicTypeInfo<ALLOC>& underlyingType, Span<const StringView> underlyingTypeArguments); |
625 | | |
626 | | const IBasicTypeInfo<ALLOC>& getUnderlyingType() const override; |
627 | | Span<const StringView> getUnderlyingTypeArguments() const override; |
628 | | |
629 | | private: |
630 | | const IBasicTypeInfo<ALLOC>& m_underlyingType; |
631 | | Span<const StringView> m_underlyingTypeArguments; |
632 | | }; |
633 | | |
634 | | /** |
635 | | * Type information class for enumeration types. |
636 | | */ |
637 | | template <typename ALLOC> |
638 | | class EnumTypeInfo : public TypeInfoWithUnderlyingTypeBase<ALLOC> |
639 | | { |
640 | | public: |
641 | | /** |
642 | | * Constructor. |
643 | | * |
644 | | * \param schemaName The schema name to be stored in type information. |
645 | | * \param underlyingType The reference to type information of underlying zserio type. |
646 | | * \param underlyingTypeArguments The underlying zserio type arguments. |
647 | | * \param enumItems The sequence of type informations for enumeration items. |
648 | | */ |
649 | | EnumTypeInfo(StringView schemaName, const IBasicTypeInfo<ALLOC>& underlyingType, |
650 | | Span<const StringView> underlyingTypeArguments, Span<const ItemInfo> enumItems); |
651 | | |
652 | | Span<const ItemInfo> getEnumItems() const override; |
653 | | |
654 | | private: |
655 | | Span<const ItemInfo> m_enumItems; |
656 | | }; |
657 | | |
658 | | /** |
659 | | * Type information class for bitmask types. |
660 | | */ |
661 | | template <typename ALLOC> |
662 | | class BitmaskTypeInfo : public TypeInfoWithUnderlyingTypeBase<ALLOC> |
663 | | { |
664 | | public: |
665 | | /** |
666 | | * Constructor. |
667 | | * |
668 | | * \param schemaName The schema name to be stored in type information. |
669 | | * \param underlyingType The reference to type information of underlying zserio type. |
670 | | * \param underlyingTypeArguments The underlying zserio type arguments. |
671 | | * \param bitmaskValues The sequence of type informations for bitmask values. |
672 | | */ |
673 | | BitmaskTypeInfo(StringView schemaName, const IBasicTypeInfo<ALLOC>& underlyingType, |
674 | | Span<const StringView> underlyingTypeArguments, Span<const ItemInfo> bitmaskValues); |
675 | | |
676 | | Span<const ItemInfo> getBitmaskValues() const override; |
677 | | |
678 | | private: |
679 | | Span<const ItemInfo> m_bitmaskValues; |
680 | | }; |
681 | | |
682 | | /** |
683 | | * Type information class for SQL table types. |
684 | | */ |
685 | | template <typename ALLOC> |
686 | | class SqlTableTypeInfo : public TemplatableTypeInfoBase<ALLOC> |
687 | | { |
688 | | public: |
689 | | /** |
690 | | * Constructor. |
691 | | * |
692 | | * \param schemaName The schema name to be stored in type information. |
693 | | * \param templateName The full schema template name. |
694 | | * \param templateArguments The sequence of type informations for template arguments. |
695 | | * \param columns The sequence of type informations for columns. |
696 | | * \param sqlConstraint The SQL table constraint. |
697 | | * \param virtualTableUsing The SQL virtual table using specification. |
698 | | * \param isWithoutRowId true if SQL table is without row id table, otherwise false. |
699 | | */ |
700 | | SqlTableTypeInfo(StringView schemaName, |
701 | | StringView templateName, Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments, |
702 | | Span<const BasicColumnInfo<ALLOC>> columns, StringView sqlConstraint, StringView virtualTableUsing, |
703 | | bool isWithoutRowId); |
704 | | |
705 | | Span<const BasicColumnInfo<ALLOC>> getColumns() const override; |
706 | | StringView getSqlConstraint() const override; |
707 | | StringView getVirtualTableUsing() const override; |
708 | | bool isWithoutRowId() const override; |
709 | | |
710 | | private: |
711 | | Span<const BasicColumnInfo<ALLOC>> m_columns; |
712 | | StringView m_sqlConstraint; |
713 | | StringView m_virtualTableUsing; |
714 | | bool m_isWithoutRowId; |
715 | | }; |
716 | | |
717 | | /** |
718 | | * Type information class for SQL database types. |
719 | | */ |
720 | | template <typename ALLOC> |
721 | | class SqlDatabaseTypeInfo : public TypeInfoBase<ALLOC> |
722 | | { |
723 | | public: |
724 | | /** |
725 | | * Constructor. |
726 | | * |
727 | | * \param schemaName The schema name to be stored in type information. |
728 | | * \param tables The sequence of type informations for tables. |
729 | | */ |
730 | | SqlDatabaseTypeInfo(StringView schemaName, Span<const BasicTableInfo<ALLOC>> tables); |
731 | | |
732 | | Span<const BasicTableInfo<ALLOC>> getTables() const override; |
733 | | |
734 | | private: |
735 | | Span<const BasicTableInfo<ALLOC>> m_tables; |
736 | | }; |
737 | | |
738 | | /** |
739 | | * Type information class for pubsub types. |
740 | | */ |
741 | | template <typename ALLOC> |
742 | | class PubsubTypeInfo : public TypeInfoBase<ALLOC> |
743 | | { |
744 | | public: |
745 | | /** |
746 | | * Constructor. |
747 | | * |
748 | | * \param schemaName The schema name to be stored in type information. |
749 | | * \param messages The sequence of type informations for pubsub messages. |
750 | | */ |
751 | | PubsubTypeInfo(StringView schemaName, Span<const BasicMessageInfo<ALLOC>> messages); |
752 | | |
753 | | Span<const BasicMessageInfo<ALLOC>> getMessages() const override; |
754 | | |
755 | | private: |
756 | | Span<const BasicMessageInfo<ALLOC>> m_messages; |
757 | | }; |
758 | | |
759 | | /** |
760 | | * Type information class for service types. |
761 | | */ |
762 | | template <typename ALLOC> |
763 | | class ServiceTypeInfo : public TypeInfoBase<ALLOC> |
764 | | { |
765 | | public: |
766 | | /** |
767 | | * Constructor. |
768 | | * |
769 | | * \param schemaName The schema name to be stored in type information. |
770 | | * \param methods The sequence of type informations for service methods. |
771 | | */ |
772 | | ServiceTypeInfo(StringView schemaName, Span<const BasicMethodInfo<ALLOC>> methods); |
773 | | |
774 | | Span<const BasicMethodInfo<ALLOC>> getMethods() const override; |
775 | | |
776 | | private: |
777 | | Span<const BasicMethodInfo<ALLOC>> m_methods; |
778 | | }; |
779 | | |
780 | | /** |
781 | | * Type info for recursive types used as a wrapper around generated static typeInfo method to prevent |
782 | | * infinite recursion in type info definition. |
783 | | */ |
784 | | template <typename ALLOC> |
785 | | class RecursiveTypeInfo : public IBasicTypeInfo<ALLOC> |
786 | | { |
787 | | public: |
788 | | /** Typedef to pointer to static typeInfo method on generated objects. */ |
789 | | using TypeInfoFunc = const IBasicTypeInfo<ALLOC>& (*)(); |
790 | | |
791 | | /** |
792 | | * Constructor. |
793 | | * |
794 | | * \param typeInfoFunc Pointer to static typeInfo method. |
795 | | */ |
796 | | explicit RecursiveTypeInfo(TypeInfoFunc typeInfoFunc) : |
797 | | m_typeInfoFunc(typeInfoFunc) |
798 | 1 | {} |
799 | | |
800 | 1 | ~RecursiveTypeInfo() override = default; |
801 | | |
802 | | /** |
803 | | * Copying and moving is disallowed! |
804 | | * \{ |
805 | | */ |
806 | | RecursiveTypeInfo(const RecursiveTypeInfo&) = delete; |
807 | | RecursiveTypeInfo& operator=(const RecursiveTypeInfo&) = delete; |
808 | | |
809 | | RecursiveTypeInfo(const RecursiveTypeInfo&&) = delete; |
810 | | RecursiveTypeInfo& operator=(const RecursiveTypeInfo&&) = delete; |
811 | | /** |
812 | | * \} |
813 | | */ |
814 | | |
815 | | StringView getSchemaName() const override; |
816 | | SchemaType getSchemaType() const override; |
817 | | CppType getCppType() const override; |
818 | | uint8_t getBitSize() const override; |
819 | | |
820 | | Span<const BasicFieldInfo<ALLOC>> getFields() const override; |
821 | | Span<const BasicParameterInfo<ALLOC>> getParameters() const override; |
822 | | Span<const BasicFunctionInfo<ALLOC>> getFunctions() const override; |
823 | | |
824 | | StringView getSelector() const override; |
825 | | Span<const BasicCaseInfo<ALLOC>> getCases() const override; |
826 | | |
827 | | const IBasicTypeInfo<ALLOC>& getUnderlyingType() const override; |
828 | | Span<const StringView> getUnderlyingTypeArguments() const override; |
829 | | Span<const ItemInfo> getEnumItems() const override; |
830 | | Span<const ItemInfo> getBitmaskValues() const override; |
831 | | |
832 | | Span<const BasicColumnInfo<ALLOC>> getColumns() const override; |
833 | | StringView getSqlConstraint() const override; |
834 | | StringView getVirtualTableUsing() const override; |
835 | | bool isWithoutRowId() const override; |
836 | | |
837 | | Span<const BasicTableInfo<ALLOC>> getTables() const override; |
838 | | |
839 | | StringView getTemplateName() const override; |
840 | | Span<const BasicTemplateArgumentInfo<ALLOC>> getTemplateArguments() const override; |
841 | | |
842 | | Span<const BasicMessageInfo<ALLOC>> getMessages() const override; |
843 | | Span<const BasicMethodInfo<ALLOC>> getMethods() const override; |
844 | | |
845 | | IBasicReflectablePtr<ALLOC> createInstance(const ALLOC& allocator) const override; |
846 | | IBasicReflectablePtr<ALLOC> createInstance() const override; |
847 | | |
848 | | private: |
849 | | TypeInfoFunc m_typeInfoFunc; |
850 | | }; |
851 | | |
852 | | template <typename ALLOC> |
853 | | TypeInfoBase<ALLOC>::TypeInfoBase(StringView schemaName, SchemaType schemaType, CppType cppType) : |
854 | | m_schemaName(schemaName), m_schemaType(schemaType), m_cppType(cppType) |
855 | 315 | {} |
856 | | |
857 | | template <typename ALLOC> |
858 | | TypeInfoBase<ALLOC>::~TypeInfoBase() = default; |
859 | | |
860 | | template <typename ALLOC> |
861 | | StringView TypeInfoBase<ALLOC>::getSchemaName() const |
862 | 16.0k | { |
863 | 16.0k | return m_schemaName; |
864 | 16.0k | } |
865 | | |
866 | | template <typename ALLOC> |
867 | | SchemaType TypeInfoBase<ALLOC>::getSchemaType() const |
868 | 3.74k | { |
869 | 3.74k | return m_schemaType; |
870 | 3.74k | } |
871 | | |
872 | | template <typename ALLOC> |
873 | | CppType TypeInfoBase<ALLOC>::getCppType() const |
874 | 946 | { |
875 | 946 | return m_cppType; |
876 | 946 | } |
877 | | |
878 | | template <typename ALLOC> |
879 | | uint8_t TypeInfoBase<ALLOC>::getBitSize() const |
880 | 150 | { |
881 | 150 | throw CppRuntimeException("Type '") << getSchemaName() << "' is not a fixed size type!"; |
882 | 150 | } |
883 | | |
884 | | template <typename ALLOC> |
885 | | Span<const BasicFieldInfo<ALLOC>> TypeInfoBase<ALLOC>::getFields() const |
886 | 286 | { |
887 | 286 | throw CppRuntimeException("Type '") << getSchemaName() << "' is not a compound type!"; |
888 | 286 | } |
889 | | |
890 | | template <typename ALLOC> |
891 | | Span<const BasicParameterInfo<ALLOC>> TypeInfoBase<ALLOC>::getParameters() const |
892 | 286 | { |
893 | 286 | throw CppRuntimeException("Type '") << getSchemaName() << "' is not a compound type!"; |
894 | 286 | } |
895 | | |
896 | | template <typename ALLOC> |
897 | | Span<const BasicFunctionInfo<ALLOC>> TypeInfoBase<ALLOC>::getFunctions() const |
898 | 286 | { |
899 | 286 | throw CppRuntimeException("Type '") << getSchemaName() << "' is not a compound type!"; |
900 | 286 | } |
901 | | |
902 | | template <typename ALLOC> |
903 | | StringView TypeInfoBase<ALLOC>::getSelector() const |
904 | 289 | { |
905 | 289 | throw CppRuntimeException("Type '") << getSchemaName() << "' is not a choice type!"; |
906 | 289 | } |
907 | | |
908 | | template <typename ALLOC> |
909 | | Span<const BasicCaseInfo<ALLOC>> TypeInfoBase<ALLOC>::getCases() const |
910 | 289 | { |
911 | 289 | throw CppRuntimeException("Type '") << getSchemaName() << "' is not a choice type!"; |
912 | 289 | } |
913 | | |
914 | | template <typename ALLOC> |
915 | | const IBasicTypeInfo<ALLOC>& TypeInfoBase<ALLOC>::getUnderlyingType() const |
916 | 288 | { |
917 | 288 | throw CppRuntimeException("Type '") << getSchemaName() << "' does not have underlying type!"; |
918 | 288 | } |
919 | | |
920 | | template <typename ALLOC> |
921 | | Span<const StringView> TypeInfoBase<ALLOC>::getUnderlyingTypeArguments() const |
922 | 288 | { |
923 | 288 | throw CppRuntimeException("Type '") << getSchemaName() << "' does not have underlying type!"; |
924 | 288 | } |
925 | | |
926 | | template <typename ALLOC> |
927 | | Span<const ItemInfo> TypeInfoBase<ALLOC>::getEnumItems() const |
928 | 289 | { |
929 | 289 | throw CppRuntimeException("Type '") << getSchemaName() << "' is not an enum type!"; |
930 | 289 | } |
931 | | |
932 | | template <typename ALLOC> |
933 | | Span<const ItemInfo> TypeInfoBase<ALLOC>::getBitmaskValues() const |
934 | 289 | { |
935 | 289 | throw CppRuntimeException("Type '") << getSchemaName() << "' is not a bitmask type!"; |
936 | 289 | } |
937 | | |
938 | | template <typename ALLOC> |
939 | | Span<const BasicColumnInfo<ALLOC>> TypeInfoBase<ALLOC>::getColumns() const |
940 | 289 | { |
941 | 289 | throw CppRuntimeException("Type '") << getSchemaName() << "' is not a SQL table type!"; |
942 | 289 | } |
943 | | |
944 | | template <typename ALLOC> |
945 | | StringView TypeInfoBase<ALLOC>::getSqlConstraint() const |
946 | 289 | { |
947 | 289 | throw CppRuntimeException("Type '") << getSchemaName() << "' is not a SQL table type!"; |
948 | 289 | } |
949 | | |
950 | | template <typename ALLOC> |
951 | | StringView TypeInfoBase<ALLOC>::getVirtualTableUsing() const |
952 | 289 | { |
953 | 289 | throw CppRuntimeException("Type '") << getSchemaName() << "' is not a SQL table type!"; |
954 | 289 | } |
955 | | |
956 | | template <typename ALLOC> |
957 | | bool TypeInfoBase<ALLOC>::isWithoutRowId() const |
958 | 289 | { |
959 | 289 | throw CppRuntimeException("Type '") << getSchemaName() << "' is not a SQL table type!"; |
960 | 289 | } |
961 | | |
962 | | template <typename ALLOC> |
963 | | Span<const BasicTableInfo<ALLOC>> TypeInfoBase<ALLOC>::getTables() const |
964 | 289 | { |
965 | 289 | throw CppRuntimeException("Type '") << getSchemaName() << "' is not a SQL database type!"; |
966 | 289 | } |
967 | | |
968 | | template <typename ALLOC> |
969 | | StringView TypeInfoBase<ALLOC>::getTemplateName() const |
970 | 285 | { |
971 | 285 | throw CppRuntimeException("Type '") << getSchemaName() << "' is not a templatable type!"; |
972 | 285 | } |
973 | | |
974 | | template <typename ALLOC> |
975 | | Span<const BasicTemplateArgumentInfo<ALLOC>> TypeInfoBase<ALLOC>::getTemplateArguments() const |
976 | 285 | { |
977 | 285 | throw CppRuntimeException("Type '") << getSchemaName() << "' is not a templatable type!"; |
978 | 285 | } |
979 | | |
980 | | template <typename ALLOC> |
981 | | Span<const BasicMessageInfo<ALLOC>> TypeInfoBase<ALLOC>::getMessages() const |
982 | 289 | { |
983 | 289 | throw CppRuntimeException("Type '") << getSchemaName() << "' is not a pubsub type!"; |
984 | 289 | } |
985 | | |
986 | | template <typename ALLOC> |
987 | | Span<const BasicMethodInfo<ALLOC>> TypeInfoBase<ALLOC>::getMethods() const |
988 | 289 | { |
989 | 289 | throw CppRuntimeException("Type '") << getSchemaName() << "' is not a service type!"; |
990 | 289 | } |
991 | | |
992 | | template <typename ALLOC> |
993 | | IBasicReflectablePtr<ALLOC> TypeInfoBase<ALLOC>::createInstance(const ALLOC&) const |
994 | 286 | { |
995 | 286 | throw CppRuntimeException("Type '") << getSchemaName() << "' is not a compound type!"; |
996 | 286 | } |
997 | | |
998 | | template <typename ALLOC> |
999 | | IBasicReflectablePtr<ALLOC> TypeInfoBase<ALLOC>::createInstance() const |
1000 | 281 | { |
1001 | 281 | return createInstance(ALLOC()); |
1002 | 281 | } |
1003 | | |
1004 | | template <typename ALLOC> |
1005 | | BuiltinTypeInfo<ALLOC>::BuiltinTypeInfo(StringView schemaName, SchemaType schemaType, CppType cppType) : |
1006 | | TypeInfoBase<ALLOC>(schemaName, schemaType, cppType) |
1007 | 162 | {} |
1008 | | |
1009 | | template <typename ALLOC> |
1010 | | const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getBool() |
1011 | 59 | { |
1012 | 59 | return FixedSizeBuiltinTypeInfo<ALLOC>::getBool(); |
1013 | 59 | } |
1014 | | |
1015 | | template <typename ALLOC> |
1016 | | const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getInt8() |
1017 | 103 | { |
1018 | 103 | return FixedSizeBuiltinTypeInfo<ALLOC>::getInt8(); |
1019 | 103 | } |
1020 | | |
1021 | | template <typename ALLOC> |
1022 | | const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getInt16() |
1023 | 59 | { |
1024 | 59 | return FixedSizeBuiltinTypeInfo<ALLOC>::getInt16(); |
1025 | 59 | } |
1026 | | |
1027 | | template <typename ALLOC> |
1028 | | const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getInt32() |
1029 | 64 | { |
1030 | 64 | return FixedSizeBuiltinTypeInfo<ALLOC>::getInt32(); |
1031 | 64 | } |
1032 | | |
1033 | | template <typename ALLOC> |
1034 | | const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getInt64() |
1035 | 57 | { |
1036 | 57 | return FixedSizeBuiltinTypeInfo<ALLOC>::getInt64(); |
1037 | 57 | } |
1038 | | |
1039 | | template <typename ALLOC> |
1040 | | const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getUInt8() |
1041 | 124 | { |
1042 | 124 | return FixedSizeBuiltinTypeInfo<ALLOC>::getUInt8(); |
1043 | 124 | } |
1044 | | |
1045 | | template <typename ALLOC> |
1046 | | const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getUInt16() |
1047 | 59 | { |
1048 | 59 | return FixedSizeBuiltinTypeInfo<ALLOC>::getUInt16(); |
1049 | 59 | } |
1050 | | |
1051 | | template <typename ALLOC> |
1052 | | const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getUInt32() |
1053 | 233 | { |
1054 | 233 | return FixedSizeBuiltinTypeInfo<ALLOC>::getUInt32(); |
1055 | 233 | } |
1056 | | |
1057 | | template <typename ALLOC> |
1058 | | const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getUInt64() |
1059 | 59 | { |
1060 | 59 | return FixedSizeBuiltinTypeInfo<ALLOC>::getUInt64(); |
1061 | 59 | } |
1062 | | |
1063 | | template <typename ALLOC> |
1064 | | const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getVarInt16() |
1065 | 13 | { |
1066 | 13 | static const BuiltinTypeInfo<ALLOC> typeInfo = { |
1067 | 13 | makeStringView("varint16"), SchemaType::VARINT16, CppType::INT16 |
1068 | 13 | }; |
1069 | 13 | return typeInfo; |
1070 | 13 | } |
1071 | | |
1072 | | template <typename ALLOC> |
1073 | | const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getVarInt32() |
1074 | 13 | { |
1075 | 13 | static const BuiltinTypeInfo<ALLOC> typeInfo = { |
1076 | 13 | makeStringView("varint32"), SchemaType::VARINT32, CppType::INT32 |
1077 | 13 | }; |
1078 | 13 | return typeInfo; |
1079 | 13 | } |
1080 | | |
1081 | | template <typename ALLOC> |
1082 | | const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getVarInt64() |
1083 | 13 | { |
1084 | 13 | static const BuiltinTypeInfo<ALLOC> typeInfo = { |
1085 | 13 | makeStringView("varint64"), SchemaType::VARINT64, CppType::INT64 |
1086 | 13 | }; |
1087 | 13 | return typeInfo; |
1088 | 13 | } |
1089 | | |
1090 | | template <typename ALLOC> |
1091 | | const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getVarInt() |
1092 | 14 | { |
1093 | 14 | static const BuiltinTypeInfo<ALLOC> typeInfo = { |
1094 | 14 | makeStringView("varint"), SchemaType::VARINT, CppType::INT64 |
1095 | 14 | }; |
1096 | 14 | return typeInfo; |
1097 | 14 | } |
1098 | | |
1099 | | template <typename ALLOC> |
1100 | | const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getVarUInt16() |
1101 | 13 | { |
1102 | 13 | static const BuiltinTypeInfo<ALLOC> typeInfo = { |
1103 | 13 | makeStringView("varuint16"), SchemaType::VARUINT16, CppType::UINT16 |
1104 | 13 | }; |
1105 | 13 | return typeInfo; |
1106 | 13 | } |
1107 | | |
1108 | | template <typename ALLOC> |
1109 | | const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getVarUInt32() |
1110 | 13 | { |
1111 | 13 | static const BuiltinTypeInfo<ALLOC> typeInfo = { |
1112 | 13 | makeStringView("varuint32"), SchemaType::VARUINT32, CppType::UINT32 |
1113 | 13 | }; |
1114 | 13 | return typeInfo; |
1115 | 13 | } |
1116 | | |
1117 | | template <typename ALLOC> |
1118 | | const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getVarUInt64() |
1119 | 13 | { |
1120 | 13 | static const BuiltinTypeInfo<ALLOC> typeInfo = { |
1121 | 13 | makeStringView("varuint64"), SchemaType::VARUINT64, CppType::UINT64 |
1122 | 13 | }; |
1123 | 13 | return typeInfo; |
1124 | 13 | } |
1125 | | |
1126 | | template <typename ALLOC> |
1127 | | const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getVarUInt() |
1128 | 13 | { |
1129 | 13 | static const BuiltinTypeInfo<ALLOC> typeInfo = { |
1130 | 13 | makeStringView("varuint"), SchemaType::VARUINT, CppType::UINT64 |
1131 | 13 | }; |
1132 | 13 | return typeInfo; |
1133 | 13 | } |
1134 | | |
1135 | | template <typename ALLOC> |
1136 | | const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getVarSize() |
1137 | 14 | { |
1138 | 14 | static const BuiltinTypeInfo<ALLOC> typeInfo = { |
1139 | 14 | makeStringView("varsize"), SchemaType::VARSIZE, CppType::UINT32 |
1140 | 14 | }; |
1141 | 14 | return typeInfo; |
1142 | 14 | } |
1143 | | |
1144 | | template <typename ALLOC> |
1145 | | const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getFloat16() |
1146 | 14 | { |
1147 | 14 | return FixedSizeBuiltinTypeInfo<ALLOC>::getFloat16(); |
1148 | 14 | } |
1149 | | |
1150 | | template <typename ALLOC> |
1151 | | const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getFloat32() |
1152 | 53 | { |
1153 | 53 | return FixedSizeBuiltinTypeInfo<ALLOC>::getFloat32(); |
1154 | 53 | } |
1155 | | |
1156 | | template <typename ALLOC> |
1157 | | const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getFloat64() |
1158 | 81 | { |
1159 | 81 | return FixedSizeBuiltinTypeInfo<ALLOC>::getFloat64(); |
1160 | 81 | } |
1161 | | |
1162 | | template <typename ALLOC> |
1163 | | const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getBytes() |
1164 | 76 | { |
1165 | 76 | static const BuiltinTypeInfo<ALLOC> typeInfo = { |
1166 | 76 | makeStringView("bytes"), SchemaType::BYTES, CppType::BYTES |
1167 | 76 | }; |
1168 | 76 | return typeInfo; |
1169 | 76 | } |
1170 | | |
1171 | | template <typename ALLOC> |
1172 | | const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getString() |
1173 | 226 | { |
1174 | 226 | static const BuiltinTypeInfo<ALLOC> typeInfo = { |
1175 | 226 | makeStringView("string"), SchemaType::STRING, CppType::STRING |
1176 | 226 | }; |
1177 | 226 | return typeInfo; |
1178 | 226 | } |
1179 | | |
1180 | | template <typename ALLOC> |
1181 | | const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getBitBuffer() |
1182 | 74 | { |
1183 | 74 | static const BuiltinTypeInfo<ALLOC> typeInfo = { |
1184 | 74 | makeStringView("extern"), SchemaType::EXTERN, CppType::BIT_BUFFER |
1185 | 74 | }; |
1186 | 74 | return typeInfo; |
1187 | 74 | } |
1188 | | |
1189 | | template <typename ALLOC> |
1190 | | const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getFixedSignedBitField(uint8_t bitSize) |
1191 | 321 | { |
1192 | 321 | return FixedSizeBuiltinTypeInfo<ALLOC>::getFixedSignedBitField(bitSize); |
1193 | 321 | } |
1194 | | |
1195 | | template <typename ALLOC> |
1196 | | const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getFixedUnsignedBitField(uint8_t bitSize) |
1197 | 352 | { |
1198 | 352 | return FixedSizeBuiltinTypeInfo<ALLOC>::getFixedUnsignedBitField(bitSize); |
1199 | 352 | } |
1200 | | |
1201 | | template <typename ALLOC> |
1202 | | const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getDynamicSignedBitField(uint8_t maxBitSize) |
1203 | 291 | { |
1204 | 291 | if (maxBitSize == 0 || maxBitSize > 64290 ) |
1205 | 193 | { |
1206 | 193 | throw CppRuntimeException("BuiltinTypeInfo::getDynamicSignedBitField: Invalid max bit size '") << |
1207 | 193 | maxBitSize << "'!"; |
1208 | 193 | } |
1209 | | |
1210 | 98 | if (maxBitSize <= 8) |
1211 | 30 | { |
1212 | 30 | static const BuiltinTypeInfo<ALLOC> typeInfo = { |
1213 | 30 | "int<>"_sv, SchemaType::DYNAMIC_SIGNED_BITFIELD, CppType::INT8 |
1214 | 30 | }; |
1215 | 30 | return typeInfo; |
1216 | 30 | } |
1217 | 68 | else if (maxBitSize <= 16) |
1218 | 12 | { |
1219 | 12 | static const BuiltinTypeInfo<ALLOC> typeInfo = { |
1220 | 12 | "int<>"_sv, SchemaType::DYNAMIC_SIGNED_BITFIELD, CppType::INT16 |
1221 | 12 | }; |
1222 | 12 | return typeInfo; |
1223 | 12 | } |
1224 | 56 | else if (maxBitSize <= 32) |
1225 | 20 | { |
1226 | 20 | static const BuiltinTypeInfo<ALLOC> typeInfo = { |
1227 | 20 | "int<>"_sv, SchemaType::DYNAMIC_SIGNED_BITFIELD, CppType::INT32 |
1228 | 20 | }; |
1229 | 20 | return typeInfo; |
1230 | 20 | } |
1231 | 36 | else |
1232 | 36 | { |
1233 | 36 | static const BuiltinTypeInfo<ALLOC> typeInfo = { |
1234 | 36 | "int<>"_sv, SchemaType::DYNAMIC_SIGNED_BITFIELD, CppType::INT64 |
1235 | 36 | }; |
1236 | 36 | return typeInfo; |
1237 | 36 | } |
1238 | 98 | } |
1239 | | |
1240 | | template <typename ALLOC> |
1241 | | const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getDynamicUnsignedBitField(uint8_t maxBitSize) |
1242 | 284 | { |
1243 | 284 | if (maxBitSize == 0 || maxBitSize > 64283 ) |
1244 | 193 | { |
1245 | 193 | throw CppRuntimeException("BuiltinTypeInfo::getDynamicUnsignedBitField: Invalid max bit size '") << |
1246 | 193 | maxBitSize << "'!"; |
1247 | 193 | } |
1248 | | |
1249 | 91 | if (maxBitSize <= 8) |
1250 | 23 | { |
1251 | 23 | static const BuiltinTypeInfo<ALLOC> typeInfo = { |
1252 | 23 | "bit<>"_sv, SchemaType::DYNAMIC_UNSIGNED_BITFIELD, CppType::UINT8 |
1253 | 23 | }; |
1254 | 23 | return typeInfo; |
1255 | 23 | } |
1256 | 68 | else if (maxBitSize <= 16) |
1257 | 12 | { |
1258 | 12 | static const BuiltinTypeInfo<ALLOC> typeInfo = { |
1259 | 12 | "bit<>"_sv, SchemaType::DYNAMIC_UNSIGNED_BITFIELD, CppType::UINT16 |
1260 | 12 | }; |
1261 | 12 | return typeInfo; |
1262 | 12 | } |
1263 | 56 | else if (maxBitSize <= 32) |
1264 | 20 | { |
1265 | 20 | static const BuiltinTypeInfo<ALLOC> typeInfo = { |
1266 | 20 | "bit<>"_sv, SchemaType::DYNAMIC_UNSIGNED_BITFIELD, CppType::UINT32 |
1267 | 20 | }; |
1268 | 20 | return typeInfo; |
1269 | 20 | } |
1270 | 36 | else |
1271 | 36 | { |
1272 | 36 | static const BuiltinTypeInfo<ALLOC> typeInfo = { |
1273 | 36 | "bit<>"_sv, SchemaType::DYNAMIC_UNSIGNED_BITFIELD, CppType::UINT64 |
1274 | 36 | }; |
1275 | 36 | return typeInfo; |
1276 | 36 | } |
1277 | 91 | } |
1278 | | |
1279 | | template <typename ALLOC> |
1280 | | FixedSizeBuiltinTypeInfo<ALLOC>::FixedSizeBuiltinTypeInfo(StringView schemaName, SchemaType schemaType, |
1281 | | CppType cppType, uint8_t bitSize) : |
1282 | | BuiltinTypeInfo<ALLOC>(schemaName, schemaType, cppType), m_bitSize(bitSize) |
1283 | 141 | {} |
1284 | | |
1285 | | template <typename ALLOC> |
1286 | | uint8_t FixedSizeBuiltinTypeInfo<ALLOC>::getBitSize() const |
1287 | 233 | { |
1288 | 233 | return m_bitSize; |
1289 | 233 | } |
1290 | | |
1291 | | template <typename ALLOC> |
1292 | | const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getBool() |
1293 | 59 | { |
1294 | 59 | static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = { |
1295 | 59 | makeStringView("bool"), SchemaType::BOOL, CppType::BOOL, 1 |
1296 | 59 | }; |
1297 | 59 | return typeInfo; |
1298 | 59 | } |
1299 | | |
1300 | | template <typename ALLOC> |
1301 | | const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getInt8() |
1302 | 103 | { |
1303 | 103 | static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = { |
1304 | 103 | makeStringView("int8"), SchemaType::INT8, CppType::INT8, 8 |
1305 | 103 | }; |
1306 | 103 | return typeInfo; |
1307 | 103 | } |
1308 | | |
1309 | | template <typename ALLOC> |
1310 | | const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getInt16() |
1311 | 59 | { |
1312 | 59 | static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = { |
1313 | 59 | makeStringView("int16"), SchemaType::INT16, CppType::INT16, 16 |
1314 | 59 | }; |
1315 | 59 | return typeInfo; |
1316 | 59 | } |
1317 | | |
1318 | | template <typename ALLOC> |
1319 | | const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getInt32() |
1320 | 64 | { |
1321 | 64 | static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = { |
1322 | 64 | makeStringView("int32"), SchemaType::INT32, CppType::INT32, 32 |
1323 | 64 | }; |
1324 | 64 | return typeInfo; |
1325 | 64 | } |
1326 | | |
1327 | | template <typename ALLOC> |
1328 | | const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getInt64() |
1329 | 57 | { |
1330 | 57 | static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = { |
1331 | 57 | makeStringView("int64"), SchemaType::INT64, CppType::INT64, 64 |
1332 | 57 | }; |
1333 | 57 | return typeInfo; |
1334 | 57 | } |
1335 | | |
1336 | | template <typename ALLOC> |
1337 | | const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getUInt8() |
1338 | 124 | { |
1339 | 124 | static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = { |
1340 | 124 | makeStringView("uint8"), SchemaType::UINT8, CppType::UINT8, 8 |
1341 | 124 | }; |
1342 | 124 | return typeInfo; |
1343 | 124 | } |
1344 | | |
1345 | | template <typename ALLOC> |
1346 | | const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getUInt16() |
1347 | 59 | { |
1348 | 59 | static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = { |
1349 | 59 | makeStringView("uint16"), SchemaType::UINT16, CppType::UINT16, 16 |
1350 | 59 | }; |
1351 | 59 | return typeInfo; |
1352 | 59 | } |
1353 | | |
1354 | | template <typename ALLOC> |
1355 | | const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getUInt32() |
1356 | 233 | { |
1357 | 233 | static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = { |
1358 | 233 | makeStringView("uint32"), SchemaType::UINT32, CppType::UINT32, 32 |
1359 | 233 | }; |
1360 | 233 | return typeInfo; |
1361 | 233 | } |
1362 | | |
1363 | | template <typename ALLOC> |
1364 | | const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getUInt64() |
1365 | 59 | { |
1366 | 59 | static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = { |
1367 | 59 | makeStringView("uint64"), SchemaType::UINT64, CppType::UINT64, 64 |
1368 | 59 | }; |
1369 | 59 | return typeInfo; |
1370 | 59 | } |
1371 | | |
1372 | | template <typename ALLOC> |
1373 | | const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getFloat16() |
1374 | 14 | { |
1375 | 14 | static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = { |
1376 | 14 | makeStringView("float16"), SchemaType::FLOAT16, CppType::FLOAT, 16 |
1377 | 14 | }; |
1378 | 14 | return typeInfo; |
1379 | 14 | } |
1380 | | |
1381 | | template <typename ALLOC> |
1382 | | const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getFloat32() |
1383 | 53 | { |
1384 | 53 | static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = { |
1385 | 53 | makeStringView("float32"), SchemaType::FLOAT32, CppType::FLOAT, 32 |
1386 | 53 | }; |
1387 | 53 | return typeInfo; |
1388 | 53 | } |
1389 | | |
1390 | | template <typename ALLOC> |
1391 | | const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getFloat64() |
1392 | 81 | { |
1393 | 81 | static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = { |
1394 | 81 | makeStringView("float64"), SchemaType::FLOAT64, CppType::DOUBLE, 64 |
1395 | 81 | }; |
1396 | 81 | return typeInfo; |
1397 | 81 | } |
1398 | | |
1399 | | template <typename ALLOC> |
1400 | | const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getFixedSignedBitField(uint8_t bitSize) |
1401 | 321 | { |
1402 | 321 | if (bitSize == 0 || bitSize > 64320 ) |
1403 | 193 | { |
1404 | 193 | throw CppRuntimeException("FixedSizeBuiltinTypeInfo::getFixedSignedBitField: Invalid bit size '") << |
1405 | 193 | bitSize << "'!"; |
1406 | 193 | } |
1407 | | |
1408 | 128 | static const std::array<FixedSizeBuiltinTypeInfo<ALLOC>, 64> bitFieldTypeInfoArray = {{ |
1409 | 128 | { "int:1"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT8, 1 }, |
1410 | 128 | { "int:2"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT8, 2 }, |
1411 | 128 | { "int:3"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT8, 3 }, |
1412 | 128 | { "int:4"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT8, 4 }, |
1413 | 128 | { "int:5"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT8, 5 }, |
1414 | 128 | { "int:6"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT8, 6 }, |
1415 | 128 | { "int:7"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT8, 7 }, |
1416 | 128 | { "int:8"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT8, 8 }, |
1417 | 128 | { "int:9"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT16, 9 }, |
1418 | 128 | { "int:10"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT16, 10 }, |
1419 | 128 | { "int:11"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT16, 11 }, |
1420 | 128 | { "int:12"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT16, 12 }, |
1421 | 128 | { "int:13"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT16, 13 }, |
1422 | 128 | { "int:14"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT16, 14 }, |
1423 | 128 | { "int:15"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT16, 15 }, |
1424 | 128 | { "int:16"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT16, 16 }, |
1425 | 128 | { "int:17"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 17 }, |
1426 | 128 | { "int:18"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 18 }, |
1427 | 128 | { "int:19"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 19 }, |
1428 | 128 | { "int:20"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 20 }, |
1429 | 128 | { "int:21"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 21 }, |
1430 | 128 | { "int:22"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 22 }, |
1431 | 128 | { "int:23"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 23 }, |
1432 | 128 | { "int:24"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 24 }, |
1433 | 128 | { "int:25"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 25 }, |
1434 | 128 | { "int:26"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 26 }, |
1435 | 128 | { "int:27"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 27 }, |
1436 | 128 | { "int:28"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 28 }, |
1437 | 128 | { "int:29"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 29 }, |
1438 | 128 | { "int:30"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 30 }, |
1439 | 128 | { "int:31"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 31 }, |
1440 | 128 | { "int:32"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 32 }, |
1441 | 128 | { "int:33"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 33 }, |
1442 | 128 | { "int:34"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 34 }, |
1443 | 128 | { "int:35"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 35 }, |
1444 | 128 | { "int:36"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 36 }, |
1445 | 128 | { "int:37"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 37 }, |
1446 | 128 | { "int:38"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 38 }, |
1447 | 128 | { "int:39"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 39 }, |
1448 | 128 | { "int:40"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 40 }, |
1449 | 128 | { "int:41"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 41 }, |
1450 | 128 | { "int:42"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 42 }, |
1451 | 128 | { "int:43"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 43 }, |
1452 | 128 | { "int:44"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 44 }, |
1453 | 128 | { "int:45"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 45 }, |
1454 | 128 | { "int:46"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 46 }, |
1455 | 128 | { "int:47"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 47 }, |
1456 | 128 | { "int:48"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 48 }, |
1457 | 128 | { "int:49"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 49 }, |
1458 | 128 | { "int:50"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 50 }, |
1459 | 128 | { "int:51"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 51 }, |
1460 | 128 | { "int:52"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 52 }, |
1461 | 128 | { "int:53"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 53 }, |
1462 | 128 | { "int:54"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 54 }, |
1463 | 128 | { "int:55"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 55 }, |
1464 | 128 | { "int:56"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 56 }, |
1465 | 128 | { "int:57"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 57 }, |
1466 | 128 | { "int:58"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 58 }, |
1467 | 128 | { "int:59"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 59 }, |
1468 | 128 | { "int:60"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 60 }, |
1469 | 128 | { "int:61"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 61 }, |
1470 | 128 | { "int:62"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 62 }, |
1471 | 128 | { "int:63"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 63 }, |
1472 | 128 | { "int:64"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 64 } |
1473 | 128 | }}; |
1474 | | |
1475 | 128 | return bitFieldTypeInfoArray[bitSize - 1]; |
1476 | 321 | } |
1477 | | |
1478 | | template <typename ALLOC> |
1479 | | const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getFixedUnsignedBitField(uint8_t bitSize) |
1480 | 352 | { |
1481 | 352 | if (bitSize == 0 || bitSize > 64351 ) |
1482 | 193 | { |
1483 | 193 | throw CppRuntimeException("FixedSizeBuiltinTypeInfo::getFixedUnsignedBitField: Invalid bit size '") << |
1484 | 193 | bitSize << "'!"; |
1485 | 193 | } |
1486 | | |
1487 | 159 | static const std::array<FixedSizeBuiltinTypeInfo<ALLOC>, 64> bitFieldTypeInfoArray = {{ |
1488 | 159 | { "bit:1"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT8, 1 }, |
1489 | 159 | { "bit:2"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT8, 2 }, |
1490 | 159 | { "bit:3"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT8, 3 }, |
1491 | 159 | { "bit:4"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT8, 4 }, |
1492 | 159 | { "bit:5"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT8, 5 }, |
1493 | 159 | { "bit:6"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT8, 6 }, |
1494 | 159 | { "bit:7"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT8, 7 }, |
1495 | 159 | { "bit:8"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT8, 8 }, |
1496 | 159 | { "bit:9"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT16, 9 }, |
1497 | 159 | { "bit:10"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT16, 10 }, |
1498 | 159 | { "bit:11"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT16, 11 }, |
1499 | 159 | { "bit:12"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT16, 12 }, |
1500 | 159 | { "bit:13"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT16, 13 }, |
1501 | 159 | { "bit:14"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT16, 14 }, |
1502 | 159 | { "bit:15"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT16, 15 }, |
1503 | 159 | { "bit:16"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT16, 16 }, |
1504 | 159 | { "bit:17"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 17 }, |
1505 | 159 | { "bit:18"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 18 }, |
1506 | 159 | { "bit:19"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 19 }, |
1507 | 159 | { "bit:20"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 20 }, |
1508 | 159 | { "bit:21"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 21 }, |
1509 | 159 | { "bit:22"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 22 }, |
1510 | 159 | { "bit:23"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 23 }, |
1511 | 159 | { "bit:24"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 24 }, |
1512 | 159 | { "bit:25"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 25 }, |
1513 | 159 | { "bit:26"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 26 }, |
1514 | 159 | { "bit:27"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 27 }, |
1515 | 159 | { "bit:28"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 28 }, |
1516 | 159 | { "bit:29"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 29 }, |
1517 | 159 | { "bit:30"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 30 }, |
1518 | 159 | { "bit:31"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 31 }, |
1519 | 159 | { "bit:32"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 32 }, |
1520 | 159 | { "bit:33"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 33 }, |
1521 | 159 | { "bit:34"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 34 }, |
1522 | 159 | { "bit:35"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 35 }, |
1523 | 159 | { "bit:36"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 36 }, |
1524 | 159 | { "bit:37"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 37 }, |
1525 | 159 | { "bit:38"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 38 }, |
1526 | 159 | { "bit:39"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 39 }, |
1527 | 159 | { "bit:40"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 40 }, |
1528 | 159 | { "bit:41"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 41 }, |
1529 | 159 | { "bit:42"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 42 }, |
1530 | 159 | { "bit:43"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 43 }, |
1531 | 159 | { "bit:44"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 44 }, |
1532 | 159 | { "bit:45"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 45 }, |
1533 | 159 | { "bit:46"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 46 }, |
1534 | 159 | { "bit:47"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 47 }, |
1535 | 159 | { "bit:48"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 48 }, |
1536 | 159 | { "bit:49"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 49 }, |
1537 | 159 | { "bit:50"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 50 }, |
1538 | 159 | { "bit:51"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 51 }, |
1539 | 159 | { "bit:52"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 52 }, |
1540 | 159 | { "bit:53"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 53 }, |
1541 | 159 | { "bit:54"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 54 }, |
1542 | 159 | { "bit:55"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 55 }, |
1543 | 159 | { "bit:56"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 56 }, |
1544 | 159 | { "bit:57"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 57 }, |
1545 | 159 | { "bit:58"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 58 }, |
1546 | 159 | { "bit:59"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 59 }, |
1547 | 159 | { "bit:60"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 60 }, |
1548 | 159 | { "bit:61"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 61 }, |
1549 | 159 | { "bit:62"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 62 }, |
1550 | 159 | { "bit:63"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 63 }, |
1551 | 159 | { "bit:64"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 64 } |
1552 | 159 | }}; |
1553 | | |
1554 | 159 | return bitFieldTypeInfoArray[bitSize - 1]; |
1555 | 352 | } |
1556 | | |
1557 | | template <typename ALLOC> |
1558 | | TemplatableTypeInfoBase<ALLOC>::TemplatableTypeInfoBase(StringView schemaName, |
1559 | | SchemaType schemaType, CppType cppType, |
1560 | | StringView templateName, Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments) : |
1561 | | TypeInfoBase<ALLOC>(schemaName, schemaType, cppType), |
1562 | | m_templateName(templateName), m_templateArguments(templateArguments) |
1563 | 50 | {} |
1564 | | |
1565 | | template <typename ALLOC> |
1566 | | TemplatableTypeInfoBase<ALLOC>::~TemplatableTypeInfoBase() = default; |
1567 | | |
1568 | | template <typename ALLOC> |
1569 | | StringView TemplatableTypeInfoBase<ALLOC>::getTemplateName() const |
1570 | 6 | { |
1571 | 6 | return m_templateName; |
1572 | 6 | } |
1573 | | |
1574 | | template <typename ALLOC> |
1575 | | Span<const BasicTemplateArgumentInfo<ALLOC>> TemplatableTypeInfoBase<ALLOC>::getTemplateArguments() const |
1576 | 5 | { |
1577 | 5 | return m_templateArguments; |
1578 | 5 | } |
1579 | | |
1580 | | template <typename ALLOC> |
1581 | | CompoundTypeInfoBase<ALLOC>::CompoundTypeInfoBase(StringView schemaName, CreateInstanceFunc createInstanceFunc, |
1582 | | SchemaType schemaType, CppType cppType, |
1583 | | StringView templateName, Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments, |
1584 | | Span<const BasicFieldInfo<ALLOC>> fields, Span<const BasicParameterInfo<ALLOC>> parameters, |
1585 | | Span<const BasicFunctionInfo<ALLOC>> functions) : |
1586 | | TemplatableTypeInfoBase<ALLOC>(schemaName, schemaType, cppType, templateName, templateArguments), |
1587 | | m_createInstanceFunc(createInstanceFunc), |
1588 | | m_fields(fields), m_parameters(parameters), m_functions(functions) |
1589 | 49 | {} |
1590 | | |
1591 | | template <typename ALLOC> |
1592 | | CompoundTypeInfoBase<ALLOC>::~CompoundTypeInfoBase() = default; |
1593 | | |
1594 | | template <typename ALLOC> |
1595 | | Span<const BasicFieldInfo<ALLOC>> CompoundTypeInfoBase<ALLOC>::getFields() const |
1596 | 685 | { |
1597 | 685 | return m_fields; |
1598 | 685 | } |
1599 | | |
1600 | | template <typename ALLOC> |
1601 | | Span<const BasicParameterInfo<ALLOC>> CompoundTypeInfoBase<ALLOC>::getParameters() const |
1602 | 127 | { |
1603 | 127 | return m_parameters; |
1604 | 127 | } |
1605 | | |
1606 | | template <typename ALLOC> |
1607 | | Span<const BasicFunctionInfo<ALLOC>> CompoundTypeInfoBase<ALLOC>::getFunctions() const |
1608 | 69 | { |
1609 | 69 | return m_functions; |
1610 | 69 | } |
1611 | | |
1612 | | template <typename ALLOC> |
1613 | | IBasicReflectablePtr<ALLOC> CompoundTypeInfoBase<ALLOC>::createInstance(const ALLOC& allocator) const |
1614 | 88 | { |
1615 | 88 | if (!m_createInstanceFunc) |
1616 | 5 | { |
1617 | 5 | throw CppRuntimeException("Reflectable '") << getSchemaName() << "': Cannot create instance, " << |
1618 | 5 | "either '-withoutWriterCode' or '-withoutReflectionCode' zserio option is used!"; |
1619 | 5 | } |
1620 | 83 | return m_createInstanceFunc(allocator); |
1621 | 88 | } |
1622 | | |
1623 | | template <typename ALLOC> |
1624 | | StructTypeInfo<ALLOC>::StructTypeInfo(StringView schemaName, CreateInstanceFunc createInstanceFunc, |
1625 | | StringView templateName, Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments, |
1626 | | Span<const BasicFieldInfo<ALLOC>> fields, Span<const BasicParameterInfo<ALLOC>> parameters, |
1627 | | Span<const BasicFunctionInfo<ALLOC>> functions) : |
1628 | | CompoundTypeInfoBase<ALLOC>(schemaName, createInstanceFunc, SchemaType::STRUCT, CppType::STRUCT, |
1629 | | templateName, templateArguments, fields, parameters, functions) |
1630 | 43 | {} |
1631 | | |
1632 | | template <typename ALLOC> |
1633 | | UnionTypeInfo<ALLOC>::UnionTypeInfo(StringView schemaName, CreateInstanceFunc createInstanceFunc, |
1634 | | StringView templateName, Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments, |
1635 | | Span<const BasicFieldInfo<ALLOC>> fields, Span<const BasicParameterInfo<ALLOC>> parameters, |
1636 | | Span<const BasicFunctionInfo<ALLOC>> functions) : |
1637 | | CompoundTypeInfoBase<ALLOC>(schemaName, createInstanceFunc, SchemaType::UNION, CppType::UNION, |
1638 | | templateName, templateArguments, fields, parameters, functions) |
1639 | 3 | {} |
1640 | | |
1641 | | template <typename ALLOC> |
1642 | | ChoiceTypeInfo<ALLOC>::ChoiceTypeInfo(StringView schemaName, CreateInstanceFunc createInstanceFunc, |
1643 | | StringView templateName, Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments, |
1644 | | Span<const BasicFieldInfo<ALLOC>> fields, Span<const BasicParameterInfo<ALLOC>> parameters, |
1645 | | Span<const BasicFunctionInfo<ALLOC>> functions, |
1646 | | StringView selector, Span<const BasicCaseInfo<ALLOC>> cases) : |
1647 | | CompoundTypeInfoBase<ALLOC>(schemaName, createInstanceFunc, SchemaType::CHOICE, CppType::CHOICE, |
1648 | | templateName, templateArguments, fields, parameters, functions), |
1649 | | m_selector(selector), m_cases(cases) |
1650 | 3 | {} |
1651 | | |
1652 | | template <typename ALLOC> |
1653 | | StringView ChoiceTypeInfo<ALLOC>::getSelector() const |
1654 | 1 | { |
1655 | 1 | return m_selector; |
1656 | 1 | } |
1657 | | |
1658 | | template <typename ALLOC> |
1659 | | Span<const BasicCaseInfo<ALLOC>> ChoiceTypeInfo<ALLOC>::getCases() const |
1660 | 1 | { |
1661 | 1 | return m_cases; |
1662 | 1 | } |
1663 | | |
1664 | | template <typename ALLOC> |
1665 | | SqlTableTypeInfo<ALLOC>::SqlTableTypeInfo(StringView schemaName, |
1666 | | StringView templateName, Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments, |
1667 | | Span<const BasicColumnInfo<ALLOC>> columns, StringView sqlConstraint, StringView virtualTableUsing, |
1668 | | bool isWithoutRowId) : |
1669 | | TemplatableTypeInfoBase<ALLOC>(schemaName, SchemaType::SQL_TABLE, CppType::SQL_TABLE, |
1670 | | templateName, templateArguments), |
1671 | | m_columns(columns), m_sqlConstraint(sqlConstraint), m_virtualTableUsing(virtualTableUsing), |
1672 | | m_isWithoutRowId(isWithoutRowId) |
1673 | 1 | {} |
1674 | | |
1675 | | template <typename ALLOC> |
1676 | | Span<const BasicColumnInfo<ALLOC>> SqlTableTypeInfo<ALLOC>::getColumns() const |
1677 | 1 | { |
1678 | 1 | return m_columns; |
1679 | 1 | } |
1680 | | |
1681 | | template <typename ALLOC> |
1682 | | StringView SqlTableTypeInfo<ALLOC>::getSqlConstraint() const |
1683 | 1 | { |
1684 | 1 | return m_sqlConstraint; |
1685 | 1 | } |
1686 | | |
1687 | | template <typename ALLOC> |
1688 | | StringView SqlTableTypeInfo<ALLOC>::getVirtualTableUsing() const |
1689 | 1 | { |
1690 | 1 | return m_virtualTableUsing; |
1691 | 1 | } |
1692 | | |
1693 | | template <typename ALLOC> |
1694 | | bool SqlTableTypeInfo<ALLOC>::isWithoutRowId() const |
1695 | 1 | { |
1696 | 1 | return m_isWithoutRowId; |
1697 | 1 | } |
1698 | | |
1699 | | template <typename ALLOC> |
1700 | | SqlDatabaseTypeInfo<ALLOC>::SqlDatabaseTypeInfo(StringView schemaName, |
1701 | | Span<const BasicTableInfo<ALLOC>> tables) : |
1702 | | TypeInfoBase<ALLOC>(schemaName, SchemaType::SQL_DATABASE, CppType::SQL_DATABASE), |
1703 | | m_tables(tables) |
1704 | 1 | {} |
1705 | | |
1706 | | template <typename ALLOC> |
1707 | | Span<const BasicTableInfo<ALLOC>> SqlDatabaseTypeInfo<ALLOC>::getTables() const |
1708 | 1 | { |
1709 | 1 | return m_tables; |
1710 | 1 | } |
1711 | | |
1712 | | template <typename ALLOC> |
1713 | | TypeInfoWithUnderlyingTypeBase<ALLOC>::TypeInfoWithUnderlyingTypeBase( |
1714 | | StringView schemaName, SchemaType schemaType, CppType cppType, |
1715 | | const IBasicTypeInfo<ALLOC>& underlyingType, Span<const StringView> underlyingTypeArguments) : |
1716 | | TypeInfoBase<ALLOC>(schemaName, schemaType, cppType), |
1717 | | m_underlyingType(underlyingType), m_underlyingTypeArguments(underlyingTypeArguments) |
1718 | 98 | {} |
1719 | | |
1720 | | template <typename ALLOC> |
1721 | | const IBasicTypeInfo<ALLOC>& TypeInfoWithUnderlyingTypeBase<ALLOC>::getUnderlyingType() const |
1722 | 75 | { |
1723 | 75 | return m_underlyingType; |
1724 | 75 | } |
1725 | | |
1726 | | template <typename ALLOC> |
1727 | | Span<const StringView> TypeInfoWithUnderlyingTypeBase<ALLOC>::getUnderlyingTypeArguments() const |
1728 | 2 | { |
1729 | 2 | return m_underlyingTypeArguments; |
1730 | 2 | } |
1731 | | |
1732 | | template <typename ALLOC> |
1733 | | EnumTypeInfo<ALLOC>::EnumTypeInfo(StringView schemaName, const IBasicTypeInfo<ALLOC>& underlyingType, |
1734 | | Span<const StringView> underlyingTypeArguments, Span<const ItemInfo> enumItems) : |
1735 | | TypeInfoWithUnderlyingTypeBase<ALLOC>(schemaName, SchemaType::ENUM, CppType::ENUM, |
1736 | | underlyingType, underlyingTypeArguments), |
1737 | | m_enumItems(enumItems) |
1738 | 63 | {} |
1739 | | |
1740 | | template <typename ALLOC> |
1741 | | Span<const ItemInfo> EnumTypeInfo<ALLOC>::getEnumItems() const |
1742 | 23 | { |
1743 | 23 | return m_enumItems; |
1744 | 23 | } |
1745 | | |
1746 | | template <typename ALLOC> |
1747 | | BitmaskTypeInfo<ALLOC>::BitmaskTypeInfo(StringView schemaName, const IBasicTypeInfo<ALLOC>& underlyingType, |
1748 | | Span<const StringView> underlyingTypeArguments, Span<const ItemInfo> bitmaskValues) : |
1749 | | TypeInfoWithUnderlyingTypeBase<ALLOC>(schemaName, SchemaType::BITMASK, CppType::BITMASK, |
1750 | | underlyingType, underlyingTypeArguments), |
1751 | | m_bitmaskValues(bitmaskValues) |
1752 | 35 | {} |
1753 | | |
1754 | | template <typename ALLOC> |
1755 | | Span<const ItemInfo> BitmaskTypeInfo<ALLOC>::getBitmaskValues() const |
1756 | 48 | { |
1757 | 48 | return m_bitmaskValues; |
1758 | 48 | } |
1759 | | |
1760 | | template <typename ALLOC> |
1761 | | PubsubTypeInfo<ALLOC>::PubsubTypeInfo(StringView schemaName, Span<const BasicMessageInfo<ALLOC>> messages) : |
1762 | | TypeInfoBase<ALLOC>(schemaName, SchemaType::PUBSUB, CppType::PUBSUB), m_messages(messages) |
1763 | 1 | {} |
1764 | | |
1765 | | template <typename ALLOC> |
1766 | | Span<const BasicMessageInfo<ALLOC>> PubsubTypeInfo<ALLOC>::getMessages() const |
1767 | 1 | { |
1768 | 1 | return m_messages; |
1769 | 1 | } |
1770 | | |
1771 | | template <typename ALLOC> |
1772 | | ServiceTypeInfo<ALLOC>::ServiceTypeInfo(StringView schemaName, Span<const BasicMethodInfo<ALLOC>> methods) : |
1773 | | TypeInfoBase<ALLOC>(schemaName, SchemaType::SERVICE, CppType::SERVICE), m_methods(methods) |
1774 | 1 | {} |
1775 | | |
1776 | | template <typename ALLOC> |
1777 | | Span<const BasicMethodInfo<ALLOC>> ServiceTypeInfo<ALLOC>::getMethods() const |
1778 | 1 | { |
1779 | 1 | return m_methods; |
1780 | 1 | } |
1781 | | |
1782 | | template <typename ALLOC> |
1783 | | StringView RecursiveTypeInfo<ALLOC>::getSchemaName() const |
1784 | 1 | { |
1785 | 1 | return m_typeInfoFunc().getSchemaName(); |
1786 | 1 | } |
1787 | | |
1788 | | template <typename ALLOC> |
1789 | | SchemaType RecursiveTypeInfo<ALLOC>::getSchemaType() const |
1790 | 1 | { |
1791 | 1 | return m_typeInfoFunc().getSchemaType(); |
1792 | 1 | } |
1793 | | |
1794 | | template <typename ALLOC> |
1795 | | CppType RecursiveTypeInfo<ALLOC>::getCppType() const |
1796 | 1 | { |
1797 | 1 | return m_typeInfoFunc().getCppType(); |
1798 | 1 | } |
1799 | | |
1800 | | template <typename ALLOC> |
1801 | | uint8_t RecursiveTypeInfo<ALLOC>::getBitSize() const |
1802 | 1 | { |
1803 | 1 | return m_typeInfoFunc().getBitSize(); |
1804 | 1 | } |
1805 | | |
1806 | | template <typename ALLOC> |
1807 | | Span<const BasicFieldInfo<ALLOC>> RecursiveTypeInfo<ALLOC>::getFields() const |
1808 | 1 | { |
1809 | 1 | return m_typeInfoFunc().getFields(); |
1810 | 1 | } |
1811 | | |
1812 | | template <typename ALLOC> |
1813 | | Span<const BasicParameterInfo<ALLOC>> RecursiveTypeInfo<ALLOC>::getParameters() const |
1814 | 1 | { |
1815 | 1 | return m_typeInfoFunc().getParameters(); |
1816 | 1 | } |
1817 | | |
1818 | | template <typename ALLOC> |
1819 | | Span<const BasicFunctionInfo<ALLOC>> RecursiveTypeInfo<ALLOC>::getFunctions() const |
1820 | 1 | { |
1821 | 1 | return m_typeInfoFunc().getFunctions(); |
1822 | 1 | } |
1823 | | |
1824 | | template <typename ALLOC> |
1825 | | StringView RecursiveTypeInfo<ALLOC>::getSelector() const |
1826 | 1 | { |
1827 | 1 | return m_typeInfoFunc().getSelector(); |
1828 | 1 | } |
1829 | | |
1830 | | template <typename ALLOC> |
1831 | | Span<const BasicCaseInfo<ALLOC>> RecursiveTypeInfo<ALLOC>::getCases() const |
1832 | 1 | { |
1833 | 1 | return m_typeInfoFunc().getCases(); |
1834 | 1 | } |
1835 | | |
1836 | | template <typename ALLOC> |
1837 | | const IBasicTypeInfo<ALLOC>& RecursiveTypeInfo<ALLOC>::getUnderlyingType() const |
1838 | 1 | { |
1839 | 1 | return m_typeInfoFunc().getUnderlyingType(); |
1840 | 1 | } |
1841 | | |
1842 | | template <typename ALLOC> |
1843 | | Span<const StringView> RecursiveTypeInfo<ALLOC>::getUnderlyingTypeArguments() const |
1844 | 1 | { |
1845 | 1 | return m_typeInfoFunc().getUnderlyingTypeArguments(); |
1846 | 1 | } |
1847 | | |
1848 | | template <typename ALLOC> |
1849 | | Span<const ItemInfo> RecursiveTypeInfo<ALLOC>::getEnumItems() const |
1850 | 1 | { |
1851 | 1 | return m_typeInfoFunc().getEnumItems(); |
1852 | 1 | } |
1853 | | |
1854 | | template <typename ALLOC> |
1855 | | Span<const ItemInfo> RecursiveTypeInfo<ALLOC>::getBitmaskValues() const |
1856 | 1 | { |
1857 | 1 | return m_typeInfoFunc().getBitmaskValues(); |
1858 | 1 | } |
1859 | | |
1860 | | template <typename ALLOC> |
1861 | | Span<const BasicColumnInfo<ALLOC>> RecursiveTypeInfo<ALLOC>::getColumns() const |
1862 | 1 | { |
1863 | 1 | return m_typeInfoFunc().getColumns(); |
1864 | 1 | } |
1865 | | |
1866 | | template <typename ALLOC> |
1867 | | StringView RecursiveTypeInfo<ALLOC>::getSqlConstraint() const |
1868 | 1 | { |
1869 | 1 | return m_typeInfoFunc().getSqlConstraint(); |
1870 | 1 | } |
1871 | | |
1872 | | template <typename ALLOC> |
1873 | | StringView RecursiveTypeInfo<ALLOC>::getVirtualTableUsing() const |
1874 | 1 | { |
1875 | 1 | return m_typeInfoFunc().getVirtualTableUsing(); |
1876 | 1 | } |
1877 | | |
1878 | | template <typename ALLOC> |
1879 | | bool RecursiveTypeInfo<ALLOC>::isWithoutRowId() const |
1880 | 1 | { |
1881 | 1 | return m_typeInfoFunc().isWithoutRowId(); |
1882 | 1 | } |
1883 | | |
1884 | | template <typename ALLOC> |
1885 | | Span<const BasicTableInfo<ALLOC>> RecursiveTypeInfo<ALLOC>::getTables() const |
1886 | 1 | { |
1887 | 1 | return m_typeInfoFunc().getTables(); |
1888 | 1 | } |
1889 | | |
1890 | | template <typename ALLOC> |
1891 | | StringView RecursiveTypeInfo<ALLOC>::getTemplateName() const |
1892 | 1 | { |
1893 | 1 | return m_typeInfoFunc().getTemplateName(); |
1894 | 1 | } |
1895 | | |
1896 | | template <typename ALLOC> |
1897 | | Span<const BasicTemplateArgumentInfo<ALLOC>> RecursiveTypeInfo<ALLOC>::getTemplateArguments() const |
1898 | 1 | { |
1899 | 1 | return m_typeInfoFunc().getTemplateArguments(); |
1900 | 1 | } |
1901 | | |
1902 | | template <typename ALLOC> |
1903 | | Span<const BasicMessageInfo<ALLOC>> RecursiveTypeInfo<ALLOC>::getMessages() const |
1904 | 1 | { |
1905 | 1 | return m_typeInfoFunc().getMessages(); |
1906 | 1 | } |
1907 | | |
1908 | | template <typename ALLOC> |
1909 | | Span<const BasicMethodInfo<ALLOC>> RecursiveTypeInfo<ALLOC>::getMethods() const |
1910 | 1 | { |
1911 | 1 | return m_typeInfoFunc().getMethods(); |
1912 | 1 | } |
1913 | | |
1914 | | template <typename ALLOC> |
1915 | | IBasicReflectablePtr<ALLOC> RecursiveTypeInfo<ALLOC>::createInstance(const ALLOC& allocator) const |
1916 | 2 | { |
1917 | 2 | return m_typeInfoFunc().createInstance(allocator); |
1918 | 2 | } |
1919 | | |
1920 | | template <typename ALLOC> |
1921 | | IBasicReflectablePtr<ALLOC> RecursiveTypeInfo<ALLOC>::createInstance() const |
1922 | 1 | { |
1923 | 1 | return createInstance(ALLOC()); |
1924 | 1 | } |
1925 | | |
1926 | | } // namespace zserio |
1927 | | |
1928 | | #endif // ZSERIO_TYPE_INFO_INC_H |