diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-02-20 18:42:30 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-02-21 00:35:49 +0000 |
commit | 0724047fbbbf02e053e2686299d726fcb2c7d295 (patch) | |
tree | dd367585d80c40ba9e8387d1ff2b3e8a16094a6c /lib/saxParse.cpp | |
parent | Swap @ prefix for p. prefix for special value names (diff) | |
download | ilt-0724047fbbbf02e053e2686299d726fcb2c7d295.tar.bz2 ilt-0724047fbbbf02e053e2686299d726fcb2c7d295.tar.xz ilt-0724047fbbbf02e053e2686299d726fcb2c7d295.zip |
Add SAXParse base class
Diffstat (limited to 'lib/saxParse.cpp')
-rw-r--r-- | lib/saxParse.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/saxParse.cpp b/lib/saxParse.cpp new file mode 100644 index 0000000..d592a1f --- /dev/null +++ b/lib/saxParse.cpp @@ -0,0 +1,41 @@ +#include "saxParse.h" +#include "mxml.h" + +namespace Persistence { + void + SAXParse::comment(mxml_node_t *) + { + // Default to just ignore comments + } + + void + SAXParse::parseFile(FILE * file) + { + mxmlSAXLoadFile( + nullptr, file, MXML_TEXT_CALLBACK, + [](mxml_node_t * n, mxml_sax_event_t e, void * data) { + SAXParse * self = static_cast<SAXParse *>(data); + switch (e) { + case MXML_SAX_ELEMENT_OPEN: + return self->elementOpen(n); + break; + case MXML_SAX_ELEMENT_CLOSE: + return self->elementClose(n); + break; + case MXML_SAX_COMMENT: + return self->comment(n); + break; + case MXML_SAX_DATA: + return self->data(n); + break; + case MXML_SAX_DIRECTIVE: + return self->directive(n); + break; + case MXML_SAX_CDATA:; + return self->cdata(n); + break; + } + }, + this); + } +} |