diff --git a/source/backend/engine/CarlaEngine.cpp b/source/backend/engine/CarlaEngine.cpp index 377627027..2459cfe86 100644 --- a/source/backend/engine/CarlaEngine.cpp +++ b/source/backend/engine/CarlaEngine.cpp @@ -1956,76 +1956,76 @@ bool CarlaEngine::loadProjectInternal(water::XmlDocument& xmlDoc) const String& tag(settElem->getTagName()); const String text(settElem->getAllSubText().trim()); - /** some settings might be incorrect or require extra work, - so we call setOption rather than modifying them direly */ + /** some settings might be incorrect or require extra work, + so we call setOption rather than modifying them direly */ - int option = -1; - int value = 0; - const char* valueStr = nullptr; + int option = -1; + int value = 0; + const char* valueStr = nullptr; - /**/ if (tag.equalsIgnoreCase("forcestereo")) + /**/ if (tag == "ForceStereo") { option = ENGINE_OPTION_FORCE_STEREO; - value = text.equalsIgnoreCase("true") ? 1 : 0; + value = text == "true" ? 1 : 0; } - else if (tag.equalsIgnoreCase("preferpluginbridges")) + else if (tag == "PreferPluginBridges") { option = ENGINE_OPTION_PREFER_PLUGIN_BRIDGES; - value = text.equalsIgnoreCase("true") ? 1 : 0; + value = text == "true" ? 1 : 0; } - else if (tag.equalsIgnoreCase("preferuibridges")) + else if (tag == "PreferUiBridges") { option = ENGINE_OPTION_PREFER_UI_BRIDGES; - value = text.equalsIgnoreCase("true") ? 1 : 0; + value = text == "true" ? 1 : 0; } - else if (tag.equalsIgnoreCase("uisalwaysontop")) + else if (tag == "UIsAlwaysOnTop") { option = ENGINE_OPTION_UIS_ALWAYS_ON_TOP; - value = text.equalsIgnoreCase("true") ? 1 : 0; + value = text == "true" ? 1 : 0; } - else if (tag.equalsIgnoreCase("maxparameters")) + else if (tag == "MaxParameters") { option = ENGINE_OPTION_MAX_PARAMETERS; value = text.getIntValue(); } - else if (tag.equalsIgnoreCase("uibridgestimeout")) + else if (tag == "UIBridgesTimeout") { option = ENGINE_OPTION_UI_BRIDGES_TIMEOUT; value = text.getIntValue(); } else if (isPlugin) { - /**/ if (tag.equalsIgnoreCase("LADSPA_PATH")) + /**/ if (tag == "LADSPA_PATH") { option = ENGINE_OPTION_PLUGIN_PATH; value = PLUGIN_LADSPA; valueStr = text.toRawUTF8(); } - else if (tag.equalsIgnoreCase("DSSI_PATH")) + else if (tag == "DSSI_PATH") { option = ENGINE_OPTION_PLUGIN_PATH; value = PLUGIN_DSSI; valueStr = text.toRawUTF8(); } - else if (tag.equalsIgnoreCase("LV2_PATH")) + else if (tag == "LV2_PATH") { option = ENGINE_OPTION_PLUGIN_PATH; value = PLUGIN_LV2; valueStr = text.toRawUTF8(); } - else if (tag.equalsIgnoreCase("VST2_PATH")) + else if (tag == "VST2_PATH") { option = ENGINE_OPTION_PLUGIN_PATH; value = PLUGIN_VST2; valueStr = text.toRawUTF8(); } - else if (tag.equalsIgnoreCase("SF2_PATH")) + else if (tag == "SF2_PATH") { option = ENGINE_OPTION_PLUGIN_PATH; value = PLUGIN_SF2; valueStr = text.toRawUTF8(); } - else if (tag.equalsIgnoreCase("SFZ_PATH")) + else if (tag == "SFZ_PATH") { option = ENGINE_OPTION_PLUGIN_PATH; value = PLUGIN_SFZ; @@ -2064,7 +2064,7 @@ bool CarlaEngine::loadProjectInternal(water::XmlDocument& xmlDoc) { const String& tagName(elem->getTagName()); - if (isPreset || tagName.equalsIgnoreCase("plugin")) + if (isPreset || tagName == "Plugin") { CarlaStateSave stateSave; stateSave.fillFromXmlElement(isPreset ? xmlElement.get() : elem); @@ -2278,41 +2278,34 @@ bool CarlaEngine::loadProjectInternal(water::XmlDocument& xmlDoc) { const bool isUsingExternal(pData->graph.isUsingExternal()); - for (XmlElement* elem = xmlElement->getFirstChildElement(); elem != nullptr; elem = elem->getNextElement()) + if (XmlElement* const elem = xmlElement->getChildByName("Patchbay")) { - const String& tagName(elem->getTagName()); - - // only load internal patchbay connections - if (! tagName.equalsIgnoreCase("patchbay")) - continue; - CarlaString sourcePort, targetPort; for (XmlElement* patchElem = elem->getFirstChildElement(); patchElem != nullptr; patchElem = patchElem->getNextElement()) { const String& patchTag(patchElem->getTagName()); + if (patchTag != "Connection") + continue; + sourcePort.clear(); targetPort.clear(); - if (! patchTag.equalsIgnoreCase("connection")) - continue; - for (XmlElement* connElem = patchElem->getFirstChildElement(); connElem != nullptr; connElem = connElem->getNextElement()) { const String& tag(connElem->getTagName()); const String text(connElem->getAllSubText().trim()); - /**/ if (tag.equalsIgnoreCase("source")) + /**/ if (tag == "Source") sourcePort = xmlSafeString(text, false).toRawUTF8(); - else if (tag.equalsIgnoreCase("target")) + else if (tag == "Target") targetPort = xmlSafeString(text, false).toRawUTF8(); } if (sourcePort.isNotEmpty() && targetPort.isNotEmpty()) restorePatchbayConnection(false, sourcePort, targetPort, !isUsingExternal); } - break; } callback(ENGINE_CALLBACK_IDLE, 0, 0, 0, 0.0f, nullptr); @@ -2348,13 +2341,13 @@ bool CarlaEngine::loadProjectInternal(water::XmlDocument& xmlDoc) const String& tagName(elem->getTagName()); // check if we want to load patchbay-mode connections into an external (multi-client) graph - if (tagName.equalsIgnoreCase("patchbay")) + if (tagName == "Patchbay") { if (pData->options.processMode == ENGINE_PROCESS_MODE_PATCHBAY) continue; } // or load external patchbay connections - else if (! tagName.equalsIgnoreCase("externalpatchbay")) + else if (tagName != "ExternalPatchbay") { continue; } @@ -2365,20 +2358,20 @@ bool CarlaEngine::loadProjectInternal(water::XmlDocument& xmlDoc) { const String& patchTag(patchElem->getTagName()); + if (patchTag != "Connection") + continue; + sourcePort.clear(); targetPort.clear(); - if (! patchTag.equalsIgnoreCase("connection")) - continue; - for (XmlElement* connElem = patchElem->getFirstChildElement(); connElem != nullptr; connElem = connElem->getNextElement()) { const String& tag(connElem->getTagName()); const String text(connElem->getAllSubText().trim()); - /**/ if (tag.equalsIgnoreCase("source")) + /**/ if (tag == "Source") sourcePort = xmlSafeString(text, false).toRawUTF8(); - else if (tag.equalsIgnoreCase("target")) + else if (tag == "Target") targetPort = xmlSafeString(text, false).toRawUTF8(); } diff --git a/source/utils/CarlaStateUtils.cpp b/source/utils/CarlaStateUtils.cpp index 6041d379b..3178601ff 100644 --- a/source/utils/CarlaStateUtils.cpp +++ b/source/utils/CarlaStateUtils.cpp @@ -293,22 +293,22 @@ bool CarlaStateSave::fillFromXmlElement(const XmlElement* const xmlElement) // --------------------------------------------------------------- // Info - if (tagName.equalsIgnoreCase("info")) + if (tagName == "Info") { for (XmlElement* xmlInfo = elem->getFirstChildElement(); xmlInfo != nullptr; xmlInfo = xmlInfo->getNextElement()) { const String& tag(xmlInfo->getTagName()); const String text(xmlInfo->getAllSubText().trim()); - if (tag.equalsIgnoreCase("type")) + /**/ if (tag == "Type") type = xmlSafeStringCharDup(text, false); - else if (tag.equalsIgnoreCase("name")) + else if (tag == "Name") name = xmlSafeStringCharDup(text, false); - else if (tag.equalsIgnoreCase("label") || tag.equalsIgnoreCase("identifier") || tag.equalsIgnoreCase("uri") || tag.equalsIgnoreCase("setup")) + else if (tag == "Label" || tag == "URI" || tag == "Setup") label = xmlSafeStringCharDup(text, false); - else if (tag.equalsIgnoreCase("binary") || tag.equalsIgnoreCase("bundle") || tag.equalsIgnoreCase("filename")) + else if (tag == "Binary" || tag == "Filename") binary = xmlSafeStringCharDup(text, false); - else if (tag.equalsIgnoreCase("uniqueid")) + else if (tag == "UniqueID") uniqueId = text.getLargeIntValue(); } } @@ -316,7 +316,7 @@ bool CarlaStateSave::fillFromXmlElement(const XmlElement* const xmlElement) // --------------------------------------------------------------- // Data - else if (tagName.equalsIgnoreCase("data")) + else if (tagName == "Data") { for (XmlElement* xmlData = elem->getFirstChildElement(); xmlData != nullptr; xmlData = xmlData->getNextElement()) { @@ -327,31 +327,31 @@ bool CarlaStateSave::fillFromXmlElement(const XmlElement* const xmlElement) // ------------------------------------------------------- // Internal Data - if (tag.equalsIgnoreCase("active")) + /**/ if (tag == "Active") { - active = (text.equalsIgnoreCase("yes") || text.equalsIgnoreCase("true")); + active = (text == "Yes"); } - else if (tag.equalsIgnoreCase("drywet")) + else if (tag == "DryWet") { dryWet = carla_fixedValue(0.0f, 1.0f, text.getFloatValue()); } - else if (tag.equalsIgnoreCase("volume")) + else if (tag == "Volume") { volume = carla_fixedValue(0.0f, 1.27f, text.getFloatValue()); } - else if (tag.equalsIgnoreCase("balanceleft") || tag.equalsIgnoreCase("balance-left")) + else if (tag == "Balance-Left") { balanceLeft = carla_fixedValue(-1.0f, 1.0f, text.getFloatValue()); } - else if (tag.equalsIgnoreCase("balanceright") || tag.equalsIgnoreCase("balance-right")) + else if (tag == "Balance-Right") { balanceRight = carla_fixedValue(-1.0f, 1.0f, text.getFloatValue()); } - else if (tag.equalsIgnoreCase("panning")) + else if (tag == "Panning") { panning = carla_fixedValue(-1.0f, 1.0f, text.getFloatValue()); } - else if (tag.equalsIgnoreCase("controlchannel") || tag.equalsIgnoreCase("control-channel")) + else if (tag == "ControlChannel") { if (! text.startsWithIgnoreCase("n")) { @@ -360,7 +360,7 @@ bool CarlaStateSave::fillFromXmlElement(const XmlElement* const xmlElement) ctrlChannel = static_cast(value-1); } } - else if (tag.equalsIgnoreCase("options")) + else if (tag == "Options") { const int value(text.getHexValue32()); if (value > 0) @@ -373,13 +373,13 @@ bool CarlaStateSave::fillFromXmlElement(const XmlElement* const xmlElement) // ------------------------------------------------------- // Program (current) - else if (tag.equalsIgnoreCase("currentprogramindex") || tag.equalsIgnoreCase("current-program-index")) + else if (tag == "CurrentProgramIndex") { const int value(text.getIntValue()); if (value >= 1) currentProgramIndex = value-1; } - else if (tag.equalsIgnoreCase("currentprogramname") || tag.equalsIgnoreCase("current-program-name")) + else if (tag == "CurrentProgramName") { currentProgramName = xmlSafeStringCharDup(text, false); } @@ -387,13 +387,13 @@ bool CarlaStateSave::fillFromXmlElement(const XmlElement* const xmlElement) // ------------------------------------------------------- // Midi Program (current) - else if (tag.equalsIgnoreCase("currentmidibank") || tag.equalsIgnoreCase("current-midi-bank")) + else if (tag == "CurrentMidiBank") { const int value(text.getIntValue()); if (value >= 1) currentMidiBank = value-1; } - else if (tag.equalsIgnoreCase("currentmidiprogram") || tag.equalsIgnoreCase("current-midi-program")) + else if (tag == "CurrentMidiProgram") { const int value(text.getIntValue()); if (value >= 1) @@ -403,7 +403,7 @@ bool CarlaStateSave::fillFromXmlElement(const XmlElement* const xmlElement) // ------------------------------------------------------- // Parameters - else if (tag.equalsIgnoreCase("parameter")) + else if (tag == "Parameter") { Parameter* const stateParameter(new Parameter()); @@ -412,33 +412,33 @@ bool CarlaStateSave::fillFromXmlElement(const XmlElement* const xmlElement) const String& pTag(xmlSubData->getTagName()); const String pText(xmlSubData->getAllSubText().trim()); - if (pTag.equalsIgnoreCase("index")) + /**/ if (pTag == "Index") { const int index(pText.getIntValue()); if (index >= 0) stateParameter->index = index; } - else if (pTag.equalsIgnoreCase("name")) + else if (pTag == "Name") { stateParameter->name = xmlSafeStringCharDup(pText, false); } - else if (pTag.equalsIgnoreCase("symbol")) + else if (pTag == "Symbol") { stateParameter->symbol = xmlSafeStringCharDup(pText, false); } - else if (pTag.equalsIgnoreCase("value")) + else if (pTag == "Value") { stateParameter->dummy = false; stateParameter->value = pText.getFloatValue(); } #ifndef BUILD_BRIDGE - else if (pTag.equalsIgnoreCase("midichannel") || pTag.equalsIgnoreCase("midi-channel")) + else if (pTag == "MidiChannel") { const int channel(pText.getIntValue()); if (channel >= 1 && channel <= MAX_MIDI_CHANNELS) stateParameter->midiChannel = static_cast(channel-1); } - else if (pTag.equalsIgnoreCase("midicc") || pTag.equalsIgnoreCase("midi-cc")) + else if (pTag == "MidiCC") { const int cc(pText.getIntValue()); if (cc >= -1 && cc < MAX_MIDI_CONTROL) @@ -453,7 +453,7 @@ bool CarlaStateSave::fillFromXmlElement(const XmlElement* const xmlElement) // ------------------------------------------------------- // Custom Data - else if (tag.equalsIgnoreCase("customdata") || tag.equalsIgnoreCase("custom-data")) + else if (tag == "CustomData") { CustomData* const stateCustomData(new CustomData()); @@ -462,11 +462,11 @@ bool CarlaStateSave::fillFromXmlElement(const XmlElement* const xmlElement) const String& cTag(xmlSubData->getTagName()); const String cText(xmlSubData->getAllSubText().trim()); - if (cTag.equalsIgnoreCase("type")) + /**/ if (cTag == "Type") stateCustomData->type = xmlSafeStringCharDup(cText, false); - else if (cTag.equalsIgnoreCase("key")) + else if (cTag == "Key") stateCustomData->key = xmlSafeStringCharDup(cText, false); - else if (cTag.equalsIgnoreCase("value")) + else if (cTag == "Value") stateCustomData->value = carla_strdup(cText.toRawUTF8()); //xmlSafeStringCharDup(cText, false); } @@ -479,7 +479,7 @@ bool CarlaStateSave::fillFromXmlElement(const XmlElement* const xmlElement) // ------------------------------------------------------- // Chunk - else if (tag.equalsIgnoreCase("chunk")) + else if (tag == "Chunk") { chunk = carla_strdup(text.toRawUTF8()); }