Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SkXMLWriter Class Referenceabstract

#include <SkXMLWriter.h>

Inheritance diagram for SkXMLWriter:
SkXMLParserWriter SkXMLStreamWriter

Classes

struct  Elem
 

Public Member Functions

 SkXMLWriter (bool doEscapeMarkup=true)
 
virtual ~SkXMLWriter ()
 
void addS32Attribute (const char name[], int32_t value)
 
void addAttribute (const char name[], const char value[])
 
void addAttributeLen (const char name[], const char value[], size_t length)
 
void addHexAttribute (const char name[], uint32_t value, int minDigits=0)
 
void addScalarAttribute (const char name[], SkScalar value)
 
void addText (const char text[], size_t length)
 
void endElement ()
 
void startElement (const char elem[])
 
void startElementLen (const char elem[], size_t length)
 
void writeDOM (const SkDOM &, const SkDOM::Node *, bool skipRoot)
 
void flush ()
 
virtual void writeHeader ()
 

Protected Member Functions

virtual void onStartElementLen (const char elem[], size_t length)=0
 
virtual void onAddAttributeLen (const char name[], const char value[], size_t length)=0
 
virtual void onAddText (const char text[], size_t length)=0
 
virtual void onEndElement ()=0
 
void doEnd (Elem *elem)
 
bool doStart (const char name[], size_t length)
 
ElemgetEnd ()
 
const char * getHeader ()
 

Protected Attributes

SkTDArray< Elem * > fElems
 

Detailed Description

Definition at line 18 of file SkXMLWriter.h.

Constructor & Destructor Documentation

◆ SkXMLWriter()

SkXMLWriter::SkXMLWriter ( bool  doEscapeMarkup = true)

Definition at line 13 of file SkXMLWriter.cpp.

13 : fDoEscapeMarkup(doEscapeMarkup)
14{}

◆ ~SkXMLWriter()

SkXMLWriter::~SkXMLWriter ( )
virtual

Definition at line 16 of file SkXMLWriter.cpp.

16 {
17 SkASSERT(fElems.empty());
18}
#define SkASSERT(cond)
Definition: SkAssert.h:116
SkTDArray< Elem * > fElems
Definition: SkXMLWriter.h:56

Member Function Documentation

◆ addAttribute()

void SkXMLWriter::addAttribute ( const char  name[],
const char  value[] 
)

Definition at line 26 of file SkXMLWriter.cpp.

26 {
27 this->addAttributeLen(name, value, strlen(value));
28}
void addAttributeLen(const char name[], const char value[], size_t length)
uint8_t value
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

◆ addAttributeLen()

void SkXMLWriter::addAttributeLen ( const char  name[],
const char  value[],
size_t  length 
)

Definition at line 131 of file SkXMLWriter.cpp.

131 {
132 SkString valueStr;
133
134 if (fDoEscapeMarkup) {
135 size_t extra = escape_markup(nullptr, value, length);
136 if (extra) {
137 valueStr.resize(length + extra);
138 (void)escape_markup(valueStr.data(), value, length);
139 value = valueStr.c_str();
140 length += extra;
141 }
142 }
144}
static size_t escape_markup(char dst[], const char src[], size_t length)
const char * data() const
Definition: SkString.h:132
void resize(size_t len)
Definition: SkString.cpp:374
const char * c_str() const
Definition: SkString.h:133
virtual void onAddAttributeLen(const char name[], const char value[], size_t length)=0
size_t length

◆ addHexAttribute()

void SkXMLWriter::addHexAttribute ( const char  name[],
uint32_t  value,
int  minDigits = 0 
)

Definition at line 36 of file SkXMLWriter.cpp.

36 {
37 SkString tmp("0x");
38 tmp.appendHex(value, minDigits);
39 this->addAttribute(name, tmp.c_str());
40}
void addAttribute(const char name[], const char value[])
Definition: SkXMLWriter.cpp:26

◆ addS32Attribute()

void SkXMLWriter::addS32Attribute ( const char  name[],
int32_t  value 
)

Definition at line 30 of file SkXMLWriter.cpp.

30 {
31 SkString tmp;
32 tmp.appendS32(value);
33 this->addAttribute(name, tmp.c_str());
34}
void appendS32(int32_t value)
Definition: SkString.h:208

◆ addScalarAttribute()

void SkXMLWriter::addScalarAttribute ( const char  name[],
SkScalar  value 
)

Definition at line 42 of file SkXMLWriter.cpp.

42 {
43 SkString tmp;
45 this->addAttribute(name, tmp.c_str());
46}
void appendScalar(SkScalar value)
Definition: SkString.h:213

◆ addText()

void SkXMLWriter::addText ( const char  text[],
size_t  length 
)

Definition at line 48 of file SkXMLWriter.cpp.

48 {
49 if (fElems.empty()) {
50 return;
51 }
52
53 this->onAddText(text, length);
54
55 fElems.back()->fHasText = true;
56}
virtual void onAddText(const char text[], size_t length)=0
std::u16string text

◆ doEnd()

void SkXMLWriter::doEnd ( Elem elem)
protected

Definition at line 58 of file SkXMLWriter.cpp.

58 {
59 delete elem;
60}

◆ doStart()

bool SkXMLWriter::doStart ( const char  name[],
size_t  length 
)
protected

Definition at line 62 of file SkXMLWriter.cpp.

62 {
63 int level = fElems.size();
64 bool firstChild = level > 0 && !fElems[level-1]->fHasChildren;
65 if (firstChild) {
66 fElems[level-1]->fHasChildren = true;
67 }
68 Elem** elem = fElems.append();
69 *elem = new Elem(name, length);
70 return firstChild;
71}

◆ endElement()

void SkXMLWriter::endElement ( )
inline

Definition at line 29 of file SkXMLWriter.h.

29{ this->onEndElement(); }
virtual void onEndElement()=0

◆ flush()

void SkXMLWriter::flush ( )

Definition at line 20 of file SkXMLWriter.cpp.

20 {
21 while (!fElems.empty()) {
22 this->endElement();
23 }
24}
void endElement()
Definition: SkXMLWriter.h:29

◆ getEnd()

SkXMLWriter::Elem * SkXMLWriter::getEnd ( )
protected

Definition at line 73 of file SkXMLWriter.cpp.

73 {
74 Elem* elem = fElems.back();
75 fElems.pop_back();
76 return elem;
77}

◆ getHeader()

const char * SkXMLWriter::getHeader ( )
protected

Definition at line 79 of file SkXMLWriter.cpp.

79 {
80 static const char gHeader[] = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";
81 return gHeader;
82}

◆ onAddAttributeLen()

virtual void SkXMLWriter::onAddAttributeLen ( const char  name[],
const char  value[],
size_t  length 
)
protectedpure virtual

Implemented in SkXMLStreamWriter, and SkXMLParserWriter.

◆ onAddText()

virtual void SkXMLWriter::onAddText ( const char  text[],
size_t  length 
)
protectedpure virtual

Implemented in SkXMLStreamWriter, and SkXMLParserWriter.

◆ onEndElement()

virtual void SkXMLWriter::onEndElement ( )
protectedpure virtual

Implemented in SkXMLStreamWriter, and SkXMLParserWriter.

◆ onStartElementLen()

virtual void SkXMLWriter::onStartElementLen ( const char  elem[],
size_t  length 
)
protectedpure virtual

Implemented in SkXMLStreamWriter, and SkXMLParserWriter.

◆ startElement()

void SkXMLWriter::startElement ( const char  elem[])

Definition at line 84 of file SkXMLWriter.cpp.

84 {
85 this->startElementLen(name, strlen(name));
86}
void startElementLen(const char elem[], size_t length)

◆ startElementLen()

void SkXMLWriter::startElementLen ( const char  elem[],
size_t  length 
)

Definition at line 146 of file SkXMLWriter.cpp.

146 {
147 this->onStartElementLen(elem, length);
148}
virtual void onStartElementLen(const char elem[], size_t length)=0

◆ writeDOM()

void SkXMLWriter::writeDOM ( const SkDOM dom,
const SkDOM::Node node,
bool  skipRoot 
)

Definition at line 182 of file SkXMLWriter.cpp.

182 {
183 if (node) {
184 write_dom(dom, node, this, skipRoot);
185 }
186}
static void write_dom(const SkDOM &dom, const SkDOM::Node *node, SkXMLWriter *w, bool skipRoot)
Definition: dom.py:1

◆ writeHeader()

void SkXMLWriter::writeHeader ( )
virtual

Reimplemented in SkXMLStreamWriter.

Definition at line 188 of file SkXMLWriter.cpp.

189{}

Member Data Documentation

◆ fElems

SkTDArray<Elem*> SkXMLWriter::fElems
protected

Definition at line 56 of file SkXMLWriter.h.


The documentation for this class was generated from the following files: