TOC PREV NEXT INDEX


Generated Stream-Oriented C++ Encode Method Format and Calling Parameters



C++ code generation of stream-based encoders is selected by using the -c++ and -stream compiler command line options. In this case, ASN1C generates an EncodeTo method that wraps the C function call. This method provides a more simplified calling interface because it hides things such as the context structure and tag type parameters.

The calling sequence for the generated C++ class method is as follows:

    stat = <object>.EncodeTo (<outputStream>); 
 

In this definition, <object> is an instance of the control class (i.e., ASN1C_<prodName>) generated for the given production.

The <outputStream> placeholder represents an output stream object type. This is an object derived from an ASN1EncodeStream class.

The function result variable stat returns the completion status. Error status codes are negative. Return status values are defined in the rtxErrCodes.h include file.

Another way to encode a message using the C++ classes is to use the << streaming operator:

    <outputStream> << <object>; 
 

Exceptions are not used in ASN1C C++, therefore, the user must fetch the status value following a call such as this in order to determine if it was successful. The getStatus method in the ASN1EncodeStream class is used for this purpose.

Also, the method Encode without parameters is supported for backward compatibility. In this case it is necessary to create control class (i.e., ASN1C_<prodName>) using an output stream reference as the first parameter and msgdata reference as the second parameter of the constructor.



Objective Systems, Inc.

55 Dowlin Forge Road
Exton, 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
TOC PREV NEXT INDEX