Struct VariantObjectReader
Zero-copy reader for a variant object value. Provides access to field names (via the metadata dictionary) and field values.
public ref struct VariantObjectReader
- Inherited Members
Remarks
Binary layout (after the header byte):
[num_fields: 1 or 4 bytes depending on is_large]
[field_ids: num_fields * field_id_size bytes]
[offsets: (num_fields + 1) * offset_size bytes]
[field values: concatenated variant values]
Field IDs index into the metadata string dictionary. Field IDs must be sorted by the lexicographic order of their corresponding field names in the metadata dictionary.
Constructors
VariantObjectReader(ReadOnlySpan<byte>, ReadOnlySpan<byte>)
Creates an object reader from the metadata and the object value buffer.
public VariantObjectReader(ReadOnlySpan<byte> metadata, ReadOnlySpan<byte> value)
Parameters
metadataReadOnlySpan<byte>valueReadOnlySpan<byte>
Properties
FieldCount
Gets the number of fields in this object.
public int FieldCount { get; }
Property Value
Methods
GetFieldId(int)
Gets the metadata dictionary field ID for the field at the given index.
public int GetFieldId(int index)
Parameters
indexint
Returns
GetFieldName(int)
Gets the field name for the field at the given index by looking up the field ID in the metadata dictionary.
public string GetFieldName(int index)
Parameters
indexint
Returns
GetFieldNameBytes(int)
Gets the raw UTF-8 bytes of the field name at the given index.
public ReadOnlySpan<byte> GetFieldNameBytes(int index)
Parameters
indexint
Returns
GetFieldValue(int)
Gets a VariantReader for the field value at the given index.
public VariantReader GetFieldValue(int index)
Parameters
indexint
Returns
TryGetField(scoped ReadOnlySpan<byte>, out VariantReader)
Tries to find a field by name and returns a reader for its value.
public bool TryGetField(scoped ReadOnlySpan<byte> name, out VariantReader value)
Parameters
nameReadOnlySpan<byte>The UTF-8 bytes of the field name to look for.
valueVariantReaderThe reader for the field value, if found.
Returns
- bool
True if the field was found; false otherwise.
TryGetField(string, out VariantReader)
Tries to find a field by name (string) and returns a reader for its value.
public bool TryGetField(string name, out VariantReader value)
Parameters
namestringvalueVariantReader