This function returns just the payload part as a hex string. Also works if the ByteVector is encoded as BCD. Probably not efficient, but we are using C++.
| 369 | // Also works if the ByteVector is encoded as BCD. |
| 370 | // Probably not efficient, but we are using C++. |
| 371 | std::string ByteVector::hexstr() const |
| 372 | { |
| 373 | int b = 0, numBits = (int) sizeBits(); // Must be int, not unsigned |
| 374 | std::string ss; |
| 375 | while (numBits > 0) { |
| 376 | char ch = getNibble(b,1); |
| 377 | ss.push_back(ch + (ch > 9 ? ('A'-10) : '0')); |
| 378 | numBits -= 4; |
| 379 | if (numBits >= 4) { |
| 380 | ch = getNibble(b,0); |
| 381 | ss.push_back(ch + (ch > 9 ? ('A'-10) : '0')); |
| 382 | } |
| 383 | b++; |
| 384 | numBits -= 4; |
| 385 | } |
| 386 | return ss; |
| 387 | } |
| 388 | |
| 389 | // This function returns "ByteVector(size=... data:...)" |
| 390 | std::string ByteVector::str() const |
no test coverage detected