Skip to main content

Abstract Class: ConfigParser

Defined in: src/sdk/utils/config/ConfigUtils.ts:4

A parser for FmsConfig elements.

Constructors

Constructor

new ConfigParser(): ConfigParser

Returns

ConfigParser

Properties

configName

static configName: string = 'ConfigParser'

Defined in: src/sdk/utils/config/ConfigUtils.ts:5

Methods

getBooleanAttrValue()

static getBooleanAttrValue(element, attributeName): boolean

Defined in: src/sdk/utils/config/ConfigUtils.ts:241

Gets a boolean attribute value of an element.

Parameters

ParameterTypeDescription
elementElementThe element to search on.
attributeNamestringThe attribute to find on the element.

Returns

boolean

The attribute's value.

Throws

If the attribute is not present or invalid.


getChildElectricityConfig()

static getChildElectricityConfig(element, baseInstrument): CompositeLogicXMLElement | undefined

Defined in: src/sdk/utils/config/ConfigUtils.ts:61

Gets the electricity logic from a given element

Parameters

ParameterTypeDescription
elementElement | undefinedElement to get the electric circuit from
baseInstrumentBaseInstrumentthe BaseInstrument the electrical logic is created in the context of

Returns

CompositeLogicXMLElement | undefined

The electricity logic element, or undefined if none is present


getChildElement()

static getChildElement(parentElement, tagName): Element

Defined in: src/sdk/utils/config/ConfigUtils.ts:32

Gets the first occurrence of a given child element.

Parameters

ParameterTypeDescription
parentElementElementThe element to search on.
tagNamestringThe tag name to find.

Returns

Element

An element.

Throws

If no element is found.


getChildElements()

static getChildElements(parentElement, tagName): Element[]

Defined in: src/sdk/utils/config/ConfigUtils.ts:49

Gets all occurrences of a given child element type.

Parameters

ParameterTypeDescription
parentElementElementThe element to search on.
tagNamestringThe tag name to find.

Returns

Element[]

All child elements that match.


getChildLerpLookupTable()

static getChildLerpLookupTable(parentElement, tagName): LerpLookupTable

Defined in: src/sdk/utils/config/ConfigUtils.ts:82

Gets a LookupTable child of an element

Parameters

ParameterTypeDescription
parentElementElementThe element to search on.
tagNamestringThe tag name to find.

Returns

LerpLookupTable

LerpLookupTable

Throws

If a lookup table cannot be parsed


getEnumAttrValue()

static getEnumAttrValue<T>(element, attributeName, allowedValues): T

Defined in: src/sdk/utils/config/ConfigUtils.ts:193

Gets an enum attribute value of an element.

Type Parameters

Type Parameter
T extends string

Parameters

ParameterTypeDescription
elementElementThe element to search on.
attributeNamestringThe attribute to find on the element.
allowedValuesT[]The list of allowed values.

Returns

T

The attribute's value.

Throws

If the attribute is not present or invalid.


getIntegerAttrValue()

static getIntegerAttrValue<T>(element, attributeName, allowZero, allowNegative): T

Defined in: src/sdk/utils/config/ConfigUtils.ts:214

Gets an integer attribute value of an element.

Type Parameters

Type Parameter
T extends number

Parameters

ParameterTypeDefault valueDescription
elementElementundefinedThe element to search on.
attributeNamestringundefinedThe attribute to find on the element.
allowZerobooleanfalseWhether zero should be allowed as a value.
allowNegativebooleanfalseWhether negative numbers should be allowed as a value.

Returns

T

The attribute's value.

Throws

If the attribute is not present or invalid.


getStringAttrValue()

static getStringAttrValue<T>(element, attributeName, allowEmptyString): T

Defined in: src/sdk/utils/config/ConfigUtils.ts:175

Gets a string attribute value of an element.

Type Parameters

Type Parameter
T extends string

Parameters

ParameterTypeDefault valueDescription
elementElementundefinedThe element to search on.
attributeNamestringundefinedThe attribute to find on the element.
allowEmptyStringbooleantrueWhether to allow the empty string as a value.

Returns

T

The attribute's value.

Throws

If the attribute is not present.


getTextContent()

static getTextContent(element): string

Defined in: src/sdk/utils/config/ConfigUtils.ts:140

Gets the text content of an element.

Parameters

ParameterTypeDescription
elementElementThe element to search on.

Returns

string

The element's text content.

Throws

If no text content is present.


optional()

static optional<T>(executor, defaultValue): T

Defined in: src/sdk/utils/config/ConfigUtils.ts:15

Returns a value computed by an executor, with a fallback value if the executor throws

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
executor() => Tthe executor which returns the value
defaultValueTa fallback value in case the executor throws

Returns

T

T