zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit 6d085be11da936ce036d4bbffcad5c8a1c1a8e45
parent abf10fc26b8e1f0328d14ee2a89943574ffb6fd7
Author: michiboo <chanmickyyun@gmail.com>
Date:   Wed,  6 Mar 2019 08:08:49 +0200

Add MXML 3.0 Compatability

Add check for MXML version and compatibility for MXML3.0:
- Add #ifndef for MXML_MAJOR_VERSION in XMLwrapper.h for version that
  don't have it defined
- Replace internal structure with MXML 3.0  API

Diffstat:
Msrc/Misc/XMLwrapper.cpp | 36+++++++++++++++++-------------------
Msrc/Misc/XMLwrapper.h | 4++++
2 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/src/Misc/XMLwrapper.cpp b/src/Misc/XMLwrapper.cpp @@ -520,11 +520,11 @@ void XMLwrapper::getparstr(const string &name, char *par, int maxstrlen) const { ZERO(par, maxstrlen); mxml_node_t *tmp = mxmlFindElement(node, - node, - "string", - "name", - name.c_str(), - MXML_DESCEND_FIRST); + node, + "string", + "name", + name.c_str(), + MXML_DESCEND_FIRST); if(tmp == NULL) return; @@ -545,11 +545,11 @@ string XMLwrapper::getparstr(const string &name, const std::string &defaultpar) const { mxml_node_t *tmp = mxmlFindElement(node, - node, - "string", - "name", - name.c_str(), - MXML_DESCEND_FIRST); + node, + "string", + "name", + name.c_str(), + MXML_DESCEND_FIRST); if((tmp == NULL) || (mxmlGetFirstChild(tmp) == NULL)) return defaultpar; @@ -683,24 +683,22 @@ std::vector<XmlNode> XMLwrapper::getBranch(void) const std::vector<XmlNode> res; mxml_node_t *current = mxmlGetFirstChild(node); while(current) { - if (mxmlGetType(current) == MXML_ELEMENT) { - #if MXML_MAJOR_VERSION == 3 + if(mxmlGetType(current) == MXML_ELEMENT) { +#if MXML_MAJOR_VERSION == 3 XmlNode n(mxmlGetElement(current)); int count = mxmlElementGetAttrCount(current); - char *name; - for (int i = 0; i < count; ++i) - { + const char *name; + for(int i = 0; i < count; ++i) { n[name] = mxmlElementGetAttrByIndex(current, i, &name); } - #else +#else auto elm = current->value.element; XmlNode n(elm.name); - for (int i = 0; i < elm.num_attrs; ++i) - { + for(int i = 0; i < elm.num_attrs; ++i) { auto &attr = elm.attrs[i]; n[attr.name] = attr.value; } - #endif +#endif res.push_back(n); } current = mxmlWalkNext(current, node, MXML_NO_DESCEND); diff --git a/src/Misc/XMLwrapper.h b/src/Misc/XMLwrapper.h @@ -21,6 +21,10 @@ #ifndef XML_WRAPPER_H #define XML_WRAPPER_H +#ifndef MXML_MAJOR_VERSION +#define MXML_MAJOR_VERSION 1 +#endif + namespace zyn { class XmlAttr