Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Side by Side Diff: include/xml/SkXMLWriter.h

Issue 896363002: add length parameter to addText, to match attr values (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/animator/SkXMLAnimatorWriter.h » ('j') | src/xml/SkXMLWriter.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1
2 /* 1 /*
3 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
4 * 3 *
5 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 5 * found in the LICENSE file.
7 */ 6 */
8 7
9
10 #ifndef SkXMLWriter_DEFINED 8 #ifndef SkXMLWriter_DEFINED
11 #define SkXMLWriter_DEFINED 9 #define SkXMLWriter_DEFINED
12 10
13 #include "SkTDArray.h" 11 #include "SkTDArray.h"
14 #include "SkString.h" 12 #include "SkString.h"
15 #include "SkDOM.h" 13 #include "SkDOM.h"
16 14
17 class SkWStream; 15 class SkWStream;
18 class SkXMLParser; 16 class SkXMLParser;
19 17
20 class SkXMLWriter { 18 class SkXMLWriter {
21 public: 19 public:
22 SkXMLWriter(bool doEscapeMarkup = true); 20 SkXMLWriter(bool doEscapeMarkup = true);
23 virtual ~SkXMLWriter(); 21 virtual ~SkXMLWriter();
24 22
25 void addS32Attribute(const char name[], int32_t value); 23 void addS32Attribute(const char name[], int32_t value);
26 void addAttribute(const char name[], const char value[]); 24 void addAttribute(const char name[], const char value[]);
27 void addAttributeLen(const char name[], const char value[], size_t length ); 25 void addAttributeLen(const char name[], const char value[], size_t length );
28 void addHexAttribute(const char name[], uint32_t value, int minDigits = 0 ); 26 void addHexAttribute(const char name[], uint32_t value, int minDigits = 0 );
29 void addScalarAttribute(const char name[], SkScalar value); 27 void addScalarAttribute(const char name[], SkScalar value);
30 void addText(const char text[]); 28 void addText(const char text[], size_t length);
29 void addText(const char cstr[]);
f(malita) 2015/02/05 02:16:17 Is there any value in keeping this variant around?
reed1 2015/02/05 02:17:45 Good point. Will remove.
31 void endElement() { this->onEndElement(); } 30 void endElement() { this->onEndElement(); }
32 void startElement(const char elem[]); 31 void startElement(const char elem[]);
33 void startElementLen(const char elem[], size_t length); 32 void startElementLen(const char elem[], size_t length);
34 void writeDOM(const SkDOM&, const SkDOM::Node*, bool skipRoot); 33 void writeDOM(const SkDOM&, const SkDOM::Node*, bool skipRoot);
35 void flush(); 34 void flush();
36 virtual void writeHeader(); 35 virtual void writeHeader();
37 36
38 protected: 37 protected:
39 virtual void onStartElementLen(const char elem[], size_t length) = 0; 38 virtual void onStartElementLen(const char elem[], size_t length) = 0;
40 virtual void onAddAttributeLen(const char name[], const char value[], size_t length) = 0; 39 virtual void onAddAttributeLen(const char name[], const char value[], size_t length) = 0;
41 virtual void onAddText(const char text[]) = 0; 40 virtual void onAddText(const char text[], size_t length) = 0;
42 virtual void onEndElement() = 0; 41 virtual void onEndElement() = 0;
43 42
44 struct Elem { 43 struct Elem {
45 Elem(const char name[], size_t len) 44 Elem(const char name[], size_t len)
46 : fName(name, len) 45 : fName(name, len)
47 , fHasChildren(false) 46 , fHasChildren(false)
48 , fHasText(false) {} 47 , fHasText(false) {}
49 48
50 SkString fName; 49 SkString fName;
51 bool fHasChildren; 50 bool fHasChildren;
(...skipping 10 matching lines...) Expand all
62 // illegal 61 // illegal
63 SkXMLWriter& operator=(const SkXMLWriter&); 62 SkXMLWriter& operator=(const SkXMLWriter&);
64 }; 63 };
65 64
66 class SkXMLStreamWriter : public SkXMLWriter { 65 class SkXMLStreamWriter : public SkXMLWriter {
67 public: 66 public:
68 SkXMLStreamWriter(SkWStream*); 67 SkXMLStreamWriter(SkWStream*);
69 virtual ~SkXMLStreamWriter(); 68 virtual ~SkXMLStreamWriter();
70 virtual void writeHeader(); 69 virtual void writeHeader();
71 SkDEBUGCODE(static void UnitTest();) 70 SkDEBUGCODE(static void UnitTest();)
71
72 protected: 72 protected:
73 virtual void onStartElementLen(const char elem[], size_t length); 73 void onStartElementLen(const char elem[], size_t length) SK_OVERRIDE;
74 virtual void onEndElement(); 74 void onEndElement() SK_OVERRIDE;
75 virtual void onAddAttributeLen(const char name[], const char value[], size_t length); 75 void onAddAttributeLen(const char name[], const char value[], size_t length) SK_OVERRIDE;
76 virtual void onAddText(const char text[]) SK_OVERRIDE; 76 void onAddText(const char text[], size_t length) SK_OVERRIDE;
77 77
78 private: 78 private:
79 SkWStream& fStream; 79 SkWStream& fStream;
80 }; 80 };
81 81
82 class SkXMLParserWriter : public SkXMLWriter { 82 class SkXMLParserWriter : public SkXMLWriter {
83 public: 83 public:
84 SkXMLParserWriter(SkXMLParser*); 84 SkXMLParserWriter(SkXMLParser*);
85 virtual ~SkXMLParserWriter(); 85 virtual ~SkXMLParserWriter();
86 protected: 86 protected:
87 virtual void onStartElementLen(const char elem[], size_t length); 87 virtual void onStartElementLen(const char elem[], size_t length);
88 virtual void onEndElement(); 88 virtual void onEndElement();
89 virtual void onAddAttributeLen(const char name[], const char value[], size_t length); 89 virtual void onAddAttributeLen(const char name[], const char value[], size_t length);
90 virtual void onAddText(const char text[]) SK_OVERRIDE; 90 virtual void onAddText(const char text[], size_t length) SK_OVERRIDE;
91 private: 91 private:
92 SkXMLParser& fParser; 92 SkXMLParser& fParser;
93 }; 93 };
94 94
95 95
96 #endif 96 #endif
OLDNEW
« no previous file with comments | « no previous file | src/animator/SkXMLAnimatorWriter.h » ('j') | src/xml/SkXMLWriter.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698