Chromium Code Reviews| 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..a8c27d6d09aca996624f67d3a72c91512fe16ad7 |
| --- /dev/null |
| +++ b/webkit/fileapi/media/picasa/pmp_column_reader.h |
| @@ -0,0 +1,68 @@ |
| +// 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 fileapi { |
| + |
| +// 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.
|
| +class WEBKIT_STORAGE_EXPORT_PRIVATE PmpColumnReader { |
| + public: |
| + explicit PmpColumnReader(std::string column_name); |
| + virtual ~PmpColumnReader(); |
| + |
| + // Returns true if read successfully. |rows_read| undefined if returns false. |
| + 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
|
| + |
| + // 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.
|
| + bool ReadString(const uint32 row, std::string* target) const; |
| + bool ReadUInt32(const uint32 row, uint32* target) const; |
| + bool ReadDouble64(const uint32 row, double* target) const; |
| + bool ReadUInt8(const uint32 row, uint8* target) const; |
| + bool ReadUInt64(const uint32 row, uint64* target) const; |
| + |
| + const std::string column_name() const { |
| + return column_name_; |
| + } |
| + |
| + private: |
| + // Private template method to support all the numeric Read*() methods. |
| + template<class T> bool ReadPrimitive(const uint32 row, T* target) const; |
| + |
| + // Only called from ReadFromMemory(). |
| + bool ParseData(uint32* rows_read); |
| + bool IndexStrings(); |
| + template<class T> bool SetAndValidateFieldsize(); |
| + |
| + const std::string column_name_; |
| + |
| + scoped_array<uint8> data_; |
| + size_t length_; |
| + uint32 rows_; |
| + |
| + // Index of string start locations if fields are strings. Empty otherwise. |
| + std::vector<const char*> strings_; |
| + |
| + // Size in bytes of each field. This is for validation of Read requests. |
| + // |fieldsize_| is -1 for uninitialized cases or string field types. |
| + int fieldsize_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PmpColumnReader); |
| +}; |
| + |
| +} // namespace fileapi |
| + |
| +#endif // WEBKIT_FILEAPI_MEDIA_PICASA_PMP_COLUMN_READER_H_ |