@wildboar/acse
Version:
Association Control Service Element PDUs in TypeScript
145 lines (144 loc) • 5.29 kB
JavaScript
/* eslint-disable */
import { ASN1TagClass as _TagClass, ASN1ConstructionError as _ConstructionError, } from '@wildboar/asn1';
import * as $ from '@wildboar/asn1/functional';
import { _decode_Presentation_context_identifier, _encode_Presentation_context_identifier, } from '../ACSE-1/Presentation-context-identifier.ta.mjs';
import { _decode_Abstract_syntax_name, _encode_Abstract_syntax_name, } from '../ACSE-1/Abstract-syntax-name.ta.mjs';
import { _decode_Transfer_syntax_name, _encode_Transfer_syntax_name, } from '../ACSE-1/Transfer-syntax-name.ta.mjs';
/**
* @summary Context_list_Item
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* Context-list-Item ::= SEQUENCE { -- REMOVED_FROM_UNNESTING -- }
* ```
*
*/
export class Context_list_Item {
pci;
abstract_syntax;
transfer_syntaxes;
constructor(
/**
* @summary `pci`.
* @public
* @readonly
*/
pci,
/**
* @summary `abstract_syntax`.
* @public
* @readonly
*/
abstract_syntax,
/**
* @summary `transfer_syntaxes`.
* @public
* @readonly
*/
transfer_syntaxes) {
this.pci = pci;
this.abstract_syntax = abstract_syntax;
this.transfer_syntaxes = transfer_syntaxes;
}
/**
* @summary Restructures an object into a Context_list_Item
* @description
*
* This takes an `object` and converts it to a `Context_list_Item`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `Context_list_Item`.
* @returns {Context_list_Item}
*/
static _from_object(_o) {
return new Context_list_Item(_o.pci, _o.abstract_syntax, _o.transfer_syntaxes);
}
}
/**
* @summary The Leading Root Component Types of Context_list_Item
* @description
*
* This is an array of `ComponentSpec`s that define how to decode the leading root component type list of a SET or SEQUENCE.
*
* @constant
*/
export const _root_component_type_list_1_spec_for_Context_list_Item = [
new $.ComponentSpec('pci', false, $.hasTag(_TagClass.universal, 2)),
new $.ComponentSpec('abstract-syntax', false, $.hasTag(_TagClass.universal, 6)),
new $.ComponentSpec('transfer-syntaxes', false, $.hasTag(_TagClass.universal, 16)),
];
/**
* @summary The Trailing Root Component Types of Context_list_Item
* @description
*
* This is an array of `ComponentSpec`s that define how to decode the trailing root component type list of a SET or SEQUENCE.
*
* @constant
*/
export const _root_component_type_list_2_spec_for_Context_list_Item = [];
/**
* @summary The Extension Addition Component Types of Context_list_Item
* @description
*
* This is an array of `ComponentSpec`s that define how to decode the extension addition component type list of a SET or SEQUENCE.
*
* @constant
*/
export const _extension_additions_list_spec_for_Context_list_Item = [];
let _cached_decoder_for_Context_list_Item = null;
/**
* @summary Decodes an ASN.1 element into a(n) Context_list_Item
* @function
* @param {_Element} el The element being decoded.
* @returns {Context_list_Item} The decoded data structure.
*/
export function _decode_Context_list_Item(el) {
if (!_cached_decoder_for_Context_list_Item) {
_cached_decoder_for_Context_list_Item = function (el) {
const sequence = el.sequence;
if (sequence.length < 3) {
throw new _ConstructionError('Context-list-Item contained only ' +
sequence.length.toString() +
' elements.');
}
sequence[0].name = 'pci';
sequence[1].name = 'abstract-syntax';
sequence[2].name = 'transfer-syntaxes';
let pci;
let abstract_syntax;
let transfer_syntaxes;
pci = _decode_Presentation_context_identifier(sequence[0]);
abstract_syntax = _decode_Abstract_syntax_name(sequence[1]);
transfer_syntaxes = $._decodeSequenceOf(() => _decode_Transfer_syntax_name)(sequence[2]);
return new Context_list_Item(pci, abstract_syntax, transfer_syntaxes);
};
}
return _cached_decoder_for_Context_list_Item(el);
}
let _cached_encoder_for_Context_list_Item = null;
/**
* @summary Encodes a(n) Context_list_Item into an ASN.1 Element.
* @function
* @param value The element being encoded.
* @param elGetter A function that can be used to get new ASN.1 elements.
* @returns {_Element} The Context_list_Item, encoded as an ASN.1 Element.
*/
export function _encode_Context_list_Item(value, elGetter) {
if (!_cached_encoder_for_Context_list_Item) {
_cached_encoder_for_Context_list_Item = function (value) {
return $._encodeSequence([]
.concat([
/* REQUIRED */ _encode_Presentation_context_identifier(value.pci, $.BER),
/* REQUIRED */ _encode_Abstract_syntax_name(value.abstract_syntax, $.BER),
/* REQUIRED */ $._encodeSequenceOf(() => _encode_Transfer_syntax_name, $.BER)(value.transfer_syntaxes, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_Context_list_Item(value, elGetter);
}
/* eslint-enable */