Name
InitSerializer -- create new serializer (V9.0)
Synopsis
APTR handle = InitSerializer(
                     int (*readfunc)(APTR buf, int len, APTR userdata),
                     int (*writefunc)(APTR data, int len, APTR userdata),
                     APTR userdata, struct hwTagList *tags);
Function
This function must create a new serializer, either for serializing or for deserializing data. If Hollywood passes the function pointer readfunc to you, InitSerializer() must initialize for deserializing data. If Hollywood passes the function pointer writefunc to you, InitSerializer() must prepare for serializing data. You must store the pointer to the I/O function because you will need it later to pass data to Hollywood or get data from Hollywood. You also have to store the userdata pointer because you need to pass it to readfunc() and writefunc().

To serialize or deserialize items, Hollywood will repeatedly call your SerializeItem() and DeserializeItem() implementations. SerializeItem() needs to call writefunc() to send the serialized data to Hollywood and DeserializeItem() needs to call readfunc() to get new data from Hollywood to deserialize.

See SerializeItem for details.

See DeserializeItem for details.

The tag list that is passed in tags may contain the following tags:

HWISZTAG_SRCENCODING:
The charset used by the source data. Typically this will be HWOS_ENCODING_UTF8 but it also could be a different charset. See hw_GetEncoding for a list of supported charsets.

HWISZTAG_DSTENCODING:
The charset that should be used by your serializer on output. Typically this will be HWOS_ENCODING_UTF8 but it also could be a different charset. See hw_GetEncoding for a list of supported charsets.

HWISZTAG_USERTAGS:
If this is set, pData will point to a struct hwUserTagList containing a list of user tags passed by the Hollywood script. User tags are a way of passing additional information from Hollywood scripts to plugin functions. See User tags for details. (V10.0)

HWISZTAG_SERIALIZEMODE:
The iData member of this tag contains the serialization mode requested by the Hollywood script. The following serialization modes are currently defined:

HWSERIALIZEMODE_HOLLYWOOD:
Hollywood serialization mode.

HWSERIALIZEMODE_NAMED:
Named serialization mode.

HWSERIALIZEMODE_LIST:
List serialization mode.

How you interpret the different serialization modes is up to your plugin. (V10.0)

HWISZTAG_SERIALIZEOPTS:
The iData member of this tag contains the serialization options requested by the Hollywood script. The following options are currently defined:

HWSERIALIZEOPTS_NOLOWERCASE:
Do not automatically convert key names to lower case.

How you interpret the individual serialization options is up to your plugin. (V10.0)

Note that if one of the tags above is not specified, your serializer should use Hollywood's default string charset. You can get this by calling hw_GetEncoding() using the HWGENCTAG_STRING tag. See hw_GetEncoding for details.

Inputs
readfunc
function to call to get data to deserialize from Hollywood or NULL
writefunc
function to call to send serialized data to Hollywood or NULL
userdata
user data that needs to be passed to readfunc() and writefunc()
tags
tag list containing optional arguments or NULL
Results
handle
handle to the serializer or NULL in case of an error

Show TOC