File indexing completed on 2024-03-24 17:26:49

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 #include "offsetformat.hpp"
0010 
0011 // Std
0012 #include <cstdio>
0013 
0014 namespace Okteta {
0015 
0016 const unsigned int OffsetFormat::CodingWidth[2] = { 9, 10 };
0017 
0018 const OffsetFormat::print OffsetFormat::PrintFunction[2] =
0019 { OffsetFormat::printHexadecimalOffset, OffsetFormat::printDecimalOffset };
0020 
0021 void OffsetFormat::printHexadecimalOffset(char* Buffer, unsigned int Offset)
0022 {
0023     sprintf(Buffer, "%04X:%04X", Offset >> 16, Offset & 0x0000FFFF);
0024 }
0025 
0026 void OffsetFormat::printHexadecimalSmallOffset(char* Buffer, unsigned int Offset)
0027 {
0028     sprintf(Buffer, "%04x:%04x", Offset >> 16, Offset & 0x0000FFFF);
0029 }
0030 
0031 void OffsetFormat::printDecimalOffset(char* Buffer, unsigned int Offset)
0032 {
0033     sprintf(Buffer, "%010u", Offset);
0034 }
0035 
0036 }