Download Generated C Function Format and Calling Parameters

Transcript
ASN.1 To C/C++ Mappings
As an example, consider the following ASN.1 class definition :
ATTRIBUTE ::= CLASS {
&Type,
&id OBJECT IDENTIFIER UNIQUE }
WITH SYNTAX { &Type ID &id }
This would result in the following definition in the C source file:
typedef struct ATTRIBUTE {
int TypeSize;
int (*encodeType) (OSCTXT* , void *, ASN1TagType );
int (*decodeType) (OSCTXT* , void *, ASN1TagType, int );
ASN1OBJID id;
}
C++ Code generation
The C++ abstract class generated to model an ASN.1 CLASS contains member variables for each of the fields within
the class. Derived information object classes are required to populate these variables with the values defined in the
ASN.1 information object specification. The C++ class also contains virtual methods representing each of the type
fields within the ASN.1 class specification. If the field is not defined to be OPTIONAL in the ASN.1 specification,
then it is declared to be abstract in the generated class definition. A class generated for an ASN.1 information object
that references this base class is required to implement these abstract virtual methods.
For each of the following CLASS fields, a corresponding member variable is generated in the C++ class definition
as follows:
For a Value Field definition, the following member variable will be added. Also, an Equals() method will be added
if required for table constraint processing.
<TypeName> <FieldName>;
inline OSBOOL idEquals (<TypeName>* pvalue)
For a Type Field definition, a virtual method is added for each encoding rules type to call the generated C encode and
decode functions. If -print is specified, a print method is also generated.
virtual int encode<ER><FieldName>
(OSCTXT* pctxt, ASN1TObject& object) { return 0; }
virtual int decode<ER><FieldName>
(OSCTXT* pctxt, ASN1TObject& object) { return 0; }
virtual void print<FieldName>
(ASN1ConstCharPtr name, ASN1TObject& object) {}
For an Object Field:
class <ClassName>* <FieldName>;
In each of these definitions:
<FieldName> would be replaced with the name of the field (without the leading '&').
<TypeName> would be replaced with the C type name for the ASN.1 Type.
96