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