• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 /*
3  * Copyright 2006 The Android Open Source Project
4  *
5  * Use of this source code is governed by a BSD-style license that can be
6  * found in the LICENSE file.
7  */
8 
9 
10 #include "SkXMLParser.h"
11 
12 static char const* const gErrorStrings[] = {
13     "empty or missing file ",
14     "unknown element ",
15     "unknown attribute name ",
16     "error in attribute value ",
17     "duplicate ID ",
18     "unknown error "
19 };
20 
SkXMLParserError()21 SkXMLParserError::SkXMLParserError() : fCode(kNoError), fLineNumber(-1),
22     fNativeCode(-1)
23 {
24     reset();
25 }
26 
~SkXMLParserError()27 SkXMLParserError::~SkXMLParserError()
28 {
29     // need a virtual destructor for our subclasses
30 }
31 
getErrorString(SkString * str) const32 void SkXMLParserError::getErrorString(SkString* str) const
33 {
34     SkASSERT(str);
35     SkString temp;
36     if (fCode != kNoError) {
37         if ((unsigned)fCode < SK_ARRAY_COUNT(gErrorStrings))
38             temp.set(gErrorStrings[fCode - 1]);
39         temp.append(fNoun);
40     } else
41         SkXMLParser::GetNativeErrorString(fNativeCode, &temp);
42     str->append(temp);
43 }
44 
reset()45 void SkXMLParserError::reset() {
46     fCode = kNoError;
47     fLineNumber = -1;
48     fNativeCode = -1;
49 }
50 
51 
52 ////////////////
53 
SkXMLParser(SkXMLParserError * parserError)54 SkXMLParser::SkXMLParser(SkXMLParserError* parserError) : fParser(nullptr), fError(parserError)
55 {
56 }
57 
~SkXMLParser()58 SkXMLParser::~SkXMLParser()
59 {
60 }
61 
parse(SkStream & docStream)62 bool SkXMLParser::parse(SkStream& docStream)
63 {
64     return false;
65 }
66 
parse(const char doc[],size_t len)67 bool SkXMLParser::parse(const char doc[], size_t len)
68 {
69     return false;
70 }
71 
GetNativeErrorString(int error,SkString * str)72 void SkXMLParser::GetNativeErrorString(int error, SkString* str)
73 {
74 
75 }
76 
startElement(const char elem[])77 bool SkXMLParser::startElement(const char elem[])
78 {
79     return this->onStartElement(elem);
80 }
81 
addAttribute(const char name[],const char value[])82 bool SkXMLParser::addAttribute(const char name[], const char value[])
83 {
84     return this->onAddAttribute(name, value);
85 }
86 
endElement(const char elem[])87 bool SkXMLParser::endElement(const char elem[])
88 {
89     return this->onEndElement(elem);
90 }
91 
text(const char text[],int len)92 bool SkXMLParser::text(const char text[], int len)
93 {
94     return this->onText(text, len);
95 }
96 
97 ////////////////////////////////////////////////////////////////////////////////
98 
onStartElement(const char elem[])99 bool SkXMLParser::onStartElement(const char elem[]) {return false; }
onAddAttribute(const char name[],const char value[])100 bool SkXMLParser::onAddAttribute(const char name[], const char value[]) {return false; }
onEndElement(const char elem[])101 bool SkXMLParser::onEndElement(const char elem[]) { return false; }
onText(const char text[],int len)102 bool SkXMLParser::onText(const char text[], int len) {return false; }
103