Show / Hide Table of Contents

    Class PiecewiseCodec<TObj>

    An encoder/decoder for a broad class of values that uses identifiers to differentiate between different types of encoded objects.

    Inheritance
    System.Object
    Codec<TObj, Loyc.Syntax.LNode>
    PiecewiseCodec<TObj>
    Inherited Members
    Codec<TObj, LNode>.Encode(TObj, EncoderState)
    Codec<TObj, LNode>.Decode(LNode, DecoderState)
    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 Source

    PiecewiseCodec()

    Creates an empty codec.

    Declaration
    public PiecewiseCodec()

    Methods

    | Improve this Doc View Source

    Add<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 T.

    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    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 T.

    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    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)
    • Improve this Doc
    • View Source
    Back to top Generated by DocFX