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;
202 bool addDefaultHeader =
true;
203 int lineWrapLength = 60;
204 const char* newLineChars =
"\r\n";
220 void writeTo (
OutputStream& output,
const TextFormat& format = {})
const;
225 bool writeTo (
const File& destinationFile,
const TextFormat& format = {})
const;
235 String getNamespace()
const;
238 String getTagNameWithoutNamespace()
const;
244 bool hasTagName (
StringRef possibleTagName)
const noexcept;
250 bool hasTagNameIgnoringNamespace (
StringRef possibleTagName)
const;
263 int getNumAttributes() const noexcept;
272 const
String& getAttributeName (
int attributeIndex) const noexcept;
281 const
String& getAttributeValue (
int attributeIndex) const noexcept;
287 bool hasAttribute (
StringRef attributeName) const noexcept;
292 const
String& getStringAttribute (
StringRef attributeName) const noexcept;
309 bool compareAttribute (
StringRef attributeName,
311 bool ignoreCase = false) const noexcept;
323 int getIntAttribute (
StringRef attributeName,
int defaultReturnValue = 0) const;
335 double getDoubleAttribute (
StringRef attributeName,
double defaultReturnValue = 0.0) const;
347 bool getBoolAttribute (
StringRef attributeName,
bool defaultReturnValue = false) const;
362 void setAttribute (const
Identifier& attributeName, const
String& newValue);
376 void setAttribute (const
Identifier& attributeName,
int newValue);
390 void setAttribute (const
Identifier& attributeName,
double newValue);
397 void removeAttribute (const
Identifier& attributeName) noexcept;
400 void removeAllAttributes() noexcept;
409 XmlElement* getFirstChildElement() const noexcept {
return firstChildElement; }
452 int getNumChildElements() const noexcept;
462 XmlElement* getChildElement (
int index) const noexcept;
480 StringRef attributeValue) const noexcept;
496 void addChildElement (
XmlElement* newChildElement) noexcept;
509 void insertChildElement (
XmlElement* newChildElement,
510 int indexToInsertAt) noexcept;
524 void prependChildElement (
XmlElement* newChildElement) noexcept;
549 bool replaceChildElement (
XmlElement* currentChildElement,
558 void removeChildElement (
XmlElement* childToRemove,
559 bool shouldDeleteTheChild) noexcept;
564 void deleteAllChildElements() noexcept;
569 void deleteAllChildElementsWithTagName (
StringRef tagName) noexcept;
572 bool containsChildElement (const
XmlElement* possibleChild) const noexcept;
609 template <class ElementComparator>
610 void sortChildElements (ElementComparator& comparator,
611 bool retainOrderOfEquivalentItems = false)
613 auto num = getNumChildElements();
618 getChildElementsAsArray (elems);
619 sortArray (comparator, (
XmlElement**) elems, 0, num - 1, retainOrderOfEquivalentItems);
620 reorderChildElements (elems, num);
632 bool isTextElement() const noexcept;
650 const
String& getText() const noexcept;
658 void setText (const
String& newText);
673 String getAllSubText() const;
684 const
String& defaultReturnValue) const;
689 void addTextElement (const
String& text);
694 void deleteAllTextElements() noexcept;
700 static
bool isValidXmlName (
StringRef possibleName) noexcept;
705 bool allOnOneLine = false,
706 bool includeXmlHeader = true,
708 int lineWrapLength = 60) const);
713 bool allOnOneLine = false,
714 bool includeXmlHeader = true,
716 int lineWrapLength = 60) const);
719 JUCE_DEPRECATED (
bool writeToFile (const
File& destinationFile,
722 int lineWrapLength = 60) const);
726 struct XmlAttributeNode
728 XmlAttributeNode (
const XmlAttributeNode&) noexcept;
737 XmlAttributeNode& operator= (
const XmlAttributeNode&) =
delete;
751 void copyChildrenAndAttributesFrom (const XmlElement&);
752 void writeElementAsText (OutputStream&, int, int, const char*) const;
753 void getChildElementsAsArray (XmlElement**) const noexcept;
754 void reorderChildElements (XmlElement**, int) noexcept;
755 XmlAttributeNode* getAttribute (StringRef) const noexcept;
762 JUCE_LEAK_DETECTOR (XmlElement)
Wraps a pointer to a null-terminated UTF-8 character string, and provides various methods to operate ...
Represents a local file or directory.
Very simple container class to hold a pointer to some data on the heap.
Represents a string identifier, designed for accessing properties by name.
Holds a set of named var objects.
The base class for streams that write data to some kind of destination.
A simple class for holding temporary references to a string literal or String.
Parses a text-based XML document and creates an XmlElement object from it.
Used to build a tree of elements representing an XML document.
XmlElement * getNextElement() const noexcept
Returns the next of this element's siblings.
const String & getTagName() const noexcept
Returns this element's tag type name.
#define JUCE_API
This macro is added to all JUCE public class declarations.
A struct containing options for formatting the text when representing an XML element as a string.
String customEncoding
If not empty and addDefaultHeader is true, this will be set as the encoding.
String dtd
If supplied, this DTD will be added to the document.
String customHeader
If supplied, this header will be used (and customEncoding & addDefaultHeader will be ignored).