26 CharBuffer(CharBuffer &&that)
27 : blocks_(std::move(that.blocks_)), bytes_{that.bytes_},
28 lastBlockEmpty_{that.lastBlockEmpty_} {
31 CharBuffer &operator=(CharBuffer &&that) {
32 blocks_ = std::move(that.blocks_);
34 lastBlockEmpty_ = that.lastBlockEmpty_;
39 bool empty()
const {
return bytes_ == 0; }
40 std::size_t bytes()
const {
return bytes_; }
45 lastBlockEmpty_ =
false;
48 char *FreeSpace(std::size_t &);
49 void Claim(std::size_t);
53 std::size_t Put(
const char *data, std::size_t n);
54 std::size_t Put(
const std::string &);
55 std::size_t Put(
char x) {
return Put(&x, 1); }
57 std::string Marshal()
const;
61 static constexpr std::size_t capacity{1 << 20};
65 int LastBlockOffset()
const {
return bytes_ % Block::capacity; }
66 std::list<Block> blocks_;
67 std::size_t bytes_{0};
68 bool lastBlockEmpty_{
false};