Browse Source

Added an overload to ValueTree::fromXml() which can take an XML string and parse it

tags/2021-05-28
jules 6 years ago
parent
commit
49fa0f73e4
2 changed files with 14 additions and 0 deletions
  1. +8
    -0
      modules/juce_data_structures/values/juce_ValueTree.cpp
  2. +6
    -0
      modules/juce_data_structures/values/juce_ValueTree.h

+ 8
- 0
modules/juce_data_structures/values/juce_ValueTree.cpp View File

@@ -1015,6 +1015,14 @@ ValueTree ValueTree::fromXml (const XmlElement& xml)
return {};
}
ValueTree ValueTree::fromXml (const String& xmlText)
{
if (auto xml = parseXML (xmlText))
return fromXml (*xml);
return {};
}
String ValueTree::toXmlString (const XmlElement::TextFormat& format) const
{
if (auto xml = createXml())


+ 6
- 0
modules/juce_data_structures/values/juce_ValueTree.h View File

@@ -438,6 +438,12 @@ public:
*/
static ValueTree fromXml (const XmlElement& xml);
/** Tries to recreate a tree from its XML representation.
This isn't designed to cope with random XML data - it should only be fed XML that was created
by the createXml() method.
*/
static ValueTree fromXml (const String& xmlText);
/** This returns a string containing an XML representation of the tree.
This is quite handy for debugging purposes, as it provides a quick way to view a tree.
@see createXml()


Loading…
Cancel
Save