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

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

Issue 23132002: GTTF: Add a basic new unit test launcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed gyp cycle 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 | « third_party/libxml/chromium/libxml_utils.h ('k') | third_party/zlib/google/zip.gyp » ('j') | 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 #include "libxml_utils.h" 5 #include "libxml_utils.h"
6 6
7 #include "libxml/xmlreader.h" 7 #include "libxml/xmlreader.h"
8 8
9 std::string XmlStringToStdString(const xmlChar* xmlstring) { 9 std::string XmlStringToStdString(const xmlChar* xmlstring) {
10 // xmlChar*s are UTF-8, so this cast is safe. 10 // xmlChar*s are UTF-8, so this cast is safe.
(...skipping 30 matching lines...) Expand all
41 41
42 bool XmlReader::NodeAttribute(const char* name, std::string* out) { 42 bool XmlReader::NodeAttribute(const char* name, std::string* out) {
43 xmlChar* value = xmlTextReaderGetAttribute(reader_, BAD_CAST name); 43 xmlChar* value = xmlTextReaderGetAttribute(reader_, BAD_CAST name);
44 if (!value) 44 if (!value)
45 return false; 45 return false;
46 *out = XmlStringToStdString(value); 46 *out = XmlStringToStdString(value);
47 xmlFree(value); 47 xmlFree(value);
48 return true; 48 return true;
49 } 49 }
50 50
51 bool XmlReader::IsClosingElement() {
52 return NodeType() == XML_READER_TYPE_END_ELEMENT;
53 }
54
51 bool XmlReader::ReadElementContent(std::string* content) { 55 bool XmlReader::ReadElementContent(std::string* content) {
52 const int start_depth = Depth(); 56 const int start_depth = Depth();
53 57
54 if (xmlTextReaderIsEmptyElement(reader_)) { 58 if (xmlTextReaderIsEmptyElement(reader_)) {
55 // Empty tag. We succesfully read the content, but it's 59 // Empty tag. We succesfully read the content, but it's
56 // empty. 60 // empty.
57 *content = ""; 61 *content = "";
58 // Advance past this empty tag. 62 // Advance past this empty tag.
59 if (!Read()) 63 if (!Read())
60 return false; 64 return false;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 writer_ = xmlNewTextWriterMemory(buffer_, 0); 118 writer_ = xmlNewTextWriterMemory(buffer_, 0);
115 xmlTextWriterSetIndent(writer_, 1); 119 xmlTextWriterSetIndent(writer_, 1);
116 xmlTextWriterStartDocument(writer_, NULL, NULL, NULL); 120 xmlTextWriterStartDocument(writer_, NULL, NULL, NULL);
117 } 121 }
118 122
119 void XmlWriter::StopWriting() { 123 void XmlWriter::StopWriting() {
120 xmlTextWriterEndDocument(writer_); 124 xmlTextWriterEndDocument(writer_);
121 xmlFreeTextWriter(writer_); 125 xmlFreeTextWriter(writer_);
122 writer_ = NULL; 126 writer_ = NULL;
123 } 127 }
OLDNEW
« no previous file with comments | « third_party/libxml/chromium/libxml_utils.h ('k') | third_party/zlib/google/zip.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698