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

Unified 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: Add missing include Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: webkit/fileapi/media/picasa/pmp_column_reader.h
diff --git a/webkit/fileapi/media/picasa/pmp_column_reader.h b/webkit/fileapi/media/picasa/pmp_column_reader.h
new file mode 100644
index 0000000000000000000000000000000000000000..e6f652354bd58effc36a727baf9359bae19af2a3
--- /dev/null
+++ b/webkit/fileapi/media/picasa/pmp_column_reader.h
@@ -0,0 +1,66 @@
+// Copyright 2013 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 WEBKIT_FILEAPI_MEDIA_PICASA_PMP_COLUMN_READER_H_
+#define WEBKIT_FILEAPI_MEDIA_PICASA_PMP_COLUMN_READER_H_
+
+#include <string>
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
+#include "webkit/storage/webkit_storage_export.h"
+
+namespace base {
+class FilePath;
+}
+
+namespace picasaimport {
+
+// Reads a single PMP column from a file.
+class WEBKIT_STORAGE_EXPORT_PRIVATE PmpColumnReader {
+ public:
+ PmpColumnReader();
+ virtual ~PmpColumnReader();
+
+ // Returns true if read successfully.
+ // |rows_read| is undefined if returns false.
+ bool Init(const base::FilePath& filepath, uint32* rows_read);
+
+ // These functions read the value of that |row| into |result|.
+ // Functions return false if the column is of the wrong type or the row
+ // is out of range.
+ bool ReadString(const uint32 row, std::string* result) const;
+ bool ReadUInt32(const uint32 row, uint32* result) const;
+ bool ReadDouble64(const uint32 row, double* result) const;
+ bool ReadUInt8(const uint32 row, uint8* result) const;
+ bool ReadUInt64(const uint32 row, uint64* result) const;
+
+ // Returns the native encoding of field_type.
+ uint16 field_type() const {
vandebo (ex-Chrome) 2013/04/05 18:52:47 Shouldn't this return a PmpFieldType ?
tommycli 2013/04/05 20:06:44 Done.
+ return field_type_;
+ }
+
+ private:
+ bool ParseData(uint32* rows_read);
+ // Returns the number of bytes parsed in the body, or, -1 on failure.
+ long IndexStrings();
+
+ // Source data
+ scoped_array<uint8> data_;
+ size_t length_;
+
+ // Header data
+ uint16 field_type_;
vandebo (ex-Chrome) 2013/04/05 18:52:47 And similarly store one?
tommycli 2013/04/05 20:06:44 Done.
+ uint32 rows_;
+
+ // Index of string start locations if fields are strings. Empty otherwise.
+ std::vector<const char*> strings_;
+
+ DISALLOW_COPY_AND_ASSIGN(PmpColumnReader);
+};
+
+} // namespace picasaimport
+
+#endif // WEBKIT_FILEAPI_MEDIA_PICASA_PMP_COLUMN_READER_H_

Powered by Google App Engine
This is Rietveld 408576698