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

Side by Side Diff: third_party/libxml/chromium/libxml_utils.h

Issue 22337003: Made XmlWriter able to write elements with both attributes and content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 4 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef THIRD_PARTY_LIBXML_CHROMIUM_LIBXML_UTILS_H_ 5 #ifndef THIRD_PARTY_LIBXML_CHROMIUM_LIBXML_UTILS_H_
6 #define THIRD_PARTY_LIBXML_CHROMIUM_LIBXML_UTILS_H_ 6 #define THIRD_PARTY_LIBXML_CHROMIUM_LIBXML_UTILS_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 bool StartElement(const std::string& element_name) { 126 bool StartElement(const std::string& element_name) {
127 return xmlTextWriterStartElement(writer_, 127 return xmlTextWriterStartElement(writer_,
128 BAD_CAST element_name.c_str()) >= 0; 128 BAD_CAST element_name.c_str()) >= 0;
129 } 129 }
130 130
131 // Ends the current open element. Returns false on error. 131 // Ends the current open element. Returns false on error.
132 bool EndElement() { 132 bool EndElement() {
133 return xmlTextWriterEndElement(writer_) >= 0; 133 return xmlTextWriterEndElement(writer_) >= 0;
134 } 134 }
135 135
136 // Appends to the content of the current open element.
137 bool AppendElementContent(const std::string& content) {
138 return xmlTextWriterWriteString(writer_,
139 BAD_CAST content.c_str()) >= 0;
140 }
141
136 // Adds an attribute to the current open element. Returns false on error. 142 // Adds an attribute to the current open element. Returns false on error.
137 bool AddAttribute(const std::string& attribute_name, 143 bool AddAttribute(const std::string& attribute_name,
138 const std::string& attribute_value) { 144 const std::string& attribute_value) {
139 return xmlTextWriterWriteAttribute(writer_, 145 return xmlTextWriterWriteAttribute(writer_,
140 BAD_CAST attribute_name.c_str(), 146 BAD_CAST attribute_name.c_str(),
141 BAD_CAST attribute_value.c_str()) >= 0; 147 BAD_CAST attribute_value.c_str()) >= 0;
142 } 148 }
143 149
144 // Adds a new element with name |element_name| and content |content| 150 // Adds a new element with name |element_name| and content |content|
145 // to the buffer. Example: <|element_name|>|content|</|element_name|> 151 // to the buffer. Example: <|element_name|>|content|</|element_name|>
(...skipping 16 matching lines...) Expand all
162 168
163 private: 169 private:
164 // The underlying libxml xmlTextWriter. 170 // The underlying libxml xmlTextWriter.
165 xmlTextWriterPtr writer_; 171 xmlTextWriterPtr writer_;
166 172
167 // Stores the output. 173 // Stores the output.
168 xmlBufferPtr buffer_; 174 xmlBufferPtr buffer_;
169 }; 175 };
170 176
171 #endif // THIRD_PARTY_LIBXML_CHROMIUM_INCLUDE_LIBXML_LIBXML_UTILS_H_ 177 #endif // THIRD_PARTY_LIBXML_CHROMIUM_INCLUDE_LIBXML_LIBXML_UTILS_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698