-
Notifications
You must be signed in to change notification settings - Fork 1
/
demo.cc
74 lines (71 loc) · 1.92 KB
/
demo.cc
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
67
68
69
70
71
72
73
74
#include "unify.hpp"
// UID, hypothetical sugar class {
struct UID : public std::string {
UID() : std::string()
{}
template<typename T>
UID( const T &t ) : std::string(unify(t))
{}
UID( const UID &t ) : std::string(t)
{}
template<typename T>
bool operator<( const T &t ) const {
const std::string &self = *this;
return self < (std::string)UID(t);
}
template<typename T>
bool operator==( const T &t ) const {
const std::string &self = *this;
return self == (std::string)UID(t);
}
template<typename T>
bool operator!=( const T &t ) const {
const std::string &self = *this;
return self != (std::string)UID(t);
}
operator const std::string() const {
return *this;
}
operator std::string() {
return *this;
}
operator const char*() const {
return this->c_str();
}
};
// }
#include <stdlib.h>
int main() {
// demo: transparent UID conversion
// UID stands for Unified Identifier.
// UID is inmutable on code always, even if changed on disk.
// UID can be converted from paths, URLs, URIs, and IDs
UID test = "game\\logo.bmp";
puts(test);
test = "game_logo";
puts(test);
test = "logo/game";
puts(test);
test = "game_logo";
puts(test);
test = "~home/game/folder/asset.jpg";
puts(test);
test = "~user/game1/folder/asset.jpg";
puts(test);
test = "~mark/game2/folder/asset.jpg";
puts(test);
test = "~john/game3/data/folder/asset.jpg";
puts(test);
test = "../folder/asset.jpg";
puts(test);
test = "C:\\data\\folder\\asset.jpg";
puts(test);
test = "C:/game/data/folder/asset.jpg";
puts(test);
test = "data.zip/data/folder/asset.jpg";
puts(test);
test = "virtual.rar/folder/asset.jpg";
puts(test);
test = "http://web.domain.com%20/folder/asset.jpg?blabla=123&abc=123#qwe";
puts(test);
}