-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathutils.h
More file actions
47 lines (41 loc) · 1.09 KB
/
utils.h
File metadata and controls
47 lines (41 loc) · 1.09 KB
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
45
46
47
#pragma once
#include <iostream>
#include <cstdint>
#include <chrono>
template <typename T>
inline void print(T value, size_t width = sizeof(T))
{
std::cout << static_cast<int>(value) << std::endl;
}
void print(const char *start, int width = sizeof(char *))
{
for (int i = 0; i < width; i++)
{
std::cout << static_cast<int>(start[i]);
}
std::cout << std::endl;
return;
}
template <typename T>
inline void Print(T value, size_t width = sizeof(T))
{
std::cout << std::hex << static_cast<int>(value) << std::endl;
}
void Print(const char *start, int width = sizeof(char *))
{
for (int i = 0; i < width; i++)
{
std::cout << std::hex << static_cast<int>(start[i]);
}
std::cout << std::endl;
return;
}
inline uint8_t hexCharToByte(char c)
{
return (c >= '0' && c <= '9') ? (c - '0') : (c >= 'A' && c <= 'F') ? (c - 'A' + 10)
: (c - 'a' + 10);
}
inline uint8_t hexPairToByte(char hexPair0, char hexPair1)
{
return ((hexCharToByte(hexPair0) << 4) | hexCharToByte(hexPair1));
}