| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 |
| 11 | #ifndef RTC_BASE_MESSAGE_BUFFER_READER_H_ |
| 12 | #define RTC_BASE_MESSAGE_BUFFER_READER_H_ |
| 13 |
| 14 | #include "rtc_base/byte_buffer.h" |
| 15 |
| 16 | namespace webrtc { |
| 17 |
| 18 | // A simple subclass of the ByteBufferReader that exposes the starting address |
| 19 | // of the message and its length, so that we can recall previously parsed data. |
| 20 | class MessageBufferReader : public rtc::ByteBufferReader { |
| 21 | public: |
| 22 | MessageBufferReader(const char* bytes, size_t len) |
| 23 | : rtc::ByteBufferReader(bytes, len) {} |
| 24 | ~MessageBufferReader() = default; |
| 25 |
| 26 | // Starting address of the message. |
| 27 | const char* MessageData() const { return bytes_; } |
| 28 | // Total length of the message. Note that this is different from Length(), |
| 29 | // which is the length of the remaining message from the current offset. |
| 30 | size_t MessageLength() const { return size_; } |
| 31 | // Current offset in the message. |
| 32 | size_t CurrentOffset() const { return start_; } |
| 33 | }; |
| 34 |
| 35 | } // namespace webrtc |
| 36 |
| 37 | #endif // RTC_BASE_MESSAGE_BUFFER_READER_H_ |
| 38 |