mxml
mxml copied to clipboard
Add capability to load/save with a generic callback
Version: 3.x-feature Original reporter:
This enhancement would allow a generalized method to be used to load or save XML data with mini XML.
For example, a callback could be specified to new function entry points such as mxmlLoadStream, mxmlSAXLoadStream, mxmlSaveStream, etc.
The callback would consist of a function prototype defined like this:
typedef int (*mxml_read_stream_cb_t)(void *,void *,unsigned int); typedef int (*mxml_write_stream_cb_t)(void *,const void *,unsigned int);
For the read, the first argument would be the context passed through the entry point, the second argument would be the buffer used to store the data or the data to be written, and the third argument would be the number of bytes to read/write.
Thus, mxmlLoadStream would look like this:
extern mxml_node_t *mxmlLoadStream ( mxml_node_t *top, mxml_read_stream_cb_t read_stream_cb,void *read_stream_context, mxml_type_t (*cb)(mxml_node_t *) );
Internally, in mxml-file.c new functions would be needed similar to the file descriptor entry points, where a generalized function is called rather than read/write.
In fact, this generalized method could potentially replace all of the separate getc and putc functions currently used (mxml_fd_getc, mxml_file_getc, etc.).
Original reporter: Michael Sweet
Potentially for Mini-XML 3.0; FWIW, the internal implementation already uses a similar API.
Deferring to a later release.
I had to implement this because I needed the functionality for my language binding.
Thanks for the library :-)
[master 4e92848] Add mxmlLoadIO/mxmlSaveIO functions, merge everything under the new roof (Issue #98)