Flutter Engine
The Flutter Engine
SkDOM.h
Go to the documentation of this file.
1/*
2 * Copyright 2006 The Android Open Source Project
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
8#ifndef SkDOM_DEFINED
9#define SkDOM_DEFINED
10
16
17struct SkDOMNode;
18struct SkDOMAttr;
19
20class SkDOMParser;
21class SkStream;
22class SkXMLParser;
23
24class SkDOM : public SkNoncopyable {
25public:
26 SkDOM();
27 ~SkDOM();
28
29 typedef SkDOMNode Node;
30 typedef SkDOMAttr Attr;
31
32 /** Returns null on failure
33 */
34 const Node* build(SkStream&);
35 const Node* copy(const SkDOM& dom, const Node* node);
36
37 const Node* getRootNode() const;
38
40 const Node* finishParsing();
41
42 enum Type {
45 };
46 Type getType(const Node*) const;
47
48 const char* getName(const Node*) const;
49 const Node* getFirstChild(const Node*, const char elem[] = nullptr) const;
50 const Node* getNextSibling(const Node*, const char elem[] = nullptr) const;
51
52 const char* findAttr(const Node*, const char attrName[]) const;
53 const Attr* getFirstAttr(const Node*) const;
54 const Attr* getNextAttr(const Node*, const Attr*) const;
55 const char* getAttrName(const Node*, const Attr*) const;
56 const char* getAttrValue(const Node*, const Attr*) const;
57
58 // helpers for walking children
59 int countChildren(const Node* node, const char elem[] = nullptr) const;
60
61 // helpers for calling SkParse
62 bool findS32(const Node*, const char name[], int32_t* value) const;
63 bool findScalars(const Node*, const char name[], SkScalar value[], int count) const;
64 bool findHex(const Node*, const char name[], uint32_t* value) const;
65 bool findBool(const Node*, const char name[], bool*) const;
66 int findList(const Node*, const char name[], const char list[]) const;
67
68 bool findScalar(const Node* node, const char name[], SkScalar value[]) const {
69 return this->findScalars(node, name, value, 1);
70 }
71
72 bool hasAttr(const Node*, const char name[], const char value[]) const;
73 bool hasS32(const Node*, const char name[], int32_t value) const;
74 bool hasScalar(const Node*, const char name[], SkScalar value) const;
75 bool hasHex(const Node*, const char name[], uint32_t value) const;
76 bool hasBool(const Node*, const char name[], bool value) const;
77
78 class AttrIter {
79 public:
80 AttrIter(const SkDOM&, const Node*);
81 const char* next(const char** value);
82 private:
83 const Attr* fAttr;
84 const Attr* fStop;
85 };
86
87private:
89 Node* fRoot;
90 std::unique_ptr<SkDOMParser> fParser;
91
93};
94
95#endif
int count
Definition: FontMgrTest.cpp:50
const char * next(const char **value)
Definition: SkDOM.cpp:165
AttrIter(const SkDOM &, const Node *)
Definition: SkDOM.cpp:159
Definition: SkDOM.h:24
const Node * finishParsing()
Definition: SkDOM.cpp:351
const Attr * getNextAttr(const Node *, const Attr *) const
Definition: SkDOM.cpp:137
bool hasS32(const Node *, const char name[], int32_t value) const
Definition: SkDOM.cpp:406
@ kText_Type
Definition: SkDOM.h:44
@ kElement_Type
Definition: SkDOM.h:43
bool findS32(const Node *, const char name[], int32_t *value) const
Definition: SkDOM.cpp:376
const Attr * getFirstAttr(const Node *) const
Definition: SkDOM.cpp:133
bool findScalar(const Node *node, const char name[], SkScalar value[]) const
Definition: SkDOM.h:68
int findList(const Node *, const char name[], const char list[]) const
Definition: SkDOM.cpp:396
const char * getAttrValue(const Node *, const Attr *) const
Definition: SkDOM.cpp:151
bool findBool(const Node *, const char name[], bool *) const
Definition: SkDOM.cpp:391
const Node * getRootNode() const
Definition: SkDOM.cpp:76
SkDOMNode Node
Definition: SkDOM.h:29
const Node * copy(const SkDOM &dom, const Node *node)
Definition: SkDOM.cpp:335
bool findScalars(const Node *, const char name[], SkScalar value[], int count) const
Definition: SkDOM.cpp:381
bool hasScalar(const Node *, const char name[], SkScalar value) const
Definition: SkDOM.cpp:412
const Node * getNextSibling(const Node *, const char elem[]=nullptr) const
Definition: SkDOM.cpp:94
bool hasHex(const Node *, const char name[], uint32_t value) const
Definition: SkDOM.cpp:418
SkDOM()
Definition: SkDOM.cpp:72
SkDOMAttr Attr
Definition: SkDOM.h:30
~SkDOM()
Definition: SkDOM.cpp:74
bool findHex(const Node *, const char name[], uint32_t *value) const
Definition: SkDOM.cpp:386
bool hasAttr(const Node *, const char name[], const char value[]) const
Definition: SkDOM.cpp:401
const Node * getFirstChild(const Node *, const char elem[]=nullptr) const
Definition: SkDOM.cpp:80
const char * getName(const Node *) const
Definition: SkDOM.cpp:112
bool hasBool(const Node *, const char name[], bool value) const
Definition: SkDOM.cpp:424
Type getType(const Node *) const
Definition: SkDOM.cpp:107
SkXMLParser * beginParsing()
Definition: SkDOM.cpp:344
const Node * build(SkStream &)
Definition: SkDOM.cpp:294
int countChildren(const Node *node, const char elem[]=nullptr) const
Definition: SkDOM.cpp:361
const char * findAttr(const Node *, const char attrName[]) const
Definition: SkDOM.cpp:117
const char * getAttrName(const Node *, const Attr *) const
Definition: SkDOM.cpp:145
SkNoncopyable()=default
float SkScalar
Definition: extension.cpp:12
uint8_t value
Definition: dart.idl:29
Definition: dom.py:1
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32