Flutter Engine
The Flutter Engine
SkXMLWriter.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 SkXMLWriter_DEFINED
9#define SkXMLWriter_DEFINED
10
13#include "src/xml/SkDOM.h"
14
15class SkWStream;
16class SkXMLParser;
17
19public:
20 SkXMLWriter(bool doEscapeMarkup = true);
21 virtual ~SkXMLWriter();
22
23 void addS32Attribute(const char name[], int32_t value);
24 void addAttribute(const char name[], const char value[]);
25 void addAttributeLen(const char name[], const char value[], size_t length);
26 void addHexAttribute(const char name[], uint32_t value, int minDigits = 0);
27 void addScalarAttribute(const char name[], SkScalar value);
28 void addText(const char text[], size_t length);
29 void endElement() { this->onEndElement(); }
30 void startElement(const char elem[]);
31 void startElementLen(const char elem[], size_t length);
32 void writeDOM(const SkDOM&, const SkDOM::Node*, bool skipRoot);
33 void flush();
34 virtual void writeHeader();
35
36protected:
37 virtual void onStartElementLen(const char elem[], size_t length) = 0;
38 virtual void onAddAttributeLen(const char name[], const char value[], size_t length) = 0;
39 virtual void onAddText(const char text[], size_t length) = 0;
40 virtual void onEndElement() = 0;
41
42 struct Elem {
43 Elem(const char name[], size_t len)
44 : fName(name, len)
46 , fHasText(false) {}
47
51 };
52 void doEnd(Elem* elem);
53 bool doStart(const char name[], size_t length);
54 Elem* getEnd();
55 const char* getHeader();
57
58private:
59 bool fDoEscapeMarkup;
60 // illegal
61 SkXMLWriter& operator=(const SkXMLWriter&);
62};
63
65public:
66 enum : uint32_t {
68 };
69
70 SkXMLStreamWriter(SkWStream*, uint32_t flags = 0);
71 ~SkXMLStreamWriter() override;
72 void writeHeader() override;
73
74protected:
75 void onStartElementLen(const char elem[], size_t length) override;
76 void onEndElement() override;
77 void onAddAttributeLen(const char name[], const char value[], size_t length) override;
78 void onAddText(const char text[], size_t length) override;
79
80private:
81 void newline();
82 void tab(int lvl);
83
84 SkWStream& fStream;
85 const uint32_t fFlags;
86};
87
89public:
91 ~SkXMLParserWriter() override;
92protected:
93 void onStartElementLen(const char elem[], size_t length) override;
94 void onEndElement() override;
95 void onAddAttributeLen(const char name[], const char value[], size_t length) override;
96 void onAddText(const char text[], size_t length) override;
97private:
98 SkXMLParser& fParser;
99};
100
101
102#endif
Definition: SkDOM.h:24
void onEndElement() override
SkXMLParserWriter(SkXMLParser *)
void onAddText(const char text[], size_t length) override
void onAddAttributeLen(const char name[], const char value[], size_t length) override
~SkXMLParserWriter() override
void onStartElementLen(const char elem[], size_t length) override
~SkXMLStreamWriter() override
void onStartElementLen(const char elem[], size_t length) override
void onEndElement() override
SkXMLStreamWriter(SkWStream *, uint32_t flags=0)
void onAddText(const char text[], size_t length) override
void writeHeader() override
void onAddAttributeLen(const char name[], const char value[], size_t length) override
virtual void onEndElement()=0
virtual ~SkXMLWriter()
Definition: SkXMLWriter.cpp:16
virtual void onStartElementLen(const char elem[], size_t length)=0
void addText(const char text[], size_t length)
Definition: SkXMLWriter.cpp:48
void writeDOM(const SkDOM &, const SkDOM::Node *, bool skipRoot)
void addAttributeLen(const char name[], const char value[], size_t length)
void addHexAttribute(const char name[], uint32_t value, int minDigits=0)
Definition: SkXMLWriter.cpp:36
const char * getHeader()
Definition: SkXMLWriter.cpp:79
void doEnd(Elem *elem)
Definition: SkXMLWriter.cpp:58
void flush()
Definition: SkXMLWriter.cpp:20
virtual void onAddText(const char text[], size_t length)=0
void addScalarAttribute(const char name[], SkScalar value)
Definition: SkXMLWriter.cpp:42
SkXMLWriter(bool doEscapeMarkup=true)
Definition: SkXMLWriter.cpp:13
Elem * getEnd()
Definition: SkXMLWriter.cpp:73
void addS32Attribute(const char name[], int32_t value)
Definition: SkXMLWriter.cpp:30
SkTDArray< Elem * > fElems
Definition: SkXMLWriter.h:56
void addAttribute(const char name[], const char value[])
Definition: SkXMLWriter.cpp:26
virtual void onAddAttributeLen(const char name[], const char value[], size_t length)=0
virtual void writeHeader()
bool doStart(const char name[], size_t length)
Definition: SkXMLWriter.cpp:62
void endElement()
Definition: SkXMLWriter.h:29
void startElement(const char elem[])
Definition: SkXMLWriter.cpp:84
void startElementLen(const char elem[], size_t length)
float SkScalar
Definition: extension.cpp:12
FlutterSemanticsFlag flags
uint8_t value
size_t length
std::u16string text
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
Elem(const char name[], size_t len)
Definition: SkXMLWriter.h:43