Class PiecewiseCodec<TObj>
An encoder/decoder for a broad class of values that uses identifiers to differentiate between different types of encoded objects.
Inherited Members
Namespace: Flame.Ir
Assembly: Flame.Ir.dll
Syntax
public sealed class PiecewiseCodec<TObj> : Codec<TObj, LNode>
Type Parameters
| Name | Description |
|---|---|
| TObj |
Constructors
| Edit this page View SourcePiecewiseCodec()
Creates an empty codec.
Declaration
public PiecewiseCodec()
Methods
| Edit this page View SourceAdd<T>(CodecElement<T, LNode>)
Adds an encoder for a specific type of element to this more general codec.
Declaration
public PiecewiseCodec<TObj> Add<T>(CodecElement<T, LNode> element) where T : TObj
Parameters
| Type | Name | Description |
|---|---|---|
| CodecElement<T, LNode> | element | A codec for a particular type of element. |
Returns
| Type | Description |
|---|---|
| PiecewiseCodec<TObj> | A new codec that can encode and decode elements of type |
Type Parameters
| Name | Description |
|---|---|
| T |
Add<T>(CodecElement<T, IReadOnlyList<LNode>>)
Adds an encoder for a specific type of element to this more general codec.
Declaration
public PiecewiseCodec<TObj> Add<T>(CodecElement<T, IReadOnlyList<LNode>> element) where T : TObj
Parameters
| Type | Name | Description |
|---|---|---|
| CodecElement<T, IReadOnlyList<LNode>> | element | A codec for a particular type of element. |
Returns
| Type | Description |
|---|---|
| PiecewiseCodec<TObj> | A new codec that can encode and decode elements of type |
Type Parameters
| Name | Description |
|---|---|
| T |
Decode(LNode, DecoderState)
Decodes a particular piece of data.
Declaration
public override TObj Decode(LNode data, DecoderState state)
Parameters
| Type | Name | Description |
|---|---|---|
| LNode | data | Encoded data to decode. |
| DecoderState | state | The decoder's state. |
Returns
| Type | Description |
|---|---|
| TObj | A decoded object. |
Overrides
| Edit this page View SourceEncode(TObj, EncoderState)
Encodes a value.
Declaration
public override LNode Encode(TObj value, EncoderState state)
Parameters
| Type | Name | Description |
|---|---|---|
| TObj | value | The value to encode. |
| EncoderState | state | The state of the encoder. |
Returns
| Type | Description |
|---|---|
| LNode | The encoded value. |