Loading...
Searching...
No Matches
juce_XmlDocument.h
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2022 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
licensing.
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce
{
//==============================================================================
class JUCE_API XmlDocument
{
public:
//==============================================================================
XmlDocument (const String& documentText);
XmlDocument (const File& file);
~XmlDocument();
//==============================================================================
std::unique_ptr<XmlElement> getDocumentElement (bool onlyReadOuterDocumentElement = false);
std::unique_ptr<XmlElement> getDocumentElementIfTagMatches (StringRef requiredTag);
const String& getLastParseError() const noexcept;
void setInputSource (InputSource* newSource) noexcept;
void setEmptyTextElementsIgnored (bool shouldBeIgnored) noexcept;
//==============================================================================
static std::unique_ptr<XmlElement> parse (const File& file);
static std::unique_ptr<XmlElement> parse (const String& xmlData);
//==============================================================================
private:
String originalText;
String::CharPointerType input { nullptr };
bool outOfData = false, errorOccurred = false;
String lastError, dtdText;
StringArray tokenisedDTD;
bool needToLoadDTD = false, ignoreEmptyTextElements = true;
std::unique_ptr<InputSource> inputSource;
std::unique_ptr<XmlElement> parseDocumentElement (String::CharPointerType, bool outer);
void setLastError (const String&, bool carryOn);
bool parseHeader();
bool parseDTD();
void skipNextWhiteSpace();
juce_wchar readNextChar() noexcept;
XmlElement* readNextElement (bool alsoParseSubElements);
void readChildElements (XmlElement&);
void readQuotedString (String&);
void readEntity (String&);
String getFileContents (const String&) const;
String expandEntity (const String&);
String expandExternalEntity (const String&);
String getParameterEntity (const String&);
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (XmlDocument)
};
//==============================================================================
std::unique_ptr<XmlElement> parseXML (const String& textToParse);
std::unique_ptr<XmlElement> parseXML (const File& fileToParse);
std::unique_ptr<XmlElement> parseXMLIfTagMatches (const String& textToParse, StringRef requiredTag);
std::unique_ptr<XmlElement> parseXMLIfTagMatches (const File& fileToParse, StringRef requiredTag);
} // namespace juce
juce::File
Definition juce_File.h:45
juce::InputSource
Definition juce_InputSource.h:38
juce::StringArray
Definition juce_StringArray.h:35
juce::StringRef
Definition juce_StringRef.h:62
juce::String
Definition juce_String.h:53
juce::XmlDocument::getLastParseError
const String & getLastParseError() const noexcept
Definition juce_XmlDocument.cpp:159
juce::XmlDocument::getDocumentElementIfTagMatches
std::unique_ptr< XmlElement > getDocumentElementIfTagMatches(StringRef requiredTag)
Definition juce_XmlDocument.cpp:150
juce::XmlDocument::getDocumentElement
std::unique_ptr< XmlElement > getDocumentElement(bool onlyReadOuterDocumentElement=false)
Definition juce_XmlDocument.cpp:110
juce::XmlDocument::XmlDocument
XmlDocument(const String &documentText)
Definition juce_XmlDocument.cpp:26
juce::XmlDocument::parse
static std::unique_ptr< XmlElement > parse(const File &file)
Definition juce_XmlDocument.cpp:31
juce::XmlDocument::setInputSource
void setInputSource(InputSource *newSource) noexcept
Definition juce_XmlDocument.cpp:61
juce::XmlDocument::setEmptyTextElementsIgnored
void setEmptyTextElementsIgnored(bool shouldBeIgnored) noexcept
Definition juce_XmlDocument.cpp:66
juce::XmlElement
Definition juce_XmlElement.h:83