1 #ifndef PROTOZERO_BUFFER_STRING_HPP
2 #define PROTOZERO_BUFFER_STRING_HPP
32 struct buffer_customization<std::string> {
34 static std::size_t size(
const std::string* buffer) noexcept {
35 return buffer->size();
38 static void append(std::string* buffer,
const char* data, std::size_t count) {
39 buffer->append(data, count);
42 static void append_zeros(std::string* buffer, std::size_t count) {
43 buffer->append(count,
'\0');
46 static void resize(std::string* buffer, std::size_t size) {
47 protozero_assert(size < buffer->size());
51 static void reserve_additional(std::string* buffer, std::size_t size) {
52 buffer->reserve(buffer->size() + size);
55 static void erase_range(std::string* buffer, std::size_t from, std::size_t to) {
56 protozero_assert(from <= buffer->size());
57 protozero_assert(to <= buffer->size());
58 protozero_assert(from <= to);
59 buffer->erase(std::next(buffer->begin(), from), std::next(buffer->begin(), to));
62 static char* at_pos(std::string* buffer, std::size_t pos) {
63 protozero_assert(pos <= buffer->size());
64 return (&*buffer->begin()) + pos;
67 static void push_back(std::string* buffer,
char ch) {
68 buffer->push_back(ch);
Contains the customization points for buffer implementations.
All parts of the protozero header-only library are in this namespace.
Definition: basic_pbf_builder.hpp:24