Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: webkit/fileapi/media/picasa/pmp_column_reader.h

Issue 12704024: Simple PMP reader to parse Picasa's metadata (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More formatting/ style changes. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2013 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 WEBKIT_FILEAPI_MEDIA_PICASA_PMP_COLUMN_READER_H_
6 #define WEBKIT_FILEAPI_MEDIA_PICASA_PMP_COLUMN_READER_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "webkit/storage/webkit_storage_export.h"
14
15 namespace base {
16 class FilePath;
17 }
18
19 namespace fileapi {
20
21 // Parses a PMP bytestream from either a file or directly from memory.
vandebo (ex-Chrome) 2013/03/27 00:06:19 nit: update or remove comment.
tommycli 2013/03/27 19:34:30 Done.
22 class WEBKIT_STORAGE_EXPORT_PRIVATE PmpColumnReader {
23 public:
24 explicit PmpColumnReader(std::string column_name);
25 virtual ~PmpColumnReader();
26
27 // Returns true if read successfully. |rows_read| undefined if returns false.
28 bool ReadFromMemory(uint32* rows_read, const uint8* data, const size_t len);
vandebo (ex-Chrome) 2013/03/27 00:06:19 output paramaters should go at the end of the list
tommycli 2013/03/27 19:34:30 Number of rows is defined as a uint32. We will run
29
30 // Family of functions to read fields.
vandebo (ex-Chrome) 2013/03/27 00:06:19 A bit more description wouldn't hurt here. Only o
tommycli 2013/03/27 19:34:30 Done.
31 bool ReadString(const uint32 row, std::string* target) const;
32 bool ReadUInt32(const uint32 row, uint32* target) const;
33 bool ReadDouble64(const uint32 row, double* target) const;
34 bool ReadUInt8(const uint32 row, uint8* target) const;
35 bool ReadUInt64(const uint32 row, uint64* target) const;
36
37 const std::string column_name() const {
38 return column_name_;
39 }
40
41 private:
42 // Private template method to support all the numeric Read*() methods.
43 template<class T> bool ReadPrimitive(const uint32 row, T* target) const;
44
45 // Only called from ReadFromMemory().
46 bool ParseData(uint32* rows_read);
47 bool IndexStrings();
48 template<class T> bool SetAndValidateFieldsize();
49
50 const std::string column_name_;
51
52 scoped_array<uint8> data_;
53 size_t length_;
54 uint32 rows_;
55
56 // Index of string start locations if fields are strings. Empty otherwise.
57 std::vector<const char*> strings_;
58
59 // Size in bytes of each field. This is for validation of Read requests.
60 // |fieldsize_| is -1 for uninitialized cases or string field types.
61 int fieldsize_;
62
63 DISALLOW_COPY_AND_ASSIGN(PmpColumnReader);
64 };
65
66 } // namespace fileapi
67
68 #endif // WEBKIT_FILEAPI_MEDIA_PICASA_PMP_COLUMN_READER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698