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