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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 } | 117 } |
118 | 118 |
119 template <typename U = T, | 119 template <typename U = T, |
120 typename std::enable_if< | 120 typename std::enable_if< |
121 internal::BufferCompat<T, U>::value>::type* = nullptr> | 121 internal::BufferCompat<T, U>::value>::type* = nullptr> |
122 U* data() { | 122 U* data() { |
123 RTC_DCHECK(IsConsistent()); | 123 RTC_DCHECK(IsConsistent()); |
124 return reinterpret_cast<U*>(data_.get()); | 124 return reinterpret_cast<U*>(data_.get()); |
125 } | 125 } |
126 | 126 |
| 127 bool empty() const { |
| 128 RTC_DCHECK(IsConsistent()); |
| 129 return size_ == 0; |
| 130 } |
| 131 |
127 size_t size() const { | 132 size_t size() const { |
128 RTC_DCHECK(IsConsistent()); | 133 RTC_DCHECK(IsConsistent()); |
129 return size_; | 134 return size_; |
130 } | 135 } |
131 | 136 |
132 size_t capacity() const { | 137 size_t capacity() const { |
133 RTC_DCHECK(IsConsistent()); | 138 RTC_DCHECK(IsConsistent()); |
134 return capacity_; | 139 return capacity_; |
135 } | 140 } |
136 | 141 |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 size_t capacity_; | 354 size_t capacity_; |
350 std::unique_ptr<T[]> data_; | 355 std::unique_ptr<T[]> data_; |
351 }; | 356 }; |
352 | 357 |
353 // By far the most common sort of buffer. | 358 // By far the most common sort of buffer. |
354 using Buffer = BufferT<uint8_t>; | 359 using Buffer = BufferT<uint8_t>; |
355 | 360 |
356 } // namespace rtc | 361 } // namespace rtc |
357 | 362 |
358 #endif // WEBRTC_BASE_BUFFER_H_ | 363 #endif // WEBRTC_BASE_BUFFER_H_ |
OLD | NEW |