1 #ifndef LIBFILEZILLA_NONOWNING_BUFFER_HEADER
2 #define LIBFILEZILLA_NONOWNING_BUFFER_HEADER
38 if (size > capacity) {
52 size_t capacity()
const {
return capacity_; }
53 size_t size()
const {
return size_; }
54 bool empty()
const {
return size_ == 0; }
55 explicit operator bool()
const {
return !empty(); }
64 void clear() { resize(0); }
67 uint8_t
operator[](
size_t offset) {
return *(buffer_ + start_ + offset); }
70 uint8_t
const*
get()
const {
return buffer_ + start_; }
71 uint8_t * get() {
return buffer_ + start_; }
81 uint8_t*
get(
size_t bytes);
88 void add(
size_t bytes);
98 void append(uint8_t
const* data,
size_t len);
99 void append(uint8_t c) { append(&c, 1); }
101 std::string_view to_view()
const;
The buffer class is a simple buffer where data can be appended at the end and consumed at the front....
Definition: buffer.hpp:27
Similar to fz::buffer, but does not own memory.
Definition: nonowning_buffer.hpp:23
void consume(size_t bytes)
Removes consumed bytes from the beginning of the buffer.
void resize(size_t size)
Resizes the buffer.
uint8_t operator[](size_t offset)
Gets element at offset. No safety check.
Definition: nonowning_buffer.hpp:67
uint8_t * get(size_t bytes)
Returns a writable buffer guaranteed to be large enough for write_size bytes, call add when done.
uint8_t const * get() const
Gets buffer.
Definition: nonowning_buffer.hpp:70
void add(size_t bytes)
Grows size by passed amount.
Sets some global macros and further includes string.hpp.
The namespace used by libfilezilla.
Definition: apply.hpp:17