File indexing completed on 2024-05-05 17:57:58

0001 /*
0002     This file is part of the Okteta Core library, made within the KDE community.
0003 
0004     SPDX-FileCopyrightText: 2004, 2011 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 OKTETA_HEXADECIMALBYTECODEC_HPP
0010 #define OKTETA_HEXADECIMALBYTECODEC_HPP
0011 
0012 // lib
0013 #include <valuecodec.hpp>
0014 
0015 class QChar;
0016 
0017 namespace Okteta {
0018 
0019 class HexadecimalByteCodec : public ValueCodec
0020 {
0021 public:
0022     explicit HexadecimalByteCodec(bool lowerCaseDigits = false);
0023     HexadecimalByteCodec(const HexadecimalByteCodec&) = delete;
0024     HexadecimalByteCodec& operator=(const HexadecimalByteCodec&) = delete;
0025 
0026 public:
0027     bool setLowerCaseDigits(bool lowerCaseDigits);
0028     bool isLowerCaseDigits() const;
0029 
0030 public: // ValueCodec API
0031     unsigned int encodingWidth() const override;
0032     Byte digitsFilledLimit() const override;
0033 
0034     void encode(QString* digits, unsigned int pos, Byte byte) const override;
0035     void encodeShort(QString* digits, unsigned int pos, Byte byte) const override;
0036     bool appendDigit(Byte* byte, unsigned char digit) const override;
0037     void removeLastDigit(Byte* byte) const override;
0038     bool isValidDigit(unsigned char digit) const override;
0039     bool turnToValue(unsigned char* digit) const override;
0040 
0041 private:
0042     const QChar* mDigits;
0043 };
0044 
0045 }
0046 
0047 #endif