text: #include "buffer.h"
  
  Buffer::Buffer(int initBufferSize):buffer_(initBufferSize),readPos_(0),writePos_(0){}
  
  size_t Buffer::ReadableBytes() const {
      return writePos_ - readPos_;
  }
  
  size_t Buffer::WritableBytes() const {
      return buffer_.size() - writePos_;
  }
  
  size_t Buffer::PrependableBytes() const {
      return readPos_;
  }
  
  const char* Buffer::Peek() const {
      return BeginPtr_() + readPos_;
  }
  
  void Buffer::Retrieve(size_t len) {
      assert(len<=ReadableBytes());
      readPos_ += len;
  }
  
  void Buffer::RetrieveUntil(const char* end) {
      assert(Peek() <= end);
      Retrieve(end - Peek());
  }
  
  void Buffer::RetrieveAll() {
      bzero(&buffer_[0],buffer_.size());
      readPos_ = 0;
      writePos_ = 0;
  }
  
  std::string Buffer::RetrieveAllToStr() {
      std::string str(Peek(),ReadableBytes());
      RetrieveAll();
      return str;
  }
  
  const char* Buffer::BeginWriteConst() const {
      return BeginPtr_() + writePos_;
  }
  
  char* Buffer::BeginWrite() {
      return BeginPtr_() + writePos_;
  }
  
  void Buffer::HasWritten(size_t len) {
      writePos_ += len;
  }
  
  void Buffer::Append(const std::string
  