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

Unified Diff: webrtc/base/buffer.h

Issue 1745033002: Added an operator[] to Buffer, to make reading data easier. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Added DCHECKs for index against size_ Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | webrtc/base/buffer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/buffer.h
diff --git a/webrtc/base/buffer.h b/webrtc/base/buffer.h
index 0ef1e3b5c8a70a99068cbcf2ce32ac5e5da8d06f..6fe91854464e5055d703117d7645bc7f804841f7 100644
--- a/webrtc/base/buffer.h
+++ b/webrtc/base/buffer.h
@@ -124,6 +124,16 @@ class Buffer {
bool operator!=(const Buffer& buf) const { return !(*this == buf); }
+ uint8_t& operator[](size_t index) {
+ RTC_DCHECK_LT(index, size_);
+ return data()[index];
+ }
+
+ uint8_t operator[](size_t index) const {
+ RTC_DCHECK_LT(index, size_);
+ return data()[index];
+ }
+
// The SetData functions replace the contents of the buffer. They accept the
// same input types as the constructors.
template <typename T, typename internal::ByteType<T>::t = 0>
« no previous file with comments | « no previous file | webrtc/base/buffer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698