Additional Code Generated for the -tables Option

The following additional code is generated for type definitions when the the -tables command-line option is used. The code generated to support table constraints is intended for use only in compiler-generated code. Therefore, it is not necessary for the average user to understand the mappings in order to use the product. The information presented here is informative only to provide a better understanding of how the compiler handles table constraints.

An equals() method will be generated for Sequence, Set, Sequence Of, Set Of or Choice types if required for table constraint processing. This method will be an implementation of the Asn1Type.equals() virtual method. These methods are used by the generated code to verify that data in a generated structure to be encoded (or data that has just been decoded) matches the table constraint values.

An additional table constraint check method is also generated for each type that contains table constraints. These functions have the following prototypes:

BER/DER:

   void CheckTC (bool decode);

PER:

   void CheckTC (bool decode, bool aligned);

The decode argument is used to decide if this method is to used for encoding or decoding. The aligned argument is for PER and specifies whether aligned or unaligned encoding/decoding is in effect.

The purpose of these methods is to verify that the fixed values within the table constraints are what they should be and to encode or decode the open type fields using the encoder or decoder methods from the Asn1Type objects assigned to the given table row. Calls to these functions are automatically built into the standard encode or decode functions for the given type. They should be considered hidden functions not for use within an application that uses the API.

The CheckTC method will have different logic for relative and simple table constraints. The logic to invoke this method is as follows:

On the encode side:

Relative Table Constraint:

  1. The table constraint key is searched in the object set array to find the class object for the data in the populated type variable to be encoded.

  2. If the key element value is NOT found and the table constraint object set is extensible, the CheckTC method will do no further processing (i.e. a value field match will not be performed). The user will have had to populate the type field using an Asn1OpenType object in order for it to be encoded because the generated table contains no information on how to encode the value.

  3. If the key element value is found, the method will verify all fixed type values match what is defined in the key row of the object set and will also verify that the type of any variable type fields matches the expected type.

  4. If the key element value is not found in the table (or object set) and the object set is NOT extensible, then a table constraint violation exception will be thrown.

Simple Table Constraint:

  1. The CheckTC method will verify that all of the fixed type values match what is defined in the table constraint object set. If the element value does not exist in the table (or object set) and the object set is NOT extensible, then a table constraint violation exception will be thrown.

    After the CheckTC method call, the normal encode logic is performed.

    For decoding, the logic is reversed:

    The normal decode logic is performed first to populate the standard and open type fields in the generated structure. After that, the CheckTC method is invoked to perform the following table constraint checks:

Relative Table Constraint:

  1. The table constraint key is searched in the object set array to find the class object for the data in the populated type variable to be encoded.

  2. If the key element value is NOT found and the table constraint object set is extensible, the CheckTC method will do no further processing (i.e. a value field match will not be performed) and the variable type fields will be stored as open types (i.e. as instances of C# Asn1OpenType classes). The user will be responsible for further decoding of the open type value.

  3. If the key element value is found, the CheckTC method will verify all fixed type values match what is defined in the key row of the object set and will fully decode all type fields according to the key row type and store the resulting decoded type in the ASN1Type fields.

  4. If the key element value is NOT found in the table (or object set) and the object set is NOT extensible, then a table constraint violation exception will be thrown.

Simple Table Constraint:

  1. This function will verify all the fixed type values match what is defined in the table constraint object set. If an element value does not exist in the table (or object set) and the object set is NOT extensible, then a table constraint violation exception will be thrown.