41 explicit Buffer(
size_t initialCapacity);
44 explicit Buffer(
const char *s);
47 explicit Buffer(
const std::string s);
54 {
return this->contents; }
59 {
return this->length; };
63 {
return this->capacity; }
69 bool Append(
const char *s);
75 bool Append(
const std::string s);
82 bool Append(
const uint8_t *data,
const size_t datalen);
88 bool Append(
const uint8_t c);
95 bool Insert(
const size_t index,
const char *s);
102 bool Insert(
const size_t index,
const std::string s);
111 Insert(
const size_t index,
const uint8_t *data,
const size_t datalen);
118 bool Insert(
const size_t index,
const uint8_t c);
125 bool Remove(
const size_t index,
const size_t count);
131 bool Remove(
size_t index);
141 void Resize(
size_t newCapacity);
152 { this->autoTrim =
false; }
157 { this->autoTrim =
true; }
163 {
return this->autoTrim; }
177 void HexDump(std::ostream &os);
195 size_t mustGrow(
size_t delta)
const;
197 bool shiftRight(
size_t offset,
size_t delta);
199 bool shiftLeft(
size_t offset,
size_t delta);
208std::ostream &
operator<<(std::ostream &os,
const Buffer &buf);
size_t Capacity() const
Capacity returns the amount of memory allocated to the Buffer.
Definition: Buffer.h:62
void HexDump(std::ostream &os)
Definition: Buffer.cc:246
uint8_t * Contents() const
Contents returns the Buffer's contents.
Definition: Buffer.h:53
Buffer()
A Buffer can be constructed empty, with no memory allocated (yet).
Definition: Buffer.cc:47
void EnableAutoTrim()
Definition: Buffer.h:156
size_t Length() const
Definition: Buffer.h:58
friend bool operator==(const Buffer &lhs, const Buffer &rhs)
Definition: Buffer.cc:344
void Clear()
Definition: Buffer.cc:207
uint8_t & operator[](size_t index)
Definition: Buffer.cc:330
size_t Trim()
Definition: Buffer.cc:192
void Resize(size_t newCapacity)
Definition: Buffer.cc:170
void DisableAutoTrim()
Definition: Buffer.h:151
bool Append(const char *s)
Definition: Buffer.cc:78
bool Remove(const size_t index, const size_t count)
Definition: Buffer.cc:153
bool AutoTrimIsEnabled()
Definition: Buffer.h:162
bool Insert(const size_t index, const char *s)
Definition: Buffer.cc:119
void Reclaim()
Definition: Buffer.cc:218
scsl is the top-level namespace containing all the code in this library.
Definition: scsl.h:37
std::ostream & operator<<(std::ostream &os, Arena &arena)
Definition: Arena.cc:281
bool operator!=(const Buffer &lhs, const Buffer &rhs)
Definition: Buffer.h:212