Codec utilities
The header files AP_EventParser.h and AP_EventWriter.h provide definitions for the Event Parser and Event Writer utilities. These utilities allow parsing and writing of the string form of reference types that are used by any <map type="reference"> elements in the adapters configuration file. From the header files:
AP_EventParser
/**
* Event Parser - a utility to parse events from strings
*
* An EventParser struct is created from a C string (NULL terminated). The
* type of event can then be interogated (the type member), though both
* integers and floats are labelled as floats. The number of elements is
* the number of fields in an event, entries in a sequence, or key,value
* pairs in a dictionary.
*
* Individual fields can then be retrieved, either as a basic type, or as a
* reference type - basic types retrieved as reference types have a single
* element which must be retrieved using the relevant method. getRefValue
* will return NULL if there are no more elements, and the basic type
* methods will return 0/ false/ empty string.
*
* Dictionary entries must be obtained via the getDictPair function, which
* sets two pointers to the key and value as reference types.
*
* No type checking is performed on the get methods; the behaviour when
* there is a type mismatch is undefined.
*
* There are two variants of the get methods; the Next set maintain a
* counter while those with an idx argument retrieve a specific element,
* which does not affect the next counter. The next counter cannot be reset.
*
* Note that the implementation is lazy - it only parses stuff if requested
* to. (though getNumberElements will parse all of that entity). Parsing is
* cached, so calling getNumberElements repeatedly is cheap, and
* getRefValue/ getString/ getDictPair will return the same objects if
* called repeatedly with the same index.
*
* Where methods return an pointer (getString and getRefValue), that
* pointer is valid until the top-level AP_EventParser is destroyed by
* AP_EventParser_dtor (no need to destroy any of its sub- objects). A
* well-formed program should have a matching number of AP_EventParser_ctor
* and AP_EventParser_dtor calls, and only use string or refValue pointers
* before AP_EventParser_dtor is called.
*
*/AP_EventWriter
/**
* Event Writer - a utility to create string forms of events.
*
* A utility class that can build string forms of events, sequences and
* dictionaries.
* An AP_EventWriter object holds a number of fields, each of which may be
* a basic type (string, int, float, boolean), or a reference type (event,
* sequence, dictionary). Once the structure has been built up by adding
* values, the toString method can be called. This returns a string that
* the caller is responsible for freeing.
* Calling the destructor on an object will destroy all AP_EventWriter
* objects it refers to in a recursive manner - thus, only the top-level
* object should be destroyed, and it is not possible to share
* AP_EventWriter objects between two different containing events.
*
*/