 |
libfilezilla
|
Go to the documentation of this file. 1 #ifndef LIBFILEZILLA_BUFFER_HEADER
2 #define LIBFILEZILLA_BUFFER_HEADER
34 ~
buffer() {
delete[] data_; }
40 unsigned char const*
get()
const {
return pos_; }
41 unsigned char* get() {
return pos_; }
61 unsigned char*
get(
size_t write_size);
64 void add(
size_t added);
72 size_t size()
const {
return size_; }
83 void append(
unsigned char const* data,
size_t len);
84 void append(std::string_view
const& str);
86 bool empty()
const {
return size_ == 0; }
87 explicit operator bool()
const {
91 void reserve(
size_t capacity);
93 void resize(
size_t size);
96 unsigned char operator[](
size_t i)
const {
return pos_[i]; }
97 unsigned char & operator[](
size_t i) {
return pos_[i]; }
101 bool operator!=(buffer
const& rhs)
const {
102 return !(*
this == rhs);
111 unsigned char* data_{};
112 unsigned char* pos_{};
void append(unsigned char const *data, size_t len)
Appends the passed data to the buffer.
bool operator==(symmetric_key const &lhs, symmetric_key const &rhs)
Side-channel safe comparison.
The buffer class is a simple buffer where data can be appended at the end and consumed at the front....
Definition: buffer.hpp:24
buffer(size_t capacity)
Initially reserves the passed capacity.
unsigned char operator[](size_t i) const
Gets element at offset i. Does not do bounds checking.
Definition: buffer.hpp:96
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.
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
unsigned char const * get() const
Undefined if buffer is empty.
Definition: buffer.hpp:40