OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BASE_PICKLE_H__ | 5 #ifndef BASE_PICKLE_H__ |
6 #define BASE_PICKLE_H__ | 6 #define BASE_PICKLE_H__ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 // Methods for reading the payload of the Pickle. To read from the start of | 63 // Methods for reading the payload of the Pickle. To read from the start of |
64 // the Pickle, initialize *iter to NULL. If successful, these methods return | 64 // the Pickle, initialize *iter to NULL. If successful, these methods return |
65 // true. Otherwise, false is returned to indicate that the result could not | 65 // true. Otherwise, false is returned to indicate that the result could not |
66 // be extracted. | 66 // be extracted. |
67 bool ReadBool(void** iter, bool* result) const; | 67 bool ReadBool(void** iter, bool* result) const; |
68 bool ReadInt(void** iter, int* result) const; | 68 bool ReadInt(void** iter, int* result) const; |
69 bool ReadLong(void** iter, long* result) const; | 69 bool ReadLong(void** iter, long* result) const; |
70 bool ReadSize(void** iter, size_t* result) const; | 70 bool ReadSize(void** iter, size_t* result) const; |
71 bool ReadUInt32(void** iter, uint32* result) const; | 71 bool ReadUInt32(void** iter, uint32* result) const; |
72 bool ReadInt64(void** iter, int64* result) const; | 72 bool ReadInt64(void** iter, int64* result) const; |
| 73 bool ReadUInt64(void** iter, uint64* result) const; |
73 bool ReadIntPtr(void** iter, intptr_t* result) const; | 74 bool ReadIntPtr(void** iter, intptr_t* result) const; |
74 bool ReadString(void** iter, std::string* result) const; | 75 bool ReadString(void** iter, std::string* result) const; |
75 bool ReadWString(void** iter, std::wstring* result) const; | 76 bool ReadWString(void** iter, std::wstring* result) const; |
76 bool ReadString16(void** iter, string16* result) const; | 77 bool ReadString16(void** iter, string16* result) const; |
77 bool ReadData(void** iter, const char** data, int* length) const; | 78 bool ReadData(void** iter, const char** data, int* length) const; |
78 bool ReadBytes(void** iter, const char** data, int length) const; | 79 bool ReadBytes(void** iter, const char** data, int length) const; |
79 | 80 |
80 // Safer version of ReadInt() checks for the result not being negative. | 81 // Safer version of ReadInt() checks for the result not being negative. |
81 // Use it for reading the object sizes. | 82 // Use it for reading the object sizes. |
82 bool ReadLength(void** iter, int* result) const; | 83 bool ReadLength(void** iter, int* result) const; |
(...skipping 13 matching lines...) Expand all Loading... |
96 } | 97 } |
97 bool WriteSize(size_t value) { | 98 bool WriteSize(size_t value) { |
98 return WriteBytes(&value, sizeof(value)); | 99 return WriteBytes(&value, sizeof(value)); |
99 } | 100 } |
100 bool WriteUInt32(uint32 value) { | 101 bool WriteUInt32(uint32 value) { |
101 return WriteBytes(&value, sizeof(value)); | 102 return WriteBytes(&value, sizeof(value)); |
102 } | 103 } |
103 bool WriteInt64(int64 value) { | 104 bool WriteInt64(int64 value) { |
104 return WriteBytes(&value, sizeof(value)); | 105 return WriteBytes(&value, sizeof(value)); |
105 } | 106 } |
| 107 bool WriteUInt64(uint64 value) { |
| 108 return WriteBytes(&value, sizeof(value)); |
| 109 } |
106 bool WriteIntPtr(intptr_t value) { | 110 bool WriteIntPtr(intptr_t value) { |
107 return WriteBytes(&value, sizeof(value)); | 111 return WriteBytes(&value, sizeof(value)); |
108 } | 112 } |
109 bool WriteString(const std::string& value); | 113 bool WriteString(const std::string& value); |
110 bool WriteWString(const std::wstring& value); | 114 bool WriteWString(const std::wstring& value); |
111 bool WriteString16(const string16& value); | 115 bool WriteString16(const string16& value); |
112 bool WriteData(const char* data, int length); | 116 bool WriteData(const char* data, int length); |
113 bool WriteBytes(const void* data, int data_len); | 117 bool WriteBytes(const void* data, int data_len); |
114 | 118 |
115 // Same as WriteData, but allows the caller to write directly into the | 119 // Same as WriteData, but allows the caller to write directly into the |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 // Allocation size of payload (or -1 if allocation is const). | 234 // Allocation size of payload (or -1 if allocation is const). |
231 size_t capacity_; | 235 size_t capacity_; |
232 size_t variable_buffer_offset_; // IF non-zero, then offset to a buffer. | 236 size_t variable_buffer_offset_; // IF non-zero, then offset to a buffer. |
233 | 237 |
234 FRIEND_TEST(PickleTest, Resize); | 238 FRIEND_TEST(PickleTest, Resize); |
235 FRIEND_TEST(PickleTest, FindNext); | 239 FRIEND_TEST(PickleTest, FindNext); |
236 FRIEND_TEST(PickleTest, IteratorHasRoom); | 240 FRIEND_TEST(PickleTest, IteratorHasRoom); |
237 }; | 241 }; |
238 | 242 |
239 #endif // BASE_PICKLE_H__ | 243 #endif // BASE_PICKLE_H__ |
OLD | NEW |