Generated C++ Encoding Methods

Generated C++ encoding methods use the control classes and the OSJSONEncodeBuffer and OSJSONOutputStream classes to accomplish encodings, as in the following code snippet:

   OSJSONEncodeBuffer encodeBuffer (0, 0);
   encodeBuffer.setDiag (verbose);

   ASN1T_PersonnelRecord msgData;
   ASN1C_PersonnelRecord employee (encodeBuffer, msgData);

   /* Populate structure of generated type here */

   // Encode

   if ((stat = employee.Encode ()) == 0) {
      if (trace) {
         printf ("Encoding was successful\n");
         printf ("%s\n", (const char *)encodeBuffer.getMsgPtr());
      }
   }	 
	 

The generated control class (ASN1C_PersonnelRecord) contains methods for encoding (Encode). It unites the message data (held in ASN1T_PersonnelRecord) and the encoding buffer (OSJSONEncodeBuffer) to encode the JSON message.