WPILibC++ 2024.3.2
|
Dynamic (run-time) read-only access to a serialized raw struct. More...
#include <wpi/struct/DynamicStruct.h>
Public Member Functions | |
DynamicStruct (const StructDescriptor *desc, std::span< const uint8_t > data) | |
Constructs a new dynamic struct. More... | |
const StructDescriptor * | GetDescriptor () const |
Gets the struct descriptor. More... | |
std::span< const uint8_t > | GetData () const |
Gets the serialized data. More... | |
const StructFieldDescriptor * | FindField (std::string_view name) const |
Gets a struct field descriptor by name. More... | |
bool | GetBoolField (const StructFieldDescriptor *field, size_t arrIndex=0) const |
Gets the value of a boolean field. More... | |
int64_t | GetIntField (const StructFieldDescriptor *field, size_t arrIndex=0) const |
Gets the value of a signed integer field. More... | |
uint64_t | GetUintField (const StructFieldDescriptor *field, size_t arrIndex=0) const |
Gets the value of an unsigned integer field. More... | |
float | GetFloatField (const StructFieldDescriptor *field, size_t arrIndex=0) const |
Gets the value of a float field. More... | |
double | GetDoubleField (const StructFieldDescriptor *field, size_t arrIndex=0) const |
Gets the value of a double field. More... | |
std::string_view | GetStringField (const StructFieldDescriptor *field) const |
Gets the value of a char or char array field. More... | |
DynamicStruct | GetStructField (const StructFieldDescriptor *field, size_t arrIndex=0) const |
Gets the value of a struct field. More... | |
Protected Attributes | |
const StructDescriptor * | m_desc |
Dynamic (run-time) read-only access to a serialized raw struct.
|
inline |
Constructs a new dynamic struct.
Note: the passed data is a span; no copy is made, so it's necessary for the lifetime of the referenced data to be longer than this object.
desc | struct descriptor |
data | serialized data |
|
inline |
Gets a struct field descriptor by name.
name | field name |
|
inline |
Gets the value of a boolean field.
field | field descriptor |
arrIndex | array index (must be less than field array size) |
|
inline |
Gets the serialized data.
|
inline |
Gets the struct descriptor.
|
inline |
Gets the value of a double field.
field | field descriptor |
arrIndex | array index (must be less than field array size) |
|
inline |
Gets the value of a float field.
field | field descriptor |
arrIndex | array index (must be less than field array size) |
|
inline |
Gets the value of a signed integer field.
field | field descriptor |
arrIndex | array index (must be less than field array size) |
std::string_view wpi::DynamicStruct::GetStringField | ( | const StructFieldDescriptor * | field | ) | const |
Gets the value of a char or char array field.
field | field descriptor |
|
inline |
Gets the value of a struct field.
field | field descriptor |
arrIndex | array index (must be less than field array size) |
|
inline |
Gets the value of an unsigned integer field.
field | field descriptor |
arrIndex | array index (must be less than field array size) |
|
protected |