-
Notifications
You must be signed in to change notification settings - Fork 0
/
coagulate.cpp
66 lines (54 loc) · 1.12 KB
/
coagulate.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <fstream>
#include <unordered_map>
#include <vector>
#include <cstdint>
#include <string>
#include <sstream>
#include <iostream>
typedef std::uint32_t crc32_t;
int main()
{
std::string beginning = "db:>textures>fxs>";
std::ifstream resultsFile("out.txt");
std::ifstream hashesFile("hashes.cog");
std::ifstream dictionaryFile("dictionary.cog");
struct HashPair
{
crc32_t hash;
std::string ext;
};
std::unordered_map<crc32_t, std::vector<HashPair>> hashes;
crc32_t hash;
crc32_t temp;
std::string str;
while (hashesFile >> temp >> hash >> str)
{
hashes[hash].push_back({temp, str});
}
std::unordered_map<crc32_t, std::vector<std::string>> dictionary;
while (dictionaryFile >> hash >> str)
{
dictionary[hash].push_back(str);
}
while (std::getline(resultsFile, str))
{
std::stringstream ss(str);
ss >> hash;
std::vector<HashPair> hp = hashes[hash];
std::cout << beginning;
ss >> hash;
while (true)
{
std::cout << dictionary[hash][0];
if (ss >> hash)
{
std::cout << ">";
}
else
{
break;
}
}
std::cout << hp[0].ext << " = " << hp[0].hash << "\n";
}
}