| 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 18 matching lines...) Expand all Loading... |
| 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 ReadFloat(float* result) WARN_UNUSED_RESULT; | 38 bool ReadFloat(float* result) WARN_UNUSED_RESULT; |
| 39 bool ReadDouble(double* result) WARN_UNUSED_RESULT; |
| 39 bool ReadString(std::string* result) WARN_UNUSED_RESULT; | 40 bool ReadString(std::string* result) WARN_UNUSED_RESULT; |
| 40 bool ReadWString(std::wstring* result) WARN_UNUSED_RESULT; | 41 bool ReadWString(std::wstring* result) WARN_UNUSED_RESULT; |
| 41 bool ReadString16(base::string16* result) WARN_UNUSED_RESULT; | 42 bool ReadString16(base::string16* result) WARN_UNUSED_RESULT; |
| 42 bool ReadData(const char** data, int* length) WARN_UNUSED_RESULT; | 43 bool ReadData(const char** data, int* length) WARN_UNUSED_RESULT; |
| 43 bool ReadBytes(const char** data, int length) WARN_UNUSED_RESULT; | 44 bool ReadBytes(const char** data, int length) WARN_UNUSED_RESULT; |
| 44 | 45 |
| 45 // Safer version of ReadInt() checks for the result not being negative. | 46 // Safer version of ReadInt() checks for the result not being negative. |
| 46 // Use it for reading the object sizes. | 47 // Use it for reading the object sizes. |
| 47 bool ReadLength(int* result) WARN_UNUSED_RESULT { | 48 bool ReadLength(int* result) WARN_UNUSED_RESULT { |
| 48 return ReadInt(result) && *result >= 0; | 49 return ReadInt(result) && *result >= 0; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 return iter->ReadInt64(result); | 169 return iter->ReadInt64(result); |
| 169 } | 170 } |
| 170 bool ReadUInt64(PickleIterator* iter, | 171 bool ReadUInt64(PickleIterator* iter, |
| 171 uint64* result) const WARN_UNUSED_RESULT { | 172 uint64* result) const WARN_UNUSED_RESULT { |
| 172 return iter->ReadUInt64(result); | 173 return iter->ReadUInt64(result); |
| 173 } | 174 } |
| 174 bool ReadFloat(PickleIterator* iter, | 175 bool ReadFloat(PickleIterator* iter, |
| 175 float* result) const WARN_UNUSED_RESULT { | 176 float* result) const WARN_UNUSED_RESULT { |
| 176 return iter->ReadFloat(result); | 177 return iter->ReadFloat(result); |
| 177 } | 178 } |
| 179 bool ReadDouble(PickleIterator* iter, |
| 180 double* result) const WARN_UNUSED_RESULT { |
| 181 return iter->ReadDouble(result); |
| 182 } |
| 178 bool ReadString(PickleIterator* iter, | 183 bool ReadString(PickleIterator* iter, |
| 179 std::string* result) const WARN_UNUSED_RESULT { | 184 std::string* result) const WARN_UNUSED_RESULT { |
| 180 return iter->ReadString(result); | 185 return iter->ReadString(result); |
| 181 } | 186 } |
| 182 bool ReadWString(PickleIterator* iter, | 187 bool ReadWString(PickleIterator* iter, |
| 183 std::wstring* result) const WARN_UNUSED_RESULT { | 188 std::wstring* result) const WARN_UNUSED_RESULT { |
| 184 return iter->ReadWString(result); | 189 return iter->ReadWString(result); |
| 185 } | 190 } |
| 186 bool ReadString16(PickleIterator* iter, | 191 bool ReadString16(PickleIterator* iter, |
| 187 base::string16* result) const WARN_UNUSED_RESULT { | 192 base::string16* result) const WARN_UNUSED_RESULT { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 } | 244 } |
| 240 bool WriteInt64(int64 value) { | 245 bool WriteInt64(int64 value) { |
| 241 return WritePOD(value); | 246 return WritePOD(value); |
| 242 } | 247 } |
| 243 bool WriteUInt64(uint64 value) { | 248 bool WriteUInt64(uint64 value) { |
| 244 return WritePOD(value); | 249 return WritePOD(value); |
| 245 } | 250 } |
| 246 bool WriteFloat(float value) { | 251 bool WriteFloat(float value) { |
| 247 return WritePOD(value); | 252 return WritePOD(value); |
| 248 } | 253 } |
| 254 bool WriteDouble(double value) { |
| 255 return WritePOD(value); |
| 256 } |
| 249 bool WriteString(const std::string& value); | 257 bool WriteString(const std::string& value); |
| 250 bool WriteWString(const std::wstring& value); | 258 bool WriteWString(const std::wstring& value); |
| 251 bool WriteString16(const base::string16& value); | 259 bool WriteString16(const base::string16& value); |
| 252 // "Data" is a blob with a length. When you read it out you will be given the | 260 // "Data" is a blob with a length. When you read it out you will be given the |
| 253 // length. See also WriteBytes. | 261 // length. See also WriteBytes. |
| 254 bool WriteData(const char* data, int length); | 262 bool WriteData(const char* data, int length); |
| 255 // "Bytes" is a blob with no length. The caller must specify the length both | 263 // "Bytes" is a blob with no length. The caller must specify the length both |
| 256 // when reading and writing. It is normally used to serialize PoD types of a | 264 // when reading and writing. It is normally used to serialize PoD types of a |
| 257 // known size. See also WriteData. | 265 // known size. See also WriteData. |
| 258 bool WriteBytes(const void* data, int length); | 266 bool WriteBytes(const void* data, int length); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 } | 354 } |
| 347 inline void WriteBytesCommon(const void* data, size_t length); | 355 inline void WriteBytesCommon(const void* data, size_t length); |
| 348 | 356 |
| 349 FRIEND_TEST_ALL_PREFIXES(PickleTest, Resize); | 357 FRIEND_TEST_ALL_PREFIXES(PickleTest, Resize); |
| 350 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNext); | 358 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNext); |
| 351 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNextWithIncompleteHeader); | 359 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNextWithIncompleteHeader); |
| 352 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNextOverflow); | 360 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNextOverflow); |
| 353 }; | 361 }; |
| 354 | 362 |
| 355 #endif // BASE_PICKLE_H__ | 363 #endif // BASE_PICKLE_H__ |
| OLD | NEW |