
Procedure for Using the C++ Control Class Decode Method
- Instantiate an XML decode buffer object (OSXMLDecodeBuffer) to describe the message to be decoded. There are several choices of constructors that can be used including one that takes the name of a file which contains the XML message, one the allows a memory buffer to be specified, and one that allows an existing stream object to be used.
- Check the return status. The return value is a status value indicating whether decoding was successful or not. Zero indicates success. If decoding failed, the status value will be a negative number. The decode buffer method printErrorInfo can be invoked to get a textual explanation and stack trace of where the error occurred.
#include employee.h // include file generated by ASN1C main () { const char* filename = "message.xml"; OSBOOL verbose = FALSE, trace = TRUE; int i, stat; .. logic to read message into msgbuf .. // step 1: instantiate an XML decode buffer object OSXMLDecodeBuffer decodeBuffer (filename); // step 2: instantiate an ASN1T_<ProdName> object ASN1T_PersonnelRecord msgData; // step 3: instantiate an ASN1C_<ProdName> object ASN1C_PersonnelRecord employee (decodeBuffer, msgData); // step 4: decode the record stat = employee.Decode (); // step 5: check the return status if (stat == 0) { process received data.. } else { // error processing.. decodeBuffer.PrintErrorInfo (); } // step 6: free dynamic memory (will be done automatically // when both the decodeBuffer and employee objects go out // of scope).. }
Objective Systems, Inc.55 Dowlin Forge RoadExton, Pennsylvania 19341 http://www.obj-sys.com Phone: (484) 875-9841 Toll-free: (877) 307-6855 (US only) Fax: (484) 875-9830 info@obj-sys.com |