WPILibC++ 2025.2.1
Loading...
Searching...
No Matches
DynamicStruct.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <stdint.h>
8
9#include <cassert>
10#include <span>
11#include <string>
12#include <string_view>
13#include <unordered_set>
14#include <utility>
15#include <vector>
16
17#include "wpi/StringMap.h"
18#include "wpi/bit.h"
19
20namespace wpi {
21
22template <typename T>
23class SmallVectorImpl;
24
25class DynamicStruct;
26class MutableDynamicStruct;
27class StructDescriptor;
28class StructDescriptorDatabase;
29
30/**
31 * Known data types for raw struct dynamic fields (see StructFieldDescriptor).
32 */
33enum class StructFieldType {
34 /// bool.
35 kBool,
36 /// char.
37 kChar,
38 /// int8.
39 kInt8,
40 /// int16.
41 kInt16,
42 /// int32.
43 kInt32,
44 /// int64.
45 kInt64,
46 /// uint8.
47 kUint8,
48 /// uint16.
49 kUint16,
50 /// uint32.
51 kUint32,
52 /// uint64.
53 kUint64,
54 /// float.
55 kFloat,
56 /// double.
57 kDouble,
58 /// struct.
60};
61
62/**
63 * Raw struct dynamic field descriptor.
64 */
66 struct private_init {};
67 friend class DynamicStruct;
69 friend class StructDescriptor;
71
72 public:
73 /**
74 * Set of enumerated values.
75 */
76 using EnumValues = std::vector<std::pair<std::string, int64_t>>;
77
78 StructFieldDescriptor(const StructDescriptor* parent, std::string_view name,
79 StructFieldType type, size_t size, size_t arraySize,
80 unsigned int bitWidth, EnumValues enumValues,
81 const StructDescriptor* structDesc,
82 const private_init&);
83
84 /**
85 * Gets the dynamic struct this field is contained in.
86 *
87 * @return struct descriptor
88 */
89 const StructDescriptor* GetParent() const { return m_parent; }
90
91 /**
92 * Gets the field name.
93 *
94 * @return field name
95 */
96 const std::string& GetName() const { return m_name; }
97
98 /**
99 * Gets the field type.
100 *
101 * @return field type
102 */
103 StructFieldType GetType() const { return m_type; }
104
105 /**
106 * Returns whether the field type is a signed integer.
107 *
108 * @return true if signed integer, false otherwise
109 */
110 bool IsInt() const {
111 return m_type == StructFieldType::kInt8 ||
112 m_type == StructFieldType::kInt16 ||
113 m_type == StructFieldType::kInt32 ||
114 m_type == StructFieldType::kInt64;
115 }
116
117 /**
118 * Returns whether the field type is an unsigned integer.
119 *
120 * @return true if unsigned integer, false otherwise
121 */
122 bool IsUint() const {
123 return m_type == StructFieldType::kUint8 ||
124 m_type == StructFieldType::kUint16 ||
125 m_type == StructFieldType::kUint32 ||
126 m_type == StructFieldType::kUint64;
127 }
128
129 /**
130 * Gets the underlying storage size of the field, in bytes.
131 *
132 * @return number of bytes
133 */
134 size_t GetSize() const { return m_size; }
135
136 /**
137 * Gets the storage offset of the field, in bytes.
138 *
139 * @return number of bytes from the start of the struct
140 */
141 size_t GetOffset() const { return m_offset; }
142
143 /**
144 * Gets the bit width of the field, in bits.
145 *
146 * @return number of bits
147 */
148 unsigned int GetBitWidth() const {
149 return m_bitWidth == 0 ? m_size * 8 : m_bitWidth;
150 }
151
152 /**
153 * Gets the bit mask for the field. The mask is always the least significant
154 * bits (it is not shifted).
155 *
156 * @return bit mask
157 */
158 uint64_t GetBitMask() const { return m_bitMask; }
159
160 /**
161 * Gets the bit shift for the field (LSB=0).
162 *
163 * @return number of bits
164 */
165 unsigned int GetBitShift() const { return m_bitShift; }
166
167 /**
168 * Returns whether the field is an array.
169 *
170 * @return true if array
171 */
172 bool IsArray() const { return m_arraySize > 1; }
173
174 /**
175 * Gets the array size. Returns 1 if non-array.
176 *
177 * @return number of elements
178 */
179 size_t GetArraySize() const { return m_arraySize; }
180
181 /**
182 * Returns whether the field has enumerated values.
183 *
184 * @return true if there are enumerated values
185 */
186 bool HasEnum() const { return !m_enum.empty(); }
187
188 /**
189 * Gets the enumerated values.
190 *
191 * @return set of enumerated values
192 */
193 const EnumValues& GetEnumValues() { return m_enum; }
194
195 /**
196 * Gets the struct descriptor for a struct data type.
197 *
198 * @return struct descriptor; returns null for non-struct
199 */
200 const StructDescriptor* GetStruct() const { return m_struct; }
201
202 /**
203 * Gets the minimum unsigned integer value that can be stored in this field.
204 *
205 * @return minimum value
206 */
207 uint64_t GetUintMin() const { return 0; }
208
209 /**
210 * Gets the maximum unsigned integer value that can be stored in this field.
211 *
212 * @return maximum value
213 */
214 uint64_t GetUintMax() const { return m_bitMask; }
215
216 /**
217 * Gets the minimum signed integer value that can be stored in this field.
218 *
219 * @return minimum value
220 */
221 int64_t GetIntMin() const {
222 return static_cast<int64_t>(-(m_bitMask >> 1)) - 1;
223 }
224
225 /**
226 * Gets the maximum signed integer value that can be stored in this field.
227 *
228 * @return maximum value
229 */
230 int64_t GetIntMax() const { return m_bitMask >> 1; }
231
232 /**
233 * Returns whether the field is a bitfield.
234 *
235 * @return true if bitfield
236 */
237 bool IsBitField() const {
238 return (m_bitShift != 0 || m_bitWidth != (m_size * 8)) &&
239 m_struct == nullptr;
240 }
241
242 private:
243 // note: constructor fills in everything except offset and shift
244 const StructDescriptor* m_parent;
245 std::string m_name;
246 size_t m_size;
247 size_t m_offset = 0;
248 size_t m_arraySize; // 1 for non-arrays
249 EnumValues m_enum;
250 const StructDescriptor* m_struct; // nullptr for non-structs
251 uint64_t m_bitMask;
252 StructFieldType m_type;
253 unsigned int m_bitWidth;
254 unsigned int m_bitShift = 0;
255};
256
257/**
258 * Raw struct dynamic struct descriptor.
259 */
261 struct private_init {};
263
264 public:
265 StructDescriptor(std::string_view name, const private_init&) : m_name{name} {}
266
267 /**
268 * Gets the struct name.
269 *
270 * @return name
271 */
272 const std::string& GetName() const { return m_name; }
273
274 /**
275 * Gets the struct schema.
276 *
277 * @return schema
278 */
279 const std::string& GetSchema() const { return m_schema; }
280
281 /**
282 * Returns whether the struct is valid (e.g. the struct is fully defined and
283 * field offsets computed).
284 *
285 * @return true if valid
286 */
287 bool IsValid() const { return m_valid; }
288
289 /**
290 * Returns the struct size, in bytes. Not valid unless IsValid() is true.
291 *
292 * @return size in bytes
293 */
294 size_t GetSize() const {
295 assert(m_valid);
296 return m_size;
297 }
298
299 /**
300 * Gets a field descriptor by name. Note the field cannot be accessed until
301 * the struct is valid.
302 *
303 * @param name field name
304 * @return field descriptor, or nullptr if not found
305 */
306 const StructFieldDescriptor* FindFieldByName(std::string_view name) const;
307
308 /**
309 * Gets all field descriptors. Note fields cannot be accessed until the struct
310 * is valid.
311 *
312 * @return field descriptors
313 */
314 const std::vector<StructFieldDescriptor>& GetFields() const {
315 return m_fields;
316 }
317
318 private:
319 bool CheckCircular(
321 std::string CalculateOffsets(
323
324 std::string m_name;
325 std::string m_schema;
326 std::vector<StructDescriptor*> m_references;
327 std::vector<StructFieldDescriptor> m_fields;
328 StringMap<size_t> m_fieldsByName;
329 size_t m_size = 0;
330 bool m_valid = false;
331};
332
333/**
334 * Database of raw struct dynamic descriptors.
335 */
337 public:
338 /**
339 * Adds a structure schema to the database. If the struct references other
340 * structs that have not yet been added, it will not be valid until those
341 * structs are also added.
342 *
343 * @param[in] name structure name
344 * @param[in] schema structure schema
345 * @param[out] err detailed error, if nullptr is returned
346 * @return Added struct, or nullptr on error
347 */
348 const StructDescriptor* Add(std::string_view name, std::string_view schema,
349 std::string* err);
350
351 /**
352 * Finds a structure in the database by name.
353 *
354 * @param name structure name
355 * @return struct descriptor, or nullptr if not found
356 */
357 const StructDescriptor* Find(std::string_view name) const;
358
359 private:
361};
362
363/**
364 * Dynamic (run-time) read-only access to a serialized raw struct.
365 */
367 public:
368 /**
369 * Constructs a new dynamic struct. Note: the passed data is a span; no copy
370 * is made, so it's necessary for the lifetime of the referenced data to be
371 * longer than this object.
372 *
373 * @param desc struct descriptor
374 * @param data serialized data
375 */
376 DynamicStruct(const StructDescriptor* desc, std::span<const uint8_t> data)
377 : m_desc{desc}, m_data{data} {}
378
379 /**
380 * Gets the struct descriptor.
381 *
382 * @return struct descriptor
383 */
384 const StructDescriptor* GetDescriptor() const { return m_desc; }
385
386 /**
387 * Gets the serialized data.
388 *
389 * @return data
390 */
391 std::span<const uint8_t> GetData() const { return m_data; }
392
393 /**
394 * Gets a struct field descriptor by name.
395 *
396 * @param name field name
397 * @return field descriptor, or nullptr if no field with that name exists
398 */
399 const StructFieldDescriptor* FindField(std::string_view name) const {
400 return m_desc->FindFieldByName(name);
401 }
402
403 /**
404 * Gets the value of a boolean field.
405 *
406 * @param field field descriptor
407 * @param arrIndex array index (must be less than field array size)
408 * @return field value
409 */
411 size_t arrIndex = 0) const {
412 assert(field->m_type == StructFieldType::kBool);
413 return GetFieldImpl(field, arrIndex);
414 }
415
416 /**
417 * Gets the value of a signed integer field.
418 *
419 * @param field field descriptor
420 * @param arrIndex array index (must be less than field array size)
421 * @return field value
422 */
423 int64_t GetIntField(const StructFieldDescriptor* field,
424 size_t arrIndex = 0) const {
425 assert(field->IsInt());
426 uint64_t raw = GetFieldImpl(field, arrIndex);
427 switch (field->m_size) {
428 case 1:
429 return static_cast<int8_t>(raw);
430 case 2:
431 return static_cast<int16_t>(raw);
432 case 4:
433 return static_cast<int32_t>(raw);
434 default:
435 return raw;
436 }
437 }
438
439 /**
440 * Gets the value of an unsigned integer field.
441 *
442 * @param field field descriptor
443 * @param arrIndex array index (must be less than field array size)
444 * @return field value
445 */
446 uint64_t GetUintField(const StructFieldDescriptor* field,
447 size_t arrIndex = 0) const {
448 assert(field->IsUint());
449 return GetFieldImpl(field, arrIndex);
450 }
451
452 /**
453 * Gets the value of a float field.
454 *
455 * @param field field descriptor
456 * @param arrIndex array index (must be less than field array size)
457 * @return field value
458 */
460 size_t arrIndex = 0) const {
461 assert(field->m_type == StructFieldType::kFloat);
462 return bit_cast<float>(
463 static_cast<uint32_t>(GetFieldImpl(field, arrIndex)));
464 }
465
466 /**
467 * Gets the value of a double field.
468 *
469 * @param field field descriptor
470 * @param arrIndex array index (must be less than field array size)
471 * @return field value
472 */
474 size_t arrIndex = 0) const {
475 assert(field->m_type == StructFieldType::kDouble);
476 return bit_cast<double>(GetFieldImpl(field, arrIndex));
477 }
478
479 /**
480 * Gets the value of a char or char array field.
481 *
482 * @param field field descriptor
483 * @return field value
484 */
485 std::string_view GetStringField(const StructFieldDescriptor* field) const;
486
487 /**
488 * Gets the value of a struct field.
489 *
490 * @param field field descriptor
491 * @param arrIndex array index (must be less than field array size)
492 * @return field value
493 */
495 size_t arrIndex = 0) const {
496 assert(field->m_type == StructFieldType::kStruct);
497 assert(field->m_parent == m_desc);
498 assert(m_desc->IsValid());
499 assert(arrIndex < field->m_arraySize);
500 return DynamicStruct{field->m_struct,
501 m_data.subspan(field->m_offset +
502 arrIndex * field->m_struct->GetSize())};
503 }
504
505 protected:
507
508 private:
509 uint64_t GetFieldImpl(const StructFieldDescriptor* field,
510 size_t arrIndex) const;
511
512 std::span<const uint8_t> m_data;
513};
514
515/**
516 * Dynamic (run-time) mutable access to a serialized raw struct.
517 */
519 public:
520 /**
521 * Constructs a new dynamic struct. Note: the passed data is a span; no copy
522 * is made, so it's necessary for the lifetime of the referenced data to be
523 * longer than this object.
524 *
525 * @param desc struct descriptor
526 * @param data serialized data
527 */
528 MutableDynamicStruct(const StructDescriptor* desc, std::span<uint8_t> data)
529 : DynamicStruct{desc, data}, m_data{data} {}
530
531 /**
532 * Gets the serialized data.
533 *
534 * @return data
535 */
536 std::span<uint8_t> GetData() { return m_data; }
537
539
540 /**
541 * Overwrites the entire serialized struct by copying data from a span.
542 *
543 * @param data replacement data for the struct
544 */
545 void SetData(std::span<const uint8_t> data);
546
547 /**
548 * Sets the value of a boolean field.
549 *
550 * @param field field descriptor
551 * @param value field value
552 * @param arrIndex array index (must be less than field array size)
553 */
554 void SetBoolField(const StructFieldDescriptor* field, bool value,
555 size_t arrIndex = 0) {
556 assert(field->m_type == StructFieldType::kBool);
557 SetFieldImpl(field, value ? 1 : 0, arrIndex);
558 }
559
560 /**
561 * Sets the value of a signed integer field.
562 *
563 * @param field field descriptor
564 * @param value field value
565 * @param arrIndex array index (must be less than field array size)
566 */
567 void SetIntField(const StructFieldDescriptor* field, int64_t value,
568 size_t arrIndex = 0) {
569 assert(field->IsInt());
570 SetFieldImpl(field, value, arrIndex);
571 }
572
573 /**
574 * Sets the value of an unsigned integer field.
575 *
576 * @param field field descriptor
577 * @param value field value
578 * @param arrIndex array index (must be less than field array size)
579 */
580 void SetUintField(const StructFieldDescriptor* field, uint64_t value,
581 size_t arrIndex = 0) {
582 assert(field->IsUint());
583 SetFieldImpl(field, value, arrIndex);
584 }
585
586 /**
587 * Sets the value of a float field.
588 *
589 * @param field field descriptor
590 * @param value field value
591 * @param arrIndex array index (must be less than field array size)
592 */
593 void SetFloatField(const StructFieldDescriptor* field, float value,
594 size_t arrIndex = 0) {
595 assert(field->m_type == StructFieldType::kFloat);
596 SetFieldImpl(field, bit_cast<uint32_t>(value), arrIndex);
597 }
598
599 /**
600 * Sets the value of a double field.
601 *
602 * @param field field descriptor
603 * @param value field value
604 * @param arrIndex array index (must be less than field array size)
605 */
606 void SetDoubleField(const StructFieldDescriptor* field, double value,
607 size_t arrIndex = 0) {
608 assert(field->m_type == StructFieldType::kDouble);
609 SetFieldImpl(field, bit_cast<uint64_t>(value), arrIndex);
610 }
611
612 /**
613 * Sets the value of a char or char array field.
614 *
615 * @param field field descriptor
616 * @param value field value
617 * @return true if the full value fit in the struct, false if truncated
618 */
620 std::string_view value);
621
622 /**
623 * Sets the value of a struct field.
624 *
625 * @param field field descriptor
626 * @param value field value
627 * @param arrIndex array index (must be less than field array size)
628 */
630 const DynamicStruct& value, size_t arrIndex = 0);
631
632 /**
633 * Gets the value of a struct field.
634 *
635 * @param field field descriptor
636 * @param arrIndex array index (must be less than field array size)
637 * @return field value
638 */
640 size_t arrIndex = 0) {
641 assert(field->m_type == StructFieldType::kStruct);
642 assert(field->m_parent == m_desc);
643 assert(m_desc->IsValid());
644 assert(arrIndex < field->m_arraySize);
646 field->m_struct, m_data.subspan(field->m_offset +
647 arrIndex * field->m_struct->GetSize())};
648 }
649
651
652 private:
653 void SetFieldImpl(const StructFieldDescriptor* field, uint64_t value,
654 size_t arrIndex);
655
656 std::span<uint8_t> m_data;
657};
658
659namespace impl {
660struct DSOData {
661 explicit DSOData(size_t size) : m_dataStore(size) {}
662 explicit DSOData(std::span<const uint8_t> data)
663 : m_dataStore{data.begin(), data.end()} {}
664
665 std::vector<uint8_t> m_dataStore;
666};
667} // namespace impl
668
669/**
670 * Dynamic (run-time) mutable access to a serialized raw struct, with internal
671 * data storage.
672 */
674 /**
675 * Constructs a new dynamic struct object. The descriptor must be valid.
676 *
677 * @param desc struct descriptor
678 */
679 explicit DynamicStructObject(const StructDescriptor* desc)
680 : DSOData{desc->GetSize()}, MutableDynamicStruct{desc, m_dataStore} {}
681
682 /**
683 * Constructs a new dynamic struct object. Makes a copy of the serialized
684 * data so there are no lifetime constraints on the data parameter.
685 *
686 * @param desc struct descriptor
687 * @param data serialized data
688 */
690 std::span<const uint8_t> data)
692 assert(data.size() >= desc->GetSize());
693 }
694
695 // can't be movable due to span references
697 DynamicStructObject& operator=(DynamicStructObject&&) = delete;
698};
699
700} // namespace wpi
This file implements the C++20 <bit> header.
Dynamic (run-time) read-only access to a serialized raw struct.
Definition DynamicStruct.h:366
std::span< const uint8_t > GetData() const
Gets the serialized data.
Definition DynamicStruct.h:391
uint64_t GetUintField(const StructFieldDescriptor *field, size_t arrIndex=0) const
Gets the value of an unsigned integer field.
Definition DynamicStruct.h:446
const StructDescriptor * m_desc
Definition DynamicStruct.h:506
const StructFieldDescriptor * FindField(std::string_view name) const
Gets a struct field descriptor by name.
Definition DynamicStruct.h:399
DynamicStruct GetStructField(const StructFieldDescriptor *field, size_t arrIndex=0) const
Gets the value of a struct field.
Definition DynamicStruct.h:494
DynamicStruct(const StructDescriptor *desc, std::span< const uint8_t > data)
Constructs a new dynamic struct.
Definition DynamicStruct.h:376
double GetDoubleField(const StructFieldDescriptor *field, size_t arrIndex=0) const
Gets the value of a double field.
Definition DynamicStruct.h:473
const StructDescriptor * GetDescriptor() const
Gets the struct descriptor.
Definition DynamicStruct.h:384
int64_t GetIntField(const StructFieldDescriptor *field, size_t arrIndex=0) const
Gets the value of a signed integer field.
Definition DynamicStruct.h:423
bool GetBoolField(const StructFieldDescriptor *field, size_t arrIndex=0) const
Gets the value of a boolean field.
Definition DynamicStruct.h:410
std::string_view GetStringField(const StructFieldDescriptor *field) const
Gets the value of a char or char array field.
float GetFloatField(const StructFieldDescriptor *field, size_t arrIndex=0) const
Gets the value of a float field.
Definition DynamicStruct.h:459
Dynamic (run-time) mutable access to a serialized raw struct, with internal data storage.
Definition DynamicStruct.h:673
Dynamic (run-time) mutable access to a serialized raw struct.
Definition DynamicStruct.h:518
void SetFloatField(const StructFieldDescriptor *field, float value, size_t arrIndex=0)
Sets the value of a float field.
Definition DynamicStruct.h:593
void SetBoolField(const StructFieldDescriptor *field, bool value, size_t arrIndex=0)
Sets the value of a boolean field.
Definition DynamicStruct.h:554
MutableDynamicStruct GetStructField(const StructFieldDescriptor *field, size_t arrIndex=0)
Gets the value of a struct field.
Definition DynamicStruct.h:639
void SetUintField(const StructFieldDescriptor *field, uint64_t value, size_t arrIndex=0)
Sets the value of an unsigned integer field.
Definition DynamicStruct.h:580
MutableDynamicStruct(const StructDescriptor *desc, std::span< uint8_t > data)
Constructs a new dynamic struct.
Definition DynamicStruct.h:528
std::span< uint8_t > GetData()
Gets the serialized data.
Definition DynamicStruct.h:536
bool SetStringField(const StructFieldDescriptor *field, std::string_view value)
Sets the value of a char or char array field.
void SetDoubleField(const StructFieldDescriptor *field, double value, size_t arrIndex=0)
Sets the value of a double field.
Definition DynamicStruct.h:606
void SetData(std::span< const uint8_t > data)
Overwrites the entire serialized struct by copying data from a span.
void SetStructField(const StructFieldDescriptor *field, const DynamicStruct &value, size_t arrIndex=0)
Sets the value of a struct field.
void SetIntField(const StructFieldDescriptor *field, int64_t value, size_t arrIndex=0)
Sets the value of a signed integer field.
Definition DynamicStruct.h:567
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition sha1.h:30
StringMap is a sorted associative container that contains key-value pairs with unique string keys.
Definition StringMap.h:26
Database of raw struct dynamic descriptors.
Definition DynamicStruct.h:336
const StructDescriptor * Find(std::string_view name) const
Finds a structure in the database by name.
const StructDescriptor * Add(std::string_view name, std::string_view schema, std::string *err)
Adds a structure schema to the database.
Raw struct dynamic struct descriptor.
Definition DynamicStruct.h:260
const StructFieldDescriptor * FindFieldByName(std::string_view name) const
Gets a field descriptor by name.
StructDescriptor(std::string_view name, const private_init &)
Definition DynamicStruct.h:265
const std::vector< StructFieldDescriptor > & GetFields() const
Gets all field descriptors.
Definition DynamicStruct.h:314
size_t GetSize() const
Returns the struct size, in bytes.
Definition DynamicStruct.h:294
bool IsValid() const
Returns whether the struct is valid (e.g.
Definition DynamicStruct.h:287
const std::string & GetSchema() const
Gets the struct schema.
Definition DynamicStruct.h:279
const std::string & GetName() const
Gets the struct name.
Definition DynamicStruct.h:272
Raw struct dynamic field descriptor.
Definition DynamicStruct.h:65
const StructDescriptor * GetStruct() const
Gets the struct descriptor for a struct data type.
Definition DynamicStruct.h:200
size_t GetOffset() const
Gets the storage offset of the field, in bytes.
Definition DynamicStruct.h:141
StructFieldType GetType() const
Gets the field type.
Definition DynamicStruct.h:103
const StructDescriptor * GetParent() const
Gets the dynamic struct this field is contained in.
Definition DynamicStruct.h:89
int64_t GetIntMax() const
Gets the maximum signed integer value that can be stored in this field.
Definition DynamicStruct.h:230
const std::string & GetName() const
Gets the field name.
Definition DynamicStruct.h:96
std::vector< std::pair< std::string, int64_t > > EnumValues
Set of enumerated values.
Definition DynamicStruct.h:76
const EnumValues & GetEnumValues()
Gets the enumerated values.
Definition DynamicStruct.h:193
uint64_t GetUintMin() const
Gets the minimum unsigned integer value that can be stored in this field.
Definition DynamicStruct.h:207
unsigned int GetBitShift() const
Gets the bit shift for the field (LSB=0).
Definition DynamicStruct.h:165
size_t GetSize() const
Gets the underlying storage size of the field, in bytes.
Definition DynamicStruct.h:134
bool IsUint() const
Returns whether the field type is an unsigned integer.
Definition DynamicStruct.h:122
bool IsArray() const
Returns whether the field is an array.
Definition DynamicStruct.h:172
int64_t GetIntMin() const
Gets the minimum signed integer value that can be stored in this field.
Definition DynamicStruct.h:221
bool HasEnum() const
Returns whether the field has enumerated values.
Definition DynamicStruct.h:186
StructFieldDescriptor(const StructDescriptor *parent, std::string_view name, StructFieldType type, size_t size, size_t arraySize, unsigned int bitWidth, EnumValues enumValues, const StructDescriptor *structDesc, const private_init &)
unsigned int GetBitWidth() const
Gets the bit width of the field, in bits.
Definition DynamicStruct.h:148
uint64_t GetBitMask() const
Gets the bit mask for the field.
Definition DynamicStruct.h:158
uint64_t GetUintMax() const
Gets the maximum unsigned integer value that can be stored in this field.
Definition DynamicStruct.h:214
size_t GetArraySize() const
Gets the array size.
Definition DynamicStruct.h:179
bool IsInt() const
Returns whether the field type is a signed integer.
Definition DynamicStruct.h:110
bool IsBitField() const
Returns whether the field is a bitfield.
Definition DynamicStruct.h:237
Foonathan namespace.
Definition ntcore_cpp.h:26
StructFieldType
Known data types for raw struct dynamic fields (see StructFieldDescriptor).
Definition DynamicStruct.h:33
To bit_cast(const From &from) noexcept
Definition bit.h:51
Definition DynamicStruct.h:660
DSOData(std::span< const uint8_t > data)
Definition DynamicStruct.h:662
std::vector< uint8_t > m_dataStore
Definition DynamicStruct.h:665
DSOData(size_t size)
Definition DynamicStruct.h:661