blob: e6ee4f291d2fbe90cab3583715a0bd4aac07d96a (
plain)
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
75
76
77
|
#include <string_view>
#include <cstdint>
#include <isda/bastypes.h>
struct CurveName {
enum class Seniority: std::uint8_t {
Senior,
Subordinated,
SLA
};
enum class DocClause: std::uint8_t {
XR14,
MR14,
MM14,
CR14
};
std::string full_ticker() const {
std::string r = {ticker.begin(), ticker.end()};
return r.append("_").append(str_seniority()).
append("_").append(str_doc_clause());
}
CurveName(const char* buf) : name(buf) {
memcpy(&seniority, buf, sizeof(Seniority));
buf += sizeof(Seniority);
memcpy(&doc_clause, buf, sizeof(DocClause));
buf += sizeof(DocClause);
ticker = std::string_view((const char*)buf);
}
CurveName() {};
size_t size() const {
return sizeof(Seniority) + sizeof(DocClause) + ticker.size() + 1;
};
bool operator<(const CurveName &other) const {
return ticker < other.ticker ||
((ticker == other.ticker) && (seniority < other.seniority)) ||
((ticker == other.ticker) && (seniority == other.seniority) && (doc_clause < other.doc_clause));
}
std::string str_seniority() const {
switch (seniority) {
case Seniority::Senior:
return "Senior";
case Seniority::Subordinated:
return "Subordinated";
case Seniority::SLA:
return "SLA";
};
}
std::string str_doc_clause() const {
switch (doc_clause) {
case DocClause::XR14:
return "XR14";
case DocClause::MR14:
return "MR14";
case DocClause::MM14:
return "MM14";
case DocClause::CR14:
return "CR14";
}
}
inline TDate* defaulted() {
return (TDate*)(name - sizeof(TDate));
}
const char* name;
std::string_view ticker;
Seniority seniority;
DocClause doc_clause;
};
|