Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkXMLParser.h
Go to the documentation of this file.
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#ifndef SkXMLParser_DEFINED
11#define SkXMLParser_DEFINED
12
14
15class SkStream;
16
17class SkDOM;
18struct SkDOMNode;
19
21public:
31
33 virtual ~SkXMLParserError();
34 ErrorCode getErrorCode() const { return fCode; }
35 virtual void getErrorString(SkString* str) const;
36 int getLineNumber() const { return fLineNumber; }
37 int getNativeCode() const { return fNativeCode; }
38 bool hasError() const { return fCode != kNoError || fNativeCode != -1; }
39 bool hasNoun() const { return fNoun.size() > 0; }
40 void reset();
41 void setCode(ErrorCode code) { fCode = code; }
42 void setNoun(const SkString& str) { fNoun.set(str); }
43 void setNoun(const char* ch) { fNoun.set(ch); }
44 void setNoun(const char* ch, size_t len) { fNoun.set(ch, len); }
45protected:
47private:
48 int fLineNumber;
49 int fNativeCode;
50 SkString fNoun;
51 friend class SkXMLParser;
52};
53
55public:
56 SkXMLParser(SkXMLParserError* parserError = nullptr);
57 virtual ~SkXMLParser();
58
59 /** Returns true for success
60 */
61 bool parse(const char doc[], size_t len);
62 bool parse(SkStream& docStream);
63 bool parse(const SkDOM&, const SkDOMNode*);
64
65 static void GetNativeErrorString(int nativeErrorCode, SkString* str);
66
67protected:
68 // override in subclasses; return true to stop parsing
69 virtual bool onStartElement(const char elem[]);
70 virtual bool onAddAttribute(const char name[], const char value[]);
71 virtual bool onEndElement(const char elem[]);
72 virtual bool onText(const char text[], int len);
73
74public:
75 // public for ported implementation, not meant for clients to call
76 bool startElement(const char elem[]);
77 bool addAttribute(const char name[], const char value[]);
78 bool endElement(const char elem[]);
79 bool text(const char text[], int len);
80 void* fParser;
81protected:
83private:
84 void reportError(void* parser);
85};
86
87#endif
Definition SkDOM.h:24
size_t size() const
Definition SkString.h:131
void set(const SkString &src)
Definition SkString.h:186
bool hasError() const
Definition SkXMLParser.h:38
int getLineNumber() const
Definition SkXMLParser.h:36
int getNativeCode() const
Definition SkXMLParser.h:37
bool hasNoun() const
Definition SkXMLParser.h:39
ErrorCode fCode
Definition SkXMLParser.h:46
void setNoun(const char *ch)
Definition SkXMLParser.h:43
void setNoun(const SkString &str)
Definition SkXMLParser.h:42
virtual ~SkXMLParserError()
void setCode(ErrorCode code)
Definition SkXMLParser.h:41
ErrorCode getErrorCode() const
Definition SkXMLParser.h:34
virtual void getErrorString(SkString *str) const
void setNoun(const char *ch, size_t len)
Definition SkXMLParser.h:44
bool startElement(const char elem[])
bool endElement(const char elem[])
virtual ~SkXMLParser()
virtual bool onEndElement(const char elem[])
SkXMLParserError * fError
Definition SkXMLParser.h:82
static void GetNativeErrorString(int nativeErrorCode, SkString *str)
virtual bool onAddAttribute(const char name[], const char value[])
virtual bool onText(const char text[], int len)
void * fParser
Definition SkXMLParser.h:80
virtual bool onStartElement(const char elem[])
bool addAttribute(const char name[], const char value[])
bool parse(const char doc[], size_t len)
uint8_t value
const char * name
Definition fuchsia.cc:50
std::u16string text