OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/base_api.h" | 11 #include "base/base_export.h" |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/string16.h" | 15 #include "base/string16.h" |
16 | 16 |
17 // This class provides facilities for basic binary value packing and unpacking. | 17 // This class provides facilities for basic binary value packing and unpacking. |
18 // | 18 // |
19 // The Pickle class supports appending primitive values (ints, strings, etc.) | 19 // The Pickle class supports appending primitive values (ints, strings, etc.) |
20 // to a pickle instance. The Pickle instance grows its internal memory buffer | 20 // to a pickle instance. The Pickle instance grows its internal memory buffer |
21 // dynamically to hold the sequence of primitive values. The internal memory | 21 // dynamically to hold the sequence of primitive values. The internal memory |
22 // buffer is exposed as the "data" of the Pickle. This "data" can be passed | 22 // buffer is exposed as the "data" of the Pickle. This "data" can be passed |
23 // to a Pickle object to initialize it for reading. | 23 // to a Pickle object to initialize it for reading. |
24 // | 24 // |
25 // When reading from a Pickle object, it is important for the consumer to know | 25 // When reading from a Pickle object, it is important for the consumer to know |
26 // what value types to read and in what order to read them as the Pickle does | 26 // what value types to read and in what order to read them as the Pickle does |
27 // not keep track of the type of data written to it. | 27 // not keep track of the type of data written to it. |
28 // | 28 // |
29 // The Pickle's data has a header which contains the size of the Pickle's | 29 // The Pickle's data has a header which contains the size of the Pickle's |
30 // payload. It can optionally support additional space in the header. That | 30 // payload. It can optionally support additional space in the header. That |
31 // space is controlled by the header_size parameter passed to the Pickle | 31 // space is controlled by the header_size parameter passed to the Pickle |
32 // constructor. | 32 // constructor. |
33 // | 33 // |
34 class BASE_API Pickle { | 34 class BASE_EXPORT Pickle { |
35 public: | 35 public: |
36 // Initialize a Pickle object using the default header size. | 36 // Initialize a Pickle object using the default header size. |
37 Pickle(); | 37 Pickle(); |
38 | 38 |
39 // Initialize a Pickle object with the specified header size in bytes, which | 39 // Initialize a Pickle object with the specified header size in bytes, which |
40 // must be greater-than-or-equal-to sizeof(Pickle::Header). The header size | 40 // must be greater-than-or-equal-to sizeof(Pickle::Header). The header size |
41 // will be rounded up to ensure that the header size is 32bit-aligned. | 41 // will be rounded up to ensure that the header size is 32bit-aligned. |
42 explicit Pickle(int header_size); | 42 explicit Pickle(int header_size); |
43 | 43 |
44 // Initializes a Pickle from a const block of data. The data is not copied; | 44 // Initializes a Pickle from a const block of data. The data is not copied; |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 size_t capacity_; | 238 size_t capacity_; |
239 size_t variable_buffer_offset_; // IF non-zero, then offset to a buffer. | 239 size_t variable_buffer_offset_; // IF non-zero, then offset to a buffer. |
240 | 240 |
241 FRIEND_TEST_ALL_PREFIXES(PickleTest, Resize); | 241 FRIEND_TEST_ALL_PREFIXES(PickleTest, Resize); |
242 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNext); | 242 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNext); |
243 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNextWithIncompleteHeader); | 243 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNextWithIncompleteHeader); |
244 FRIEND_TEST_ALL_PREFIXES(PickleTest, IteratorHasRoom); | 244 FRIEND_TEST_ALL_PREFIXES(PickleTest, IteratorHasRoom); |
245 }; | 245 }; |
246 | 246 |
247 #endif // BASE_PICKLE_H__ | 247 #endif // BASE_PICKLE_H__ |
OLD | NEW |