| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 #include "SkXMLParser.h" | 8 #include "SkXMLParser.h" |
| 9 #include "SkStream.h" | 9 #include "SkStream.h" |
| 10 | 10 |
| 11 static void reset(SkXMLPullParser::Curr* curr) | 11 static void reset(SkXMLPullParser::Curr* curr) |
| 12 { | 12 { |
| 13 curr->fEventType = SkXMLPullParser::ERROR; | 13 curr->fEventType = SkXMLPullParser::ERROR; |
| 14 curr->fName = ""; | 14 curr->fName = ""; |
| 15 curr->fAttrInfoCount = 0; | 15 curr->fAttrInfoCount = 0; |
| 16 curr->fIsWhitespace = false; | 16 curr->fIsWhitespace = false; |
| 17 } | 17 } |
| 18 | 18 |
| 19 SkXMLPullParser::SkXMLPullParser() : fStream(NULL) | 19 SkXMLPullParser::SkXMLPullParser() : fStream(nullptr) |
| 20 { | 20 { |
| 21 fCurr.fEventType = ERROR; | 21 fCurr.fEventType = ERROR; |
| 22 fDepth = -1; | 22 fDepth = -1; |
| 23 } | 23 } |
| 24 | 24 |
| 25 SkXMLPullParser::SkXMLPullParser(SkStream* stream) : fStream(NULL) | 25 SkXMLPullParser::SkXMLPullParser(SkStream* stream) : fStream(nullptr) |
| 26 { | 26 { |
| 27 fCurr.fEventType = ERROR; | 27 fCurr.fEventType = ERROR; |
| 28 fDepth = 0; | 28 fDepth = 0; |
| 29 | 29 |
| 30 this->setStream(stream); | 30 this->setStream(stream); |
| 31 } | 31 } |
| 32 | 32 |
| 33 SkXMLPullParser::~SkXMLPullParser() | 33 SkXMLPullParser::~SkXMLPullParser() |
| 34 { | 34 { |
| 35 this->setStream(NULL); | 35 this->setStream(nullptr); |
| 36 } | 36 } |
| 37 | 37 |
| 38 SkStream* SkXMLPullParser::setStream(SkStream* stream) | 38 SkStream* SkXMLPullParser::setStream(SkStream* stream) |
| 39 { | 39 { |
| 40 if (fStream && !stream) | 40 if (fStream && !stream) |
| 41 this->onExit(); | 41 this->onExit(); |
| 42 | 42 |
| 43 SkRefCnt_SafeAssign(fStream, stream); | 43 SkRefCnt_SafeAssign(fStream, stream); |
| 44 | 44 |
| 45 if (fStream) | 45 if (fStream) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 return fCurr.fEventType; | 82 return fCurr.fEventType; |
| 83 } | 83 } |
| 84 | 84 |
| 85 const char* SkXMLPullParser::getName() | 85 const char* SkXMLPullParser::getName() |
| 86 { | 86 { |
| 87 switch (fCurr.fEventType) { | 87 switch (fCurr.fEventType) { |
| 88 case START_TAG: | 88 case START_TAG: |
| 89 case END_TAG: | 89 case END_TAG: |
| 90 return fCurr.fName; | 90 return fCurr.fName; |
| 91 default: | 91 default: |
| 92 return NULL; | 92 return nullptr; |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 | 95 |
| 96 const char* SkXMLPullParser::getText() | 96 const char* SkXMLPullParser::getText() |
| 97 { | 97 { |
| 98 switch (fCurr.fEventType) { | 98 switch (fCurr.fEventType) { |
| 99 case TEXT: | 99 case TEXT: |
| 100 case IGNORABLE_WHITESPACE: | 100 case IGNORABLE_WHITESPACE: |
| 101 return fCurr.fName; | 101 return fCurr.fName; |
| 102 default: | 102 default: |
| 103 return NULL; | 103 return nullptr; |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 | 106 |
| 107 bool SkXMLPullParser::isWhitespace() | 107 bool SkXMLPullParser::isWhitespace() |
| 108 { | 108 { |
| 109 switch (fCurr.fEventType) { | 109 switch (fCurr.fEventType) { |
| 110 case IGNORABLE_WHITESPACE: | 110 case IGNORABLE_WHITESPACE: |
| 111 return true; | 111 return true; |
| 112 case TEXT: | 112 case TEXT: |
| 113 case CDSECT: | 113 case CDSECT: |
| (...skipping 15 matching lines...) Expand all Loading... |
| 129 if (info) | 129 if (info) |
| 130 *info = fCurr.fAttrInfos[index]; | 130 *info = fCurr.fAttrInfos[index]; |
| 131 } | 131 } |
| 132 | 132 |
| 133 bool SkXMLPullParser::onEntityReplacement(const char name[], | 133 bool SkXMLPullParser::onEntityReplacement(const char name[], |
| 134 SkString* replacement) | 134 SkString* replacement) |
| 135 { | 135 { |
| 136 // TODO: std 5 entities here | 136 // TODO: std 5 entities here |
| 137 return false; | 137 return false; |
| 138 } | 138 } |
| OLD | NEW |