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..2a23d2533d951ad22857f9522fbea3f6a54827a3 |
| --- /dev/null |
| +++ b/webkit/fileapi/media/picasa/pmp_column_reader.h |
| @@ -0,0 +1,69 @@ |
| +// 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 { |
| + |
| +// Reads a single PMP column from a file. |
| +class WEBKIT_STORAGE_EXPORT_PRIVATE PmpColumnReader { |
| + public: |
| + explicit PmpColumnReader(std::string column_name); |
|
vandebo (ex-Chrome)
2013/03/28 00:56:04
should column_name be part of the Init method?
tommycli
2013/03/29 00:16:01
Done.
|
| + virtual ~PmpColumnReader(); |
| + |
| + // Returns true if read successfully. |rows_read| undefined if returns false. |
| + bool ReadFromFile(const base::FilePath& filepath, uint32* rows_read); |
|
vandebo (ex-Chrome)
2013/03/28 00:56:04
nit: InitFromFile ?
tommycli
2013/03/29 00:16:01
Done.
|
| + |
| + // These functions read the value of that row into the |result| variable. |
| + // Function returns 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; |
| + |
| + const std::string column_name() const { |
|
vandebo (ex-Chrome)
2013/03/28 00:56:04
Do you use this? If not, you can probably just re
tommycli
2013/03/29 00:16:01
Done.
|
| + 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(). |
|
vandebo (ex-Chrome)
2013/03/28 00:56:04
nit: outdated comment. Probably not needed anyway
tommycli
2013/03/29 00:16:01
Done.
|
| + bool ParseData(uint32* rows_read); |
| + bool IndexStrings(); |
| + template<class T> bool ValidatePrimitiveArrayLength(); |
| + |
| + 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_; |
| + |
| + // Store type of field |
| + uint16 fieldtype_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PmpColumnReader); |
| +}; |
| + |
| +} // namespace fileapi |
| + |
| +#endif // WEBKIT_FILEAPI_MEDIA_PICASA_PMP_COLUMN_READER_H_ |