Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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


 

Info
titleExample - out_map


Code Block
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).

Info
titleExample - Encoding Optional Fields


Code Block
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.

Code Block
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.

Code Block
internal myInt { 
      int fieldA ; 
 };

Case 3 - No mapped internal field:

Code Block
internal myInt { 
 };




Scroll ignore
scroll-viewportfalse
scroll-pdftrue
scroll-officefalse
scroll-chmtrue
scroll-docbooktrue
scroll-eclipsehelptrue
scroll-epubtrue
scroll-htmlfalse


Next:



Scroll pagebreak