File indexing completed on 2024-04-14 15:52:55
0001 /* 0002 This file is part of the Okteta Gui library, made within the KDE community. 0003 0004 SPDX-FileCopyrightText: 2003 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_OFFSETFORMAT_HPP 0010 #define OKTETA_OFFSETFORMAT_HPP 0011 0012 // lib 0013 #include "oktetagui_export.hpp" 0014 0015 namespace Okteta { 0016 0017 /** 0018 * @author Friedrich W. H. Kossebau 0019 */ 0020 0021 class OKTETAGUI_EXPORT OffsetFormat 0022 { 0023 public: 0024 /** */ 0025 using print = void (*)(char* Buffer, unsigned int Offset); 0026 /** */ 0027 enum Format 0028 { 0029 Hexadecimal = 0, 0030 Decimal 0031 }; 0032 /** */ 0033 static constexpr int MaxFormatWidth = 10; 0034 0035 public: 0036 OffsetFormat() = delete; 0037 OffsetFormat(const OffsetFormat&) = delete; 0038 ~OffsetFormat() = delete; 0039 0040 OffsetFormat& operator=(const OffsetFormat&) = delete; 0041 0042 public: 0043 /** */ 0044 static unsigned int codingWidth(int i); 0045 /** */ 0046 static print printFunction(int i); 0047 0048 public: 0049 static void printHexadecimalOffset(char* Buffer, unsigned int Offset); 0050 static void printHexadecimalSmallOffset(char* Buffer, unsigned int Offset); 0051 static void printDecimalOffset(char* Buffer, unsigned int Offset); 0052 0053 private: 0054 /** */ 0055 static const unsigned int CodingWidth[2]; // TODO: would sizeof(Coding} work? 0056 /** */ 0057 static const print PrintFunction[2]; 0058 }; 0059 0060 inline unsigned int OffsetFormat::codingWidth(int i) 0061 { return CodingWidth[i]; } 0062 0063 inline OffsetFormat::print OffsetFormat::printFunction(int i) 0064 { return PrintFunction[i]; } 0065 0066 } 0067 0068 #endif