1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_PARSERS_METADATA_PARSER_FILEBASE_H_ 6 #define CHROME_BROWSER_PARSERS_METADATA_PARSER_FILEBASE_H_ 7 8 #include <string> 9 10 #include "base/basictypes.h" 11 #include "base/containers/hash_tables.h" 12 #include "base/files/file_path.h" 13 #include "chrome/browser/parsers/metadata_parser.h" 14 15 typedef base::hash_map<std::string, std::string> PropertyMap; 16 17 // Parser for the file type. Allows for parsing of files, and gets 18 // properties associated with files. 19 class FileMetadataParser : public MetadataParser { 20 public: 21 explicit FileMetadataParser(const base::FilePath& path); 22 23 virtual ~FileMetadataParser(); 24 25 // Implementation of MetadataParser 26 virtual bool Parse() OVERRIDE; 27 virtual bool GetProperty(const std::string& key, std::string* value) OVERRIDE; 28 29 virtual MetadataPropertyIterator* GetPropertyIterator() OVERRIDE; 30 31 protected: 32 PropertyMap properties_; 33 base::FilePath path_; 34 35 private: 36 DISALLOW_COPY_AND_ASSIGN(FileMetadataParser); 37 }; 38 39 class FileMetadataPropertyIterator : public MetadataPropertyIterator { 40 public: 41 explicit FileMetadataPropertyIterator(PropertyMap& properties); 42 43 virtual ~FileMetadataPropertyIterator(); 44 45 // Implementation of MetadataPropertyIterator 46 virtual bool GetNext(std::string* key, std::string* value) OVERRIDE; 47 virtual int Length() OVERRIDE; 48 virtual bool IsEnd() OVERRIDE; 49 50 private: 51 PropertyMap& properties_; 52 PropertyMap::iterator it; 53 54 DISALLOW_COPY_AND_ASSIGN(FileMetadataPropertyIterator); 55 }; 56 57 #endif // CHROME_BROWSER_PARSERS_METADATA_PARSER_FILEBASE_H_ 58