예제 #1
0
	uint32_t crc32(io::reader& src, uint32_t crc /* = crc32_init()*/){
		buffer<byte> bin;
		bin.resize(K_BufferSize);
		while (src.readable()){
			auto rest = src.read(to_range(bin));
			crc =  ::crc32(crc, (const Bytef*)bin.begin(), (uInt)(bin.size() - rest.size()));
		}
		return crc;
	}
예제 #2
0
	size_t Message::Load( io::reader &reader )
	{
		lemon_pid_t pid;

		uint32_t	tid;

		lemon_trace_flag flag;

		uint32_t length;

		size_t result = reader.read((byte_t*)&_node,sizeof(_node));

		result += reader.read((byte_t*)&pid,sizeof(pid));

		_processid = ntohl(pid);

		result += reader.read((byte_t*)&tid,sizeof(tid));

		_threadId = ntohl(tid);

		result += reader.read((byte_t*)&flag,sizeof(flag));

		__lemon_ntoh64(flag);

		_flag = flag;

		result += reader.read((byte_t*)&_uuid,sizeof(uuid_t));

		result += reader.read((byte_t*)&length,sizeof(length));

		_length = ntohl(length);

		if(_length > LEMON_TRACE_MESSAGE_MAX_LENGTH)
		{
			error_info errorCode;

			LEMON_USER_ERROR(errorCode,LEMON_TRACE_BINARY_MESSAGE_FORMAT_ERROR);

			errorCode.check_throw();
		}

		result += reader.read((byte_t*)_buffer,_length);

		return result;
	}