1#ifndef LIBFILEZILLA_BUFFER_HEADER
2#define LIBFILEZILLA_BUFFER_HEADER
42 unsigned char const*
get()
const {
return pos_; }
43 unsigned char* get() {
return pos_; }
63 unsigned char*
get(
size_t write_size);
66 void add(
size_t added);
74 size_t size()
const {
return size_; }
85 void append(
unsigned char const* data,
size_t len);
86 void append(std::string_view
const& str);
87 void append(std::vector<uint8_t>
const& data);
88 void append(
unsigned char v);
90 bool empty()
const {
return size_ == 0; }
91 explicit operator bool()
const {
95 size_t capacity()
const {
return capacity_; }
96 void reserve(
size_t capacity);
98 void resize(
size_t size);
102 unsigned char & operator[](
size_t i) {
return pos_[i]; }
106 bool operator!=(buffer
const& rhs)
const {
107 return !(*
this == rhs);
116 unsigned char* data_{};
117 unsigned char* pos_{};
The buffer class is a simple buffer where data can be appended at the end and consumed at the front....
Definition: buffer.hpp:26
buffer(size_t capacity)
Initially reserves the passed capacity.
void consume(size_t consumed)
Removes consumed bytes from the beginning of the buffer.
unsigned char * get(size_t write_size)
Returns a writable buffer guaranteed to be large enough for write_size bytes, call add when done.
unsigned char const * get() const
Undefined if buffer is empty.
Definition: buffer.hpp:42
void append(unsigned char const *data, size_t len)
Appends the passed data to the buffer.
unsigned char operator[](size_t i) const
Gets element at offset i. Does not do bounds checking.
Definition: buffer.hpp:101
void add(size_t added)
Increase size by the passed amount. Call this after having obtained a writable buffer with get(size_t...
Sets some global macros and further includes string.hpp.
The namespace used by libfilezilla.
Definition: apply.hpp:17
bool operator==(symmetric_key const &lhs, symmetric_key const &rhs)
Side-channel safe comparison.