TomlParseEvent Struct

Represents a semantic parse event produced by TomlParser.

public readonly struct TomlParseEvent

Properties

NameDescription
ColumnGets the 1-based column number associated with this event, or 0 when unknown.
DataGets the raw scalar payload for numeric and boolean scalars. When TomlParseEvent.Kind is TomlParseEventKind.String, this contains the underlying TokenKind for the string literal. When TomlParseEvent.Kind is TomlParseEventKind.PropertyName, this contains an internal packed payload that includes the TokenKind of the key literal (in the low 8 bits) as well as a case-sensitive hash of the decoded property name (in the remaining high bits). When TomlParseEvent.Kind is TomlParseEventKind.StartTable or TomlParseEventKind.StartArray, this is 1 for an inline table or array, and 0 for a table or an array of tables opened by a header or a dotted key.
KindGets the event kind.
LineGets the 1-based line number associated with this event, or 0 when unknown.
PropertyNameGets the property name when TomlParseEvent.Kind is TomlParseEventKind.PropertyName. This value is only populated when the parser was configured to decode scalars eagerly; otherwise use TomlParser.GetPropertyName to decode it from the original input.
SpanGets the source span associated with this event, when available.
StringValueGets the string scalar value when TomlParseEvent.Kind is TomlParseEventKind.String or TomlParseEventKind.DateTime. For TomlParseEventKind.String, this value is only populated when the parser was configured to decode scalars eagerly; otherwise use TomlParser.GetString. When TomlParserOptions.EagerStringValues is enabled, this value may also be populated for simple basic strings (single-line, no escape sequences) even when TomlParserOptions.DecodeScalars is false. For TomlParseEventKind.DateTime, this value contains the raw literal text so that consumers can parse it without requiring TomlParserOptions.DecodeScalars.

Gets the 1-based column number associated with this event, or 0 when unknown.

public int Column { get; }

Property value

int

Gets the raw scalar payload for numeric and boolean scalars. When TomlParseEvent.Kind is TomlParseEventKind.String, this contains the underlying TokenKind for the string literal. When TomlParseEvent.Kind is TomlParseEventKind.PropertyName, this contains an internal packed payload that includes the TokenKind of the key literal (in the low 8 bits) as well as a case-sensitive hash of the decoded property name (in the remaining high bits). When TomlParseEvent.Kind is TomlParseEventKind.StartTable or TomlParseEventKind.StartArray, this is 1 for an inline table or array, and 0 for a table or an array of tables opened by a header or a dotted key.

public ulong Data { get; }

Property value

ulong

Gets the event kind.

public TomlParseEventKind Kind { get; }

Property value

TomlParseEventKind

Gets the 1-based line number associated with this event, or 0 when unknown.

public int Line { get; }

Property value

int

PropertyName

TomlParseEvent.cs

Gets the property name when TomlParseEvent.Kind is TomlParseEventKind.PropertyName. This value is only populated when the parser was configured to decode scalars eagerly; otherwise use TomlParser.GetPropertyName to decode it from the original input.

public string? PropertyName { get; }

Property value

string?

Gets the source span associated with this event, when available.

public TomlSourceSpan? Span { get; }

Property value

TomlSourceSpan?

Gets the string scalar value when TomlParseEvent.Kind is TomlParseEventKind.String or TomlParseEventKind.DateTime. For TomlParseEventKind.String, this value is only populated when the parser was configured to decode scalars eagerly; otherwise use TomlParser.GetString. When TomlParserOptions.EagerStringValues is enabled, this value may also be populated for simple basic strings (single-line, no escape sequences) even when TomlParserOptions.DecodeScalars is false. For TomlParseEventKind.DateTime, this value contains the raw literal text so that consumers can parse it without requiring TomlParserOptions.DecodeScalars.

public string? StringValue { get; }

Property value

string?

Methods

NameDescription
GetBoolean()Gets the current scalar value as a boolean.
GetDouble()Gets the current scalar value as a double-precision number.
GetInt64()Gets the current scalar value as a 64-bit integer.
GetString()Gets the current scalar value as a string.
GetTomlDateTime()Gets the current scalar value as a TomlDateTime.

GetBoolean()

TomlParseEvent.cs

Gets the current scalar value as a boolean.

public bool GetBoolean()

Returns

bool

Exceptions

InvalidOperationException
The current event is not a boolean scalar.

Gets the current scalar value as a double-precision number.

public double GetDouble()

Returns

double

Exceptions

InvalidOperationException
The current event is not a numeric scalar.

Gets the current scalar value as a 64-bit integer.

public long GetInt64()

Returns

long

Exceptions

InvalidOperationException
The current event is not an integer scalar.

Gets the current scalar value as a string.

public string GetString()

Returns

string

Exceptions

InvalidOperationException
The current event is not a string scalar.

GetTomlDateTime()

TomlParseEvent.cs

Gets the current scalar value as a TomlDateTime.

public TomlDateTime GetTomlDateTime()

Returns

TomlDateTime

Exceptions

InvalidOperationException
The current event is not a date/time scalar.