#pragma once #include #include #include #include /* A data steam @core pointer -getp read pointer -putp write pointer -endp end pointer,putp can not greater endp */ class hstream { private: uint32_t getp; uint32_t putp; uint32_t size; char *_datap; public: hstream(uint32_t buffer_size = HSTREAM_DEFAULT_SIZE) : getp(0), putp(0), size(buffer_size), _datap(nullptr) { try { _datap = new char[buffer_size]; } catch (const std::bad_alloc &e) { LOG(hlog_level::HLOG_CRIT, "Faied to alloc Memory"); } } bool write_char(char c); bool write_u8(u_int8_t val); bool write_u16(u_int16_t val); bool write_u32(u_int32_t val); bool write_u64(u_int64_t val); ~hstream(); }; hstream::~hstream() { delete[] _datap; }