UNPKG

@wildboar/qc

Version:
133 lines (132 loc) 4.28 kB
/* eslint-disable */ import { ASN1TagClass as _TagClass, } from "@wildboar/asn1"; import * as $ from "@wildboar/asn1/functional"; /** * @summary QCStatement * @description * * ### ASN.1 Definition: * * ```asn1 * QCStatement ::= SEQUENCE { * statementId QC-STATEMENT.&id({SupportedStatements}), * statementInfo QC-STATEMENT.&Type * ({SupportedStatements}{@statementId}) OPTIONAL } * ``` * */ export class QCStatement { statementId; statementInfo; constructor( /** * @summary `statementId`. * @public * @readonly */ statementId, /** * @summary `statementInfo`. * @public * @readonly */ statementInfo) { this.statementId = statementId; this.statementInfo = statementInfo; } /** * @summary Restructures an object into a QCStatement * @description * * This takes an `object` and converts it to a `QCStatement`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `QCStatement`. * @returns {QCStatement} */ static _from_object(_o) { return new QCStatement(_o.statementId, _o.statementInfo); } } /** * @summary The Leading Root Component Types of QCStatement * @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_QCStatement = [ new $.ComponentSpec("statementId", false, $.hasTag(_TagClass.universal, 6)), new $.ComponentSpec("statementInfo", true, $.hasAnyTag), ]; /** * @summary The Trailing Root Component Types of QCStatement * @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_QCStatement = []; /** * @summary The Extension Addition Component Types of QCStatement * @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_QCStatement = []; let _cached_decoder_for_QCStatement = null; /** * @summary Decodes an ASN.1 element into a(n) QCStatement * @function * @param {_Element} el The element being decoded. * @returns {QCStatement} The decoded data structure. */ export function _decode_QCStatement(el) { if (!_cached_decoder_for_QCStatement) { _cached_decoder_for_QCStatement = function (el) { let statementId; let statementInfo; const callbacks = { statementId: (_el) => { statementId = $._decodeObjectIdentifier(_el); }, statementInfo: (_el) => { statementInfo = $._decodeAny(_el); }, }; $._parse_sequence(el, callbacks, _root_component_type_list_1_spec_for_QCStatement, _extension_additions_list_spec_for_QCStatement, _root_component_type_list_2_spec_for_QCStatement, undefined); return new QCStatement(statementId, statementInfo); }; } return _cached_decoder_for_QCStatement(el); } let _cached_encoder_for_QCStatement = null; /** * @summary Encodes a(n) QCStatement 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 QCStatement, encoded as an ASN.1 Element. */ export function _encode_QCStatement(value, elGetter) { if (!_cached_encoder_for_QCStatement) { _cached_encoder_for_QCStatement = function (value) { return $._encodeSequence([] .concat([ /* REQUIRED */ $._encodeObjectIdentifier(value.statementId, $.BER), /* IF_ABSENT */ value.statementInfo === undefined ? undefined : $._encodeAny(value.statementInfo, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_QCStatement(value, elGetter); } /* eslint-enable */