Utf8YamlReader Struct
- Obsolete: Types with embedded references are not supported in this version of your compiler.
A forward-only reader of UTF-8 YAML that records the position of every token and allocates nothing while reading.
[Obsolete("Types with embedded references are not supported in this version of your compiler.", true)]
public ref struct Utf8YamlReaderRemarks
Every byte of the input that is not whitespace, a line break or a comment belongs to a token: the token itself (Utf8YamlReader.TokenStart, Utf8YamlReader.TokenLength), the indicator that precedes it (Utf8YamlReader.IndicatorOffset: -, ?, : or ,), or its properties (Utf8YamlReader.AnchorStart, Utf8YamlReader.TagStart). The gaps between them are the trivia.
Scalars are decoded on demand by Utf8YamlReader.GetString, Utf8YamlReader.CopyValue and Utf8YamlReader.ValueEquals.
Constructors
| Name | Description |
|---|---|
| Utf8YamlReader(ReadOnlySpan<byte>) | Initializes a reader over a complete UTF-8 YAML input. |
| Utf8YamlReader(ReadOnlySpan<byte>, Utf8YamlReaderOptions) | Initializes a reader over a complete UTF-8 YAML input. |
| Utf8YamlReader(ReadOnlySpan<byte>, bool, Utf8YamlReaderState) | Initializes a reader over a part of a UTF-8 YAML input. |
Utf8YamlReader overloads
Utf8YamlReader(ReadOnlySpan<byte>)
Utf8YamlReader.csInitializes a reader over a complete UTF-8 YAML input.
public Utf8YamlReader(ReadOnlySpan<byte> utf8Yaml)Parameters
utf8YamlReadOnlySpan<byte>
Utf8YamlReader(ReadOnlySpan<byte>, Utf8YamlReaderOptions)
Utf8YamlReader.csInitializes a reader over a complete UTF-8 YAML input.
public Utf8YamlReader(ReadOnlySpan<byte> utf8Yaml, Utf8YamlReaderOptions options)Parameters
utf8YamlReadOnlySpan<byte>optionsUtf8YamlReaderOptions
Utf8YamlReader(ReadOnlySpan<byte>, bool, Utf8YamlReaderState)
Utf8YamlReader.csInitializes a reader over a part of a UTF-8 YAML input.
public Utf8YamlReader(ReadOnlySpan<byte> utf8Yaml, bool isFinalBlock, Utf8YamlReaderState state)Parameters
utf8YamlReadOnlySpan<byte>- The bytes not consumed by the previous reader, followed by the new data.
isFinalBlockbooltruewhenutf8Yamlholds the end of the input.stateUtf8YamlReaderState- The
Utf8YamlReader.CurrentStateof the previous reader, or a new state for the first block.
Properties
| Name | Description |
|---|---|
| AnchorLength | Gets the length of the anchor of the current node, including the &. |
| AnchorName | Gets the name of the anchor of the current node, or of the current alias, without the & or *. |
| AnchorStart | Gets the offset of the anchor (&name) of the current node, or -1. |
| BufferOffset | Gets the absolute offset, in the whole input, of the first byte of the current buffer. |
| BytesConsumed | Gets the number of bytes of the input that the next reader does not need: the caller can drop them. |
| CurrentDepth | Gets the number of collections that contain the current position. |
| CurrentState | Gets the state to pass to the next reader, relative to the input without the first Utf8YamlReader.BytesConsumed bytes. |
| ExplicitKeyIndicatorOffset | Gets the offset of the ? indicator of an explicit key, or -1. |
| IndicatorOffset | Gets the offset of the indicator (-, ?, : or ,) that precedes the current token, or -1. |
| IsFlow | Gets a value indicating whether the current collection token belongs to a flow collection. |
| MaxValueLength | Gets the maximum number of bytes Utf8YamlReader.CopyValue writes for the current scalar. |
| RawValueSpan | Gets the content of the current scalar as written: without the quotes or the block scalar header, with the escapes and the line breaks. |
| ScalarStyle | Gets the style of the current scalar. |
| Tag | Gets the tag of the current node as written, such as !!str, or an empty span. |
| TagLength | Gets the length of the tag of the current node. |
| TagStart | Gets the offset of the tag of the current node, or -1. |
| TokenFlags | Gets the flags of the current token: scalar style, flow collection, implicit document marker. |
| TokenKind | Gets the kind of the current token. |
| TokenLength | Gets the length of the current token, 0 for a zero-width token. |
| TokenSpan | Gets the bytes of the current token. |
| TokenStart | Gets the offset of the first byte of the current token. |
| ValueIsRaw | Gets a value indicating whether the value of the current scalar is Utf8YamlReader.RawValueSpan unchanged. |
AnchorLength
Utf8YamlReader.csAnchorName
Utf8YamlReader.csGets the name of the anchor of the current node, or of the current alias, without the & or *.
public readonly ReadOnlySpan<byte> AnchorName { get; }Property value
AnchorStart
Utf8YamlReader.csBufferOffset
Utf8YamlReader.csBytesConsumed
Utf8YamlReader.csCurrentDepth
Utf8YamlReader.csCurrentState
Utf8YamlReader.csGets the state to pass to the next reader, relative to the input without the first Utf8YamlReader.BytesConsumed bytes.
public readonly Utf8YamlReaderState CurrentState { get; }Property value
ExplicitKeyIndicatorOffset
Utf8YamlReader.csIndicatorOffset
Utf8YamlReader.csIsFlow
Utf8YamlReader.csMaxValueLength
Utf8YamlReader.csGets the maximum number of bytes Utf8YamlReader.CopyValue writes for the current scalar.
public readonly int MaxValueLength { get; }Property value
RawValueSpan
Utf8YamlReader.csGets the content of the current scalar as written: without the quotes or the block scalar header, with the escapes and the line breaks.
public readonly ReadOnlySpan<byte> RawValueSpan { get; }Property value
ScalarStyle
Utf8YamlReader.csGets the tag of the current node as written, such as !!str, or an empty span.
public readonly ReadOnlySpan<byte> Tag { get; }Property value
TagLength
Utf8YamlReader.csTagStart
Utf8YamlReader.csTokenFlags
Utf8YamlReader.csGets the flags of the current token: scalar style, flow collection, implicit document marker.
public readonly Utf8YamlTokenFlags TokenFlags { get; }Property value
TokenKind
Utf8YamlReader.csGets the kind of the current token.
public readonly Utf8YamlTokenKind TokenKind { get; }Property value
TokenLength
Utf8YamlReader.csTokenSpan
Utf8YamlReader.csGets the bytes of the current token.
public readonly ReadOnlySpan<byte> TokenSpan { get; }Property value
TokenStart
Utf8YamlReader.csValueIsRaw
Utf8YamlReader.csGets a value indicating whether the value of the current scalar is Utf8YamlReader.RawValueSpan unchanged.
public readonly bool ValueIsRaw { get; }Property value
Methods
| Name | Description |
|---|---|
| CopyValue(Span<byte>) | Writes the UTF-8 value of the current scalar to destination, which must hold at least Utf8YamlReader.MaxValueLength bytes. |
| GetMark(int) | Computes the location of a position of the buffer, like the marks of Parser: UTF-16 index, 0-based line and column. |
| GetString() | Decodes the value of the current scalar. |
| GetTag() | Gets the tag of the current node resolved with the %TAG directives, such as tag:yaml.org,2002:str; ! for the non-specific tag; null without tag. |
| Read() | Reads the next token. |
| ValueEquals(ReadOnlySpan<byte>) | Compares the value of the current scalar with a UTF-8 text without allocating. |
| ValueEquals(ReadOnlySpan<char>) | Compares the value of the current scalar with a text without allocating. |
| ValueEquals(string) | Compares the value of the current scalar with a text without allocating. |
CopyValue(Span<byte>)
Utf8YamlReader.csWrites the UTF-8 value of the current scalar to destination, which must hold at least Utf8YamlReader.MaxValueLength bytes.
GetMark(int)
Utf8YamlReader.csGetString()
Utf8YamlReader.csGetTag()
Utf8YamlReader.csRead()
Utf8YamlReader.csReads the next token.
public bool Read()Returns
bool true if a token was read; false at the end of the input.
Exceptions
SyntaxErrorException- The input is not valid YAML.
ValueEquals overloads
ValueEquals(ReadOnlySpan<byte>)
Utf8YamlReader.csCompares the value of the current scalar with a UTF-8 text without allocating.
public readonly bool ValueEquals(ReadOnlySpan<byte> utf8Text)ValueEquals(ReadOnlySpan<char>)
Utf8YamlReader.csCompares the value of the current scalar with a text without allocating.
public readonly bool ValueEquals(ReadOnlySpan<char> text)Parameters
textReadOnlySpan<char>
Returns
Remarks
A text with an invalid UTF-16 sequence, such as a lone surrogate, is equal to no value.
ValueEquals(string)
Utf8YamlReader.csCompares the value of the current scalar with a text without allocating.