Torch
Loading...
Searching...
No Matches
TorchUtils.h
1#pragma once
2
3#include <string>
4#include <vector>
5#include <fstream>
6#include <sstream>
7#include <iomanip>
8#include <cstdint>
9#include <algorithm>
10#include <filesystem>
11
12namespace Torch {
13template< typename T >
14std::string to_hex(T number, const bool append0x = true) {
15 std::stringstream stream;
16 if(append0x) {
17 stream << "0x";
18 }
19 stream << std::setfill ('0')
20 << std::hex << number;
21
22 auto format = stream.str();
23 std::transform(format.begin(), format.end(), format.begin(), ::toupper);
24 return format;
25}
26
27template <typename Container, typename Key>
28constexpr bool contains(const Container& c, const Key& k) {
29#if __cplusplus >= 202002L
30 return c.contains(k);
31#else
32 return c.find(k) != c.end();
33#endif
34}
35
36uint32_t translate(uint32_t offset);
37std::vector<std::filesystem::directory_entry> getRecursiveEntries(const std::filesystem::path baseDir);
38
39};