Is there any way to construct a std::bitset
from a hexadecimal std::string
or QString
and vise versa without performing binary shift operations? I know how to do it that way but I was wondering if it's possible to do this using C++ streams or something similar.
here's my code so far (trying to avoid coming under fire of moderators) :
QString data("aabbccddeeff");
QByteArray temp = QByteArray::fromHex(data.simplified().toLatin1());
QBitArray bits(temp.count()*8);
for(int i=0; i<temp.count(); ++i) {
for(int b=0; b<8;b++) {
bits.setBit( i*8+b, temp.at(i)&(1<<(7-b)) );
}
}