OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
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 | 8 |
9 | 9 |
10 #ifndef SkDOM_DEFINED | 10 #ifndef SkDOM_DEFINED |
11 #define SkDOM_DEFINED | 11 #define SkDOM_DEFINED |
12 | 12 |
13 #include "SkChunkAlloc.h" | 13 #include "SkChunkAlloc.h" |
14 #include "SkScalar.h" | 14 #include "SkScalar.h" |
15 #include "SkTemplates.h" | 15 #include "SkTemplates.h" |
16 | 16 |
17 struct SkDOMNode; | 17 struct SkDOMNode; |
18 struct SkDOMAttr; | 18 struct SkDOMAttr; |
19 | 19 |
| 20 class SkDOMParser; |
| 21 class SkXMLParser; |
| 22 |
20 class SkDOM { | 23 class SkDOM { |
21 public: | 24 public: |
22 SkDOM(); | 25 SkDOM(); |
23 ~SkDOM(); | 26 ~SkDOM(); |
24 | 27 |
25 typedef SkDOMNode Node; | 28 typedef SkDOMNode Node; |
26 typedef SkDOMAttr Attr; | 29 typedef SkDOMAttr Attr; |
27 | 30 |
28 /** Returns null on failure | 31 /** Returns null on failure |
29 */ | 32 */ |
30 const Node* build(const char doc[], size_t len); | 33 const Node* build(const char doc[], size_t len); |
31 const Node* copy(const SkDOM& dom, const Node* node); | 34 const Node* copy(const SkDOM& dom, const Node* node); |
32 | 35 |
33 const Node* getRootNode() const; | 36 const Node* getRootNode() const; |
34 | 37 |
| 38 SkXMLParser* beginParsing(); |
| 39 const Node* finishParsing(); |
| 40 |
35 enum Type { | 41 enum Type { |
36 kElement_Type, | 42 kElement_Type, |
37 kText_Type | 43 kText_Type |
38 }; | 44 }; |
39 Type getType(const Node*) const; | 45 Type getType(const Node*) const; |
40 | 46 |
41 const char* getName(const Node*) const; | 47 const char* getName(const Node*) const; |
42 const Node* getFirstChild(const Node*, const char elem[] = NULL) const; | 48 const Node* getFirstChild(const Node*, const char elem[] = NULL) const; |
43 const Node* getNextSibling(const Node*, const char elem[] = NULL) const; | 49 const Node* getNextSibling(const Node*, const char elem[] = NULL) const; |
44 | 50 |
(...skipping 30 matching lines...) Expand all Loading... |
75 const char* next(const char** value); | 81 const char* next(const char** value); |
76 private: | 82 private: |
77 const Attr* fAttr; | 83 const Attr* fAttr; |
78 const Attr* fStop; | 84 const Attr* fStop; |
79 }; | 85 }; |
80 | 86 |
81 SkDEBUGCODE(void dump(const Node* node = NULL, int tabLevel = 0) const;) | 87 SkDEBUGCODE(void dump(const Node* node = NULL, int tabLevel = 0) const;) |
82 SkDEBUGCODE(static void UnitTest();) | 88 SkDEBUGCODE(static void UnitTest();) |
83 | 89 |
84 private: | 90 private: |
85 SkChunkAlloc fAlloc; | 91 SkChunkAlloc fAlloc; |
86 Node* fRoot; | 92 Node* fRoot; |
| 93 SkAutoTDelete<SkDOMParser> fParser; |
| 94 |
87 friend class AttrIter; | 95 friend class AttrIter; |
88 friend class SkDOMParser; | 96 friend class SkDOMParser; |
89 }; | 97 }; |
90 | 98 |
91 #endif | 99 #endif |
OLD | NEW |