-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatch_key.cpp
More file actions
62 lines (48 loc) · 1.17 KB
/
Copy pathmatch_key.cpp
File metadata and controls
62 lines (48 loc) · 1.17 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
62
#include "match_key.h"
#include "event_key.h"
#include "util.h"
namespace tba{
Match_key::Match_key(std::string s1):s(std::move(s1)){
//format: event_key / "_" / level / (maybe set # and 'm') / match #
auto check=[&](bool b){
if(b) return;
throw std::invalid_argument{[&](){
std::ostringstream ss;
ss<<"Expected Match_key, found:"<<s;
return ss.str();
}()};
};
Year{atoi(s.c_str())};
size_t at=4;
while(at<s.size() && s[at]!='_') at++;
check(s[at]=='_');
at++;
at+=2;//skip match type, which is 2 chars long.
check(at<s.size());
/*while(at<s.size()){
check(isdigit(s[at]));
at++;
}*/
}
std::string const& Match_key::get()const{ return s; }
Year Match_key::year()const{
return Year(atoi(s.c_str()));
}
Match_key decode(JSON_value in,const Match_key*){
return Match_key{decode(in,(std::string*)nullptr)};
}
Match_key decode2(std::string_view a,Match_key const*){
return Match_key{std::string(a)};
}
Match_key decode(std::string const& a,Match_key const*){
return Match_key(a);
}
std::ostream& operator<<(std::ostream& o,Match_key const& a){
return o<<a.get();
}
Match_key rand(Match_key const*){
auto e=rand((Event_key*)0);
(void)e;
TBA_NYI
}
}