| #pragma once |
| |
| #include <cstdint> |
| #include <iostream> |
| #include <stdexcept> // NOLINT |
| #include <string> |
| #include <vector> |
| |
| #include "boost/beast/http/verb.hpp" // NOLINT |
| #include "utility.hpp" // NOLINT |
| |
| namespace crow { |
| |
| enum class ParamType : std::uint8_t { |
| INT, |
| UINT, |
| DOUBLE, |
| STRING, |
| PATH, |
| |
| MAX |
| }; |
| |
| struct RoutingParams { |
| std::vector<int64_t> intParams; |
| std::vector<uint64_t> uintParams; |
| std::vector<double> doubleParams; |
| std::vector<std::string> stringParams; |
| |
| void debugPrint() const { |
| std::cerr << "RoutingParams" << '\n'; |
| for (auto i : intParams) { |
| std::cerr << i << ", "; |
| } |
| std::cerr << '\n'; |
| for (auto i : uintParams) { |
| std::cerr << i << ", "; |
| } |
| std::cerr << '\n'; |
| for (auto i : doubleParams) { |
| std::cerr << i << ", "; |
| } |
| std::cerr << '\n'; |
| for (const std::string& i : stringParams) { |
| std::cerr << i << ", "; |
| } |
| std::cerr << '\n'; |
| } |
| |
| template <typename T> |
| T get(unsigned) const; |
| }; |
| |
| template <> |
| inline int64_t RoutingParams::get<int64_t>(unsigned index) const { |
| return intParams[index]; |
| } |
| |
| template <> |
| inline uint64_t RoutingParams::get<uint64_t>(unsigned index) const { |
| return uintParams[index]; |
| } |
| |
| template <> |
| inline double RoutingParams::get<double>(unsigned index) const { |
| return doubleParams[index]; |
| } |
| |
| template <> |
| inline std::string RoutingParams::get<std::string>(unsigned index) const { |
| return stringParams[index]; |
| } |
| |
| } // namespace crow |