@wildboar/copp
Version:
Connection-oriented presentation protocol (COPP) data structures and business logic in TypeScript
159 lines (158 loc) • 6.21 kB
JavaScript
/* eslint-disable */
import { ASN1TagClass as _TagClass, } from '@wildboar/asn1';
import * as $ from '@wildboar/asn1/functional';
import { _decode_Presentation_context_addition_list, _encode_Presentation_context_addition_list, } from '../ISO8823-PRESENTATION/Presentation-context-addition-list.ta.mjs';
import { _decode_Presentation_context_deletion_list, _encode_Presentation_context_deletion_list, } from '../ISO8823-PRESENTATION/Presentation-context-deletion-list.ta.mjs';
import { _decode_User_data, _encode_User_data, } from '../ISO8823-PRESENTATION/User-data.ta.mjs';
/**
* @summary AC_PPDU
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* AC-PPDU ::= SEQUENCE {
* presentation-context-addition-list
* [0] IMPLICIT Presentation-context-addition-list OPTIONAL,
* presentation-context-deletion-list
* [1] IMPLICIT Presentation-context-deletion-list OPTIONAL,
* user-data User-data OPTIONAL
* }
* ```
*
*/
export class AC_PPDU {
presentation_context_addition_list;
presentation_context_deletion_list;
user_data;
constructor(
/**
* @summary `presentation_context_addition_list`.
* @public
* @readonly
*/
presentation_context_addition_list,
/**
* @summary `presentation_context_deletion_list`.
* @public
* @readonly
*/
presentation_context_deletion_list,
/**
* @summary `user_data`.
* @public
* @readonly
*/
user_data) {
this.presentation_context_addition_list = presentation_context_addition_list;
this.presentation_context_deletion_list = presentation_context_deletion_list;
this.user_data = user_data;
}
/**
* @summary Restructures an object into a AC_PPDU
* @description
*
* This takes an `object` and converts it to a `AC_PPDU`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `AC_PPDU`.
* @returns {AC_PPDU}
*/
static _from_object(_o) {
return new AC_PPDU(_o.presentation_context_addition_list, _o.presentation_context_deletion_list, _o.user_data);
}
}
/**
* @summary The Leading Root Component Types of AC_PPDU
* @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_AC_PPDU = [
new $.ComponentSpec('presentation-context-addition-list', true, $.hasTag(_TagClass.context, 0)),
new $.ComponentSpec('presentation-context-deletion-list', true, $.hasTag(_TagClass.context, 1)),
new $.ComponentSpec('user-data', true, $.hasAnyTag),
];
/**
* @summary The Trailing Root Component Types of AC_PPDU
* @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_AC_PPDU = [];
/**
* @summary The Extension Addition Component Types of AC_PPDU
* @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_AC_PPDU = [];
let _cached_decoder_for_AC_PPDU = null;
/**
* @summary Decodes an ASN.1 element into a(n) AC_PPDU
* @function
* @param {_Element} el The element being decoded.
* @returns {AC_PPDU} The decoded data structure.
*/
export function _decode_AC_PPDU(el) {
if (!_cached_decoder_for_AC_PPDU) {
_cached_decoder_for_AC_PPDU = function (el) {
let presentation_context_addition_list;
let presentation_context_deletion_list;
let user_data;
const callbacks = {
'presentation-context-addition-list': (_el) => {
presentation_context_addition_list = $._decode_implicit(() => _decode_Presentation_context_addition_list)(_el);
},
'presentation-context-deletion-list': (_el) => {
presentation_context_deletion_list = $._decode_implicit(() => _decode_Presentation_context_deletion_list)(_el);
},
'user-data': (_el) => {
user_data = _decode_User_data(_el);
},
};
$._parse_sequence(el, callbacks, _root_component_type_list_1_spec_for_AC_PPDU, _extension_additions_list_spec_for_AC_PPDU, _root_component_type_list_2_spec_for_AC_PPDU, undefined);
return new AC_PPDU(presentation_context_addition_list, presentation_context_deletion_list, user_data);
};
}
return _cached_decoder_for_AC_PPDU(el);
}
let _cached_encoder_for_AC_PPDU = null;
/**
* @summary Encodes a(n) AC_PPDU 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 AC_PPDU, encoded as an ASN.1 Element.
*/
export function _encode_AC_PPDU(value, elGetter) {
if (!_cached_encoder_for_AC_PPDU) {
_cached_encoder_for_AC_PPDU = function (value) {
return $._encodeSequence([]
.concat([
/* IF_ABSENT */ value.presentation_context_addition_list ===
undefined
? undefined
: $._encode_implicit(_TagClass.context, 0, () => _encode_Presentation_context_addition_list, $.BER)(value.presentation_context_addition_list, $.BER),
/* IF_ABSENT */ value.presentation_context_deletion_list ===
undefined
? undefined
: $._encode_implicit(_TagClass.context, 1, () => _encode_Presentation_context_deletion_list, $.BER)(value.presentation_context_deletion_list, $.BER),
/* IF_ABSENT */ value.user_data === undefined
? undefined
: _encode_User_data(value.user_data, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_AC_PPDU(value, elGetter);
}
/* eslint-enable */