#include "MercuryResponse.h" MercuryResponse::MercuryResponse(std::vector &data) { // this->mercuryHeader = std::make_unique
(); this->mercuryHeader = {}; this->parts = mercuryParts(0); this->parseResponse(data); } MercuryResponse::~MercuryResponse() { } void MercuryResponse::parseResponse(std::vector &data) { auto sequenceLength = ntohs(extract(data, 0)); this->sequenceId = hton64(extract(data, 2)); auto partsNumber = ntohs(extract(data, 11)); auto headerSize = ntohs(extract(data, 13)); auto headerBytes = std::vector(data.begin() + 15, data.begin() + 15 + headerSize); auto pos = 15 + headerSize; while (pos < data.size()) { auto partSize = ntohs(extract(data, pos)); this->parts.push_back( std::vector( data.begin() + pos + 2, data.begin() + pos + 2 + partSize)); pos += 2 + partSize; } pb_release(Header_fields, &this->mercuryHeader); pbDecode(this->mercuryHeader, Header_fields, headerBytes); }