Fixed some build errors...
This commit is contained in:
parent
8a3f3f5b38
commit
e67f5cda36
|
@ -3,13 +3,13 @@
|
||||||
|
|
||||||
RandomAccessBinary::RandomAccessBinary()
|
RandomAccessBinary::RandomAccessBinary()
|
||||||
{
|
{
|
||||||
this->ptr_data = std::make_unique<vector<uint8_t>>();
|
this->ptr_data = std::make_unique<std::vector<uint8_t>>();
|
||||||
this->ptr_data->reserve(1548);
|
this->ptr_data->reserve(1548);
|
||||||
}
|
}
|
||||||
|
|
||||||
RandomAccessBinary::RandomAccessBinary(uint possible_packetsize)
|
RandomAccessBinary::RandomAccessBinary(uint possible_packetsize)
|
||||||
{
|
{
|
||||||
this->ptr_data = std::make_unique<vector<uint8_t>>();
|
this->ptr_data = std::make_unique<std::vector<uint8_t>>();
|
||||||
this->ptr_data->reserve(possible_packetsize);
|
this->ptr_data->reserve(possible_packetsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,9 +23,9 @@ const RandomAccessBinary::Endianness RandomAccessBinary::getEndianness()
|
||||||
return this->endianness;
|
return this->endianness;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RandomAccessBinary::setEndianess(RandomAccessBinary::Endianness endianess)
|
void RandomAccessBinary::setEndianness(RandomAccessBinary::Endianness endianness)
|
||||||
{
|
{
|
||||||
this->endianness = endianess;
|
this->endianness = endianness;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RandomAccessBinary::setBytes(uint position, const std::vector<uint8_t> &data)
|
void RandomAccessBinary::setBytes(uint position, const std::vector<uint8_t> &data)
|
||||||
|
@ -79,66 +79,66 @@ void RandomAccessBinary::setBits(uint bytePosition, uint bitPosition, uint bits,
|
||||||
(*this->ptr_data)[bytePosition] = byte;
|
(*this->ptr_data)[bytePosition] = byte;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RandomAccessBinary::set_uint16(uint position, const uint16_t &data)
|
void RandomAccessBinary::set_uint16(uint byteOffset, const uint16_t &data)
|
||||||
{
|
{
|
||||||
if (this->endianness == Endianness::BIG) {
|
if (this->endianness == Endianness::BIG) {
|
||||||
this->setByte(position, (uint8_t)(data >> 8));
|
this->setByte(byteOffset, (uint8_t)(data >> 8));
|
||||||
this->setbyte(position+1, (uint8_t)(data & 0x0FF));
|
this->setByte(byteOffset+1, (uint8_t)(data & 0x0FF));
|
||||||
} else if (this->endianness == Endianness::LITTLE) {
|
} else if (this->endianness == Endianness::LITTLE) {
|
||||||
this->setbyte(position, (uint8_t)(data & 0x0FF));
|
this->setByte(byteOffset, (uint8_t)(data & 0x0FF));
|
||||||
this->setByte(position+1, (uint8_t)(data >> 8));
|
this->setByte(byteOffset+1, (uint8_t)(data >> 8));
|
||||||
} else {
|
} else {
|
||||||
//TODO
|
//TODO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RandomAccessBinary::set_uint32(uint position, const uint32_t &data)
|
void RandomAccessBinary::set_uint32(uint byteOffset, const uint32_t &data)
|
||||||
{
|
{
|
||||||
if (this->endianness == Endianness::BIG) {
|
if (this->endianness == Endianness::BIG) {
|
||||||
this->setByte(position+0, (uint8_t)((data >> 24) & 0x0FF));
|
this->setByte(byteOffset+0, (uint8_t)((data >> 24) & 0x0FF));
|
||||||
this->setByte(position+1, (uint8_t)((data >> 16) & 0x0FF));
|
this->setByte(byteOffset+1, (uint8_t)((data >> 16) & 0x0FF));
|
||||||
this->setByte(position+2, (uint8_t)((data >> 8) & 0x0FF));
|
this->setByte(byteOffset+2, (uint8_t)((data >> 8) & 0x0FF));
|
||||||
this->setbyte(position+3, (uint8_t)(data & 0x0FF));
|
this->setByte(byteOffset+3, (uint8_t)(data & 0x0FF));
|
||||||
} else if (this->endianness == Endianness::LITTLE) {
|
} else if (this->endianness == Endianness::LITTLE) {
|
||||||
this->setByte(position+3, (uint8_t)((data >> 24) & 0x0FF));
|
this->setByte(byteOffset+3, (uint8_t)((data >> 24) & 0x0FF));
|
||||||
this->setByte(position+2, (uint8_t)((data >> 16) & 0x0FF));
|
this->setByte(byteOffset+2, (uint8_t)((data >> 16) & 0x0FF));
|
||||||
this->setByte(position+1, (uint8_t)((data >> 8) & 0x0FF));
|
this->setByte(byteOffset+1, (uint8_t)((data >> 8) & 0x0FF));
|
||||||
this->setbyte(position+0, (uint8_t)(data & 0x0FF));
|
this->setByte(byteOffset+0, (uint8_t)(data & 0x0FF));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RandomAccessBinary::set_uint64(uint position, const uint64_t &data)
|
void RandomAccessBinary::set_uint64(uint byteOffset, const uint64_t &data)
|
||||||
{
|
{
|
||||||
if (this->endianness == Endianness::BIG) {
|
if (this->endianness == Endianness::BIG) {
|
||||||
this->setByte(position+0, (uint8_t)((data >> 56) & 0x0FF));
|
this->setByte(byteOffset+0, (uint8_t)((data >> 56) & 0x0FF));
|
||||||
this->setByte(position+1, (uint8_t)((data >> 48) & 0x0FF));
|
this->setByte(byteOffset+1, (uint8_t)((data >> 48) & 0x0FF));
|
||||||
this->setByte(position+2, (uint8_t)((data >> 40) & 0x0FF));
|
this->setByte(byteOffset+2, (uint8_t)((data >> 40) & 0x0FF));
|
||||||
this->setByte(position+3, (uint8_t)((data >> 32) & 0x0FF));
|
this->setByte(byteOffset+3, (uint8_t)((data >> 32) & 0x0FF));
|
||||||
this->setByte(position+4, (uint8_t)((data >> 24) & 0x0FF));
|
this->setByte(byteOffset+4, (uint8_t)((data >> 24) & 0x0FF));
|
||||||
this->setByte(position+5, (uint8_t)((data >> 16) & 0x0FF));
|
this->setByte(byteOffset+5, (uint8_t)((data >> 16) & 0x0FF));
|
||||||
this->setByte(position+6, (uint8_t)((data >> 8) & 0x0FF));
|
this->setByte(byteOffset+6, (uint8_t)((data >> 8) & 0x0FF));
|
||||||
this->setbyte(position+7, (uint8_t)(data & 0x0FF));
|
this->setByte(byteOffset+7, (uint8_t)(data & 0x0FF));
|
||||||
} else if (this->endianness == Endianness::LITTLE) {
|
} else if (this->endianness == Endianness::LITTLE) {
|
||||||
this->setByte(position+7, (uint8_t)((data >> 56) & 0x0FF));
|
this->setByte(byteOffset+7, (uint8_t)((data >> 56) & 0x0FF));
|
||||||
this->setByte(position+6, (uint8_t)((data >> 48) & 0x0FF));
|
this->setByte(byteOffset+6, (uint8_t)((data >> 48) & 0x0FF));
|
||||||
this->setByte(position+5, (uint8_t)((data >> 40) & 0x0FF));
|
this->setByte(byteOffset+5, (uint8_t)((data >> 40) & 0x0FF));
|
||||||
this->setByte(position+4, (uint8_t)((data >> 32) & 0x0FF));
|
this->setByte(byteOffset+4, (uint8_t)((data >> 32) & 0x0FF));
|
||||||
this->setByte(position+3, (uint8_t)((data >> 24) & 0x0FF));
|
this->setByte(byteOffset+3, (uint8_t)((data >> 24) & 0x0FF));
|
||||||
this->setByte(position+2, (uint8_t)((data >> 16) & 0x0FF));
|
this->setByte(byteOffset+2, (uint8_t)((data >> 16) & 0x0FF));
|
||||||
this->setByte(position+1, (uint8_t)((data >> 8) & 0x0FF));
|
this->setByte(byteOffset+1, (uint8_t)((data >> 8) & 0x0FF));
|
||||||
this->setbyte(position+0, (uint8_t)(data & 0x0FF));
|
this->setByte(byteOffset+0, (uint8_t)(data & 0x0FF));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RandomAccessBinary::set_float(uint position, const float &data)
|
void RandomAccessBinary::set_float(uint position, float &data)
|
||||||
{
|
{
|
||||||
const uint32_t * conv = &data;
|
float * conv = &data;
|
||||||
this->set_uint32(position, *conv);
|
this->set_uint32(position, *conv);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RandomAccessBinary::set_double(uint position, const double &data)
|
void RandomAccessBinary::set_double(uint position, double &data)
|
||||||
{
|
{
|
||||||
const uint64_t * conv = &data;
|
double * conv = &data;
|
||||||
this->set_uint64(position, *conv);
|
this->set_uint64(position, *conv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ uint8_t RandomAccessBinary::getByte(uint position)
|
||||||
|
|
||||||
const std::vector<uint8_t> RandomAccessBinary::getBytes(uint position, uint length)
|
const std::vector<uint8_t> RandomAccessBinary::getBytes(uint position, uint length)
|
||||||
{
|
{
|
||||||
std::vector<const uint8_t> vec;
|
std::vector<uint8_t> vec;
|
||||||
for(uint i = position; i< position+length; ++i)
|
for(uint i = position; i< position+length; ++i)
|
||||||
vec.push_back((*this->ptr_data)[i]);
|
vec.push_back((*this->ptr_data)[i]);
|
||||||
return vec;
|
return vec;
|
||||||
|
@ -158,57 +158,57 @@ const std::vector<uint8_t> RandomAccessBinary::getBytes(uint position, uint leng
|
||||||
bool RandomAccessBinary::getBit(uint byteOffset, uint bitOffset)
|
bool RandomAccessBinary::getBit(uint byteOffset, uint bitOffset)
|
||||||
{
|
{
|
||||||
uint8_t byte = (*this->ptr_data)[byteOffset];
|
uint8_t byte = (*this->ptr_data)[byteOffset];
|
||||||
return (byte & (1 << (7-bitOffset)) > 0;
|
return (byte & (1 << (7-bitOffset))) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RandomAccessBinary::getBit(uint64_t position)
|
bool RandomAccessBinary::getBit(uint64_t position)
|
||||||
{
|
{
|
||||||
uint64_t byteOffset = position>>3;
|
uint64_t byteOffset = position>>3;
|
||||||
uint bitOffset = position%8;
|
uint bitOffset = position%8;
|
||||||
return this->getbit(byteOffset, bitOffset);
|
return this->getBit(byteOffset, bitOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<uint8_t> RandomAccessBinary::getBits(uint byteOffset, uint8_t bitOffset, uint64_t length)
|
const std::vector<bool> RandomAccessBinary::getBits(uint byteOffset, uint8_t bitOffset, uint64_t length)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<uint8_t> RandomAccessBinary::getBits(uint64_t position, uint64_t length)
|
const std::vector<bool> RandomAccessBinary::getBits(uint64_t position, uint64_t length)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t RandomAccessBinary::get_uint16(uint position)
|
uint16_t RandomAccessBinary::get_uint16(uint byteOffset)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t RandomAccessBinary::get_uint32(uint position)
|
uint32_t RandomAccessBinary::get_uint32(uint byteOffset)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t RandomAccessBinary::get_uint64(uint position)
|
uint64_t RandomAccessBinary::get_uint64(uint byteOffset)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float RandomAccessBinary::get_float(uint position)
|
float RandomAccessBinary::get_float(uint byteOffset)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double RandomAccessBinary::get_double(uint position)
|
double RandomAccessBinary::get_double(uint byteOffset)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::__cxx11::string RandomAccessBinary::get_string(uint position, uint length)
|
std::__cxx11::string RandomAccessBinary::get_string(uint byteOffset, uint length)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::__cxx11::string RandomAccessBinary::get_hex_string(uint position, uint length)
|
std::__cxx11::string RandomAccessBinary::get_hex_string(uint byteOffset, uint length)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,10 +16,10 @@ public:
|
||||||
|
|
||||||
RandomAccessBinary();
|
RandomAccessBinary();
|
||||||
RandomAccessBinary(uint possible_packetsize);
|
RandomAccessBinary(uint possible_packetsize);
|
||||||
explicit ~RandomAccessBinary();
|
~RandomAccessBinary();
|
||||||
|
|
||||||
void setEndianness(Endianness endianess);
|
void setEndianness(RandomAccessBinary::Endianness endianness);
|
||||||
Endianness getEndianness();
|
const RandomAccessBinary::Endianness getEndianness();
|
||||||
|
|
||||||
void setBytes(uint position, const std::vector<uint8_t>& data);
|
void setBytes(uint position, const std::vector<uint8_t>& data);
|
||||||
void setByte(uint position, const uint8_t& data);
|
void setByte(uint position, const uint8_t& data);
|
||||||
|
@ -33,8 +33,8 @@ public:
|
||||||
void set_uint32(uint position, const uint32_t& data);
|
void set_uint32(uint position, const uint32_t& data);
|
||||||
void set_uint64(uint position, const uint64_t& data);
|
void set_uint64(uint position, const uint64_t& data);
|
||||||
|
|
||||||
void set_float(uint position, const float& data);
|
void set_float(uint position, float& data);
|
||||||
void set_double(uint position, const double& data);
|
void set_double(uint position, double& data);
|
||||||
|
|
||||||
uint8_t
|
uint8_t
|
||||||
getByte(uint position);
|
getByte(uint position);
|
||||||
|
@ -44,22 +44,22 @@ public:
|
||||||
|
|
||||||
bool getBit(uint byteOffset, uint bitOffset);
|
bool getBit(uint byteOffset, uint bitOffset);
|
||||||
bool getBit(uint64_t position);
|
bool getBit(uint64_t position);
|
||||||
const std::vector<uint8_t>
|
const std::vector<bool>
|
||||||
getBits(uint byteOffset, uint8_t bitOffset, uint64_t length);
|
getBits(uint byteOffset, uint8_t bitOffset, uint64_t length);
|
||||||
|
|
||||||
const std::vector<uint8_t>
|
const std::vector<bool>
|
||||||
getBits(uint64_t position, uint64_t length);
|
getBits(uint64_t position, uint64_t length);
|
||||||
|
|
||||||
uint16_t get_uint16(uint position);
|
uint16_t get_uint16(uint byteOffset);
|
||||||
uint32_t get_uint32(uint position);
|
uint32_t get_uint32(uint byteOffset);
|
||||||
uint64_t get_uint64(uint position);
|
uint64_t get_uint64(uint byteOffset);
|
||||||
|
|
||||||
float get_float(uint position);
|
float get_float(uint byteOffset);
|
||||||
double get_double(uint position);
|
double get_double(uint byteOffset);
|
||||||
|
|
||||||
std::string get_string(uint position, uint length);
|
std::string get_string(uint byteOffset, uint length);
|
||||||
|
|
||||||
std::string get_hex_string(uint position, uint length);
|
std::string get_hex_string(uint byteOffset, uint length);
|
||||||
std::string get_hex_string();
|
std::string get_hex_string();
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<std::vector<uint8_t>> ptr_data;
|
std::unique_ptr<std::vector<uint8_t>> ptr_data;
|
||||||
|
|
Reference in New Issue