#ifndef seafire__server__query_parameter_hxx_ #define seafire__server__query_parameter_hxx_ #include #include #include #include namespace seafire::server { template class query_parameter_t { public: using parameter_type = ParameterType; using value_type = typename parameter_type::value_type; static std::string const& name() { static std::string const name{Name}; return name; } query_parameter_t(std::optional value) : value_{std::move(value)} {} std::optional const& value() const { return value_; } operator std::optional const&() const { return value(); } std::optional const* operator->() const { return &value(); } static query_parameter_t fetch(request_t& r) { auto value = r.extensions().use().get(name()); return std::optional{parameter_type::try_parse(value)}; } private: std::optional value_; }; } // namespace seafire::server #endif