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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
185 } | 185 } |
186 | 186 |
187 template <typename U, | 187 template <typename U, |
188 size_t N, | 188 size_t N, |
189 typename std::enable_if< | 189 typename std::enable_if< |
190 internal::BufferCompat<T, U>::value>::type* = nullptr> | 190 internal::BufferCompat<T, U>::value>::type* = nullptr> |
191 void SetData(const U (&array)[N]) { | 191 void SetData(const U (&array)[N]) { |
192 SetData(array, N); | 192 SetData(array, N); |
193 } | 193 } |
194 | 194 |
195 void SetData(const BufferT& buf) { SetData(buf.data(), buf.size()); } | 195 template <typename W> |
ossu
2016/08/31 09:31:03
"W" as in Whatever? :)
kwiberg-webrtc
2016/09/01 09:23:53
Yeah, whatever.
| |
196 void SetData(const W& w) { | |
197 SetData(w.data(), w.size()); | |
198 } | |
196 | 199 |
197 // Replace the data in the buffer with at most |max_elements| of data, using | 200 // Replace the data in the buffer with at most |max_elements| of data, using |
198 // the function |setter|, which should have the following signature: | 201 // the function |setter|, which should have the following signature: |
199 // size_t setter(ArrayView<U> view) | 202 // size_t setter(ArrayView<U> view) |
200 // |setter| is given an appropriately typed ArrayView of the area in which to | 203 // |setter| is given an appropriately typed ArrayView of the area in which to |
201 // write the data (i.e. starting at the beginning of the buffer) and should | 204 // write the data (i.e. starting at the beginning of the buffer) and should |
202 // return the number of elements actually written. This number must be <= | 205 // return the number of elements actually written. This number must be <= |
203 // |max_elements|. | 206 // |max_elements|. |
204 template <typename U = T, | 207 template <typename U = T, |
205 typename F, | 208 typename F, |
(...skipping 21 matching lines...) Expand all Loading... | |
227 } | 230 } |
228 | 231 |
229 template <typename U, | 232 template <typename U, |
230 size_t N, | 233 size_t N, |
231 typename std::enable_if< | 234 typename std::enable_if< |
232 internal::BufferCompat<T, U>::value>::type* = nullptr> | 235 internal::BufferCompat<T, U>::value>::type* = nullptr> |
233 void AppendData(const U (&array)[N]) { | 236 void AppendData(const U (&array)[N]) { |
234 AppendData(array, N); | 237 AppendData(array, N); |
235 } | 238 } |
236 | 239 |
237 void AppendData(const BufferT& buf) { AppendData(buf.data(), buf.size()); } | 240 template <typename W, |
241 typename std::enable_if< | |
242 !internal::BufferCompat<T, W>::value>::type* = nullptr> | |
243 void AppendData(const W& w) { | |
244 AppendData(w.data(), w.size()); | |
245 } | |
238 | 246 |
239 template <typename U, | 247 template <typename U, |
240 typename std::enable_if< | 248 typename std::enable_if< |
241 internal::BufferCompat<T, U>::value>::type* = nullptr> | 249 internal::BufferCompat<T, U>::value>::type* = nullptr> |
242 void AppendData(const U& item) { | 250 void AppendData(const U& item) { |
243 AppendData(&item, 1); | 251 AppendData(&item, 1); |
244 } | 252 } |
245 | 253 |
246 // Append at most |max_elements| to the end of the buffer, using the function | 254 // Append at most |max_elements| to the end of the buffer, using the function |
247 // |setter|, which should have the following signature: | 255 // |setter|, which should have the following signature: |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
349 size_t capacity_; | 357 size_t capacity_; |
350 std::unique_ptr<T[]> data_; | 358 std::unique_ptr<T[]> data_; |
351 }; | 359 }; |
352 | 360 |
353 // By far the most common sort of buffer. | 361 // By far the most common sort of buffer. |
354 using Buffer = BufferT<uint8_t>; | 362 using Buffer = BufferT<uint8_t>; |
355 | 363 |
356 } // namespace rtc | 364 } // namespace rtc |
357 | 365 |
358 #endif // WEBRTC_BASE_BUFFER_H_ | 366 #endif // WEBRTC_BASE_BUFFER_H_ |
OLD | NEW |