25 CharBuffer(CharBuffer &&that)
26 : blocks_(std::move(that.blocks_)), bytes_{that.bytes_},
27 lastBlockEmpty_{that.lastBlockEmpty_} {
30 CharBuffer &operator=(CharBuffer &&that) {
31 blocks_ = std::move(that.blocks_);
33 lastBlockEmpty_ = that.lastBlockEmpty_;
38 bool empty()
const {
return bytes_ == 0; }
39 std::size_t bytes()
const {
return bytes_; }
44 lastBlockEmpty_ =
false;
47 char *FreeSpace(std::size_t &);
48 void Claim(std::size_t);
52 std::size_t Put(
const char *data, std::size_t n);
53 std::size_t Put(
const std::string &);
54 std::size_t Put(
char x) {
return Put(&x, 1); }
56 std::string Marshal()
const;
60 static constexpr std::size_t capacity{1 << 20};
64 int LastBlockOffset()
const {
return bytes_ % Block::capacity; }
65 std::list<Block> blocks_;
66 std::size_t bytes_{0};
67 bool lastBlockEmpty_{
false};