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 virtual ~FileMetadataParser(); 25 26 // Implementation of MetadataParser 27 virtual bool Parse(); 28 virtual bool GetProperty(const std::string& key, std::string* value); 29 30 virtual MetadataPropertyIterator* GetPropertyIterator(); 31 32 protected: 33 PropertyMap properties_; 34 FilePath path_; 35 36 private: 37 DISALLOW_COPY_AND_ASSIGN(FileMetadataParser); 38}; 39 40class FileMetadataPropertyIterator : public MetadataPropertyIterator { 41 public: 42 explicit FileMetadataPropertyIterator(PropertyMap& properties); 43 44 virtual ~FileMetadataPropertyIterator(); 45 46 // Implementation of MetadataPropertyIterator 47 virtual bool GetNext(std::string* key, std::string* value); 48 virtual int Length(); 49 virtual bool IsEnd(); 50 51 private: 52 PropertyMap& properties_; 53 PropertyMap::iterator it; 54 55 DISALLOW_COPY_AND_ASSIGN(FileMetadataPropertyIterator); 56}; 57 58#endif // CHROME_BROWSER_PARSERS_METADATA_PARSER_FILEBASE_H_ 59