Options
All
  • Public
  • Public/Protected
  • All
Menu

An ExternalLayout that supports accessing a Layout at a fixed offset from the start of another Layout. The offset may be before, within, or after the base layout.

Factory: {@link module:Layout.offset|offset}

param layout

initializer for {@link OffsetLayout#layout|layout}, modulo property.

param [offset]

Initializes {@link OffsetLayout#offset|offset}. Defaults to zero.

param [property]

Optional new property name for a {@link Layout#replicate| replica} of layout to be used as {@link OffsetLayout#layout|layout}. If not provided the layout is used unchanged.

Hierarchy

Index

Constructors

constructor

  • new OffsetLayout(layout: Layout<number>, offset?: number, property?: string): OffsetLayout

Properties

Optional boundConstructor_

boundConstructor_?: any

layout

layout: Layout<number>

offset

offset: number

Optional property

property?: string

span

span: number

Methods

decode

  • decode(b: Uint8Array, offset?: number): number

encode

  • encode(src: number, b: Uint8Array, offset?: number): number

fromArray

  • Create an object from layout properties and an array of values.

    NOTE This function returns undefined if invoked on a layout that does not return its value as an Object. Objects are returned for things that are a Structure, which includes variant layouts if they are structures, and excludes Unions. If you want this feature for a union you must use getVariant to select the desired layout.

    Parameters

    • values: any[]

      an array of values that correspond to the default order for properties. As with {@link Layout#decode|decode} layout elements that have no property name are skipped when iterating over the array values. Only the top-level properties are assigned; arguments are not assigned to properties of contained layouts. Any unused values are ignored.

    Returns undefined | LayoutObject

getSpan

  • getSpan(b?: Uint8Array, offset?: number): number
  • Calculate the span of a specific instance of a layout.

    throws

    {RangeError} - if the length of the value cannot be determined.

    Parameters

    • Optional b: Uint8Array

      the buffer that contains an encoded instance.

    • Optional offset: number

    Returns number

    • the number of bytes covered by the layout instance. If this method is not overridden in a subclass the definition-time constant {@link Layout#span|span} will be returned.

isCount

  • isCount(): boolean

makeDestinationObject

replicate

  • Replicate the layout using a new property.

    This function must be used to get a structurally-equivalent layout with a different name since all Layout instances are immutable.

    NOTE This is a shallow copy. All fields except {@link Layout#property|property} are strictly equal to the origin layout.

    Parameters

    • property: string

      the value for {@link Layout#property|property} in the replica.

    Returns OffsetLayout

    • the copy with {@link Layout#property|property} set to property.

Generated using TypeDoc