Home | History | Annotate | Download | only in parsers
      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_H_
      6 #define CHROME_BROWSER_PARSERS_METADATA_PARSER_H_
      7 
      8 #include <string>
      9 
     10 namespace base {
     11 class FilePath;
     12 }
     13 
     14 // Allows for Iteration on the Properties of a given file.
     15 class MetadataPropertyIterator {
     16  public:
     17   MetadataPropertyIterator() {}
     18   virtual ~MetadataPropertyIterator() {}
     19 
     20 
     21   // Gets the next Property in the iterator.  Returns false if at the end
     22   // of the list.
     23   virtual bool GetNext(std::string* key, std::string* value) = 0;
     24 
     25   // Gets the number of Properties in this iterator.
     26   virtual int Length() = 0;
     27 
     28   // Checks to see if we're at the end of the list.
     29   virtual bool IsEnd() = 0;
     30 };
     31 
     32 // Represents a single instance of parsing on a particular file.
     33 class MetadataParser {
     34  public:
     35   explicit MetadataParser(const base::FilePath& path) {}
     36   virtual ~MetadataParser() {}
     37 
     38 
     39   static const char* kPropertyType;
     40   static const char* kPropertyFilesize;
     41   static const char* kPropertyTitle;
     42 
     43   // Does all the heavy work of parsing out the file. Blocking until complete.
     44   virtual bool Parse() = 0;
     45 
     46   // Gets a particular property found in a parse call.
     47   virtual bool GetProperty(const std::string& key, std::string* value) = 0;
     48 
     49   // Gets an interator allowing you to iterate over all the properties found
     50   // in a parse call.
     51   virtual MetadataPropertyIterator* GetPropertyIterator() = 0;
     52 };
     53 
     54 #endif  // CHROME_BROWSER_PARSERS_METADATA_PARSER_H_
     55