1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

XmlElement: Update loops to use new iterators

This commit is contained in:
reuk 2021-01-28 15:22:46 +00:00
parent 40f6ac7c47
commit 3baaad8b5b
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11
27 changed files with 42 additions and 42 deletions

View file

@ -917,7 +917,7 @@ public:
table.setOutlineThickness (1);
// Add some columns to the table header, based on the column list in our database..
forEachXmlChildElement (*columnList, columnXml)
for (auto* columnXml : columnList->getChildIterator())
{
table.getHeader().addColumn (columnXml->getStringAttribute ("name"),
columnXml->getIntAttribute ("columnId"),
@ -1212,7 +1212,7 @@ private:
// (a utility method to search our XML for the attribute that matches a column ID)
String getAttributeNameForColumnId (const int columnId) const
{
forEachXmlChildElement (*columnList, columnXml)
for (auto* columnXml : columnList->getChildIterator())
{
if (columnXml->getIntAttribute ("columnId") == columnId)
return columnXml->getStringAttribute ("name");

View file

@ -95,7 +95,7 @@ public:
// create and add sub-items to this node of the tree, corresponding to
// each sub-element in the XML..
forEachXmlChildElement (xml, child)
for (auto* child : xml.getChildIterator())
{
jassert (child != nullptr);
addSubItem (new XmlTreeItem (*child));

View file

@ -272,7 +272,7 @@ static void readBusLayoutFromXml (AudioProcessor::BusesLayout& busesLayout, Audi
if (auto* buses = xml.getChildByName (isInput ? "INPUTS" : "OUTPUTS"))
{
forEachXmlChildElementWithTagName (*buses, e, "BUS")
for (auto* e : buses->getChildWithTagNameIterator ("BUS"))
{
const int busIdx = e->getIntAttribute ("index");
maxNumBuses = jmax (maxNumBuses, busIdx + 1);
@ -377,7 +377,7 @@ void PluginGraph::createNodeFromXml (const XmlElement& xml)
{
PluginDescription pd;
forEachXmlChildElement (xml, e)
for (auto* e : xml.getChildIterator())
{
if (pd.loadFromXml (*e))
break;
@ -461,13 +461,13 @@ void PluginGraph::restoreFromXml (const XmlElement& xml)
{
clear();
forEachXmlChildElementWithTagName (xml, e, "FILTER")
for (auto* e : xml.getChildWithTagNameIterator ("FILTER"))
{
createNodeFromXml (*e);
changed();
}
forEachXmlChildElementWithTagName (xml, e, "CONNECTION")
for (auto* e : xml.getChildWithTagNameIterator ("CONNECTION"))
{
graph.addConnection ({ { NodeID ((uint32) e->getIntAttribute ("srcFilter")), e->getIntAttribute ("srcChannel") },
{ NodeID ((uint32) e->getIntAttribute ("dstFilter")), e->getIntAttribute ("dstChannel") } });

View file

@ -30,7 +30,7 @@ namespace build_tools
//==============================================================================
static bool keyFoundAndNotSequentialDuplicate (XmlElement& xml, const String& key)
{
forEachXmlChildElementWithTagName (xml, element, "key")
for (auto* element : xml.getChildWithTagNameIterator ("key"))
{
if (element->getAllSubText().trim().equalsIgnoreCase (key))
{

View file

@ -381,7 +381,7 @@ static void restoreDocList (Project& project, Array <OpenDocumentManager::Docume
{
OpenDocumentManager& odm = ProjucerApplication::getApp().openDocumentManager;
forEachXmlChildElementWithTagName (*xml, e, "DOC")
for (auto* e : xml->getChildWithTagNameIterator ("DOC"))
{
const File file (e->getStringAttribute ("file"));

View file

@ -82,7 +82,7 @@ public:
t->clearTabs();
forEachXmlChildElement (xml, e)
for (auto* e : xml.getChildIterator())
{
addNewTab (t);
restoreTabState (t, t->getNumTabs() - 1, *e);

View file

@ -193,7 +193,7 @@ bool ButtonDocument::loadFromXml (const XmlElement& xml)
for (int i = 7; --i >= 0;)
paintStatesEnabled [i] = false;
forEachXmlChildElementWithTagName (xml, e, PaintRoutine::xmlTagName)
for (auto* e : xml.getChildWithTagNameIterator (PaintRoutine::xmlTagName))
{
const int stateIndex = stateNameToIndex (e->getStringAttribute ("buttonState"));

View file

@ -74,7 +74,7 @@ bool ComponentDocument::loadFromXml (const XmlElement& xml)
{
components->clearComponents();
forEachXmlChildElement (xml, e)
for (auto* e : xml.getChildIterator())
{
if (e->hasTagName (PaintRoutine::xmlTagName))
backgroundGraphics->loadFromXml (*e);

View file

@ -192,7 +192,7 @@ bool PaintElementGroup::loadFromXml (const XmlElement& xml)
{
if (xml.hasTagName (getTagName()))
{
forEachXmlChildElement (xml, e)
for (auto* e : xml.getChildIterator())
if (PaintElement* const pe = ObjectTypes::createElementForXml (e, owner))
subElements.add (pe);

View file

@ -274,7 +274,7 @@ void ComponentLayout::paste()
{
selected.deselectAll();
forEachXmlChildElement (*doc, e)
for (auto* e : doc->getChildIterator())
if (Component* newComp = addComponentFromXml (*e, true))
selected.addToSelection (newComp);

View file

@ -385,7 +385,7 @@ bool JucerDocument::loadFromXml (const XmlElement& xml)
activeExtraMethods.clear();
if (XmlElement* const methods = xml.getChildByName ("METHODS"))
forEachXmlChildElementWithTagName (*methods, e, "METHOD")
for (auto* e : methods->getChildWithTagNameIterator ("METHOD"))
activeExtraMethods.addIfNotAlreadyThere (e->getStringAttribute ("name"));
activeExtraMethods.trim();

View file

@ -306,7 +306,7 @@ void PaintRoutine::paste()
selectedElements.deselectAll();
selectedPoints.deselectAll();
forEachXmlChildElement (*doc, e)
for (auto* e : doc->getChildIterator())
if (PaintElement* newElement = addElementFromXml (*e, -1, true))
selectedElements.addToSelection (newElement);
}
@ -610,7 +610,7 @@ bool PaintRoutine::loadFromXml (const XmlElement& xml)
clear();
forEachXmlChildElement (xml, e)
for (auto* e : xml.getChildIterator())
if (auto* newElement = ObjectTypes::createElementForXml (e, this))
elements.add (newElement);

View file

@ -1633,7 +1633,7 @@ private:
{
auto permissions = getPermissionsRequired();
forEachXmlChildElementWithTagName (manifest, child, "uses-permission")
for (auto* child : manifest.getChildWithTagNameIterator ("uses-permission"))
{
permissions.removeString (child->getStringAttribute ("android:name"), false);
}
@ -1648,7 +1648,7 @@ private:
{
XmlElement* glVersion = nullptr;
forEachXmlChildElementWithTagName (manifest, child, "uses-feature")
for (auto* child : manifest.getChildWithTagNameIterator ("uses-feature"))
{
if (child->getStringAttribute ("android:glEsVersion").isNotEmpty())
{

View file

@ -3243,7 +3243,7 @@ private:
static StringArray parseNamesOfTargetsFromPlist (const XmlElement& dictXML)
{
forEachXmlChildElementWithTagName (dictXML, schemesKey, "key")
for (auto* schemesKey : dictXML.getChildWithTagNameIterator ("key"))
{
if (schemesKey->getAllSubText().trim().equalsIgnoreCase ("SchemeUserState"))
{
@ -3253,7 +3253,7 @@ private:
{
StringArray names;
forEachXmlChildElementWithTagName (*dict, key, "key")
for (auto* key : dict->getChildWithTagNameIterator ("key"))
names.add (key->getAllSubText().upToLastOccurrenceOf (".xcscheme", false, false).trim());
names.sort (false);

View file

@ -339,7 +339,7 @@ String AudioDeviceManager::initialiseFromXML (const XmlElement& xml,
midiDeviceInfosFromXml.clear();
enabledMidiInputs.clear();
forEachXmlChildElementWithTagName (xml, c, "MIDIINPUT")
for (auto* c : xml.getChildWithTagNameIterator ("MIDIINPUT"))
midiDeviceInfosFromXml.add ({ c->getStringAttribute ("name"), c->getStringAttribute ("identifier") });
auto isIdentifierAvailable = [] (const Array<MidiDeviceInfo>& available, const String& identifier)

View file

@ -382,7 +382,7 @@ private:
switchValueType.entries.add (new Entry({ TRANS("Off"), Range ("[0, 0.5[") }));
switchValueType.entries.add (new Entry({ TRANS("On"), Range ("[0.5, 1]") }));
forEachXmlChildElement (xml, item)
for (auto* item : xml.getChildIterator())
{
if (item->hasTagName ("Param")) parseParam (*item, nullptr, nullptr);
else if (item->hasTagName ("ValueType")) parseValueType (*item);
@ -436,7 +436,7 @@ private:
int curEntry = 0;
const int numEntries = item.getNumChildElements();
forEachXmlChildElementWithTagName (item, entryXml, "Entry")
for (auto* entryXml : item.getChildWithTagNameIterator ("Entry"))
{
auto entry = new Entry();
entry->name = entryXml->getStringAttribute ("name");
@ -465,7 +465,7 @@ private:
templates.add (temp);
temp->name = item.getStringAttribute ("name");
forEachXmlChildElement (item, param)
for (auto* param : item.getChildIterator())
parseParam (*param, nullptr, temp);
}
@ -514,7 +514,7 @@ private:
}
else
{
forEachXmlChildElement (item, subItem)
for (auto* subItem : item.getChildIterator())
{
if (subItem->hasTagName ("Param")) parseParam (*subItem, group, nullptr);
else if (subItem->hasTagName ("Group")) parseGroup (*subItem, group);

View file

@ -378,7 +378,7 @@ void KnownPluginList::recreateFromXml (const XmlElement& xml)
if (xml.hasTagName ("KNOWNPLUGINS"))
{
forEachXmlChildElement (xml, e)
for (auto* e : xml.getChildIterator())
{
PluginDescription info;

View file

@ -30,7 +30,7 @@ namespace CDReaderHelpers
{
inline const XmlElement* getElementForKey (const XmlElement& xml, const String& key)
{
forEachXmlChildElementWithTagName (xml, child, "key")
for (auto* child : xml.getChildWithTagNameIterator ("key"))
if (child->getAllSubText().trim() == key)
return child->getNextElement();
@ -71,7 +71,7 @@ namespace CDReaderHelpers
if (trackArray == nullptr)
return "Couldn't find Track Array";
forEachXmlChildElement (*trackArray, track)
for (auto* track : trackArray->getChildIterator())
{
const int trackValue = getIntValueForKey (*track, "Start Block");
if (trackValue < 0)

View file

@ -196,7 +196,7 @@ void PropertySet::restoreFromXml (const XmlElement& xml)
const ScopedLock sl (lock);
clear();
forEachXmlChildElementWithTagName (xml, e, "VALUE")
for (auto* e : xml.getChildWithTagNameIterator ("VALUE"))
{
if (e->hasAttribute ("name")
&& e->hasAttribute ("val"))

View file

@ -187,7 +187,7 @@ bool PropertiesFile::loadAsXml()
{
if (auto doc = parseXMLIfTagMatches (file, PropertyFileConstants::fileTag))
{
forEachXmlChildElementWithTagName (*doc, e, PropertyFileConstants::valueTag)
for (auto* e : doc->getChildWithTagNameIterator (PropertyFileConstants::valueTag))
{
auto name = e->getStringAttribute (PropertyFileConstants::nameAttribute);

View file

@ -1003,7 +1003,7 @@ ValueTree ValueTree::fromXml (const XmlElement& xml)
ValueTree v (xml.getTagName());
v.object->properties.setFromXmlAttributes (xml);
forEachXmlChildElement (xml, e)
for (auto* e : xml.getChildIterator())
v.appendChild (fromXml (*e), nullptr);
return v;

View file

@ -49,7 +49,7 @@ StringArray FTTypefaceList::getDefaultFontDirectories()
{
if (auto fontsInfo = findFontsConfFile())
{
forEachXmlChildElementWithTagName (*fontsInfo, e, "dir")
for (auto* e : fontsInfo->getChildWithTagNameIterator ("dir"))
{
auto fontPath = e->getAllSubText().trim();

View file

@ -227,7 +227,7 @@ bool KeyPressMappingSet::restoreFromXml (const XmlElement& xmlVersion)
clearAllKeyPresses();
}
forEachXmlChildElement (xmlVersion, map)
for (auto* map : xmlVersion.getChildIterator())
{
const CommandID commandId = map->getStringAttribute ("commandId").getHexValue32();

View file

@ -46,7 +46,7 @@ public:
template <typename OperationType>
bool applyOperationToChildWithID (const String& id, OperationType& op) const
{
forEachXmlChildElement (*xml, e)
for (auto* e : xml->getChildIterator())
{
XmlPath child (e, this);
@ -462,7 +462,7 @@ private:
//==============================================================================
void parseSubElements (const XmlPath& xml, DrawableComposite& parentDrawable, bool shouldParseClip = true)
{
forEachXmlChildElement (*xml, e)
for (auto* e : xml->getChildIterator())
{
const XmlPath child (xml.getChild (e));
@ -830,7 +830,7 @@ private:
if (fillXml.xml != nullptr)
{
forEachXmlChildElementWithTagName (*fillXml, e, "stop")
for (auto* e : fillXml->getChildWithTagNameIterator ("stop"))
{
auto col = parseColour (fillXml.getChild (e), "stop-color", Colours::black);
@ -1080,7 +1080,7 @@ private:
auto dc = new DrawableComposite();
setCommonAttributes (*dc, xml);
forEachXmlChildElement (*xml, e)
for (auto* e : xml->getChildIterator())
{
if (e->isTextElement())
{

View file

@ -367,7 +367,7 @@ void PropertyPanel::restoreOpennessState (const XmlElement& xml)
{
auto sections = getSectionNames();
forEachXmlChildElementWithTagName (xml, e, "SECTION")
for (auto* e : xml.getChildWithTagNameIterator ("SECTION"))
{
setSectionOpen (sections.indexOf (e->getStringAttribute ("name")),
e->getBoolAttribute ("open"));

View file

@ -439,7 +439,7 @@ void TableHeaderComponent::restoreFromString (const String& storedVersion)
{
int index = 0;
forEachXmlChildElement (*storedXML, col)
for (auto* col : storedXML->getChildIterator())
{
auto tabId = col->getIntAttribute ("id");

View file

@ -646,7 +646,7 @@ void TreeView::restoreOpennessState (const XmlElement& newState, const bool rest
{
clearSelectedItems();
forEachXmlChildElementWithTagName (newState, e, "SELECTED")
for (auto* e : newState.getChildWithTagNameIterator ("SELECTED"))
if (auto* item = rootItem->findItemFromIdentifierString (e->getStringAttribute ("id")))
item->setSelected (true, false);
}
@ -1834,7 +1834,7 @@ void TreeViewItem::restoreOpennessState (const XmlElement& e)
Array<TreeViewItem*> items;
items.addArray (subItems);
forEachXmlChildElement (e, n)
for (auto* n : e.getChildIterator())
{
auto id = n->getStringAttribute ("id");