
Other Generated Functions
In addition to the functions described above, the following other types of functions are generated as part of the code generation process:
All of these common functions are applicable to both encode and decode operations and, as such, are written to the common base .c file. The format of the name of this file is as follows:
where <xsdFileName> is the base name of the XSD file being parsed. For example, if code is being generated for file x.xsd and -test is specified, then the common functions will be written to x.c.
Initialization functions are for initializing a variable of a generated data type before use. This includes setting all fields that contain default or fixed values to the value specified in the schema. All other fields are set to zero. The format of an initialization functions name is as follows:
where <typeName> is the name of the XSD type for which the function is being generated and <ns> is an optional namespace setting that can be used to disambiguate names from multiple sources (note: this should not be confused with XML namespaces which are different).
<initFunc> (OSCTXT* pctxt, <typeName>* pvalue)The pctxt argument is used to hold a context pointer to keep track of global parameters. The pvalue argument is a pointer to a variable of the type to be initialized.
Memory free functions allow memory associated with a specific typed variable instance to be freed. Their use is not required to free memory - the run-time function rtxMemFree can be called directly with a context variable to free all memory associated with a context. There are applications, however, where freeing the memory contents of a specific variable are desirable.
Memory free functions are not generated for all types - only those that contain fields that use dynamic memory. This includes types that contain elements or attributes that reference other types that use dynamic memory. The format of a generated memory free function is as follows:
where <typeName> is the name of the XSD type for which the function is being generated and <ns> is an optional namespace setting that can be used to disambiguate names from multiple sources (note: this should not be confused with XML namespaces which are different).
<freeFunc> (OSCTXT* pctxt, <typeName>* pvalue)The pctxt argument is used to hold a context pointer to keep track of global parameters. The pvalue argument is a pointer to a variable of the type containing the memory to be freed.
Other utility or "helper" functions are type specific and designed to help the user work with the generated code. The following utility function are generated for the following types:
- Enumerated: <typeName>_toString and <typeName>_toEnum functions are generated to allow conversion from enumerated to string and vice-versa.
- List or array: repeating fields that result in the generation of an OSRTDList variable contain a <typeName>_Append function. This is used to append an instance of a typed variable to the list variable.
Objective Systems, Inc.102 Pickering Way, Suite #506Exton, 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 |