File indexing completed on 2025-01-05 05:23:53

0001 /*
0002     This file is part of the Okteta Kasten module, made within the KDE community.
0003 
0004     SPDX-FileCopyrightText: 2023 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_BYTEARRAYVIEWHTMLSTREAMENCODER_HPP
0010 #define KASTEN_BYTEARRAYVIEWHTMLSTREAMENCODER_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 
0021 class ByteArrayViewHtmlStreamEncoderSettings
0022 {
0023 public:
0024     ByteArrayViewHtmlStreamEncoderSettings();
0025     ByteArrayViewHtmlStreamEncoderSettings(const ByteArrayViewHtmlStreamEncoderSettings&) = default;
0026 
0027     ~ByteArrayViewHtmlStreamEncoderSettings() = default;
0028 
0029     ByteArrayViewHtmlStreamEncoderSettings& operator=(const ByteArrayViewHtmlStreamEncoderSettings&) = default;
0030 
0031 public:
0032     int codingWidth;
0033     int firstLineOffset;
0034     int startOffset;
0035     int delta;
0036     Okteta::ValueCoding valueCoding = Okteta::HexadecimalCoding;
0037     QString codecName;
0038     QChar undefinedChar = {QLatin1Char('?')};
0039     QChar substituteChar = {QLatin1Char('.')};
0040 };
0041 
0042 // TODO: this could rather be one of the default cop
0043 class ByteArrayViewHtmlStreamEncoder : public AbstractByteArrayStreamEncoder
0044 {
0045     Q_OBJECT
0046 
0047 public:
0048     ByteArrayViewHtmlStreamEncoder();
0049     ~ByteArrayViewHtmlStreamEncoder() override;
0050 
0051 protected: // AbstractByteArrayStreamEncoder API
0052     bool encodeDataToStream(QIODevice* device,
0053                             const ByteArrayView* byteArrayView,
0054                             const Okteta::AbstractByteArrayModel* byteArrayModel,
0055                             const Okteta::AddressRange& range) override;
0056 
0057 private:
0058     ByteArrayViewHtmlStreamEncoderSettings mSettings;
0059 };
0060 
0061 }
0062 
0063 #endif