Index: chrome/utility/media_galleries/iapps_xml_utils.h |
diff --git a/chrome/utility/media_galleries/iapps_xml_utils.h b/chrome/utility/media_galleries/iapps_xml_utils.h |
index edee54bead9811416383506282676dd5cd4e55e4..3f221a0717777c902550ab6550c16ee0ad0003ce 100644 |
--- a/chrome/utility/media_galleries/iapps_xml_utils.h |
+++ b/chrome/utility/media_galleries/iapps_xml_utils.h |
@@ -5,6 +5,7 @@ |
#ifndef CHROME_UTILITY_MEDIA_GALLERIES_IAPPS_XML_UTILS_H_ |
#define CHROME_UTILITY_MEDIA_GALLERIES_IAPPS_XML_UTILS_H_ |
+#include <set> |
#include <string> |
#include "base/files/file.h" |
@@ -34,6 +35,44 @@ bool ReadInteger(XmlReader* reader, uint64* result); |
// Read in the contents of the given library xml |file| and return as a string. |
std::string ReadFileAsString(base::File file); |
+class XmlDictReader { |
Lei Zhang
2014/08/05 19:38:24
This class can use some comments.
Kevin Bailey
2014/08/05 21:52:05
Done.
|
+ public: |
+ XmlDictReader(XmlReader* reader); |
Lei Zhang
2014/08/05 19:38:24
explicit
Kevin Bailey
2014/08/05 21:52:05
Done.
|
+ |
+ bool Read(); |
+ |
+ virtual bool ShouldLoop(); |
+ |
+ bool HandleKey(const std::string& key) { |
Lei Zhang
2014/08/05 19:38:24
please put non-trivial impls in the .cc files.
Kevin Bailey
2014/08/05 21:52:05
Done.
|
+ if (found_.find(key) != found_.end()) |
Lei Zhang
2014/08/05 19:38:24
Just call Found()?
Kevin Bailey
2014/08/05 21:52:05
Done.
|
+ return false; |
+ if (HandleKeyImpl(key)) { |
+ found_.insert(key); |
+ return true; |
+ } |
+ return false; |
+ } |
+ |
+ virtual bool HandleKeyImpl(const std::string& key) = 0; |
+ |
+ bool SkipToNext(); |
+ |
+ virtual bool FinishedOk(); |
+ virtual bool AllowRepeats(); |
+ |
+ bool Found(const std::string& key) { |
+ return found_.find(key) != found_.end(); |
Lei Zhang
2014/08/05 19:38:24
You can use ContainsKey() from base/stl_util.h.
Kevin Bailey
2014/08/05 21:52:05
Done.
|
+ } |
+ |
+ virtual ~XmlDictReader(); |
Lei Zhang
2014/08/05 19:38:24
Put the dtor next to the ctor?
Kevin Bailey
2014/08/05 21:52:05
Done.
|
+ |
+ protected: |
+ XmlReader* reader_; |
+ |
+ private: |
+ std::set<std::string> found_; |
+}; |
Lei Zhang
2014/08/05 19:38:24
DISALLOW_COPY_AND_ASSIGN(XmlDictReader);
Kevin Bailey
2014/08/05 21:52:05
Done.
|
+ |
} // namespace iapps |
#endif // CHROME_UTILITY_MEDIA_GALLERIES_IAPPS_XML_UTILS_H_ |