implementation of InputBuffer and OutputBuffer is not optimal
too many instructions used to implement ntoh and hton functions.
eg:
buffer_[size_ ++] = static_cast<uint8_t>((data & 0xff000000) >> 24);
buffer_[size_ ++] = static_cast<uint8_t>((data & 0x00ff0000) >> 16);
buffer_[size_ ++] = static_cast<uint8_t>((data & 0x0000ff00) >> 8);
buffer_[size_ ++] = static_cast<uint8_t>(data & 0x000000ff);
uses 4 '++' and 4 '='
simpler should be:
*(reinterpret_cast<uint32_t*>(&buffer_[size_]) = htonl(data); size_ += sizeof(uint32_t);
this might also have hw acceleration provided by compiler (one instruction for endianness conversion).
also for read:
cp = &data_[position_];
data = ((unsigned int)(cp[0])) << 24;
data |= ((unsigned int)(cp[1])) << 16;
data |= ((unsigned int)(cp[2])) << 8;
data |= ((unsigned int)(cp[3]));
simpler should be:
*cp = ntohl(*cp);