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