The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

720 lines
30KB

  1. /*
  2. ==============================================================================
  3. This file is part of the juce_core module of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software Ltd.
  5. Permission to use, copy, modify, and/or distribute this software for any purpose with
  6. or without fee is hereby granted, provided that the above copyright notice and this
  7. permission notice appear in all copies.
  8. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
  9. TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
  10. NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  11. DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  12. IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  13. CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  14. ------------------------------------------------------------------------------
  15. NOTE! This permissive ISC license applies ONLY to files within the juce_core module!
  16. All other JUCE modules are covered by a dual GPL/commercial license, so if you are
  17. using any other modules, be sure to check that you also comply with their license.
  18. For more details, visit www.juce.com
  19. ==============================================================================
  20. */
  21. #ifndef JUCE_XMLELEMENT_H_INCLUDED
  22. #define JUCE_XMLELEMENT_H_INCLUDED
  23. //==============================================================================
  24. /** A handy macro to make it easy to iterate all the child elements in an XmlElement.
  25. The parentXmlElement should be a reference to the parent XML, and the childElementVariableName
  26. will be the name of a pointer to each child element.
  27. E.g. @code
  28. XmlElement* myParentXml = createSomeKindOfXmlDocument();
  29. forEachXmlChildElement (*myParentXml, child)
  30. {
  31. if (child->hasTagName ("FOO"))
  32. doSomethingWithXmlElement (child);
  33. }
  34. @endcode
  35. @see forEachXmlChildElementWithTagName
  36. */
  37. #define forEachXmlChildElement(parentXmlElement, childElementVariableName) \
  38. \
  39. for (juce::XmlElement* childElementVariableName = (parentXmlElement).getFirstChildElement(); \
  40. childElementVariableName != nullptr; \
  41. childElementVariableName = childElementVariableName->getNextElement())
  42. /** A macro that makes it easy to iterate all the child elements of an XmlElement
  43. which have a specified tag.
  44. This does the same job as the forEachXmlChildElement macro, but only for those
  45. elements that have a particular tag name.
  46. The parentXmlElement should be a reference to the parent XML, and the childElementVariableName
  47. will be the name of a pointer to each child element. The requiredTagName is the
  48. tag name to match.
  49. E.g. @code
  50. XmlElement* myParentXml = createSomeKindOfXmlDocument();
  51. forEachXmlChildElementWithTagName (*myParentXml, child, "MYTAG")
  52. {
  53. // the child object is now guaranteed to be a <MYTAG> element..
  54. doSomethingWithMYTAGElement (child);
  55. }
  56. @endcode
  57. @see forEachXmlChildElement
  58. */
  59. #define forEachXmlChildElementWithTagName(parentXmlElement, childElementVariableName, requiredTagName) \
  60. \
  61. for (juce::XmlElement* childElementVariableName = (parentXmlElement).getChildByName (requiredTagName); \
  62. childElementVariableName != nullptr; \
  63. childElementVariableName = childElementVariableName->getNextElementWithTagName (requiredTagName))
  64. //==============================================================================
  65. /** Used to build a tree of elements representing an XML document.
  66. An XML document can be parsed into a tree of XmlElements, each of which
  67. represents an XML tag structure, and which may itself contain other
  68. nested elements.
  69. An XmlElement can also be converted back into a text document, and has
  70. lots of useful methods for manipulating its attributes and sub-elements,
  71. so XmlElements can actually be used as a handy general-purpose data
  72. structure.
  73. Here's an example of parsing some elements: @code
  74. // check we're looking at the right kind of document..
  75. if (myElement->hasTagName ("ANIMALS"))
  76. {
  77. // now we'll iterate its sub-elements looking for 'giraffe' elements..
  78. forEachXmlChildElement (*myElement, e)
  79. {
  80. if (e->hasTagName ("GIRAFFE"))
  81. {
  82. // found a giraffe, so use some of its attributes..
  83. String giraffeName = e->getStringAttribute ("name");
  84. int giraffeAge = e->getIntAttribute ("age");
  85. bool isFriendly = e->getBoolAttribute ("friendly");
  86. }
  87. }
  88. }
  89. @endcode
  90. And here's an example of how to create an XML document from scratch: @code
  91. // create an outer node called "ANIMALS"
  92. XmlElement animalsList ("ANIMALS");
  93. for (int i = 0; i < numAnimals; ++i)
  94. {
  95. // create an inner element..
  96. XmlElement* giraffe = new XmlElement ("GIRAFFE");
  97. giraffe->setAttribute ("name", "nigel");
  98. giraffe->setAttribute ("age", 10);
  99. giraffe->setAttribute ("friendly", true);
  100. // ..and add our new element to the parent node
  101. animalsList.addChildElement (giraffe);
  102. }
  103. // now we can turn the whole thing into a text document..
  104. String myXmlDoc = animalsList.createDocument (String::empty);
  105. @endcode
  106. @see XmlDocument
  107. */
  108. class JUCE_API XmlElement
  109. {
  110. public:
  111. //==============================================================================
  112. /** Creates an XmlElement with this tag name. */
  113. explicit XmlElement (const String& tagName) noexcept;
  114. /** Creates a (deep) copy of another element. */
  115. XmlElement (const XmlElement& other);
  116. /** Creates a (deep) copy of another element. */
  117. XmlElement& operator= (const XmlElement& other);
  118. #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
  119. XmlElement (XmlElement&& other) noexcept;
  120. XmlElement& operator= (XmlElement&& other) noexcept;
  121. #endif
  122. /** Deleting an XmlElement will also delete all its child elements. */
  123. ~XmlElement() noexcept;
  124. //==============================================================================
  125. /** Compares two XmlElements to see if they contain the same text and attiributes.
  126. The elements are only considered equivalent if they contain the same attiributes
  127. with the same values, and have the same sub-nodes.
  128. @param other the other element to compare to
  129. @param ignoreOrderOfAttributes if true, this means that two elements with the
  130. same attributes in a different order will be
  131. considered the same; if false, the attributes must
  132. be in the same order as well
  133. */
  134. bool isEquivalentTo (const XmlElement* other,
  135. bool ignoreOrderOfAttributes) const noexcept;
  136. //==============================================================================
  137. /** Returns an XML text document that represents this element.
  138. The string returned can be parsed to recreate the same XmlElement that
  139. was used to create it.
  140. @param dtdToUse the DTD to add to the document
  141. @param allOnOneLine if true, this means that the document will not contain any
  142. linefeeds, so it'll be smaller but not very easy to read.
  143. @param includeXmlHeader whether to add the "<?xml version..etc" line at the start of the
  144. document
  145. @param encodingType the character encoding format string to put into the xml
  146. header
  147. @param lineWrapLength the line length that will be used before items get placed on
  148. a new line. This isn't an absolute maximum length, it just
  149. determines how lists of attributes get broken up
  150. @see writeToStream, writeToFile
  151. */
  152. String createDocument (StringRef dtdToUse,
  153. bool allOnOneLine = false,
  154. bool includeXmlHeader = true,
  155. StringRef encodingType = "UTF-8",
  156. int lineWrapLength = 60) const;
  157. /** Writes the document to a stream as UTF-8.
  158. @param output the stream to write to
  159. @param dtdToUse the DTD to add to the document
  160. @param allOnOneLine if true, this means that the document will not contain any
  161. linefeeds, so it'll be smaller but not very easy to read.
  162. @param includeXmlHeader whether to add the "<?xml version..etc" line at the start of the
  163. document
  164. @param encodingType the character encoding format string to put into the xml
  165. header
  166. @param lineWrapLength the line length that will be used before items get placed on
  167. a new line. This isn't an absolute maximum length, it just
  168. determines how lists of attributes get broken up
  169. @see writeToFile, createDocument
  170. */
  171. void writeToStream (OutputStream& output,
  172. StringRef dtdToUse,
  173. bool allOnOneLine = false,
  174. bool includeXmlHeader = true,
  175. StringRef encodingType = "UTF-8",
  176. int lineWrapLength = 60) const;
  177. /** Writes the element to a file as an XML document.
  178. To improve safety in case something goes wrong while writing the file, this
  179. will actually write the document to a new temporary file in the same
  180. directory as the destination file, and if this succeeds, it will rename this
  181. new file as the destination file (overwriting any existing file that was there).
  182. @param destinationFile the file to write to. If this already exists, it will be
  183. overwritten.
  184. @param dtdToUse the DTD to add to the document
  185. @param encodingType the character encoding format string to put into the xml
  186. header
  187. @param lineWrapLength the line length that will be used before items get placed on
  188. a new line. This isn't an absolute maximum length, it just
  189. determines how lists of attributes get broken up
  190. @returns true if the file is written successfully; false if something goes wrong
  191. in the process
  192. @see createDocument
  193. */
  194. bool writeToFile (const File& destinationFile,
  195. StringRef dtdToUse,
  196. StringRef encodingType = "UTF-8",
  197. int lineWrapLength = 60) const;
  198. //==============================================================================
  199. /** Returns this element's tag type name.
  200. E.g. for an element such as \<MOOSE legs="4" antlers="2">, this would return "MOOSE".
  201. @see hasTagName
  202. */
  203. const String& getTagName() const noexcept { return tagName; }
  204. /** Returns the namespace portion of the tag-name, or an empty string if none is specified. */
  205. String getNamespace() const;
  206. /** Returns the part of the tag-name that follows any namespace declaration. */
  207. String getTagNameWithoutNamespace() const;
  208. /** Tests whether this element has a particular tag name.
  209. @param possibleTagName the tag name you're comparing it with
  210. @see getTagName
  211. */
  212. bool hasTagName (StringRef possibleTagName) const noexcept;
  213. /** Tests whether this element has a particular tag name, ignoring any XML namespace prefix.
  214. So a test for e.g. "xyz" will return true for "xyz" and also "foo:xyz", "bar::xyz", etc.
  215. @see getTagName
  216. */
  217. bool hasTagNameIgnoringNamespace (StringRef possibleTagName) const;
  218. //==============================================================================
  219. /** Returns the number of XML attributes this element contains.
  220. E.g. for an element such as \<MOOSE legs="4" antlers="2">, this would
  221. return 2.
  222. */
  223. int getNumAttributes() const noexcept;
  224. /** Returns the name of one of the elements attributes.
  225. E.g. for an element such as \<MOOSE legs="4" antlers="2">, then
  226. getAttributeName(1) would return "antlers".
  227. @see getAttributeValue, getStringAttribute
  228. */
  229. const String& getAttributeName (int attributeIndex) const noexcept;
  230. /** Returns the value of one of the elements attributes.
  231. E.g. for an element such as \<MOOSE legs="4" antlers="2">, then
  232. getAttributeName(1) would return "2".
  233. @see getAttributeName, getStringAttribute
  234. */
  235. const String& getAttributeValue (int attributeIndex) const noexcept;
  236. //==============================================================================
  237. // Attribute-handling methods..
  238. /** Checks whether the element contains an attribute with a certain name. */
  239. bool hasAttribute (StringRef attributeName) const noexcept;
  240. /** Returns the value of a named attribute.
  241. @param attributeName the name of the attribute to look up
  242. */
  243. const String& getStringAttribute (StringRef attributeName) const noexcept;
  244. /** Returns the value of a named attribute.
  245. @param attributeName the name of the attribute to look up
  246. @param defaultReturnValue a value to return if the element doesn't have an attribute
  247. with this name
  248. */
  249. String getStringAttribute (StringRef attributeName, const String& defaultReturnValue) const;
  250. /** Compares the value of a named attribute with a value passed-in.
  251. @param attributeName the name of the attribute to look up
  252. @param stringToCompareAgainst the value to compare it with
  253. @param ignoreCase whether the comparison should be case-insensitive
  254. @returns true if the value of the attribute is the same as the string passed-in;
  255. false if it's different (or if no such attribute exists)
  256. */
  257. bool compareAttribute (StringRef attributeName,
  258. StringRef stringToCompareAgainst,
  259. bool ignoreCase = false) const noexcept;
  260. /** Returns the value of a named attribute as an integer.
  261. This will try to find the attribute and convert it to an integer (using
  262. the String::getIntValue() method).
  263. @param attributeName the name of the attribute to look up
  264. @param defaultReturnValue a value to return if the element doesn't have an attribute
  265. with this name
  266. @see setAttribute
  267. */
  268. int getIntAttribute (StringRef attributeName, int defaultReturnValue = 0) const;
  269. /** Returns the value of a named attribute as floating-point.
  270. This will try to find the attribute and convert it to an integer (using
  271. the String::getDoubleValue() method).
  272. @param attributeName the name of the attribute to look up
  273. @param defaultReturnValue a value to return if the element doesn't have an attribute
  274. with this name
  275. @see setAttribute
  276. */
  277. double getDoubleAttribute (StringRef attributeName, double defaultReturnValue = 0.0) const;
  278. /** Returns the value of a named attribute as a boolean.
  279. This will try to find the attribute and interpret it as a boolean. To do this,
  280. it'll return true if the value is "1", "true", "y", etc, or false for other
  281. values.
  282. @param attributeName the name of the attribute to look up
  283. @param defaultReturnValue a value to return if the element doesn't have an attribute
  284. with this name
  285. */
  286. bool getBoolAttribute (StringRef attributeName, bool defaultReturnValue = false) const;
  287. /** Adds a named attribute to the element.
  288. If the element already contains an attribute with this name, it's value will
  289. be updated to the new value. If there's no such attribute yet, a new one will
  290. be added.
  291. Note that there are other setAttribute() methods that take integers,
  292. doubles, etc. to make it easy to store numbers.
  293. @param attributeName the name of the attribute to set
  294. @param newValue the value to set it to
  295. @see removeAttribute
  296. */
  297. void setAttribute (const String& attributeName, const String& newValue);
  298. /** Adds a named attribute to the element, setting it to an integer value.
  299. If the element already contains an attribute with this name, it's value will
  300. be updated to the new value. If there's no such attribute yet, a new one will
  301. be added.
  302. Note that there are other setAttribute() methods that take integers,
  303. doubles, etc. to make it easy to store numbers.
  304. @param attributeName the name of the attribute to set
  305. @param newValue the value to set it to
  306. */
  307. void setAttribute (const String& attributeName, int newValue);
  308. /** Adds a named attribute to the element, setting it to a floating-point value.
  309. If the element already contains an attribute with this name, it's value will
  310. be updated to the new value. If there's no such attribute yet, a new one will
  311. be added.
  312. Note that there are other setAttribute() methods that take integers,
  313. doubles, etc. to make it easy to store numbers.
  314. @param attributeName the name of the attribute to set
  315. @param newValue the value to set it to
  316. */
  317. void setAttribute (const String& attributeName, double newValue);
  318. /** Removes a named attribute from the element.
  319. @param attributeName the name of the attribute to remove
  320. @see removeAllAttributes
  321. */
  322. void removeAttribute (const String& attributeName) noexcept;
  323. /** Removes all attributes from this element. */
  324. void removeAllAttributes() noexcept;
  325. //==============================================================================
  326. // Child element methods..
  327. /** Returns the first of this element's sub-elements.
  328. see getNextElement() for an example of how to iterate the sub-elements.
  329. @see forEachXmlChildElement
  330. */
  331. XmlElement* getFirstChildElement() const noexcept { return firstChildElement; }
  332. /** Returns the next of this element's siblings.
  333. This can be used for iterating an element's sub-elements, e.g.
  334. @code
  335. XmlElement* child = myXmlDocument->getFirstChildElement();
  336. while (child != nullptr)
  337. {
  338. ...do stuff with this child..
  339. child = child->getNextElement();
  340. }
  341. @endcode
  342. Note that when iterating the child elements, some of them might be
  343. text elements as well as XML tags - use isTextElement() to work this
  344. out.
  345. Also, it's much easier and neater to use this method indirectly via the
  346. forEachXmlChildElement macro.
  347. @returns the sibling element that follows this one, or zero if this is the last
  348. element in its parent
  349. @see getNextElement, isTextElement, forEachXmlChildElement
  350. */
  351. inline XmlElement* getNextElement() const noexcept { return nextListItem; }
  352. /** Returns the next of this element's siblings which has the specified tag
  353. name.
  354. This is like getNextElement(), but will scan through the list until it
  355. finds an element with the given tag name.
  356. @see getNextElement, forEachXmlChildElementWithTagName
  357. */
  358. XmlElement* getNextElementWithTagName (StringRef requiredTagName) const;
  359. /** Returns the number of sub-elements in this element.
  360. @see getChildElement
  361. */
  362. int getNumChildElements() const noexcept;
  363. /** Returns the sub-element at a certain index.
  364. It's not very efficient to iterate the sub-elements by index - see
  365. getNextElement() for an example of how best to iterate.
  366. @returns the n'th child of this element, or nullptr if the index is out-of-range
  367. @see getNextElement, isTextElement, getChildByName
  368. */
  369. XmlElement* getChildElement (int index) const noexcept;
  370. /** Returns the first sub-element with a given tag-name.
  371. @param tagNameToLookFor the tag name of the element you want to find
  372. @returns the first element with this tag name, or nullptr if none is found
  373. @see getNextElement, isTextElement, getChildElement
  374. */
  375. XmlElement* getChildByName (StringRef tagNameToLookFor) const noexcept;
  376. //==============================================================================
  377. /** Appends an element to this element's list of children.
  378. Child elements are deleted automatically when their parent is deleted, so
  379. make sure the object that you pass in will not be deleted by anything else,
  380. and make sure it's not already the child of another element.
  381. @see getFirstChildElement, getNextElement, getNumChildElements,
  382. getChildElement, removeChildElement
  383. */
  384. void addChildElement (XmlElement* newChildElement) noexcept;
  385. /** Inserts an element into this element's list of children.
  386. Child elements are deleted automatically when their parent is deleted, so
  387. make sure the object that you pass in will not be deleted by anything else,
  388. and make sure it's not already the child of another element.
  389. @param newChildNode the element to add
  390. @param indexToInsertAt the index at which to insert the new element - if this is
  391. below zero, it will be added to the end of the list
  392. @see addChildElement, insertChildElement
  393. */
  394. void insertChildElement (XmlElement* newChildNode,
  395. int indexToInsertAt) noexcept;
  396. /** Creates a new element with the given name and returns it, after adding it
  397. as a child element.
  398. This is a handy method that means that instead of writing this:
  399. @code
  400. XmlElement* newElement = new XmlElement ("foobar");
  401. myParentElement->addChildElement (newElement);
  402. @endcode
  403. ..you could just write this:
  404. @code
  405. XmlElement* newElement = myParentElement->createNewChildElement ("foobar");
  406. @endcode
  407. */
  408. XmlElement* createNewChildElement (const String& tagName);
  409. /** Replaces one of this element's children with another node.
  410. If the current element passed-in isn't actually a child of this element,
  411. this will return false and the new one won't be added. Otherwise, the
  412. existing element will be deleted, replaced with the new one, and it
  413. will return true.
  414. */
  415. bool replaceChildElement (XmlElement* currentChildElement,
  416. XmlElement* newChildNode) noexcept;
  417. /** Removes a child element.
  418. @param childToRemove the child to look for and remove
  419. @param shouldDeleteTheChild if true, the child will be deleted, if false it'll
  420. just remove it
  421. */
  422. void removeChildElement (XmlElement* childToRemove,
  423. bool shouldDeleteTheChild) noexcept;
  424. /** Deletes all the child elements in the element.
  425. @see removeChildElement, deleteAllChildElementsWithTagName
  426. */
  427. void deleteAllChildElements() noexcept;
  428. /** Deletes all the child elements with a given tag name.
  429. @see removeChildElement
  430. */
  431. void deleteAllChildElementsWithTagName (StringRef tagName) noexcept;
  432. /** Returns true if the given element is a child of this one. */
  433. bool containsChildElement (const XmlElement* possibleChild) const noexcept;
  434. /** Recursively searches all sub-elements to find one that contains the specified
  435. child element.
  436. */
  437. XmlElement* findParentElementOf (const XmlElement* elementToLookFor) noexcept;
  438. //==============================================================================
  439. /** Sorts the child elements using a comparator.
  440. This will use a comparator object to sort the elements into order. The object
  441. passed must have a method of the form:
  442. @code
  443. int compareElements (const XmlElement* first, const XmlElement* second);
  444. @endcode
  445. ..and this method must return:
  446. - a value of < 0 if the first comes before the second
  447. - a value of 0 if the two objects are equivalent
  448. - a value of > 0 if the second comes before the first
  449. To improve performance, the compareElements() method can be declared as static or const.
  450. @param comparator the comparator to use for comparing elements.
  451. @param retainOrderOfEquivalentItems if this is true, then items which the comparator
  452. says are equivalent will be kept in the order in which they
  453. currently appear in the array. This is slower to perform, but
  454. may be important in some cases. If it's false, a faster algorithm
  455. is used, but equivalent elements may be rearranged.
  456. */
  457. template <class ElementComparator>
  458. void sortChildElements (ElementComparator& comparator,
  459. bool retainOrderOfEquivalentItems = false)
  460. {
  461. const int num = getNumChildElements();
  462. if (num > 1)
  463. {
  464. HeapBlock <XmlElement*> elems ((size_t) num);
  465. getChildElementsAsArray (elems);
  466. sortArray (comparator, (XmlElement**) elems, 0, num - 1, retainOrderOfEquivalentItems);
  467. reorderChildElements (elems, num);
  468. }
  469. }
  470. //==============================================================================
  471. /** Returns true if this element is a section of text.
  472. Elements can either be an XML tag element or a secton of text, so this
  473. is used to find out what kind of element this one is.
  474. @see getAllText, addTextElement, deleteAllTextElements
  475. */
  476. bool isTextElement() const noexcept;
  477. /** Returns the text for a text element.
  478. Note that if you have an element like this:
  479. @code<xyz>hello</xyz>@endcode
  480. then calling getText on the "xyz" element won't return "hello", because that is
  481. actually stored in a special text sub-element inside the xyz element. To get the
  482. "hello" string, you could either call getText on the (unnamed) sub-element, or
  483. use getAllSubText() to do this automatically.
  484. Note that leading and trailing whitespace will be included in the string - to remove
  485. if, just call String::trim() on the result.
  486. @see isTextElement, getAllSubText, getChildElementAllSubText
  487. */
  488. const String& getText() const noexcept;
  489. /** Sets the text in a text element.
  490. Note that this is only a valid call if this element is a text element. If it's
  491. not, then no action will be performed. If you're trying to add text inside a normal
  492. element, you probably want to use addTextElement() instead.
  493. */
  494. void setText (const String& newText);
  495. /** Returns all the text from this element's child nodes.
  496. This iterates all the child elements and when it finds text elements,
  497. it concatenates their text into a big string which it returns.
  498. E.g. @code<xyz>hello <x>there</x> world</xyz>@endcode
  499. if you called getAllSubText on the "xyz" element, it'd return "hello there world".
  500. Note that leading and trailing whitespace will be included in the string - to remove
  501. if, just call String::trim() on the result.
  502. @see isTextElement, getChildElementAllSubText, getText, addTextElement
  503. */
  504. String getAllSubText() const;
  505. /** Returns all the sub-text of a named child element.
  506. If there is a child element with the given tag name, this will return
  507. all of its sub-text (by calling getAllSubText() on it). If there is
  508. no such child element, this will return the default string passed-in.
  509. @see getAllSubText
  510. */
  511. String getChildElementAllSubText (StringRef childTagName,
  512. const String& defaultReturnValue) const;
  513. /** Appends a section of text to this element.
  514. @see isTextElement, getText, getAllSubText
  515. */
  516. void addTextElement (const String& text);
  517. /** Removes all the text elements from this element.
  518. @see isTextElement, getText, getAllSubText, addTextElement
  519. */
  520. void deleteAllTextElements() noexcept;
  521. /** Creates a text element that can be added to a parent element. */
  522. static XmlElement* createTextElement (const String& text);
  523. //==============================================================================
  524. private:
  525. struct XmlAttributeNode
  526. {
  527. XmlAttributeNode (const XmlAttributeNode&) noexcept;
  528. XmlAttributeNode (const String& name, const String& value) noexcept;
  529. LinkedListPointer<XmlAttributeNode> nextListItem;
  530. String name, value;
  531. bool hasName (StringRef) const noexcept;
  532. private:
  533. XmlAttributeNode& operator= (const XmlAttributeNode&);
  534. };
  535. friend class XmlDocument;
  536. friend class LinkedListPointer <XmlAttributeNode>;
  537. friend class LinkedListPointer <XmlElement>;
  538. friend class LinkedListPointer <XmlElement>::Appender;
  539. LinkedListPointer <XmlElement> nextListItem;
  540. LinkedListPointer <XmlElement> firstChildElement;
  541. LinkedListPointer <XmlAttributeNode> attributes;
  542. String tagName;
  543. XmlElement (int) noexcept;
  544. void copyChildrenAndAttributesFrom (const XmlElement&);
  545. void writeElementAsText (OutputStream&, int indentationLevel, int lineWrapLength) const;
  546. void getChildElementsAsArray (XmlElement**) const noexcept;
  547. void reorderChildElements (XmlElement**, int) noexcept;
  548. XmlAttributeNode* getAttribute (StringRef) const noexcept;
  549. JUCE_LEAK_DETECTOR (XmlElement)
  550. };
  551. #endif // JUCE_XMLELEMENT_H_INCLUDED