• 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(NULL), fError(parserError)
55 {
56 }
57 
~SkXMLParser()58 SkXMLParser::~SkXMLParser()
59 {
60 }
61 
startElement(const char elem[])62 bool SkXMLParser::startElement(const char elem[])
63 {
64     return this->onStartElement(elem);
65 }
66 
addAttribute(const char name[],const char value[])67 bool SkXMLParser::addAttribute(const char name[], const char value[])
68 {
69     return this->onAddAttribute(name, value);
70 }
71 
endElement(const char elem[])72 bool SkXMLParser::endElement(const char elem[])
73 {
74     return this->onEndElement(elem);
75 }
76 
text(const char text[],int len)77 bool SkXMLParser::text(const char text[], int len)
78 {
79     return this->onText(text, len);
80 }
81 
82 ////////////////////////////////////////////////////////////////////////////////
83 
onStartElement(const char elem[])84 bool SkXMLParser::onStartElement(const char elem[]) {return false; }
onAddAttribute(const char name[],const char value[])85 bool SkXMLParser::onAddAttribute(const char name[], const char value[]) {return false; }
onEndElement(const char elem[])86 bool SkXMLParser::onEndElement(const char elem[]) { return false; }
onText(const char text[],int len)87 bool SkXMLParser::onText(const char text[], int len) {return false; }
88