27#ifndef ETSI_ITS_MSGS_UTILS_IMPL_ASN1_PRIMITIVES_ASN1_PRIMITIVES_GETTERS_H
28#define ETSI_ITS_MSGS_UTILS_IMPL_ASN1_PRIMITIVES_ASN1_PRIMITIVES_GETTERS_H
42inline std::vector<bool> getBitString(
const std::vector<uint8_t>& buffer,
const int bits_unused) {
44 const int bits_per_byte = 8;
45 const int n_bytes = buffer.size();
46 const int n_bits = n_bytes * bits_per_byte;
47 std::vector<bool> bits;
48 bits.resize(n_bits - bits_unused, 0);
51 for (
int byte_idx = n_bytes - 1; byte_idx >= 0; byte_idx--) {
53 for (
int bit_idx_in_byte = bits_per_byte - 1; bit_idx_in_byte >= 0; bit_idx_in_byte--) {
56 int bit_idx = (n_bytes - byte_idx - 1) * bits_per_byte + bit_idx_in_byte;
57 if (byte_idx == 0 && bit_idx < bits_unused)
break;
60 bool byte_has_true_bit = buffer[byte_idx] & (1 << bit_idx_in_byte);
61 if (byte_has_true_bit) bits[bits_per_byte-bit_idx-1] =
true;