缓冲区的关键是: 字符串数据 和 类型数据 之间的相互转换。比如将char *的数据的按1byte 1 byte的读入转化为bool、char、uint8、int16、uint16、int32(相当于int),uint32、int64(相当于long long);当然还有double。
网络缓冲区分为发送端 和 接收端。发送端将类型数据 转换为 字符串数据。 接收端将字符数据 转换为 类型数据。
一、发送端
#ifndef SMPEnplexer_H
#define SMPEnplexer_H
#include "SMP_COMMAND.h"
class SMPEnplexer
{
public:
SMPEnplexer(unsigned bufsize=8192); //default is 8KB
~SMPEnplexer();
char* data() {return _data;};
unsigned length() {return _pos;};
void setLength(int pos){_pos += pos;};
void setBufferSize(int size);
unsigned buffersize(){return _bufSize;};
void reset();
void addHead();
// add a argument
void