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

Unified Diff: chrome/utility/media_galleries/iapps_xml_utils.h

Issue 436293002: Created helper class for parsing Apple style XML dictionaries. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Converted IPhotoLibraryParser Created 6 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 side-by-side diff with in-line comments
Download patch
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_
« no previous file with comments | « no previous file | chrome/utility/media_galleries/iapps_xml_utils.cc » ('j') | chrome/utility/media_galleries/iapps_xml_utils.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698