Out-maps(4.3)

Out-maps are used in encoders to map an internal format to an external format.


Example - out_map

internal IFormat1 {
    int f1;
    ascii f2;
};
external EFormat1 {
    ascii f1 : static_size(2), terminated_by(" ");
    ascii f2 : static_size(10), terminated_by(" ");
};
out_map OutMap : internal(IFormat1), external(EFormat1) {
    automatic;
};

The automatic mapping for out-maps only attempts to bind every field name of the external format to the respectively internal format. Just as with the in-maps, no additional formats or fields are created. Like the in-maps, out-maps support explicit mappings.

As for in-maps, specially named options can also be supplied in the out_map depending on the type of the external format. The type specific options are:


OptionDescription

PER_aligned

Only applicable for ASN.1 based formats. Specifies that PER encoding (ALIGNED version) is to be used.

PER_unaligned

Only applicable for ASN.1 based formats. Specifies that PER encoding (UNALIGNED version) is to be used.

Optional Fields

There are some additional considerations for the case where optional external fields are encoded.

An internal field can be defined as optional, enabling to encode the corresponding external field as not present. Internal fields with value null may still be considered present and are encoded as, for instance, an empty string. To override this, use the APL command udrUnsetPresent prior to encoding.

Consider the following example, where an optional field within an incoming ASN.1 record will be encoded (the definition of myInt varies).

Example - Encoding Optional Fields

asn_block { 
     main_udr ::= SEQUENCE { 
       fieldA [APPLICATION 5] INTEGER OPTIONAL 
     }; 
 }; 
 in_map inM :   external( main_udr ), 
               internal( myInt ) { 
                   automatic;
}; 
 out_map outM : internal( myInt ), 
                external( main_udr ) { 
                  automatic; 
 }; 
 decoder myDEC : in_map( inM ); 
 encoder myENC : out_map( outM );

Case 1 - Optional internal field:

If fieldA is defined as optional in the internal format definition, it will be present in the encoded record if it was present in the internal record, even if the value is null. It will not be present if it was not present in the internal record.

internal myInt { 
      int fieldA : optional; 
 };

Case 2 - Mandatory internal field:

If fieldA is defined as mandatory in the internal format definition, it will always be present in the encoded record.

internal myInt { 
      int fieldA ; 
 };

Case 3 - No mapped internal field:

internal myInt { 
 };