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