-
Notifications
You must be signed in to change notification settings - Fork 283
Expand file tree
/
Copy pathaux.h
More file actions
61 lines (37 loc) · 1.1 KB
/
aux.h
File metadata and controls
61 lines (37 loc) · 1.1 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#pragma once
#include <random>
#include <filesystem>
#include <fstream>
inline uint32_t rand_uint32(uint32_t min_value, uint32_t max_value) {
static std::random_device rd;
static std::mt19937 gen(rd());
uint32_t rand_number;
std::uniform_int_distribution<> dist(min_value, max_value);
rand_number = dist(gen);
return rand_number;
}
inline std::string uint32_to_string(uint32_t fourcc){
std::string output = "";
output += fourcc & 0xFF;
output += (fourcc >> 8) & 0xFF;
output += (fourcc >> 16) & 0xFF;
output += (fourcc >> 24) & 0xFF;
return output;
}
inline std::string uint32_to_string_BE(uint32_t fourcc){
std::string output = "";
output += (fourcc >> 24) & 0xFF;
output += (fourcc >> 16) & 0xFF;
output += (fourcc >> 8) & 0xFF;
output += fourcc & 0xFF;
return output;
}
inline bool write_to_file(const std::string &content, std::filesystem::path file){
std::ofstream ofs(file, std::ios::out | std::ios::binary);
if (!ofs) {
return false;
}
ofs << content;
ofs.close();
return true;
}