| OLD | NEW |
| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 std::string NodeName() { | 66 std::string NodeName() { |
| 67 return XmlStringToStdString(xmlTextReaderConstLocalName(reader_)); | 67 return XmlStringToStdString(xmlTextReaderConstLocalName(reader_)); |
| 68 } | 68 } |
| 69 | 69 |
| 70 // When pointing at a tag, retrieves the value of an attribute. | 70 // When pointing at a tag, retrieves the value of an attribute. |
| 71 // Returns false on failure. | 71 // Returns false on failure. |
| 72 // E.g. for <foo bar:baz="a">, NodeAttribute("bar:baz", &value) | 72 // E.g. for <foo bar:baz="a">, NodeAttribute("bar:baz", &value) |
| 73 // returns true and |value| is set to "a". | 73 // returns true and |value| is set to "a". |
| 74 bool NodeAttribute(const char* name, std::string* value); | 74 bool NodeAttribute(const char* name, std::string* value); |
| 75 | 75 |
| 76 // Returns true if the node is a closing element (e.g. </foo>). |
| 77 bool IsClosingElement(); |
| 78 |
| 76 // Helper functions not provided by libxml ---------------------------------- | 79 // Helper functions not provided by libxml ---------------------------------- |
| 77 | 80 |
| 78 // Return the string content within an element. | 81 // Return the string content within an element. |
| 79 // "<foo>bar</foo>" is a sequence of three nodes: | 82 // "<foo>bar</foo>" is a sequence of three nodes: |
| 80 // (1) open tag, (2) text, (3) close tag. | 83 // (1) open tag, (2) text, (3) close tag. |
| 81 // With the reader currently at (1), this returns the text of (2), | 84 // With the reader currently at (1), this returns the text of (2), |
| 82 // and advances past (3). | 85 // and advances past (3). |
| 83 // Returns false on error. | 86 // Returns false on error. |
| 84 bool ReadElementContent(std::string* content); | 87 bool ReadElementContent(std::string* content); |
| 85 | 88 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 | 171 |
| 169 private: | 172 private: |
| 170 // The underlying libxml xmlTextWriter. | 173 // The underlying libxml xmlTextWriter. |
| 171 xmlTextWriterPtr writer_; | 174 xmlTextWriterPtr writer_; |
| 172 | 175 |
| 173 // Stores the output. | 176 // Stores the output. |
| 174 xmlBufferPtr buffer_; | 177 xmlBufferPtr buffer_; |
| 175 }; | 178 }; |
| 176 | 179 |
| 177 #endif // THIRD_PARTY_LIBXML_CHROMIUM_INCLUDE_LIBXML_LIBXML_UTILS_H_ | 180 #endif // THIRD_PARTY_LIBXML_CHROMIUM_INCLUDE_LIBXML_LIBXML_UTILS_H_ |
| OLD | NEW |