Examples of Non-Automatic Maps(4.0)

Non-automatic maps provide explicit mapping between the external and internal format. Such mappings work on fields with primitive types and/or fields that are instances of other formats. In the latter case, the maps can be nested indefinitely. The following two examples demonstrate these concepts.


Example - Non-Automatic Maps, all primitives

 In the following example a decoder, based on the in_map, will do the following:

  1. Read an instance of the external record ExtFormat.

  2. Associate ef1 with if1, that is, any reference to if1 will force decoding of the information of ef1 and in the process convert it to an integer.

  3. Associate ef2 with if2, that is, any reference to if2 will force decoding of the information of ef2 and in the process convert it to a string.


external ExtFormat { 
     ascii ef1 : static_size(4), padded_with(" "); 
     int ef2 : static_size(2); 
 };

           
 internal IntFormat { 
     int if1; 
     ascii if2; 
 };

           
 in_map InMapFormat: external(ExtFormat), internal(IntFormat) { 
     e:ef1 and i:if1; 
     e:ef2 and i:if2; 
 };

 


Example - Non-Automatic Maps, externals in externals

In the following example a decoder, based on the in_map, will do the following:

  1. Read an instance of the external record ExtFormat2.

  2. Associate ef1 with if1, that is, any reference to if1 will force decoding of the information of ef1. The conversion between ExtFormat1 andIntFormat1 is, in this case, dictated by the in-map named InMapFormat1 as declared in InMapFormat2.


external ExtFormat1 { 
     ascii ef1 : static_size(4); 
 };

               
 external ExtFormat2 { 
     ExtFormat1 ef1; 
 };

               
 internal IntFormat1 { 
     int if1; 
 };

               
 internal IntFormat2 { 
     IntFormat1 if1; 
 };

               
 in_map InMapFormat1: external(ExtFormat1), internal(IntFormat1) { 
     e:ef1 and i:if1; 
 };

               
 in_map InMapFormat2: external(ExtFormat2), internal(IntFormat2) { 
     e:ef1 and i:if1 using in_map InMapFormat1; 
 }; 


As seen in the example, explicit map specifications for complex formats can become very large, even describing all the internals to map data too, can be a huge task. This is why automatic mapping is normally used.