AbstractSyntaxNotation1Element.validateTag

A convenient method for validating the tag of an ASN.1 element.

When writing an application that uses ASN.1 validation often has to be performed for the tagClass, construction, and tagNumber. This results in a lot of code that looks like this:

if (!canFind(acceptableTagClasses, this.tagClass))
    throw new ASN1TagClassException
    (acceptableTagClasses, this.tagClass, whatYouAttemptedToDo);

if (this.construction != acceptableConstruction)
    throw new ASN1ConstructionException
    (this.construction, whatYouAttemptedToDo);

if (!canFind(acceptableTagNumbers, this.tagNumber))
    throw new ASN1TagNumberException
    (acceptableTagNumbers, this.tagNumber, whatYouAttemptedToDo);

This function was created to combat excessive code resulting from this recurring need.

Since the construction sometimes does not matter, this method was created. No validation of the element construction is performed if this variant of validateTag is used.

  1. void validateTag(ASN1TagClass[] acceptableTagClasses, ASN1Construction acceptableConstruction, size_t[] acceptableTagNumbers, string whatYouAttemptedToDo)
  2. void validateTag(ASN1TagClass[] acceptableTagClasses, size_t[] acceptableTagNumbers, string whatYouAttemptedToDo)
    class AbstractSyntaxNotation1Element(Element)
    @system const
    void
    validateTag

Meta