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