KItinerary

bitarray.cpp
1/*
2 SPDX-FileCopyrightText: 2019 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "bitarray.h"
8
9#include "asn1/bitvectorview.h"
10
11#include <QDebug>
12
13#include <cstdint>
14
15using namespace KItinerary::JsApi;
16
17BitArray::BitArray() = default;
18BitArray::BitArray(const QByteArray &data)
19 : m_data(data)
20{
21}
22
23BitArray::~BitArray() = default;
24
25quint64 BitArray::readNumberMSB(int startBit, int size) const
26{
27 BitVectorView view(std::string_view(m_data.constData(), m_data.size()));
28 if ((int)view.size() < startBit + size || size < 0 || size > 64 || startBit < 0) {
29 return 0;
30 }
31
32 return view.valueAtMSB<quint64>(startBit, size);
33}
34
35#include "moc_bitarray.cpp"
Non-owning bit-level view for working with data that isn't byte-aligned.
size_type size() const
Size of this vector in bits.
T valueAtMSB(size_type index, size_type bits) const
Read a big endian unsigned number at bit offset index and bits in length.
Q_INVOKABLE quint64 readNumberMSB(int startBit, int size) const
Reads a size bit long numerical value in most significant bit first format starting at bit offset sta...
Definition bitarray.cpp:25
JavaScript API available to extractor scripts.
Definition barcode.h:19
const char * constData() const const
qsizetype size() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:28:48 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.