File indexing completed on 2025-01-19 05:20:18

0001 /*
0002     This file is part of the Okteta Kasten module, made within the KDE community.
0003 
0004     SPDX-FileCopyrightText: 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007 */
0008 
0009 #ifndef KASTEN_BYTEARRAYBASE64STREAMENCODER_HPP
0010 #define KASTEN_BYTEARRAYBASE64STREAMENCODER_HPP
0011 
0012 // lib
0013 #include "abstractbytearraystreamencoder.hpp"
0014 // Okteta core
0015 #include <Okteta/OktetaCore>
0016 // Qt
0017 #include <QString>
0018 
0019 namespace Kasten {
0020 extern const char base64EncodeMap[64];
0021 
0022 class ByteArrayBase64StreamEncoder : public AbstractByteArrayStreamEncoder
0023 {
0024     Q_OBJECT
0025 
0026 public:
0027     enum class InputByteIndex
0028     {
0029         First = 0,
0030         Second,
0031         Third
0032     };
0033 
0034 private:
0035     static constexpr int inputGroupLength = 3;
0036 
0037     static constexpr int outputLineLength = 76;
0038     static constexpr int outputGroupLength = 4;
0039     static constexpr int maxOutputGroupsPerLine = outputLineLength / outputGroupLength;
0040 
0041 public:
0042     ByteArrayBase64StreamEncoder();
0043     ~ByteArrayBase64StreamEncoder() override;
0044 
0045 protected: // AbstractByteArrayStreamEncoder API
0046     bool encodeDataToStream(QIODevice* device,
0047                             const ByteArrayView* byteArrayView,
0048                             const Okteta::AbstractByteArrayModel* byteArrayModel,
0049                             const Okteta::AddressRange& range) override;
0050 };
0051 
0052 }
0053 
0054 #endif