Lolly 1.4.28
Loading...
Searching...
No Matches
numeral.hpp
Go to the documentation of this file.
1
2/******************************************************************************
3 * MODULE : numberal.hpp
4 * DESCRIPTION: convertions for various numberal systems
5 * COPYRIGHT : (C) 2013 Francois Poulain
6 *******************************************************************************
7 * This software falls under the GNU general public license version 3 or later.
8 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
9 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
10 ******************************************************************************/
11
12#pragma once
13
14#include "basic.hpp"
15#include "string.hpp"
16#include <stdint.h>
17
18namespace lolly {
19namespace data {
20/**
21 * @brief Generates a Roman numeral string for an integer.
22 *
23 * @param nr The integer to be converted to Roman numeral.
24 * @return A string representing the Roman numeral.
25 */
26string to_roman (int32_t nr);
27
28/**
29 * @brief Generates an uppercase Roman numeral string for an integer.
30 *
31 * @param nr The integer to be converted to Roman numeral.
32 * @return A string representing the uppercase Roman numeral.
33 */
34string to_Roman (int32_t nr);
35
36/**
37 * @brief Generates a Chinese numeral for a given integer.
38 *
39 * @param nr The integer to be converted to a Chinese numeral.
40 * @return A string representing the Chinese numeral.
41 */
42string to_hanzi (int32_t nr);
43
44/**
45 * @brief Converts an 8-bit unsigned integer to a fixed-length (2) hex string.
46 *
47 * @param i The integer to be converted to a fixed-length hex string.
48 * @return The fixed-length (2) hexadecimal string representation of the input
49 * integer.
50 */
51string to_padded_hex (uint8_t i);
52
53/**
54 * @brief Converts an integer to a hexadecimal string.
55 *
56 * @param i The integer to be converted to a hexadecimal string.
57 * @return The hexadecimal string representation of the input integer.
58 */
59string to_hex (int i);
60
61string to_Hex (int i);
62
63/**
64 * @brief Converts a pointer to a hexadecimal string.
65 *
66 * @param ptr The pointer to be converted to a hexadecimal string.
67 * @return The hexadecimal string representation of the input pointer.
68 */
69string to_hex (pointer ptr);
70
71string to_Hex (pointer ptr);
72
73/**
74 * @brief Converts a hexadecimal string to an integer.
75 *
76 * This function takes a hexadecimal string as input and converts it into its
77 * integer representation.
78 *
79 * @param s The hexadecimal string to be converted to an integer.
80 * @return The integer representation of the input hexadecimal string.
81 */
82int from_hex (string s);
83
84/**
85 * @brief Converts an unsigned integer to a hexadecimal string with a fixed
86 * length.
87 *
88 * @param i The integer to be converted to a hexadecimal string.
89 * @param len The length of the output hexadecimal string.
90 * @return The fixed-length hexadecimal string representation of the input
91 * integer.
92 */
93string as_hexadecimal (int i, int length);
94
95/**
96 * @brief Converts an unsigned integer to a hexadecimal string.
97 *
98 * @param i The integer to be converted to a hexadecimal string.
99 * @return The hexadecimal string representation of the input integer.
100 */
101string uint32_to_Hex (uint32_t i);
102
103/**
104 * @brief Converts a binary stream to its hexadecimal represention.
105 *
106 * @param bin The binary data to be converted to a hexadecimal string.
107 * @return The hexadecimal string representation of the input binary.
108 */
109string binary_to_hexadecimal (string bin);
110
111} // namespace data
112} // namespace lolly
void * pointer
Definition basic.hpp:24
The list class represents a linked list.
Definition list.hpp:48
string to_hex(int32_t i)
Definition numeral.cpp:189
string binary_to_hexadecimal(string bin)
Converts a binary stream to its hexadecimal represention.
Definition numeral.cpp:313
string uint32_to_Hex(uint32_t i)
Converts an unsigned integer to a hexadecimal string.
Definition numeral.cpp:306
string to_hanzi(int32_t nr)
Generates a Chinese numeral for a given integer.
Definition numeral.cpp:130
string to_roman(int32_t nr)
Generates a Roman numeral string for an integer.
Definition numeral.cpp:34
string as_hexadecimal(int i, int len)
Converts an unsigned integer to a hexadecimal string with a fixed length.
Definition numeral.cpp:247
string to_padded_hex(uint8_t i)
Converts an 8-bit unsigned integer to a fixed-length (2) hex string.
Definition numeral.cpp:153
string to_Roman(int32_t nr)
Generates an uppercase Roman numeral string for an integer.
Definition numeral.cpp:43
int from_hex(string s)
Converts a hexadecimal string to an integer.
Definition numeral.cpp:214
string to_Hex(int32_t i)
Definition numeral.cpp:174