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
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Flame.Ir
Assembly: Flame.Ir.dll
Syntax
public sealed class PiecewiseCodec<TObj> : Codec<TObj, LNode>
Type Parameters
Name | Description |
---|---|
TObj |
Constructors
| Improve this Doc View SourcePiecewiseCodec()
Creates an empty codec.
Declaration
public PiecewiseCodec()
Methods
| Improve this Doc 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, Loyc.Syntax.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, System.Collections.Generic.IReadOnlyList<Loyc.Syntax.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 |
---|---|---|
Loyc.Syntax.LNode | data | Encoded data to decode. |
DecoderState | state | The decoder's state. |
Returns
Type | Description |
---|---|
TObj | A decoded object. |
Overrides
Flame.Ir.Codec<TObj, Loyc.Syntax.LNode>.Decode(Loyc.Syntax.LNode, Flame.Ir.DecoderState)
|
Improve this Doc
View Source
Encode(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 |
---|---|
Loyc.Syntax.LNode | The encoded value. |
Overrides
Flame.Ir.Codec<TObj, Loyc.Syntax.LNode>.Encode(TObj, Flame.Ir.EncoderState)