45#define forEachXmlChildElement(parentXmlElement, childElementVariableName) \
47 for (auto* childElementVariableName = (parentXmlElement).getFirstChildElement(); \
48 childElementVariableName != nullptr; \
49 childElementVariableName = childElementVariableName->getNextElement())
74#define forEachXmlChildElementWithTagName(parentXmlElement, childElementVariableName, requiredTagName) \
76 for (auto* childElementVariableName = (parentXmlElement).getChildByName (requiredTagName); \
77 childElementVariableName != nullptr; \
78 childElementVariableName = childElementVariableName->getNextElementWithTagName (requiredTagName))
154 XmlElement (String::CharPointerType tagNameBegin, String::CharPointerType tagNameEnd);
184 bool ignoreOrderOfAttributes)
const noexcept;
198 bool addDefaultHeader =
true;
199 int lineWrapLength = 60;
200 const char* newLineChars =
"\r\n";
216 void writeTo (
OutputStream& output,
const TextFormat& format = {})
const;
221 bool writeTo (
const File& destinationFile,
const TextFormat& format = {})
const;
231 String getNamespace()
const;
234 String getTagNameWithoutNamespace()
const;
240 bool hasTagName (
StringRef possibleTagName)
const noexcept;
246 bool hasTagNameIgnoringNamespace (
StringRef possibleTagName)
const;
259 int getNumAttributes() const noexcept;
268 const
String& getAttributeName (
int attributeIndex) const noexcept;
277 const
String& getAttributeValue (
int attributeIndex) const noexcept;
283 bool hasAttribute (
StringRef attributeName) const noexcept;
288 const
String& getStringAttribute (
StringRef attributeName) const noexcept;
305 bool compareAttribute (
StringRef attributeName,
307 bool ignoreCase = false) const noexcept;
319 int getIntAttribute (
StringRef attributeName,
int defaultReturnValue = 0) const;
331 double getDoubleAttribute (
StringRef attributeName,
double defaultReturnValue = 0.0) const;
343 bool getBoolAttribute (
StringRef attributeName,
bool defaultReturnValue = false) const;
358 void setAttribute (const
Identifier& attributeName, const
String& newValue);
372 void setAttribute (const
Identifier& attributeName,
int newValue);
386 void setAttribute (const
Identifier& attributeName,
double newValue);
393 void removeAttribute (const
Identifier& attributeName) noexcept;
396 void removeAllAttributes() noexcept;
405 XmlElement* getFirstChildElement() const noexcept {
return firstChildElement; }
448 int getNumChildElements() const noexcept;
458 XmlElement* getChildElement (
int index) const noexcept;
476 StringRef attributeValue) const noexcept;
492 void addChildElement (
XmlElement* newChildElement) noexcept;
505 void insertChildElement (
XmlElement* newChildElement,
506 int indexToInsertAt) noexcept;
520 void prependChildElement (
XmlElement* newChildElement) noexcept;
545 bool replaceChildElement (
XmlElement* currentChildElement,
554 void removeChildElement (
XmlElement* childToRemove,
555 bool shouldDeleteTheChild) noexcept;
560 void deleteAllChildElements() noexcept;
565 void deleteAllChildElementsWithTagName (
StringRef tagName) noexcept;
568 bool containsChildElement (const
XmlElement* possibleChild) const noexcept;
605 template <class ElementComparator>
606 void sortChildElements (ElementComparator& comparator,
607 bool retainOrderOfEquivalentItems = false)
609 auto num = getNumChildElements();
614 getChildElementsAsArray (elems);
615 sortArray (comparator, (
XmlElement**) elems, 0, num - 1, retainOrderOfEquivalentItems);
616 reorderChildElements (elems, num);
628 bool isTextElement() const noexcept;
646 const
String& getText() const noexcept;
654 void setText (const
String& newText);
669 String getAllSubText() const;
680 const
String& defaultReturnValue) const;
685 void addTextElement (const
String& text);
690 void deleteAllTextElements() noexcept;
696 static
bool isValidXmlName (
StringRef possibleName) noexcept;
701 bool allOnOneLine = false,
702 bool includeXmlHeader = true,
704 int lineWrapLength = 60) const);
709 bool allOnOneLine = false,
710 bool includeXmlHeader = true,
712 int lineWrapLength = 60) const);
715 JUCE_DEPRECATED (
bool writeToFile (const
File& destinationFile,
718 int lineWrapLength = 60) const);
722 struct XmlAttributeNode
724 XmlAttributeNode (
const XmlAttributeNode&)
noexcept;
726 XmlAttributeNode (String::CharPointerType, String::CharPointerType);
733 XmlAttributeNode& operator= (
const XmlAttributeNode&) =
delete;
747 void copyChildrenAndAttributesFrom (const XmlElement&);
748 void writeElementAsText (OutputStream&, int, int, const char*) const;
749 void getChildElementsAsArray (XmlElement**) const noexcept;
750 void reorderChildElements (XmlElement**, int) noexcept;
751 XmlAttributeNode* getAttribute (StringRef) const noexcept;
758 JUCE_LEAK_DETECTOR (XmlElement)
XmlElement * getNextElement() const noexcept
const String & getTagName() const noexcept