49 #define forEachXmlChildElement(parentXmlElement, childElementVariableName) \
51 for (auto* childElementVariableName = (parentXmlElement).getFirstChildElement(); \
52 childElementVariableName != nullptr; \
53 childElementVariableName = childElementVariableName->getNextElement())
78 #define forEachXmlChildElementWithTagName(parentXmlElement, childElementVariableName, requiredTagName) \
80 for (auto* childElementVariableName = (parentXmlElement).getChildByName (requiredTagName); \
81 childElementVariableName != nullptr; \
82 childElementVariableName = childElementVariableName->getNextElementWithTagName (requiredTagName))
188 bool ignoreOrderOfAttributes)
const noexcept;
209 bool allOnOneLine =
false,
210 bool includeXmlHeader =
true,
212 int lineWrapLength = 60)
const;
231 bool allOnOneLine =
false,
232 bool includeXmlHeader =
true,
234 int lineWrapLength = 60)
const;
255 bool writeToFile (
const File& destinationFile,
258 int lineWrapLength = 60)
const;
268 String getNamespace()
const;
271 String getTagNameWithoutNamespace()
const;
277 bool hasTagName (
StringRef possibleTagName)
const noexcept;
283 bool hasTagNameIgnoringNamespace (
StringRef possibleTagName)
const;
296 int getNumAttributes() const noexcept;
305 const
String& getAttributeName (
int attributeIndex) const noexcept;
314 const
String& getAttributeValue (
int attributeIndex) const noexcept;
320 bool hasAttribute (
StringRef attributeName) const noexcept;
325 const
String& getStringAttribute (
StringRef attributeName) const noexcept;
342 bool compareAttribute (
StringRef attributeName,
344 bool ignoreCase = false) const noexcept;
356 int getIntAttribute (
StringRef attributeName,
int defaultReturnValue = 0) const;
368 double getDoubleAttribute (
StringRef attributeName,
double defaultReturnValue = 0.0) const;
380 bool getBoolAttribute (
StringRef attributeName,
bool defaultReturnValue = false) const;
395 void setAttribute (const
Identifier& attributeName, const
String& newValue);
409 void setAttribute (const
Identifier& attributeName,
int newValue);
423 void setAttribute (const
Identifier& attributeName,
double newValue);
430 void removeAttribute (const
Identifier& attributeName) noexcept;
433 void removeAllAttributes() noexcept;
442 XmlElement* getFirstChildElement() const noexcept {
return firstChildElement; }
485 int getNumChildElements() const noexcept;
495 XmlElement* getChildElement (
int index) const noexcept;
513 StringRef attributeValue) const noexcept;
529 void addChildElement (
XmlElement* newChildElement) noexcept;
542 void insertChildElement (
XmlElement* newChildElement,
543 int indexToInsertAt) noexcept;
557 void prependChildElement (
XmlElement* newChildElement) noexcept;
582 bool replaceChildElement (
XmlElement* currentChildElement,
591 void removeChildElement (
XmlElement* childToRemove,
592 bool shouldDeleteTheChild) noexcept;
597 void deleteAllChildElements() noexcept;
602 void deleteAllChildElementsWithTagName (
StringRef tagName) noexcept;
605 bool containsChildElement (const
XmlElement* possibleChild) const noexcept;
642 template <class ElementComparator>
643 void sortChildElements (ElementComparator& comparator,
644 bool retainOrderOfEquivalentItems = false)
646 auto num = getNumChildElements();
651 getChildElementsAsArray (elems);
652 sortArray (comparator, (
XmlElement**) elems, 0, num - 1, retainOrderOfEquivalentItems);
653 reorderChildElements (elems, num);
665 bool isTextElement() const noexcept;
683 const
String& getText() const noexcept;
691 void setText (const
String& newText);
706 String getAllSubText() const;
717 const
String& defaultReturnValue) const;
722 void addTextElement (const
String& text);
727 void deleteAllTextElements() noexcept;
733 static
bool isValidXmlName (
StringRef possibleName) noexcept;
737 struct XmlAttributeNode
739 XmlAttributeNode (
const XmlAttributeNode&) noexcept;
748 XmlAttributeNode& operator= (
const XmlAttributeNode&) =
delete;
751 friend class XmlDocument;
752 friend class LinkedListPointer<XmlAttributeNode>;
753 friend class LinkedListPointer<XmlElement>;
754 friend class LinkedListPointer<XmlElement>::Appender;
755 friend class NamedValueSet;
757 LinkedListPointer<XmlElement> nextListItem;
758 LinkedListPointer<XmlElement> firstChildElement;
759 LinkedListPointer<XmlAttributeNode> attributes;
762 XmlElement (int) noexcept;
763 void copyChildrenAndAttributesFrom (const XmlElement&);
764 void writeElementAsText (OutputStream&, int indentationLevel, int lineWrapLength) const;
765 void getChildElementsAsArray (XmlElement**) const noexcept;
766 void reorderChildElements (XmlElement**, int) noexcept;
767 XmlAttributeNode* getAttribute (StringRef) const noexcept;
772 XmlElement (const wchar_t*) = delete;
774 JUCE_LEAK_DETECTOR (XmlElement)