diff --git a/source/tests/CarlaUtils4.cpp b/source/tests/CarlaUtils4.cpp index 94d93048f..41509c58f 100644 --- a/source/tests/CarlaUtils4.cpp +++ b/source/tests/CarlaUtils4.cpp @@ -48,6 +48,7 @@ using namespace CarlaBackend; int main() { + SaveState s; return 0; } diff --git a/source/utils/CarlaStateUtils.cpp b/source/utils/CarlaStateUtils.cpp index 234f36fbe..d03bce5b3 100644 --- a/source/utils/CarlaStateUtils.cpp +++ b/source/utils/CarlaStateUtils.cpp @@ -86,9 +86,9 @@ StateCustomData::~StateCustomData() noexcept } // ----------------------------------------------------------------------- -// SaveState +// StateSave -SaveState::SaveState() noexcept +StateSave::StateSave() noexcept : type(nullptr), name(nullptr), label(nullptr), @@ -107,12 +107,12 @@ SaveState::SaveState() noexcept currentMidiProgram(-1), chunk(nullptr) {} -SaveState::~SaveState() noexcept +StateSave::~StateSave() noexcept { reset(); } -void SaveState::reset() noexcept +void StateSave::reset() noexcept { if (type != nullptr) { @@ -214,10 +214,10 @@ static const char* xmlSafeStringCharDup(const QString& string, const bool toXml) #endif // ----------------------------------------------------------------------- -// fillSaveStateFromXmlNode +// fillStateSaveFromXmlNode #ifdef HAVE_JUCE_LATER -void fillSaveStateFromXmlNode(SaveState& saveState, const XmlElement* const xmlElement) +void fillStateSaveFromXmlElement(StateSave& stateSave, const XmlElement* const xmlElement) { CARLA_SAFE_ASSERT_RETURN(xmlElement != nullptr,); @@ -236,15 +236,15 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const XmlElement* const xmlE const String text(xmlInfo->getAllSubText().trim()); if (tag.equalsIgnoreCase("type")) - saveState.type = xmlSafeStringCharDup(text, false); + stateSave.type = xmlSafeStringCharDup(text, false); else if (tag.equalsIgnoreCase("name")) - saveState.name = xmlSafeStringCharDup(text, false); + stateSave.name = xmlSafeStringCharDup(text, false); else if (tag.equalsIgnoreCase("label") || tag.equalsIgnoreCase("uri")) - saveState.label = xmlSafeStringCharDup(text, false); + stateSave.label = xmlSafeStringCharDup(text, false); else if (tag.equalsIgnoreCase("binary") || tag.equalsIgnoreCase("bundle") || tag.equalsIgnoreCase("filename")) - saveState.binary = xmlSafeStringCharDup(text, false); + stateSave.binary = xmlSafeStringCharDup(text, false); else if (tag.equalsIgnoreCase("uniqueid")) - saveState.uniqueId = text.getLargeIntValue(); + stateSave.uniqueId = text.getLargeIntValue(); } } @@ -263,33 +263,33 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const XmlElement* const xmlE if (tag.equalsIgnoreCase("active")) { - saveState.active = (text.equalsIgnoreCase("yes") || text.equalsIgnoreCase("true")); + stateSave.active = (text.equalsIgnoreCase("yes") || text.equalsIgnoreCase("true")); } else if (tag.equalsIgnoreCase("drywet")) { - saveState.dryWet = carla_fixValue(0.0f, 1.0f, text.getFloatValue()); + stateSave.dryWet = carla_fixValue(0.0f, 1.0f, text.getFloatValue()); } else if (tag.equalsIgnoreCase("volume")) { - saveState.volume = carla_fixValue(0.0f, 1.27f, text.getFloatValue()); + stateSave.volume = carla_fixValue(0.0f, 1.27f, text.getFloatValue()); } else if (tag.equalsIgnoreCase("balanceleft") || tag.equalsIgnoreCase("balance-left")) { - saveState.balanceLeft = carla_fixValue(-1.0f, 1.0f, text.getFloatValue()); + stateSave.balanceLeft = carla_fixValue(-1.0f, 1.0f, text.getFloatValue()); } else if (tag.equalsIgnoreCase("balanceright") || tag.equalsIgnoreCase("balance-right")) { - saveState.balanceRight = carla_fixValue(-1.0f, 1.0f, text.getFloatValue()); + stateSave.balanceRight = carla_fixValue(-1.0f, 1.0f, text.getFloatValue()); } else if (tag.equalsIgnoreCase("panning")) { - saveState.panning = carla_fixValue(-1.0f, 1.0f, text.getFloatValue()); + stateSave.panning = carla_fixValue(-1.0f, 1.0f, text.getFloatValue()); } else if (tag.equalsIgnoreCase("controlchannel") || tag.equalsIgnoreCase("control-channel")) { const int value(text.getIntValue()); if (value >= 1 && value <= MAX_MIDI_CHANNELS) - saveState.ctrlChannel = static_cast(value-1); + stateSave.ctrlChannel = static_cast(value-1); } // ------------------------------------------------------- @@ -299,11 +299,11 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const XmlElement* const xmlE { const int value(text.getIntValue()); if (value >= 1) - saveState.currentProgramIndex = value-1; + stateSave.currentProgramIndex = value-1; } else if (tag.equalsIgnoreCase("currentprogramname") || tag.equalsIgnoreCase("current-program-name")) { - saveState.currentProgramName = xmlSafeStringCharDup(text, false); + stateSave.currentProgramName = xmlSafeStringCharDup(text, false); } // ------------------------------------------------------- @@ -313,13 +313,13 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const XmlElement* const xmlE { const int value(text.getIntValue()); if (value >= 1) - saveState.currentMidiBank = value-1; + stateSave.currentMidiBank = value-1; } else if (tag.equalsIgnoreCase("currentmidiprogram") || tag.equalsIgnoreCase("current-midi-program")) { const int value(text.getIntValue()); if (value >= 1) - saveState.currentMidiProgram = value-1; + stateSave.currentMidiProgram = value-1; } // ------------------------------------------------------- @@ -366,7 +366,7 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const XmlElement* const xmlE } } - saveState.parameters.append(stateParameter); + stateSave.parameters.append(stateParameter); } // ------------------------------------------------------- @@ -389,7 +389,7 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const XmlElement* const xmlE stateCustomData->value = xmlSafeStringCharDup(cText, false); } - saveState.customData.append(stateCustomData); + stateSave.customData.append(stateCustomData); } // ------------------------------------------------------- @@ -397,14 +397,14 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const XmlElement* const xmlE else if (tag.equalsIgnoreCase("chunk")) { - saveState.chunk = xmlSafeStringCharDup(text, false); + stateSave.chunk = xmlSafeStringCharDup(text, false); } } } } } #else -void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode) +void fillStateSaveFromXmlNode(StateSave& stateSave, const QDomNode& xmlNode) { CARLA_SAFE_ASSERT_RETURN(! xmlNode.isNull(),); @@ -424,25 +424,25 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode) if (tag.compare("type", Qt::CaseInsensitive) == 0) { - saveState.type = xmlSafeStringCharDup(text, false); + stateSave.type = xmlSafeStringCharDup(text, false); } else if (tag.compare("name", Qt::CaseInsensitive) == 0) { - saveState.name = xmlSafeStringCharDup(text, false); + stateSave.name = xmlSafeStringCharDup(text, false); } else if (tag.compare("label", Qt::CaseInsensitive) == 0 || tag.compare("uri", Qt::CaseInsensitive) == 0) { - saveState.label = xmlSafeStringCharDup(text, false); + stateSave.label = xmlSafeStringCharDup(text, false); } else if (tag.compare("binary", Qt::CaseInsensitive) == 0 || tag.compare("bundle", Qt::CaseInsensitive) == 0 || tag.compare("filename", Qt::CaseInsensitive) == 0) { - saveState.binary = xmlSafeStringCharDup(text, false); + stateSave.binary = xmlSafeStringCharDup(text, false); } else if (tag.compare("uniqueid", Qt::CaseInsensitive) == 0) { bool ok; const qlonglong uniqueId(text.toLongLong(&ok)); - if (ok) saveState.uniqueId = static_cast(uniqueId); + if (ok) stateSave.uniqueId = static_cast(uniqueId); } } } @@ -462,44 +462,44 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode) if (tag.compare("active", Qt::CaseInsensitive) == 0) { - saveState.active = (text.compare("yes", Qt::CaseInsensitive) == 0 || text.compare("true", Qt::CaseInsensitive) == 0); + stateSave.active = (text.compare("yes", Qt::CaseInsensitive) == 0 || text.compare("true", Qt::CaseInsensitive) == 0); } else if (tag.compare("drywet", Qt::CaseInsensitive) == 0) { bool ok; const float value(text.toFloat(&ok)); - if (ok) saveState.dryWet = carla_fixValue(0.0f, 1.0f, value); + if (ok) stateSave.dryWet = carla_fixValue(0.0f, 1.0f, value); } else if (tag.compare("volume", Qt::CaseInsensitive) == 0) { bool ok; const float value(text.toFloat(&ok)); - if (ok) saveState.volume = carla_fixValue(0.0f, 1.27f, value); + if (ok) stateSave.volume = carla_fixValue(0.0f, 1.27f, value); } else if (tag.compare("balanceleft", Qt::CaseInsensitive) == 0 || tag.compare("balance-left", Qt::CaseInsensitive) == 0) { bool ok; const float value(text.toFloat(&ok)); - if (ok) saveState.balanceLeft = carla_fixValue(-1.0f, 1.0f, value); + if (ok) stateSave.balanceLeft = carla_fixValue(-1.0f, 1.0f, value); } else if (tag.compare("balanceright", Qt::CaseInsensitive) == 0 || tag.compare("balance-right", Qt::CaseInsensitive) == 0) { bool ok; const float value(text.toFloat(&ok)); - if (ok) saveState.balanceRight = carla_fixValue(-1.0f, 1.0f, value); + if (ok) stateSave.balanceRight = carla_fixValue(-1.0f, 1.0f, value); } else if (tag.compare("panning", Qt::CaseInsensitive) == 0) { bool ok; const float value(text.toFloat(&ok)); - if (ok) saveState.panning = carla_fixValue(-1.0f, 1.0f, value); + if (ok) stateSave.panning = carla_fixValue(-1.0f, 1.0f, value); } else if (tag.compare("controlchannel", Qt::CaseInsensitive) == 0 || tag.compare("control-channel", Qt::CaseInsensitive) == 0) { bool ok; const short value(text.toShort(&ok)); if (ok && value >= 1 && value <= MAX_MIDI_CHANNELS) - saveState.ctrlChannel = static_cast(value-1); + stateSave.ctrlChannel = static_cast(value-1); } // ------------------------------------------------------- @@ -510,11 +510,11 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode) bool ok; const int value(text.toInt(&ok)); if (ok && value >= 1) - saveState.currentProgramIndex = value-1; + stateSave.currentProgramIndex = value-1; } else if (tag.compare("currentprogramname", Qt::CaseInsensitive) == 0 || tag.compare("current-program-name", Qt::CaseInsensitive) == 0) { - saveState.currentProgramName = xmlSafeStringCharDup(text, false); + stateSave.currentProgramName = xmlSafeStringCharDup(text, false); } // ------------------------------------------------------- @@ -525,14 +525,14 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode) bool ok; const int value(text.toInt(&ok)); if (ok && value >= 1) - saveState.currentMidiBank = value-1; + stateSave.currentMidiBank = value-1; } else if (tag.compare("currentmidiprogram", Qt::CaseInsensitive) == 0 || tag.compare("current-midi-program", Qt::CaseInsensitive) == 0) { bool ok; const int value(text.toInt(&ok)); if (ok && value >= 1) - saveState.currentMidiProgram = value-1; + stateSave.currentMidiProgram = value-1; } // ------------------------------------------------------- @@ -583,7 +583,7 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode) } } - saveState.parameters.append(stateParameter); + stateSave.parameters.append(stateParameter); } // ------------------------------------------------------- @@ -606,7 +606,7 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode) stateCustomData->value = xmlSafeStringCharDup(cText, false); } - saveState.customData.append(stateCustomData); + stateSave.customData.append(stateCustomData); } // ------------------------------------------------------- @@ -614,7 +614,7 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode) else if (tag.compare("chunk", Qt::CaseInsensitive) == 0) { - saveState.chunk = xmlSafeStringCharDup(text, false); + stateSave.chunk = xmlSafeStringCharDup(text, false); } } } @@ -623,63 +623,63 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode) #endif // ----------------------------------------------------------------------- -// fillXmlStringFromSaveState +// fillXmlStringFromStateSave #ifdef HAVE_JUCE_LATER -void fillXmlStringFromSaveState(String& content, const SaveState& saveState) +void fillXmlStringFromStateSave(String& content, const StateSave& stateSave) { { String info(" \n"); - info << " " << saveState.type << "\n"; - info << " " << xmlSafeString(saveState.name, true) << "\n"; + info << " " << stateSave.type << "\n"; + info << " " << xmlSafeString(stateSave.name, true) << "\n"; - switch (getPluginTypeFromString(saveState.type)) + switch (getPluginTypeFromString(stateSave.type)) { case PLUGIN_NONE: break; case PLUGIN_INTERNAL: - info << " \n"; + info << " \n"; break; case PLUGIN_LADSPA: - info << " " << xmlSafeString(saveState.binary, true) << "\n"; - info << " \n"; - info << " " << saveState.uniqueId << "\n"; + info << " " << xmlSafeString(stateSave.binary, true) << "\n"; + info << " \n"; + info << " " << stateSave.uniqueId << "\n"; break; case PLUGIN_DSSI: - info << " " << xmlSafeString(saveState.binary, true) << "\n"; - info << " \n"; + info << " " << xmlSafeString(stateSave.binary, true) << "\n"; + info << " \n"; break; case PLUGIN_LV2: - info << " " << xmlSafeString(saveState.binary, true) << "\n"; - info << " " << xmlSafeString(saveState.label, true) << "\n"; + info << " " << xmlSafeString(stateSave.binary, true) << "\n"; + info << " " << xmlSafeString(stateSave.label, true) << "\n"; break; case PLUGIN_VST: - info << " " << xmlSafeString(saveState.binary, true) << "\n"; - info << " " << saveState.uniqueId << "\n"; + info << " " << xmlSafeString(stateSave.binary, true) << "\n"; + info << " " << stateSave.uniqueId << "\n"; break; case PLUGIN_VST3: // TODO? - info << " " << xmlSafeString(saveState.binary, true) << "\n"; - info << " " << saveState.uniqueId << "\n"; + info << " " << xmlSafeString(stateSave.binary, true) << "\n"; + info << " " << stateSave.uniqueId << "\n"; break; case PLUGIN_AU: // TODO? - info << " " << xmlSafeString(saveState.binary, true) << "\n"; - info << " " << saveState.uniqueId << "\n"; + info << " " << xmlSafeString(stateSave.binary, true) << "\n"; + info << " " << stateSave.uniqueId << "\n"; break; case PLUGIN_JACK: - info << " " << xmlSafeString(saveState.binary, true) << "\n"; + info << " " << xmlSafeString(stateSave.binary, true) << "\n"; break; case PLUGIN_REWIRE: - info << " \n"; + info << " \n"; break; case PLUGIN_FILE_CSD: case PLUGIN_FILE_GIG: case PLUGIN_FILE_SF2: case PLUGIN_FILE_SFZ: - info << " " << xmlSafeString(saveState.binary, true) << "\n"; - info << " \n"; + info << " " << xmlSafeString(stateSave.binary, true) << "\n"; + info << " \n"; break; } @@ -693,28 +693,28 @@ void fillXmlStringFromSaveState(String& content, const SaveState& saveState) { String data; - data << " " << (saveState.active ? "Yes" : "No") << "\n"; + data << " " << (stateSave.active ? "Yes" : "No") << "\n"; - if (saveState.dryWet != 1.0f) - data << " " << saveState.dryWet << "\n"; - if (saveState.volume != 1.0f) - data << " " << saveState.volume << "\n"; - if (saveState.balanceLeft != -1.0f) - data << " " << saveState.balanceLeft << "\n"; - if (saveState.balanceRight != 1.0f) - data << " " << saveState.balanceRight << "\n"; - if (saveState.panning != 0.0f) - data << " " << saveState.panning << "\n"; + if (stateSave.dryWet != 1.0f) + data << " " << stateSave.dryWet << "\n"; + if (stateSave.volume != 1.0f) + data << " " << stateSave.volume << "\n"; + if (stateSave.balanceLeft != -1.0f) + data << " " << stateSave.balanceLeft << "\n"; + if (stateSave.balanceRight != 1.0f) + data << " " << stateSave.balanceRight << "\n"; + if (stateSave.panning != 0.0f) + data << " " << stateSave.panning << "\n"; - if (saveState.ctrlChannel < 0) + if (stateSave.ctrlChannel < 0) data << " N\n"; else - data << " " << int(saveState.ctrlChannel+1) << "\n"; + data << " " << int(stateSave.ctrlChannel+1) << "\n"; content << data; } - for (StateParameterItenerator it = saveState.parameters.begin(); it.valid(); it.next()) + for (StateParameterItenerator it = stateSave.parameters.begin(); it.valid(); it.next()) { StateParameter* const stateParameter(it.getValue()); @@ -740,29 +740,29 @@ void fillXmlStringFromSaveState(String& content, const SaveState& saveState) content << parameter; } - if (saveState.currentProgramIndex >= 0 && saveState.currentProgramName != nullptr && saveState.currentProgramName[0] != '\0') + if (stateSave.currentProgramIndex >= 0 && stateSave.currentProgramName != nullptr && stateSave.currentProgramName[0] != '\0') { // ignore 'default' program - if (saveState.currentProgramIndex > 0 || ! String(saveState.currentProgramName).equalsIgnoreCase("default")) + if (stateSave.currentProgramIndex > 0 || ! String(stateSave.currentProgramName).equalsIgnoreCase("default")) { String program("\n"); - program << " " << saveState.currentProgramIndex+1 << "\n"; - program << " " << xmlSafeString(saveState.currentProgramName, true) << "\n"; + program << " " << stateSave.currentProgramIndex+1 << "\n"; + program << " " << xmlSafeString(stateSave.currentProgramName, true) << "\n"; content << program; } } - if (saveState.currentMidiBank >= 0 && saveState.currentMidiProgram >= 0) + if (stateSave.currentMidiBank >= 0 && stateSave.currentMidiProgram >= 0) { String midiProgram("\n"); - midiProgram << " " << saveState.currentMidiBank+1 << "\n"; - midiProgram << " " << saveState.currentMidiProgram+1 << "\n"; + midiProgram << " " << stateSave.currentMidiBank+1 << "\n"; + midiProgram << " " << stateSave.currentMidiProgram+1 << "\n"; content << midiProgram; } - for (StateCustomDataItenerator it = saveState.customData.begin(); it.valid(); it.next()) + for (StateCustomDataItenerator it = stateSave.customData.begin(); it.valid(); it.next()) { StateCustomData* const stateCustomData(it.getValue()); @@ -788,10 +788,10 @@ void fillXmlStringFromSaveState(String& content, const SaveState& saveState) content << customData; } - if (saveState.chunk != nullptr && saveState.chunk[0] != '\0') + if (stateSave.chunk != nullptr && stateSave.chunk[0] != '\0') { String chunk("\n"" \n"); - chunk << saveState.chunk << "\n \n"; + chunk << stateSave.chunk << "\n \n"; content << chunk; } @@ -799,60 +799,60 @@ void fillXmlStringFromSaveState(String& content, const SaveState& saveState) content << " \n"; } #else -void fillXmlStringFromSaveState(QString& content, const SaveState& saveState) +void fillXmlStringFromStateSave(QString& content, const StateSave& stateSave) { { QString info(" \n"); - info += QString(" %1\n").arg(saveState.type); - info += QString(" %1\n").arg(xmlSafeString(saveState.name, true)); + info += QString(" %1\n").arg(stateSave.type); + info += QString(" %1\n").arg(xmlSafeString(stateSave.name, true)); - switch (getPluginTypeFromString(saveState.type)) + switch (getPluginTypeFromString(stateSave.type)) { case PLUGIN_NONE: break; case PLUGIN_INTERNAL: - info += QString(" \n").arg(xmlSafeString(saveState.label, true)); + info += QString(" \n").arg(xmlSafeString(stateSave.label, true)); break; case PLUGIN_LADSPA: - info += QString(" %1\n").arg(xmlSafeString(saveState.binary, true)); - info += QString(" \n").arg(xmlSafeString(saveState.label, true)); - info += QString(" %1\n").arg(saveState.uniqueId); + info += QString(" %1\n").arg(xmlSafeString(stateSave.binary, true)); + info += QString(" \n").arg(xmlSafeString(stateSave.label, true)); + info += QString(" %1\n").arg(stateSave.uniqueId); break; case PLUGIN_DSSI: - info += QString(" %1\n").arg(xmlSafeString(saveState.binary, true)); - info += QString(" \n").arg(xmlSafeString(saveState.label, true)); + info += QString(" %1\n").arg(xmlSafeString(stateSave.binary, true)); + info += QString(" \n").arg(xmlSafeString(stateSave.label, true)); break; case PLUGIN_LV2: - info += QString(" %1\n").arg(xmlSafeString(saveState.binary, true)); - info += QString(" %1\n").arg(xmlSafeString(saveState.label, true)); + info += QString(" %1\n").arg(xmlSafeString(stateSave.binary, true)); + info += QString(" %1\n").arg(xmlSafeString(stateSave.label, true)); break; case PLUGIN_VST: - info += QString(" %1\n").arg(xmlSafeString(saveState.binary, true)); - info += QString(" %1\n").arg(saveState.uniqueId); + info += QString(" %1\n").arg(xmlSafeString(stateSave.binary, true)); + info += QString(" %1\n").arg(stateSave.uniqueId); break; case PLUGIN_VST3: // TODO? - info += QString(" %1\n").arg(xmlSafeString(saveState.binary, true)); - info += QString(" %1\n").arg(saveState.uniqueId); + info += QString(" %1\n").arg(xmlSafeString(stateSave.binary, true)); + info += QString(" %1\n").arg(stateSave.uniqueId); break; case PLUGIN_AU: // TODO? - info += QString(" %1\n").arg(xmlSafeString(saveState.binary, true)); - info += QString(" %1\n").arg(saveState.uniqueId); + info += QString(" %1\n").arg(xmlSafeString(stateSave.binary, true)); + info += QString(" %1\n").arg(stateSave.uniqueId); break; case PLUGIN_JACK: - info += QString(" %1\n").arg(xmlSafeString(saveState.binary, true)); + info += QString(" %1\n").arg(xmlSafeString(stateSave.binary, true)); break; case PLUGIN_REWIRE: - info += QString(" \n").arg(xmlSafeString(saveState.label, true)); + info += QString(" \n").arg(xmlSafeString(stateSave.label, true)); break; case PLUGIN_FILE_CSD: case PLUGIN_FILE_GIG: case PLUGIN_FILE_SF2: case PLUGIN_FILE_SFZ: - info += QString(" %1\n").arg(xmlSafeString(saveState.binary, true)); - info += QString(" \n").arg(xmlSafeString(saveState.label, true)); + info += QString(" %1\n").arg(xmlSafeString(stateSave.binary, true)); + info += QString(" \n").arg(xmlSafeString(stateSave.label, true)); break; } @@ -866,28 +866,28 @@ void fillXmlStringFromSaveState(QString& content, const SaveState& saveState) { QString data; - data += QString(" %1\n").arg(saveState.active ? "Yes" : "No"); + data += QString(" %1\n").arg(stateSave.active ? "Yes" : "No"); - if (saveState.dryWet != 1.0f) - data += QString(" %1\n").arg(saveState.dryWet, 0, 'g', 7); - if (saveState.volume != 1.0f) - data += QString(" %1\n").arg(saveState.volume, 0, 'g', 7); - if (saveState.balanceLeft != -1.0f) - data += QString(" %1\n").arg(saveState.balanceLeft, 0, 'g', 7); - if (saveState.balanceRight != 1.0f) - data += QString(" %1\n").arg(saveState.balanceRight, 0, 'g', 7); - if (saveState.panning != 0.0f) - data += QString(" %1\n").arg(saveState.panning, 0, 'g', 7); + if (stateSave.dryWet != 1.0f) + data += QString(" %1\n").arg(stateSave.dryWet, 0, 'g', 7); + if (stateSave.volume != 1.0f) + data += QString(" %1\n").arg(stateSave.volume, 0, 'g', 7); + if (stateSave.balanceLeft != -1.0f) + data += QString(" %1\n").arg(stateSave.balanceLeft, 0, 'g', 7); + if (stateSave.balanceRight != 1.0f) + data += QString(" %1\n").arg(stateSave.balanceRight, 0, 'g', 7); + if (stateSave.panning != 0.0f) + data += QString(" %1\n").arg(stateSave.panning, 0, 'g', 7); - if (saveState.ctrlChannel < 0) + if (stateSave.ctrlChannel < 0) data += QString(" N\n"); else - data += QString(" %1\n").arg(saveState.ctrlChannel+1); + data += QString(" %1\n").arg(stateSave.ctrlChannel+1); content += data; } - for (StateParameterItenerator it = saveState.parameters.begin(); it.valid(); it.next()) + for (StateParameterItenerator it = stateSave.parameters.begin(); it.valid(); it.next()) { StateParameter* const stateParameter(it.getValue()); @@ -913,29 +913,29 @@ void fillXmlStringFromSaveState(QString& content, const SaveState& saveState) content += parameter; } - if (saveState.currentProgramIndex >= 0 && saveState.currentProgramName != nullptr && saveState.currentProgramName[0] != '\0') + if (stateSave.currentProgramIndex >= 0 && stateSave.currentProgramName != nullptr && stateSave.currentProgramName[0] != '\0') { // ignore 'default' program - if (saveState.currentProgramIndex > 0 || QString(saveState.currentProgramName).compare("default", Qt::CaseInsensitive) != 0) + if (stateSave.currentProgramIndex > 0 || QString(stateSave.currentProgramName).compare("default", Qt::CaseInsensitive) != 0) { QString program("\n"); - program += QString(" %1\n").arg(saveState.currentProgramIndex+1); - program += QString(" %1\n").arg(xmlSafeString(saveState.currentProgramName, true)); + program += QString(" %1\n").arg(stateSave.currentProgramIndex+1); + program += QString(" %1\n").arg(xmlSafeString(stateSave.currentProgramName, true)); content += program; } } - if (saveState.currentMidiBank >= 0 && saveState.currentMidiProgram >= 0) + if (stateSave.currentMidiBank >= 0 && stateSave.currentMidiProgram >= 0) { QString midiProgram("\n"); - midiProgram += QString(" %1\n").arg(saveState.currentMidiBank+1); - midiProgram += QString(" %1\n").arg(saveState.currentMidiProgram+1); + midiProgram += QString(" %1\n").arg(stateSave.currentMidiBank+1); + midiProgram += QString(" %1\n").arg(stateSave.currentMidiProgram+1); content += midiProgram; } - for (StateCustomDataItenerator it = saveState.customData.begin(); it.valid(); it.next()) + for (StateCustomDataItenerator it = stateSave.customData.begin(); it.valid(); it.next()) { StateCustomData* const stateCustomData(it.getValue()); @@ -957,10 +957,10 @@ void fillXmlStringFromSaveState(QString& content, const SaveState& saveState) content += customData; } - if (saveState.chunk != nullptr && saveState.chunk[0] != '\0') + if (stateSave.chunk != nullptr && stateSave.chunk[0] != '\0') { QString chunk("\n"" \n"); - chunk += QString("%1\n").arg(saveState.chunk); + chunk += QString("%1\n").arg(stateSave.chunk); chunk += " \n"; content += chunk; diff --git a/source/utils/CarlaStateUtils.hpp b/source/utils/CarlaStateUtils.hpp index 1c125e704..7619a0f8d 100644 --- a/source/utils/CarlaStateUtils.hpp +++ b/source/utils/CarlaStateUtils.hpp @@ -73,7 +73,7 @@ typedef LinkedList StateCustomDataList; typedef LinkedList::Itenerator StateParameterItenerator; typedef LinkedList::Itenerator StateCustomDataItenerator; -struct SaveState { +struct StateSave { const char* type; const char* name; const char* label; @@ -97,21 +97,21 @@ struct SaveState { StateParameterList parameters; StateCustomDataList customData; - SaveState() noexcept; - ~SaveState() noexcept; + StateSave() noexcept; + ~StateSave() noexcept; void reset() noexcept; - CARLA_DECLARE_NON_COPY_STRUCT(SaveState) + CARLA_DECLARE_NON_COPY_STRUCT(StateSave) }; // ----------------------------------------------------------------------- #ifdef HAVE_JUCE_LATER -void fillSaveStateFromXmlNode(SaveState& saveState, const juce::XmlElement* const xmlElement); -void fillXmlStringFromSaveState(juce::String& content, const SaveState& saveState); +void fillStateSaveFromXmlElement(StateSave& stateSave, const juce::XmlElement* const xmlElement); +void fillXmlStringFromStateSave(juce::String& content, const StateSave& stateSave); #else -void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode); -void fillXmlStringFromSaveState(QString& content, const SaveState& saveState); +void fillStateSaveFromXmlNode(StateSave& stateSave, const QDomNode& xmlNode); +void fillXmlStringFromStateSave(QString& content, const StateSave& stateSave); #endif // -----------------------------------------------------------------------