Struct IceDecoder
Provides methods to decode data encoded with Ice.
public ref struct IceDecoder
- Inherited Members
- Extension Methods
Constructors
IceDecoder(ReadOnlySequence<byte>, object?, int, IActivator?, int)
Constructs a new Ice decoder over a byte buffer.
public IceDecoder(ReadOnlySequence<byte> buffer, object? decodingContext = null, int maxCollectionAllocation = -1, IActivator? activator = null, int maxDepth = 3)
Parameters
bufferReadOnlySequence<byte>The byte buffer.
decodingContextobjectThe decoding context.
maxCollectionAllocationintThe maximum cumulative allocation in bytes when decoding strings, sequences, and dictionaries from this buffer.
-1(the default) is equivalent to 8 times the buffer length, clamped to MaxValue.activatorIActivatorThe activator for decoding classes and exceptions.
maxDepthintThe maximum depth when decoding a class recursively. The default is
3.
IceDecoder(ReadOnlyMemory<byte>, object?, int, IActivator?, int)
Constructs a new Ice decoder over a byte buffer.
public IceDecoder(ReadOnlyMemory<byte> buffer, object? decodingContext = null, int maxCollectionAllocation = -1, IActivator? activator = null, int maxDepth = 3)
Parameters
bufferReadOnlyMemory<byte>The byte buffer.
decodingContextobjectThe decoding context.
maxCollectionAllocationintThe maximum cumulative allocation in bytes when decoding strings, sequences, and dictionaries from this buffer.
-1(the default) is equivalent to 8 times the buffer length, clamped to MaxValue.activatorIActivatorThe activator for decoding classes and exceptions.
maxDepthintThe maximum depth when decoding a class recursively. The default is
3.
Properties
Consumed
Gets the number of bytes decoded in the underlying buffer.
public readonly long Consumed { get; }
Property Value
DecodingContext
Gets the decoding context.
public readonly object? DecodingContext { get; }
Property Value
Remarks
The decoding context is a kind of cookie: the code that creates the decoder can store this context in the decoder for later retrieval.
End
Gets a value indicating whether this decoder has reached the end of its underlying buffer.
public readonly bool End { get; }
Property Value
Remaining
Gets the number of bytes remaining in the underlying buffer.
public readonly long Remaining { get; }
Property Value
- long
The number of bytes remaining in the underlying buffer.
Methods
CheckBoolValue(bool)
Checks if the in memory representation of the bool value is valid according to the Ice encoding.
public static void CheckBoolValue(bool value)
Parameters
valueboolThe value to check.
Exceptions
- InvalidDataException
If the value is out of the bool type accepted range.
CopyTo(Span<byte>)
Copy bytes from the underlying reader into the destination to fill completely destination.
public void CopyTo(Span<byte> destination)
Parameters
Remarks
This method also moves the reader's Consumed property.
DecodeBool()
Decodes an Ice bool into a bool.
public bool DecodeBool()
Returns
- bool
The bool decoded by this decoder.
DecodeByte()
Decodes an Ice byte into a byte.
public byte DecodeByte()
Returns
- byte
The byte decoded by this decoder.
DecodeClass<T>()
Decodes a class instance.
public T? DecodeClass<T>() where T : IceClass
Returns
- T
The class instance, or null.
Type Parameters
TThe class type.
DecodeDouble()
Decodes an Ice double into a double.
public double DecodeDouble()
Returns
- double
The double decoded by this decoder.
DecodeException(string?)
Decodes an Ice exception.
public IceException DecodeException(string? message = null)
Parameters
messagestringThe error message. It's used only when this method fails to find an exception class to instantiate.
Returns
- IceException
The decoded Ice exception.
DecodeFloat()
Decodes an Ice float into a float.
public float DecodeFloat()
Returns
- float
The float decoded by this decoder.
DecodeInt()
Decodes an Ice int into an int.
public int DecodeInt()
Returns
- int
The int decoded by this decoder.
DecodeLong()
Decodes an Ice long into a long.
public long DecodeLong()
Returns
- long
The long decoded by this decoder.
DecodeShort()
Decodes an Ice short into a short.
public short DecodeShort()
Returns
- short
The short decoded by this decoder.
DecodeSize()
Decodes a size encoded on a variable number of bytes.
public int DecodeSize()
Returns
- int
The size decoded by this decoder.
DecodeString()
Decodes an Ice string into a string.
public string DecodeString()
Returns
- string
The string decoded by this decoder.
DecodeTagged<T>(int, TagFormat, DecodeFunc<T>)
Decodes a tagged field.
public T? DecodeTagged<T>(int tag, TagFormat tagFormat, DecodeFunc<T> decodeFunc)
Parameters
tagintThe tag.
tagFormatTagFormatThe expected tag format of this tag when found in the underlying buffer.
decodeFuncDecodeFunc<T>A decode function that decodes the value of this tag.
Returns
- T
The decoded value of the tagged field, or null if not found.
Type Parameters
TThe type of the decoded value.
Remarks
We return a T? and not a T to avoid ambiguities in the generated code with nullable reference types such as string?.
Skip(int)
Skip the given number of bytes.
public void Skip(int count)
Parameters
countintThe number of bytes to skip.
SkipSize()
Skip Ice size.
public void SkipSize()
SkipTagged()
Skips the remaining tagged fields.
public void SkipTagged()