This repository was archived by the owner on Jul 25, 2022. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathparser.h
More file actions
155 lines (126 loc) · 2.32 KB
/
Copy pathparser.h
File metadata and controls
155 lines (126 loc) · 2.32 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
// This file is autogenerated. Do not modify.
#ifndef TICKET_PARSER_H_
#define TICKET_PARSER_H_
#include <iostream>
#include "datetime.h"
#include "exception.h"
#include "optional.h"
#include "variant.h"
#include "result.h"
/// Classes and parsers for commands.
namespace ticket::command {
enum SortType { kTime, kCost };
struct AddUser {
std::string currentUser;
std::string username;
std::string password;
std::string name;
std::string email;
int privilege;
};
struct Login {
std::string username;
std::string password;
};
struct Logout {
std::string username;
};
struct QueryProfile {
std::string currentUser;
std::string username;
};
struct ModifyProfile {
std::string currentUser;
std::string username;
Optional<std::string> password;
Optional<std::string> name;
Optional<std::string> email;
Optional<int> privilege;
};
struct AddTrain {
std::string id;
int stops;
int seats;
Vector<std::string> stations;
Vector<int> prices;
Instant departure;
Vector<Duration> durations;
Vector<Duration> stopoverTimes;
Vector<Date> dates;
char type;
};
struct DeleteTrain {
std::string id;
};
struct ReleaseTrain {
std::string id;
};
struct QueryTrain {
std::string id;
Date date;
};
struct QueryTicket {
std::string from;
std::string to;
Date date;
SortType sort = kTime;
};
struct QueryTransfer {
std::string from;
std::string to;
Date date;
SortType sort = kTime;
};
struct BuyTicket {
std::string currentUser;
std::string train;
Date date;
int seats;
std::string from;
std::string to;
bool queue = false;
};
struct QueryOrder {
std::string currentUser;
};
struct RefundTicket {
std::string currentUser;
int index = 1;
};
struct Rollback {
int timestamp;
};
struct Clean {
};
struct Exit {
};
using Command = Variant<
AddUser,
Login,
Logout,
QueryProfile,
ModifyProfile,
AddTrain,
DeleteTrain,
ReleaseTrain,
QueryTrain,
QueryTicket,
QueryTransfer,
BuyTicket,
QueryOrder,
RefundTicket,
Rollback,
Clean,
Exit
>;
/**
* @brief parses the command stored in str.
*
* this function is autogenerated.
*/
auto parse (std::string &str)
-> Result<Command, ParseException>;
auto parse (const Vector<std::string_view> &argv)
-> Result<Command, ParseException>;
} // namespace ticket::command
#endif // TICKET_PARSER_H_