| OLD | NEW |
| (Empty) |
| 1 /* libs/graphics/xml/SkXMLParser.cpp | |
| 2 ** | |
| 3 ** Copyright 2006, The Android Open Source Project | |
| 4 ** | |
| 5 ** Licensed under the Apache License, Version 2.0 (the "License"); | |
| 6 ** you may not use this file except in compliance with the License. | |
| 7 ** You may obtain a copy of the License at | |
| 8 ** | |
| 9 ** http://www.apache.org/licenses/LICENSE-2.0 | |
| 10 ** | |
| 11 ** Unless required by applicable law or agreed to in writing, software | |
| 12 ** distributed under the License is distributed on an "AS IS" BASIS, | |
| 13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 14 ** See the License for the specific language governing permissions and | |
| 15 ** limitations under the License. | |
| 16 */ | |
| 17 | |
| 18 #include "SkXMLParser.h" | |
| 19 | |
| 20 static char const* const gErrorStrings[] = { | |
| 21 "empty or missing file ", | |
| 22 "unknown element ", | |
| 23 "unknown attribute name ", | |
| 24 "error in attribute value ", | |
| 25 "duplicate ID ", | |
| 26 "unknown error " | |
| 27 }; | |
| 28 | |
| 29 SkXMLParserError::SkXMLParserError() : fCode(kNoError), fLineNumber(-1), | |
| 30 fNativeCode(-1) | |
| 31 { | |
| 32 reset(); | |
| 33 } | |
| 34 | |
| 35 SkXMLParserError::~SkXMLParserError() | |
| 36 { | |
| 37 // need a virtual destructor for our subclasses | |
| 38 } | |
| 39 | |
| 40 void SkXMLParserError::getErrorString(SkString* str) const | |
| 41 { | |
| 42 SkASSERT(str); | |
| 43 SkString temp; | |
| 44 if (fCode != kNoError) { | |
| 45 if ((unsigned)fCode < SK_ARRAY_COUNT(gErrorStrings)) | |
| 46 temp.set(gErrorStrings[fCode - 1]); | |
| 47 temp.append(fNoun); | |
| 48 } else | |
| 49 SkXMLParser::GetNativeErrorString(fNativeCode, &temp); | |
| 50 str->append(temp); | |
| 51 } | |
| 52 | |
| 53 void SkXMLParserError::reset() { | |
| 54 fCode = kNoError; | |
| 55 fLineNumber = -1; | |
| 56 fNativeCode = -1; | |
| 57 } | |
| 58 | |
| 59 | |
| 60 //////////////// | |
| 61 | |
| 62 SkXMLParser::SkXMLParser(SkXMLParserError* parserError) : fParser(NULL), fError(
parserError) | |
| 63 { | |
| 64 } | |
| 65 | |
| 66 SkXMLParser::~SkXMLParser() | |
| 67 { | |
| 68 } | |
| 69 | |
| 70 bool SkXMLParser::startElement(const char elem[]) | |
| 71 { | |
| 72 return this->onStartElement(elem); | |
| 73 } | |
| 74 | |
| 75 bool SkXMLParser::addAttribute(const char name[], const char value[]) | |
| 76 { | |
| 77 return this->onAddAttribute(name, value); | |
| 78 } | |
| 79 | |
| 80 bool SkXMLParser::endElement(const char elem[]) | |
| 81 { | |
| 82 return this->onEndElement(elem); | |
| 83 } | |
| 84 | |
| 85 bool SkXMLParser::text(const char text[], int len) | |
| 86 { | |
| 87 return this->onText(text, len); | |
| 88 } | |
| 89 | |
| 90 //////////////////////////////////////////////////////////////////////////////// | |
| 91 | |
| 92 bool SkXMLParser::onStartElement(const char elem[]) {return false; } | |
| 93 bool SkXMLParser::onAddAttribute(const char name[], const char value[]) {return
false; } | |
| 94 bool SkXMLParser::onEndElement(const char elem[]) { return false; } | |
| 95 bool SkXMLParser::onText(const char text[], int len) {return false; } | |
| OLD | NEW |