OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 template <typename U, | 228 template <typename U, |
229 size_t N, | 229 size_t N, |
230 typename std::enable_if< | 230 typename std::enable_if< |
231 internal::BufferCompat<T, U>::value>::type* = nullptr> | 231 internal::BufferCompat<T, U>::value>::type* = nullptr> |
232 void AppendData(const U (&array)[N]) { | 232 void AppendData(const U (&array)[N]) { |
233 AppendData(array, N); | 233 AppendData(array, N); |
234 } | 234 } |
235 | 235 |
236 void AppendData(const BufferT& buf) { AppendData(buf.data(), buf.size()); } | 236 void AppendData(const BufferT& buf) { AppendData(buf.data(), buf.size()); } |
237 | 237 |
| 238 template <typename U, |
| 239 typename std::enable_if< |
| 240 internal::BufferCompat<T, U>::value>::type* = nullptr> |
| 241 void AppendData(const U& item) { |
| 242 AppendData(&item, 1); |
| 243 } |
| 244 |
238 // Append at most |max_elements| to the end of the buffer, using the function | 245 // Append at most |max_elements| to the end of the buffer, using the function |
239 // |setter|, which should have the following signature: | 246 // |setter|, which should have the following signature: |
240 // size_t setter(ArrayView<U> view) | 247 // size_t setter(ArrayView<U> view) |
241 // |setter| is given an appropriately typed ArrayView of the area in which to | 248 // |setter| is given an appropriately typed ArrayView of the area in which to |
242 // write the data (i.e. starting at the former end of the buffer) and should | 249 // write the data (i.e. starting at the former end of the buffer) and should |
243 // return the number of elements actually written. This number must be <= | 250 // return the number of elements actually written. This number must be <= |
244 // |max_elements|. | 251 // |max_elements|. |
245 template <typename U = T, | 252 template <typename U = T, |
246 typename F, | 253 typename F, |
247 typename std::enable_if< | 254 typename std::enable_if< |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 size_t capacity_; | 332 size_t capacity_; |
326 std::unique_ptr<T[]> data_; | 333 std::unique_ptr<T[]> data_; |
327 }; | 334 }; |
328 | 335 |
329 // By far the most common sort of buffer. | 336 // By far the most common sort of buffer. |
330 using Buffer = BufferT<uint8_t>; | 337 using Buffer = BufferT<uint8_t>; |
331 | 338 |
332 } // namespace rtc | 339 } // namespace rtc |
333 | 340 |
334 #endif // WEBRTC_BASE_BUFFER_H_ | 341 #endif // WEBRTC_BASE_BUFFER_H_ |
OLD | NEW |