| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 size_t Capacity() const { return size_ - start_; } | 45 size_t Capacity() const { return size_ - start_; } |
| 46 ByteOrder Order() const { return byte_order_; } | 46 ByteOrder Order() const { return byte_order_; } |
| 47 | 47 |
| 48 // Read a next value from the buffer. Return false if there isn't | 48 // Read a next value from the buffer. Return false if there isn't |
| 49 // enough data left for the specified type. | 49 // enough data left for the specified type. |
| 50 bool ReadUInt8(uint8_t* val); | 50 bool ReadUInt8(uint8_t* val); |
| 51 bool ReadUInt16(uint16_t* val); | 51 bool ReadUInt16(uint16_t* val); |
| 52 bool ReadUInt24(uint32_t* val); | 52 bool ReadUInt24(uint32_t* val); |
| 53 bool ReadUInt32(uint32_t* val); | 53 bool ReadUInt32(uint32_t* val); |
| 54 bool ReadUInt64(uint64_t* val); | 54 bool ReadUInt64(uint64_t* val); |
| 55 bool ReadVarint(uint64_t* val); |
| 55 bool ReadBytes(char* val, size_t len); | 56 bool ReadBytes(char* val, size_t len); |
| 56 | 57 |
| 57 // Appends next |len| bytes from the buffer to |val|. Returns false | 58 // Appends next |len| bytes from the buffer to |val|. Returns false |
| 58 // if there is less than |len| bytes left. | 59 // if there is less than |len| bytes left. |
| 59 bool ReadString(std::string* val, size_t len); | 60 bool ReadString(std::string* val, size_t len); |
| 60 | 61 |
| 61 // Write value to the buffer. Resizes the buffer when it is | 62 // Write value to the buffer. Resizes the buffer when it is |
| 62 // neccessary. | 63 // neccessary. |
| 63 void WriteUInt8(uint8_t val); | 64 void WriteUInt8(uint8_t val); |
| 64 void WriteUInt16(uint16_t val); | 65 void WriteUInt16(uint16_t val); |
| 65 void WriteUInt24(uint32_t val); | 66 void WriteUInt24(uint32_t val); |
| 66 void WriteUInt32(uint32_t val); | 67 void WriteUInt32(uint32_t val); |
| 67 void WriteUInt64(uint64_t val); | 68 void WriteUInt64(uint64_t val); |
| 69 void WriteVarint(uint64_t val); |
| 68 void WriteString(const std::string& val); | 70 void WriteString(const std::string& val); |
| 69 void WriteBytes(const char* val, size_t len); | 71 void WriteBytes(const char* val, size_t len); |
| 70 | 72 |
| 71 // Reserves the given number of bytes and returns a char* that can be written | 73 // Reserves the given number of bytes and returns a char* that can be written |
| 72 // into. Useful for functions that require a char* buffer and not a | 74 // into. Useful for functions that require a char* buffer and not a |
| 73 // ByteBuffer. | 75 // ByteBuffer. |
| 74 char* ReserveWriteBuffer(size_t len); | 76 char* ReserveWriteBuffer(size_t len); |
| 75 | 77 |
| 76 // Resize the buffer to the specified |size|. This invalidates any remembered | 78 // Resize the buffer to the specified |size|. This invalidates any remembered |
| 77 // seek positions. | 79 // seek positions. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 ByteOrder byte_order_; | 115 ByteOrder byte_order_; |
| 114 | 116 |
| 115 // There are sensible ways to define these, but they aren't needed in our code | 117 // There are sensible ways to define these, but they aren't needed in our code |
| 116 // base. | 118 // base. |
| 117 RTC_DISALLOW_COPY_AND_ASSIGN(ByteBuffer); | 119 RTC_DISALLOW_COPY_AND_ASSIGN(ByteBuffer); |
| 118 }; | 120 }; |
| 119 | 121 |
| 120 } // namespace rtc | 122 } // namespace rtc |
| 121 | 123 |
| 122 #endif // WEBRTC_BASE_BYTEBUFFER_H_ | 124 #endif // WEBRTC_BASE_BYTEBUFFER_H_ |
| OLD | NEW |