Shaka Player Embedded
shaka
src
js
dom
dom_parser.cc
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
#include "
src/js/dom/dom_parser.h
"
16
17
#include "
src/js/dom/document.h
"
18
#include "
src/js/dom/xml_document_parser.h
"
19
#include "
src/js/js_error.h
"
20
#include "
src/util/utils.h
"
21
22
namespace
shaka
{
23
namespace
js {
24
namespace
dom {
25
26
DOMParser::DOMParser
() {}
27
// \cond Doxygen_Skip
28
DOMParser::~DOMParser() {}
29
// \endcond Doxygen_Skip
30
31
ExceptionOr<RefPtr<Document>
>
DOMParser::ParseFromString
(
32
const
std::string&
source
,
const
std::string&
type
)
const
{
33
const
std::string type_lower =
util::ToAsciiLower
(type);
34
if
(type_lower ==
"text/xml"
|| type_lower ==
"application/xml"
) {
35
RefPtr<Document>
ret =
new
Document
();
36
XMLDocumentParser
parser(ret);
37
return
parser.
Parse
(source);
38
}
39
40
return
JsError::TypeError
(
"Unsupported parse type "
+ type);
41
}
42
43
44
DOMParserFactory::DOMParserFactory
() {
45
AddMemberFunction(
"parseFromString"
, &
DOMParser::ParseFromString
);
46
}
47
48
}
// namespace dom
49
}
// namespace js
50
}
// namespace shaka
shaka::util::ToAsciiLower
std::string ToAsciiLower(const std::string &source)
Definition:
utils.cc:76
shaka::ExceptionOr
Definition:
exception_or.h:36
shaka::js::dom::Document
Definition:
document.h:38
shaka::js::dom::DOMParser::ParseFromString
ExceptionOr< RefPtr< Document > > ParseFromString(const std::string &source, const std::string &type) const
Definition:
dom_parser.cc:31
source
const char * source
Definition:
media_utils.cc:30
xml_document_parser.h
shaka
Definition:
async_results.h:25
shaka::js::dom::XMLDocumentParser
Definition:
xml_document_parser.h:46
type
ExceptionCode type
Definition:
dom_exception.cc:37
dom_parser.h
utils.h
document.h
shaka::RefPtr
Definition:
ref_ptr.h:43
shaka::js::dom::DOMParserFactory::DOMParserFactory
DOMParserFactory()
Definition:
dom_parser.cc:44
shaka::js::dom::DOMParser::DOMParser
DOMParser()
Definition:
dom_parser.cc:26
shaka::js::dom::XMLDocumentParser::Parse
ExceptionOr< RefPtr< Document > > Parse(const std::string &source)
Definition:
xml_document_parser.cc:123
js_error.h
shaka::js::JsError::TypeError
static JsError TypeError(const std::string &message)
Definition:
js_error.cc:81
Generated by
1.8.13