Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add capability to load/save with a generic callback #98

Closed
michaelrsweet opened this issue Jun 8, 2009 · 4 comments
Closed

Add capability to load/save with a generic callback #98

michaelrsweet opened this issue Jun 8, 2009 · 4 comments
Assignees
Labels
enhancement New feature or request priority-high
Milestone

Comments

@michaelrsweet
Copy link
Owner

michaelrsweet commented Jun 8, 2009

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.).

@michaelrsweet
Copy link
Owner Author

Original reporter: Michael Sweet

Potentially for Mini-XML 3.0; FWIW, the internal implementation already uses a similar API.

@michaelrsweet michaelrsweet added the enhancement New feature or request label Mar 3, 2017
@michaelrsweet michaelrsweet added this to the Future milestone Mar 3, 2017
@michaelrsweet
Copy link
Owner Author

Deferring to a later release.

@woollybah
Copy link

I had to implement this because I needed the functionality for my language binding.

Thanks for the library :-)

@michaelrsweet
Copy link
Owner Author

[master 4e92848] Add mxmlLoadIO/mxmlSaveIO functions, merge everything under the new roof (Issue #98)

@michaelrsweet michaelrsweet self-assigned this Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority-high
Projects
None yet
Development

No branches or pull requests

2 participants