Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: base/pickle.h

Issue 27370: Update clipboard classes to use string16 and FilePath instead of wstring.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/clipboard_win.cc ('k') | base/pickle.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/string16.h"
12 #include "testing/gtest/include/gtest/gtest_prod.h" 13 #include "testing/gtest/include/gtest/gtest_prod.h"
13 14
14 // This class provides facilities for basic binary value packing and unpacking. 15 // This class provides facilities for basic binary value packing and unpacking.
15 // 16 //
16 // The Pickle class supports appending primitive values (ints, strings, etc.) 17 // The Pickle class supports appending primitive values (ints, strings, etc.)
17 // to a pickle instance. The Pickle instance grows its internal memory buffer 18 // to a pickle instance. The Pickle instance grows its internal memory buffer
18 // dynamically to hold the sequence of primitive values. The internal memory 19 // dynamically to hold the sequence of primitive values. The internal memory
19 // buffer is exposed as the "data" of the Pickle. This "data" can be passed 20 // buffer is exposed as the "data" of the Pickle. This "data" can be passed
20 // to a Pickle object to initialize it for reading. 21 // to a Pickle object to initialize it for reading.
21 // 22 //
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 // be extracted. 66 // be extracted.
66 bool ReadBool(void** iter, bool* result) const; 67 bool ReadBool(void** iter, bool* result) const;
67 bool ReadInt(void** iter, int* result) const; 68 bool ReadInt(void** iter, int* result) const;
68 bool ReadLong(void** iter, long* result) const; 69 bool ReadLong(void** iter, long* result) const;
69 bool ReadSize(void** iter, size_t* result) const; 70 bool ReadSize(void** iter, size_t* result) const;
70 bool ReadUInt32(void** iter, uint32* result) const; 71 bool ReadUInt32(void** iter, uint32* result) const;
71 bool ReadInt64(void** iter, int64* result) const; 72 bool ReadInt64(void** iter, int64* result) const;
72 bool ReadIntPtr(void** iter, intptr_t* result) const; 73 bool ReadIntPtr(void** iter, intptr_t* result) const;
73 bool ReadString(void** iter, std::string* result) const; 74 bool ReadString(void** iter, std::string* result) const;
74 bool ReadWString(void** iter, std::wstring* result) const; 75 bool ReadWString(void** iter, std::wstring* result) const;
76 bool ReadString16(void** iter, string16* result) const;
75 bool ReadData(void** iter, const char** data, int* length) const; 77 bool ReadData(void** iter, const char** data, int* length) const;
76 bool ReadBytes(void** iter, const char** data, int length) const; 78 bool ReadBytes(void** iter, const char** data, int length) const;
77 79
78 // Safer version of ReadInt() checks for the result not being negative. 80 // Safer version of ReadInt() checks for the result not being negative.
79 // Use it for reading the object sizes. 81 // Use it for reading the object sizes.
80 bool ReadLength(void** iter, int* result) const; 82 bool ReadLength(void** iter, int* result) const;
81 83
82 // Methods for adding to the payload of the Pickle. These values are 84 // Methods for adding to the payload of the Pickle. These values are
83 // appended to the end of the Pickle's payload. When reading values from a 85 // appended to the end of the Pickle's payload. When reading values from a
84 // Pickle, it is important to read them in the order in which they were added 86 // Pickle, it is important to read them in the order in which they were added
(...skipping 14 matching lines...) Expand all
99 return WriteBytes(&value, sizeof(value)); 101 return WriteBytes(&value, sizeof(value));
100 } 102 }
101 bool WriteInt64(int64 value) { 103 bool WriteInt64(int64 value) {
102 return WriteBytes(&value, sizeof(value)); 104 return WriteBytes(&value, sizeof(value));
103 } 105 }
104 bool WriteIntPtr(intptr_t value) { 106 bool WriteIntPtr(intptr_t value) {
105 return WriteBytes(&value, sizeof(value)); 107 return WriteBytes(&value, sizeof(value));
106 } 108 }
107 bool WriteString(const std::string& value); 109 bool WriteString(const std::string& value);
108 bool WriteWString(const std::wstring& value); 110 bool WriteWString(const std::wstring& value);
111 bool WriteString16(const string16& value);
109 bool WriteData(const char* data, int length); 112 bool WriteData(const char* data, int length);
110 bool WriteBytes(const void* data, int data_len); 113 bool WriteBytes(const void* data, int data_len);
111 114
112 // Same as WriteData, but allows the caller to write directly into the 115 // Same as WriteData, but allows the caller to write directly into the
113 // Pickle. This saves a copy in cases where the data is not already 116 // Pickle. This saves a copy in cases where the data is not already
114 // available in a buffer. The caller should take care to not write more 117 // available in a buffer. The caller should take care to not write more
115 // than the length it declares it will. Use ReadData to get the data. 118 // than the length it declares it will. Use ReadData to get the data.
116 // Returns NULL on failure. 119 // Returns NULL on failure.
117 // 120 //
118 // The returned pointer will only be valid until the next write operation 121 // The returned pointer will only be valid until the next write operation
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 size_t capacity_; 231 size_t capacity_;
229 size_t variable_buffer_offset_; // IF non-zero, then offset to a buffer. 232 size_t variable_buffer_offset_; // IF non-zero, then offset to a buffer.
230 233
231 FRIEND_TEST(PickleTest, Resize); 234 FRIEND_TEST(PickleTest, Resize);
232 FRIEND_TEST(PickleTest, FindNext); 235 FRIEND_TEST(PickleTest, FindNext);
233 FRIEND_TEST(PickleTest, IteratorHasRoom); 236 FRIEND_TEST(PickleTest, IteratorHasRoom);
234 }; 237 };
235 238
236 #endif // BASE_PICKLE_H__ 239 #endif // BASE_PICKLE_H__
237 240
OLDNEW
« no previous file with comments | « base/clipboard_win.cc ('k') | base/pickle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698