OpenShot Audio Library | OpenShotAudio  0.3.0
juce_XmlDocument.h
1 /*
2  ==============================================================================
3 
4  This file is part of the JUCE library.
5  Copyright (c) 2017 - ROLI Ltd.
6 
7  JUCE is an open source library subject to commercial or open-source
8  licensing.
9 
10  The code included in this file is provided under the terms of the ISC license
11  http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12  To use, copy, modify, and/or distribute this software for any purpose with or
13  without fee is hereby granted provided that the above copyright notice and
14  this permission notice appear in all copies.
15 
16  JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17  EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18  DISCLAIMED.
19 
20  ==============================================================================
21 */
22 
23 namespace juce
24 {
25 
26 //==============================================================================
63 class JUCE_API XmlDocument
64 {
65 public:
66  //==============================================================================
70  XmlDocument (const String& documentText);
71 
75  XmlDocument (const File& file);
76 
78  ~XmlDocument();
79 
80  //==============================================================================
100  std::unique_ptr<XmlElement> getDocumentElement (bool onlyReadOuterDocumentElement = false);
101 
106  std::unique_ptr<XmlElement> getDocumentElementIfTagMatches (StringRef requiredTag);
107 
111  const String& getLastParseError() const noexcept;
112 
124  void setInputSource (InputSource* newSource) noexcept;
125 
133  void setEmptyTextElementsIgnored (bool shouldBeIgnored) noexcept;
134 
135  //==============================================================================
141  static std::unique_ptr<XmlElement> parse (const File& file);
142 
148  static std::unique_ptr<XmlElement> parse (const String& xmlData);
149 
150 
151  //==============================================================================
152 private:
153  String originalText;
154  String::CharPointerType input { nullptr };
155  bool outOfData = false, errorOccurred = false;
156  String lastError, dtdText;
157  StringArray tokenisedDTD;
158  bool needToLoadDTD = false, ignoreEmptyTextElements = true;
159  std::unique_ptr<InputSource> inputSource;
160 
161  std::unique_ptr<XmlElement> parseDocumentElement (String::CharPointerType, bool outer);
162  void setLastError (const String&, bool carryOn);
163  bool parseHeader();
164  bool parseDTD();
165  void skipNextWhiteSpace();
166  juce_wchar readNextChar() noexcept;
167  XmlElement* readNextElement (bool alsoParseSubElements);
168  void readChildElements (XmlElement&);
169  void readQuotedString (String&);
170  void readEntity (String&);
171 
172  String getFileContents (const String&) const;
173  String expandEntity (const String&);
174  String expandExternalEntity (const String&);
175  String getParameterEntity (const String&);
176 
177  JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (XmlDocument)
178 };
179 
180 //==============================================================================
186 std::unique_ptr<XmlElement> parseXML (const String& textToParse);
187 
193 std::unique_ptr<XmlElement> parseXML (const File& fileToParse);
194 
200 std::unique_ptr<XmlElement> parseXMLIfTagMatches (const String& textToParse, StringRef requiredTag);
201 
207 std::unique_ptr<XmlElement> parseXMLIfTagMatches (const File& fileToParse, StringRef requiredTag);
208 
209 
210 } // namespace juce