Shaka Player Embedded
xml_document_parser.h
Go to the documentation of this file.
1 // Copyright 2016 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef SHAKA_EMBEDDED_JS_DOM_XML_DOCUMENT_PARSER_H_
16 #define SHAKA_EMBEDDED_JS_DOM_XML_DOCUMENT_PARSER_H_
17 
18 #include <memory>
19 #include <string>
20 #include <tuple>
21 #include <vector>
22 
23 #include "shaka/optional.h"
24 #include "src/core/member.h"
25 #include "src/core/ref_ptr.h"
27 
28 namespace shaka {
29 namespace js {
30 namespace dom {
31 class Node;
32 class Document;
33 class Text;
34 
47  public:
48  explicit XMLDocumentParser(RefPtr<Document> document);
50 
51  ExceptionOr<RefPtr<Document>> Parse(const std::string& source);
52 
53  // Callbacks from SAX
54  void EndDocument();
55  void StartElement(const std::string& local_name,
56  optional<std::string> namespace_uri,
57  optional<std::string> namespace_prefix,
58  size_t attribute_count,
59  const char** attributes);
60  void EndElement();
61  void Text(const std::string& text);
62  void Comment(const std::string& text);
63  void SetException(JsError error);
64 
65  private:
67  void FinishTextNode();
68 
69  const Member<Document> document_;
70  Member<Node> current_node_;
71  std::string current_text_;
72  std::unique_ptr<JsError> error_;
73 };
74 
75 } // namespace dom
76 } // namespace js
77 } // namespace shaka
78 
79 #endif // SHAKA_EMBEDDED_JS_DOM_XML_DOCUMENT_PARSER_H_
XMLDocumentParser(RefPtr< Document > document)
const char * source
Definition: media_utils.cc:30
void Text(const std::string &text)
void StartElement(const std::string &local_name, optional< std::string > namespace_uri, optional< std::string > namespace_prefix, size_t attribute_count, const char **attributes)
ExceptionOr< RefPtr< Document > > Parse(const std::string &source)
void Comment(const std::string &text)