Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: src/xml/SkXMLPullParser.cpp

Issue 2163463002: Delete SkXMLPullParser (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/xml/SkXMLParser.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2011 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7 #include "SkXMLParser.h"
8 #include "SkStream.h"
9
10 static void reset(SkXMLPullParser::Curr* curr)
11 {
12 curr->fEventType = SkXMLPullParser::ERROR;
13 curr->fName = "";
14 curr->fAttrInfoCount = 0;
15 curr->fIsWhitespace = false;
16 }
17
18 SkXMLPullParser::SkXMLPullParser() : fStream(nullptr)
19 {
20 fCurr.fEventType = ERROR;
21 fDepth = -1;
22 }
23
24 SkXMLPullParser::SkXMLPullParser(SkStream* stream) : fStream(nullptr)
25 {
26 fCurr.fEventType = ERROR;
27 fDepth = 0;
28
29 this->setStream(stream);
30 }
31
32 SkXMLPullParser::~SkXMLPullParser()
33 {
34 this->setStream(nullptr);
35 }
36
37 SkStream* SkXMLPullParser::setStream(SkStream* stream)
38 {
39 if (fStream && !stream)
40 this->onExit();
41
42 SkRefCnt_SafeAssign(fStream, stream);
43
44 if (fStream)
45 {
46 fCurr.fEventType = START_DOCUMENT;
47 this->onInit();
48 }
49 else
50 {
51 fCurr.fEventType = ERROR;
52 }
53 fDepth = 0;
54
55 return fStream;
56 }
57
58 SkXMLPullParser::EventType SkXMLPullParser::nextToken()
59 {
60 switch (fCurr.fEventType) {
61 case ERROR:
62 case END_DOCUMENT:
63 break;
64 case END_TAG:
65 fDepth -= 1;
66 // fall through
67 default:
68 reset(&fCurr);
69 fCurr.fEventType = this->onNextToken();
70 break;
71 }
72
73 switch (fCurr.fEventType) {
74 case START_TAG:
75 fDepth += 1;
76 break;
77 default:
78 break;
79 }
80
81 return fCurr.fEventType;
82 }
83
84 const char* SkXMLPullParser::getName()
85 {
86 switch (fCurr.fEventType) {
87 case START_TAG:
88 case END_TAG:
89 return fCurr.fName;
90 default:
91 return nullptr;
92 }
93 }
94
95 const char* SkXMLPullParser::getText()
96 {
97 switch (fCurr.fEventType) {
98 case TEXT:
99 case IGNORABLE_WHITESPACE:
100 return fCurr.fName;
101 default:
102 return nullptr;
103 }
104 }
105
106 bool SkXMLPullParser::isWhitespace()
107 {
108 switch (fCurr.fEventType) {
109 case IGNORABLE_WHITESPACE:
110 return true;
111 case TEXT:
112 case CDSECT:
113 return fCurr.fIsWhitespace;
114 default:
115 return false; // unknown/illegal
116 }
117 }
118
119 int SkXMLPullParser::getAttributeCount()
120 {
121 return fCurr.fAttrInfoCount;
122 }
123
124 void SkXMLPullParser::getAttributeInfo(int index, AttrInfo* info)
125 {
126 SkASSERT((unsigned)index < (unsigned)fCurr.fAttrInfoCount);
127
128 if (info)
129 *info = fCurr.fAttrInfos[index];
130 }
131
132 bool SkXMLPullParser::onEntityReplacement(const char name[],
133 SkString* replacement)
134 {
135 // TODO: std 5 entities here
136 return false;
137 }
OLDNEW
« no previous file with comments | « include/xml/SkXMLParser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698