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.
5 #ifndef CHROME_BROWSER_PARSERS_METADATA_PARSER_FILEBASE_H_
6 #define CHROME_BROWSER_PARSERS_METADATA_PARSER_FILEBASE_H_
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"
15 typedef base::hash_map
<std::string
, std::string
> PropertyMap
;
17 // Parser for the file type. Allows for parsing of files, and gets
18 // properties associated with files.
19 class FileMetadataParser
: public MetadataParser
{
21 explicit FileMetadataParser(const base::FilePath
& path
);
23 virtual ~FileMetadataParser();
25 // Implementation of MetadataParser
26 virtual bool Parse() OVERRIDE
;
27 virtual bool GetProperty(const std::string
& key
, std::string
* value
) OVERRIDE
;
29 virtual MetadataPropertyIterator
* GetPropertyIterator() OVERRIDE
;
32 PropertyMap properties_
;
36 DISALLOW_COPY_AND_ASSIGN(FileMetadataParser
);
39 class FileMetadataPropertyIterator
: public MetadataPropertyIterator
{
41 explicit FileMetadataPropertyIterator(PropertyMap
& properties
);
43 virtual ~FileMetadataPropertyIterator();
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
;
51 PropertyMap
& properties_
;
52 PropertyMap::iterator it
;
54 DISALLOW_COPY_AND_ASSIGN(FileMetadataPropertyIterator
);
57 #endif // CHROME_BROWSER_PARSERS_METADATA_PARSER_FILEBASE_H_