forked from KnowSheet/CTFO_BE
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema_base.h
More file actions
129 lines (104 loc) · 4.37 KB
/
schema_base.h
File metadata and controls
129 lines (104 loc) · 4.37 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*******************************************************************************
The MIT License (MIT)
Copyright (c) 2015 Maxim Zhurovich <zhurovich@gmail.com>
(c) 2015 Dmitry "Dima" Korolev <dmitry.korolev@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*******************************************************************************/
#ifndef CTFO_SCHEMA_BASE_H
#define CTFO_SCHEMA_BASE_H
#include <functional>
#include "../Current/Sherlock/sherlock.h"
#include "../Current/Bricks/util/comparators.h" // For `CurrentHashFunction`.
#include "../Current/TypeSystem/struct.h"
#include "../Current/TypeSystem/enum.h"
// This ugliness is to be removed, right on the next round of type evolution. -- D.K.
namespace current {
namespace strings {
template <typename FST, typename SND>
struct ToStringImpl<std::pair<FST, SND>, false, false> {
static std::string DoIt(const std::pair<FST, SND>& pair) {
return ToString(pair.first) + '-' + ToString(pair.second);
}
};
template <typename INPUT, typename OUTPUT_FST, typename OUTPUT_SND>
struct FromStringImpl<INPUT, std::pair<OUTPUT_FST, OUTPUT_SND>, false, false> {
static const std::pair<OUTPUT_FST, OUTPUT_SND>& Go(const std::string& input,
std::pair<OUTPUT_FST, OUTPUT_SND>& output) {
const size_t dash = input.find('-');
FromString(input.substr(0, dash), output.first);
if (dash != std::string::npos) {
FromString(input.substr(dash + 1), output.second);
} else {
output.second = OUTPUT_SND();
}
return output;
}
};
} // namespace current::strings
} // namespace current
namespace CTFO {
CURRENT_ENUM(UID, uint64_t){INVALID_USER = 0u};
CURRENT_ENUM(CID, uint64_t){INVALID_CARD = 0u};
using UIDAndCID = std::pair<UID, CID>;
} // namespace CTFO
namespace std {
template <>
struct hash<CTFO::UIDAndCID> {
size_t operator()(const CTFO::UIDAndCID& s) const {
return current::CurrentHashFunction<CTFO::UIDAndCID>()(s);
}
};
}
namespace CTFO {
CURRENT_ENUM(OID, uint64_t){INVALID_COMMENT = 0u};
CURRENT_ENUM(NID, uint64_t){INVALID_NOTIFICATION = 0u};
CURRENT_ENUM(ANSWER, int8_t){UNSEEN = 0, CTFO = 1, TFU = 2, SKIP = -1};
CURRENT_ENUM(AUTH_TYPE, uint8_t){UNDEFINED = 0u, IOS = 1u};
CURRENT_ENUM(SHARE_DESTINATION, uint8_t){UNDEFINED = 0u, FACEBOOK = 101};
CURRENT_ENUM(SHARE_STATUS, uint8_t){
UNDEFINED = 0u, COMPLETED = 1u, INITIATED = 101u, CANCELED = 111u, FAILED = 112u};
// To parse incoming Midichlorians logs.
enum class CTFO_EVENT : int {
SKIP = static_cast<int>(ANSWER::SKIP),
CTFO = static_cast<int>(ANSWER::CTFO),
TFU = static_cast<int>(ANSWER::TFU),
FAV_CARD = 101,
UNFAV_CARD = 102,
LIKE_COMMENT = 201,
UNLIKE_COMMENT = 202,
FLAG_COMMENT = 203,
FLAG_CARD = 301,
REPORT_USER = 401,
BLOCK_USER = 402,
ONE_SIGNAL_USER_ID = 501,
COMPLETE_SHARE_TO_FACEBOOK = 601,
START_SHARE_TO_FACEBOOK = 602,
CANCEL_SHARE_TO_FACEBOOK = 603,
FAIL_SHARE_TO_FACEBOOK = 604
};
CURRENT_STRUCT(Color) {
CURRENT_FIELD(red, uint8_t);
CURRENT_FIELD(green, uint8_t);
CURRENT_FIELD(blue, uint8_t);
CURRENT_DEFAULT_CONSTRUCTOR(Color) : red(0u), green(0u), blue(0u) {}
CURRENT_CONSTRUCTOR(Color)(uint8_t red, uint8_t green, uint8_t blue) : red(red), green(green), blue(blue) {}
};
inline current::sherlock::SherlockNamespaceName SchemaKey() {
return current::sherlock::SherlockNamespaceName("CTFO_2016_08_01", "CTFOLogEntry");
}
} // namespace CTFO
#endif // CTFO_SCHEMA_BASE_H