Download ASN.1 Compiler Version 6.2 C/C++ User`s Manual Objective

Transcript
Generated Methods
// standard encode/decode methods (defined in ASN1CType base class):
// int Encode ();
// int Decode ();
// stream encode/decode methods:
int EncodeTo (ASN1MessageBufferIF& msgBuf);
int DecodeFrom (ASN1MessageBufferIF& msgBuf);
// SAX Content Handler Interface
virtual void startElement
(const XMLCh* const uri,
const XMLCh* const localname,
const XMLCh* const qname,
const Attributes& attrs);
virtual void characters
(const XMLCh* const chars, const unsigned int length);
virtual void endElement
(const XMLCh* const uri,
const XMLCh* const localname,
const XMLCh* const qname);
} ;
The main differences between the BER/DER/PER control class definition and this are:
1. The class generated for XER inherits from the ASN1XERSAXHandler base class, and
2. The class implements the standard SAX content handler methods.
This allows an object of this class to be registered as a SAX content handler with any SAX-compliant XML parser.
The parser would be used to read and parse XML documents. The methods generated by ASN1C would then receive
the parsed data via the SAX interface and use the results to populate the data variables with the decoded data.
Note that for XML code generation (-xml command-line option), the SAX handler interface is not generated. That is
because XML decoders use a pull-parser instead of SAX code to parse the XML input stream.
Generated Methods
For each production, an EncodeFrom and DecodeTo method is generated within the generated class structure. These
are standard methods that initialize context information and then call the generated C-like encode or decode function.
If the generation of print functions was specified (by including –print on the compiler command line), a Print method
is also generated that calls the C print function.
For XER, additional methods are generated to implement a SAX content handler interface to an XML parser. This
includes a startElement, characters, and endElement method. An init and finalize method may also be generated to
initialize a variable prior to parsing and to complete population of a variable with decoded data.
Generated Information Object Table Structures
Information Objects and Classes are used to define multi-layer protocols in which “holes” are defined within ASN.1
types for passing message components to different layers for processing. These items are also used to define the
106