summaryrefslogtreecommitdiffstats
path: root/chrome/browser/parsers/metadata_parser.h
blob: 97a4e8557a8056455be5eb1c2b8bf69763928d43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_METADATA_PARSER_H_
#define CHROME_BROWSER_METADATA_PARSER_H_

#include <string>

#include "base/file_path.h"

// Allows for Iteration on the Properties of a given file.
class MetadataPropertyIterator {
 public:
  MetadataPropertyIterator() {}

  // Gets the next Property in the iterator.  Returns false if at the end
  // of the list.
  virtual bool GetNext(std::string* key, std::string* value) = 0;

  // Gets the number of Properties in this iterator.
  virtual int Length() = 0;

  // Checks to see if we're at the end of the list.
  virtual bool IsEnd() = 0;
};

// Represents a single instance of parsing on a particular file.
class MetadataParser {
 public:
  MetadataParser(const FilePath& path) {}

  static const char* kPropertyType;
  static const char* kPropertyFilesize;
  static const char* kPropertyTitle;

  // Does all the heavy work of parsing out the file. Blocking until complete.
  virtual bool Parse() = 0;

  // Gets a particular property found in a parse call.
  virtual bool GetProperty(const std::string& key, std::string* value) = 0;

  // Gets an interator allowing you to iterate over all the properties found
  // in a parse call.
  virtual MetadataPropertyIterator* GetPropertyIterator() = 0;
};

#endif  // CHROME_BROWSER-METADATA_PARSER_H_