The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

GDPR::IAB::TCFv2::BitField - Transparency & Consent String version 2 bitfield parser

SYNOPSIS

    my $data = unpack "B*", decode_base64url('tcf v2 consent string base64 encoded');
    
    my $max_vendor_id_consent = << get 16 bits from $data offset 213 >>

    my $bit_field = GDPR::IAB::TCFv2::BitField->new(
        data                 => $data,
        start_bit            => 230, # offset for vendor consents
        vendor_bits_required => $max_vendor_id_consent
    );

    if $bit_field->contains(284) { ... }

CONSTRUCTOR

Receive 3 parameters: data (as sequence of bits), start bit offset and vendor bits required (max vendor id).

Will die if any parameter is missing.

Will die if data does not contain all bits required.

METHODS

contains

Return the vendor id bit status (if enable or not) from the bit field. Will return false if id is bigger than max vendor id.

    my $ok = $bit_field->contains(284);

max_vendor_id

Returns the max vendor id.