| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROME_UTILITY_MEDIA_GALLERIES_IAPPS_XML_UTILS_H_ | 5 #ifndef CHROME_UTILITY_MEDIA_GALLERIES_IAPPS_XML_UTILS_H_ |
| 6 #define CHROME_UTILITY_MEDIA_GALLERIES_IAPPS_XML_UTILS_H_ | 6 #define CHROME_UTILITY_MEDIA_GALLERIES_IAPPS_XML_UTILS_H_ |
| 7 | 7 |
| 8 #include <stdint.h> |
| 9 |
| 8 #include <set> | 10 #include <set> |
| 9 #include <string> | 11 #include <string> |
| 10 | 12 |
| 11 #include "base/files/file.h" | 13 #include "base/files/file.h" |
| 14 #include "base/macros.h" |
| 12 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
| 13 | 16 |
| 14 class XmlReader; | 17 class XmlReader; |
| 15 | 18 |
| 16 namespace iapps { | 19 namespace iapps { |
| 17 | 20 |
| 18 // Like XmlReader::SkipToElement, but will advance to the next open tag if the | 21 // Like XmlReader::SkipToElement, but will advance to the next open tag if the |
| 19 // cursor is on a close tag. | 22 // cursor is on a close tag. |
| 20 bool SkipToNextElement(XmlReader* reader); | 23 bool SkipToNextElement(XmlReader* reader); |
| 21 | 24 |
| 22 // Traverse |reader| looking for a node named |name| at the current depth | 25 // Traverse |reader| looking for a node named |name| at the current depth |
| 23 // of |reader|. | 26 // of |reader|. |
| 24 bool SeekToNodeAtCurrentDepth(XmlReader* reader, const std::string& name); | 27 bool SeekToNodeAtCurrentDepth(XmlReader* reader, const std::string& name); |
| 25 | 28 |
| 26 // Search within a "dict" node for |key|. The cursor must be on the starting | 29 // Search within a "dict" node for |key|. The cursor must be on the starting |
| 27 // "dict" node when entering this function. | 30 // "dict" node when entering this function. |
| 28 bool SeekInDict(XmlReader* reader, const std::string& key); | 31 bool SeekInDict(XmlReader* reader, const std::string& key); |
| 29 | 32 |
| 30 // Get the value out of a string node. | 33 // Get the value out of a string node. |
| 31 bool ReadString(XmlReader* reader, std::string* result); | 34 bool ReadString(XmlReader* reader, std::string* result); |
| 32 | 35 |
| 33 // Get the value out of an integer node. | 36 // Get the value out of an integer node. |
| 34 bool ReadInteger(XmlReader* reader, uint64* result); | 37 bool ReadInteger(XmlReader* reader, uint64_t* result); |
| 35 | 38 |
| 36 // Read in the contents of the given library xml |file| and return as a string. | 39 // Read in the contents of the given library xml |file| and return as a string. |
| 37 std::string ReadFileAsString(base::File file); | 40 std::string ReadFileAsString(base::File file); |
| 38 | 41 |
| 39 // Contains the common code and main loop for reading the key/values | 42 // Contains the common code and main loop for reading the key/values |
| 40 // of an XML dict. The derived class must implement |HandleKeyImpl()| | 43 // of an XML dict. The derived class must implement |HandleKeyImpl()| |
| 41 // which is called with each key, and may re-implement |ShouldLoop()|, | 44 // which is called with each key, and may re-implement |ShouldLoop()|, |
| 42 // |FinishedOk()| and/or |AllowRepeats()|. | 45 // |FinishedOk()| and/or |AllowRepeats()|. |
| 43 class XmlDictReader { | 46 class XmlDictReader { |
| 44 public: | 47 public: |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 private: | 83 private: |
| 81 // The keys that the reader has run into in this element. | 84 // The keys that the reader has run into in this element. |
| 82 std::set<std::string> found_; | 85 std::set<std::string> found_; |
| 83 | 86 |
| 84 DISALLOW_COPY_AND_ASSIGN(XmlDictReader); | 87 DISALLOW_COPY_AND_ASSIGN(XmlDictReader); |
| 85 }; | 88 }; |
| 86 | 89 |
| 87 } // namespace iapps | 90 } // namespace iapps |
| 88 | 91 |
| 89 #endif // CHROME_UTILITY_MEDIA_GALLERIES_IAPPS_XML_UTILS_H_ | 92 #endif // CHROME_UTILITY_MEDIA_GALLERIES_IAPPS_XML_UTILS_H_ |
| OLD | NEW |