Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 // Reads a single PMP column from a file. | |
| 22 class WEBKIT_STORAGE_EXPORT_PRIVATE PmpColumnReader { | |
| 23 public: | |
| 24 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.
| |
| 25 virtual ~PmpColumnReader(); | |
| 26 | |
| 27 // Returns true if read successfully. |rows_read| undefined if returns false. | |
| 28 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.
| |
| 29 | |
| 30 // These functions read the value of that row into the |result| variable. | |
| 31 // Function returns false if the column is of the wrong type or the row | |
| 32 // is out of range. | |
| 33 bool ReadString(const uint32 row, std::string* result) const; | |
| 34 bool ReadUInt32(const uint32 row, uint32* result) const; | |
| 35 bool ReadDouble64(const uint32 row, double* result) const; | |
| 36 bool ReadUInt8(const uint32 row, uint8* result) const; | |
| 37 bool ReadUInt64(const uint32 row, uint64* result) const; | |
| 38 | |
| 39 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.
| |
| 40 return column_name_; | |
| 41 } | |
| 42 | |
| 43 private: | |
| 44 // Private template method to support all the numeric Read*() methods. | |
| 45 template<class T> bool ReadPrimitive(const uint32 row, T* target) const; | |
| 46 | |
| 47 // 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.
| |
| 48 bool ParseData(uint32* rows_read); | |
| 49 bool IndexStrings(); | |
| 50 template<class T> bool ValidatePrimitiveArrayLength(); | |
| 51 | |
| 52 const std::string column_name_; | |
| 53 | |
| 54 scoped_array<uint8> data_; | |
| 55 size_t length_; | |
| 56 uint32 rows_; | |
| 57 | |
| 58 // Index of string start locations if fields are strings. Empty otherwise. | |
| 59 std::vector<const char*> strings_; | |
| 60 | |
| 61 // Store type of field | |
| 62 uint16 fieldtype_; | |
| 63 | |
| 64 DISALLOW_COPY_AND_ASSIGN(PmpColumnReader); | |
| 65 }; | |
| 66 | |
| 67 } // namespace fileapi | |
| 68 | |
| 69 #endif // WEBKIT_FILEAPI_MEDIA_PICASA_PMP_COLUMN_READER_H_ | |
| OLD | NEW |