-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathoffsetformat.cpp
44 lines (32 loc) · 1.09 KB
/
offsetformat.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
This file is part of the Okteta Gui library, made within the KDE community.
SPDX-FileCopyrightText: 2003 Friedrich W. H. Kossebau <[email protected]>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "offsetformat.hpp"
// Std
#include <cstdio>
namespace Okteta {
const unsigned int OffsetFormat::CodingWidth[3] = { 9, 10, 11 };
const OffsetFormat::print OffsetFormat::PrintFunction[3] = {
OffsetFormat::printHexadecimalOffset,
OffsetFormat::printDecimalOffset,
OffsetFormat::printOctalOffset,
};
void OffsetFormat::printHexadecimalOffset(char* Buffer, unsigned int Offset)
{
sprintf(Buffer, "%04X:%04X", Offset >> 16, Offset & 0x0000FFFF);
}
void OffsetFormat::printHexadecimalSmallOffset(char* Buffer, unsigned int Offset)
{
sprintf(Buffer, "%04x:%04x", Offset >> 16, Offset & 0x0000FFFF);
}
void OffsetFormat::printDecimalOffset(char* Buffer, unsigned int Offset)
{
sprintf(Buffer, "%010u", Offset);
}
void OffsetFormat::printOctalOffset(char* Buffer, unsigned int Offset)
{
sprintf(Buffer, "%011o", Offset);
}
}