| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/base_export.h" | 10 #include "base/base_export.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 // methods return true. Otherwise, false is returned to indicate that the | 28 // methods return true. Otherwise, false is returned to indicate that the |
| 29 // result could not be extracted. It is not possible to read from iterator | 29 // result could not be extracted. It is not possible to read from iterator |
| 30 // after that. | 30 // after that. |
| 31 bool ReadBool(bool* result) WARN_UNUSED_RESULT; | 31 bool ReadBool(bool* result) WARN_UNUSED_RESULT; |
| 32 bool ReadInt(int* result) WARN_UNUSED_RESULT; | 32 bool ReadInt(int* result) WARN_UNUSED_RESULT; |
| 33 bool ReadLong(long* result) WARN_UNUSED_RESULT; | 33 bool ReadLong(long* result) WARN_UNUSED_RESULT; |
| 34 bool ReadUInt16(uint16* result) WARN_UNUSED_RESULT; | 34 bool ReadUInt16(uint16* result) WARN_UNUSED_RESULT; |
| 35 bool ReadUInt32(uint32* result) WARN_UNUSED_RESULT; | 35 bool ReadUInt32(uint32* result) WARN_UNUSED_RESULT; |
| 36 bool ReadInt64(int64* result) WARN_UNUSED_RESULT; | 36 bool ReadInt64(int64* result) WARN_UNUSED_RESULT; |
| 37 bool ReadUInt64(uint64* result) WARN_UNUSED_RESULT; | 37 bool ReadUInt64(uint64* result) WARN_UNUSED_RESULT; |
| 38 bool ReadSizeT(size_t* result) WARN_UNUSED_RESULT; |
| 38 bool ReadFloat(float* result) WARN_UNUSED_RESULT; | 39 bool ReadFloat(float* result) WARN_UNUSED_RESULT; |
| 39 bool ReadDouble(double* result) WARN_UNUSED_RESULT; | 40 bool ReadDouble(double* result) WARN_UNUSED_RESULT; |
| 40 bool ReadString(std::string* result) WARN_UNUSED_RESULT; | 41 bool ReadString(std::string* result) WARN_UNUSED_RESULT; |
| 41 bool ReadWString(std::wstring* result) WARN_UNUSED_RESULT; | 42 bool ReadWString(std::wstring* result) WARN_UNUSED_RESULT; |
| 42 bool ReadString16(base::string16* result) WARN_UNUSED_RESULT; | 43 bool ReadString16(base::string16* result) WARN_UNUSED_RESULT; |
| 43 bool ReadData(const char** data, int* length) WARN_UNUSED_RESULT; | 44 bool ReadData(const char** data, int* length) WARN_UNUSED_RESULT; |
| 44 bool ReadBytes(const char** data, int length) WARN_UNUSED_RESULT; | 45 bool ReadBytes(const char** data, int length) WARN_UNUSED_RESULT; |
| 45 | 46 |
| 46 // Safer version of ReadInt() checks for the result not being negative. | 47 // Safer version of ReadInt() checks for the result not being negative. |
| 47 // Use it for reading the object sizes. | 48 // Use it for reading the object sizes. |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 return iter->ReadUInt32(result); | 166 return iter->ReadUInt32(result); |
| 166 } | 167 } |
| 167 bool ReadInt64(PickleIterator* iter, | 168 bool ReadInt64(PickleIterator* iter, |
| 168 int64* result) const WARN_UNUSED_RESULT { | 169 int64* result) const WARN_UNUSED_RESULT { |
| 169 return iter->ReadInt64(result); | 170 return iter->ReadInt64(result); |
| 170 } | 171 } |
| 171 bool ReadUInt64(PickleIterator* iter, | 172 bool ReadUInt64(PickleIterator* iter, |
| 172 uint64* result) const WARN_UNUSED_RESULT { | 173 uint64* result) const WARN_UNUSED_RESULT { |
| 173 return iter->ReadUInt64(result); | 174 return iter->ReadUInt64(result); |
| 174 } | 175 } |
| 176 bool ReadSizeT(PickleIterator* iter, |
| 177 size_t* result) const WARN_UNUSED_RESULT { |
| 178 return iter->ReadSizeT(result); |
| 179 } |
| 175 bool ReadFloat(PickleIterator* iter, | 180 bool ReadFloat(PickleIterator* iter, |
| 176 float* result) const WARN_UNUSED_RESULT { | 181 float* result) const WARN_UNUSED_RESULT { |
| 177 return iter->ReadFloat(result); | 182 return iter->ReadFloat(result); |
| 178 } | 183 } |
| 179 bool ReadDouble(PickleIterator* iter, | 184 bool ReadDouble(PickleIterator* iter, |
| 180 double* result) const WARN_UNUSED_RESULT { | 185 double* result) const WARN_UNUSED_RESULT { |
| 181 return iter->ReadDouble(result); | 186 return iter->ReadDouble(result); |
| 182 } | 187 } |
| 183 bool ReadString(PickleIterator* iter, | 188 bool ReadString(PickleIterator* iter, |
| 184 std::string* result) const WARN_UNUSED_RESULT { | 189 std::string* result) const WARN_UNUSED_RESULT { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 } | 246 } |
| 242 bool WriteUInt32(uint32 value) { | 247 bool WriteUInt32(uint32 value) { |
| 243 return WritePOD(value); | 248 return WritePOD(value); |
| 244 } | 249 } |
| 245 bool WriteInt64(int64 value) { | 250 bool WriteInt64(int64 value) { |
| 246 return WritePOD(value); | 251 return WritePOD(value); |
| 247 } | 252 } |
| 248 bool WriteUInt64(uint64 value) { | 253 bool WriteUInt64(uint64 value) { |
| 249 return WritePOD(value); | 254 return WritePOD(value); |
| 250 } | 255 } |
| 256 bool WriteSizeT(size_t value) { |
| 257 // Always write size_t as a 64-bit value to ensure compatibility between |
| 258 // 32-bit and 64-bit processes. |
| 259 return WritePOD(static_cast<uint64>(value)); |
| 260 } |
| 251 bool WriteFloat(float value) { | 261 bool WriteFloat(float value) { |
| 252 return WritePOD(value); | 262 return WritePOD(value); |
| 253 } | 263 } |
| 254 bool WriteDouble(double value) { | 264 bool WriteDouble(double value) { |
| 255 return WritePOD(value); | 265 return WritePOD(value); |
| 256 } | 266 } |
| 257 bool WriteString(const std::string& value); | 267 bool WriteString(const std::string& value); |
| 258 bool WriteWString(const std::wstring& value); | 268 bool WriteWString(const std::wstring& value); |
| 259 bool WriteString16(const base::string16& value); | 269 bool WriteString16(const base::string16& value); |
| 260 // "Data" is a blob with a length. When you read it out you will be given the | 270 // "Data" is a blob with a length. When you read it out you will be given the |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 } | 364 } |
| 355 inline void WriteBytesCommon(const void* data, size_t length); | 365 inline void WriteBytesCommon(const void* data, size_t length); |
| 356 | 366 |
| 357 FRIEND_TEST_ALL_PREFIXES(PickleTest, Resize); | 367 FRIEND_TEST_ALL_PREFIXES(PickleTest, Resize); |
| 358 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNext); | 368 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNext); |
| 359 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNextWithIncompleteHeader); | 369 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNextWithIncompleteHeader); |
| 360 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNextOverflow); | 370 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNextOverflow); |
| 361 }; | 371 }; |
| 362 | 372 |
| 363 #endif // BASE_PICKLE_H__ | 373 #endif // BASE_PICKLE_H__ |
| OLD | NEW |