Ed Tanous | 7045c8d | 2017-04-03 10:04:37 -0700 | [diff] [blame] | 1 | #pragma once |
2 | |||||
Ed Tanous | 04e438c | 2020-10-03 08:06:26 -0700 | [diff] [blame] | 3 | #include "utility.hpp" |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 4 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 5 | #include <boost/beast/http/verb.hpp> |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 6 | |
Ed Tanous | 7045c8d | 2017-04-03 10:04:37 -0700 | [diff] [blame] | 7 | #include <iostream> |
8 | #include <stdexcept> | ||||
9 | #include <string> | ||||
10 | #include <vector> | ||||
Ed Tanous | 7045c8d | 2017-04-03 10:04:37 -0700 | [diff] [blame] | 11 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 12 | namespace crow |
13 | { | ||||
Ed Tanous | 7045c8d | 2017-04-03 10:04:37 -0700 | [diff] [blame] | 14 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 15 | enum class ParamType |
16 | { | ||||
17 | INT, | ||||
18 | UINT, | ||||
19 | DOUBLE, | ||||
20 | STRING, | ||||
21 | PATH, | ||||
Ed Tanous | 7045c8d | 2017-04-03 10:04:37 -0700 | [diff] [blame] | 22 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 23 | MAX |
Ed Tanous | 7045c8d | 2017-04-03 10:04:37 -0700 | [diff] [blame] | 24 | }; |
25 | |||||
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 26 | struct RoutingParams |
27 | { | ||||
28 | std::vector<int64_t> intParams; | ||||
29 | std::vector<uint64_t> uintParams; | ||||
30 | std::vector<double> doubleParams; | ||||
31 | std::vector<std::string> stringParams; | ||||
Ed Tanous | 7045c8d | 2017-04-03 10:04:37 -0700 | [diff] [blame] | 32 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 33 | void debugPrint() const |
34 | { | ||||
35 | std::cerr << "RoutingParams" << std::endl; | ||||
36 | for (auto i : intParams) | ||||
37 | { | ||||
38 | std::cerr << i << ", "; | ||||
39 | } | ||||
40 | std::cerr << std::endl; | ||||
41 | for (auto i : uintParams) | ||||
42 | { | ||||
43 | std::cerr << i << ", "; | ||||
44 | } | ||||
45 | std::cerr << std::endl; | ||||
46 | for (auto i : doubleParams) | ||||
47 | { | ||||
48 | std::cerr << i << ", "; | ||||
49 | } | ||||
50 | std::cerr << std::endl; | ||||
Ed Tanous | 9eb808c | 2022-01-25 10:19:23 -0800 | [diff] [blame] | 51 | for (const std::string& i : stringParams) |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 52 | { |
53 | std::cerr << i << ", "; | ||||
54 | } | ||||
55 | std::cerr << std::endl; | ||||
Borawski.Lukasz | c331344 | 2018-01-19 13:54:19 +0100 | [diff] [blame] | 56 | } |
Ed Tanous | 7045c8d | 2017-04-03 10:04:37 -0700 | [diff] [blame] | 57 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 58 | template <typename T> |
59 | T get(unsigned) const; | ||||
Ed Tanous | 7045c8d | 2017-04-03 10:04:37 -0700 | [diff] [blame] | 60 | }; |
61 | |||||
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 62 | template <> |
63 | inline int64_t RoutingParams::get<int64_t>(unsigned index) const | ||||
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 64 | { |
65 | return intParams[index]; | ||||
66 | } | ||||
67 | |||||
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 68 | template <> |
69 | inline uint64_t RoutingParams::get<uint64_t>(unsigned index) const | ||||
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 70 | { |
71 | return uintParams[index]; | ||||
72 | } | ||||
73 | |||||
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 74 | template <> |
75 | inline double RoutingParams::get<double>(unsigned index) const | ||||
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 76 | { |
77 | return doubleParams[index]; | ||||
Ed Tanous | 7045c8d | 2017-04-03 10:04:37 -0700 | [diff] [blame] | 78 | } |
79 | |||||
80 | template <> | ||||
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 81 | inline std::string RoutingParams::get<std::string>(unsigned index) const |
82 | { | ||||
83 | return stringParams[index]; | ||||
Ed Tanous | 7045c8d | 2017-04-03 10:04:37 -0700 | [diff] [blame] | 84 | } |
85 | |||||
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 86 | } // namespace crow |