configBitstreamParser, bitparser: set reverseByte as common static method

This commit is contained in:
Gwenhael Goavec-Merou 2019-12-20 08:05:32 +01:00
parent 4df9f1c81b
commit 767b120001
4 changed files with 12 additions and 11 deletions

View File

@ -127,13 +127,3 @@ int BitParser::parse()
return 0; return 0;
} }
uint8_t BitParser::reverseByte(uint8_t src)
{
uint8_t dst = 0;
for (int i=0; i < 8; i++) {
dst = (dst << 1) | (src & 0x01);
src >>= 1;
}
return dst;
}

View File

@ -14,7 +14,6 @@ class BitParser: public ConfigBitstreamParser {
private: private:
int parseField(); int parseField();
unsigned char reverseByte(unsigned char c);
std::string fieldA; std::string fieldA;
std::string part_name; std::string part_name;
std::string date; std::string date;

View File

@ -27,3 +27,13 @@ ConfigBitstreamParser::~ConfigBitstreamParser()
{ {
_fd.close(); _fd.close();
} }
uint8_t ConfigBitstreamParser::reverseByte(uint8_t src)
{
uint8_t dst = 0;
for (int i=0; i < 8; i++) {
dst = (dst << 1) | (src & 0x01);
src >>= 1;
}
return dst;
}

View File

@ -19,6 +19,8 @@ class ConfigBitstreamParser {
BIN_MODE = std::ifstream::binary BIN_MODE = std::ifstream::binary
}; };
static uint8_t reverseByte(uint8_t src);
protected: protected:
std::string _filename; std::string _filename;
int _bit_length; int _bit_length;