Messagelib

riceencodingdecoder.h
1/*
2 SPDX-FileCopyrightText: 2016-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "updatedatabaseinfo.h"
10#include "webengineviewer_private_export.h"
11#include <QList>
12namespace WebEngineViewer
13{
14// https://developers.google.com/safe-browsing/v4/compression
15class RiceDecoder
16{
17public:
18 RiceDecoder(int riceParameter, int numberEntries, const QByteArray &encodingData);
19 ~RiceDecoder();
20
21 [[nodiscard]] bool hasOtherEntries() const;
22 [[nodiscard]] bool nextValue(uint32_t *value);
23 [[nodiscard]] bool nextBits(unsigned int num_requested_bits, uint32_t *x);
24 [[nodiscard]] uint32_t bitsFromCurrentWord(unsigned int num_requested_bits);
25 [[nodiscard]] bool nextWord(uint32_t *word);
26
27private:
28 QByteArray mEncodingData;
29 int mRiceParameter;
30 int mNumberEntries;
31
32 // Represents how many total bytes have we read from |data_| into
33 // |mCurrentWord|.
34 int mDataByteIndex;
35
36 // Represents the number of bits that we have read from |mCurrentWord|. When
37 // this becomes 32, which is the size of |mCurrentWord|, a new
38 // |mCurrentWord| needs to be read from |data_|.
39 unsigned int mCurrentWordBitIndex;
40
41 // The 32-bit value read from |data_|. All bit reading operations operate on
42 // |mCurrentWord|.
43 uint32_t mCurrentWord;
44};
45
46class WEBENGINEVIEWER_TESTS_EXPORT RiceEncodingDecoder
47{
48public:
49 RiceEncodingDecoder();
50 ~RiceEncodingDecoder();
51
52 [[nodiscard]] static QList<quint32> decodeRiceIndiceDelta(const WebEngineViewer::RiceDeltaEncoding &riceDeltaEncoding);
53 [[nodiscard]] static QList<quint32> decodeRiceHashesDelta(const WebEngineViewer::RiceDeltaEncoding &riceDeltaEncoding);
54};
55}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 11 2024 12:08:46 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.