MCPcopy Create free account
hub / github.com/Snapchat/Valdi / ByteBuffer

Class ByteBuffer

valdi_core/src/valdi_core/cpp/Utils/ByteBuffer.hpp:18–150  ·  view source on GitHub ↗

A simple byte buffer, designed as a lightweight replacement to std::vector . */

Source from the content-addressed store, hash-verified

16 A simple byte buffer, designed as a lightweight replacement to std::vector<Byte>.
17 */
18class ByteBuffer : public SimpleRefCountable {
19public:
20 ByteBuffer();
21 ByteBuffer(ByteBuffer&& other) noexcept;
22 ByteBuffer(const ByteBuffer& other);
23 explicit ByteBuffer(const std::string& stringBufferToCopy);
24 explicit ByteBuffer(std::string_view stringBufferToCopy);
25 explicit ByteBuffer(const char* nullTerminatedString);
26 ByteBuffer(const Byte* begin, const Byte* end);
27
28 ~ByteBuffer() override;
29
30 ByteBuffer& operator=(const ByteBuffer& other);
31 ByteBuffer& operator=(ByteBuffer&& other) noexcept;
32 bool operator==(const ByteBuffer& other) const;
33 bool operator!=(const ByteBuffer& other) const;
34
35 void clear();
36
37 constexpr Byte* data() const {
38 return _data;
39 }
40
41 constexpr size_t size() const {
42 return _size;
43 }
44
45 constexpr bool empty() const {
46 return _size == 0;
47 }
48
49 constexpr size_t capacity() const {
50 return _capacity;
51 }
52
53 constexpr Byte* begin() const {
54 return data();
55 }
56
57 constexpr Byte* end() const {
58 return begin() + size();
59 }
60
61 void reserve(size_t capacity);
62
63 constexpr Byte* operator[](size_t i) const {
64 return _data + i;
65 }
66
67 /**
68 Append N bytes to the buffer, and return a writable pointer to the beginning
69 of the added region
70 */
71 Byte* appendWritable(size_t size);
72
73 /**
74 Append and write the given region to the buffer
75 */

Callers 1

ByteBuffer.cppFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected