userver: userver/formats/json/parser/number_parser.hpp Source File
Loading...
Searching...
No Matches
number_parser.hpp
1#pragma once
2
3#include <userver/formats/json/parser/typed_parser.hpp>
4
5USERVER_NAMESPACE_BEGIN
6
7namespace formats::json::parser {
8
9template <typename Number>
10class NumberParser final : public formats::json::parser::TypedParser<Number> {
11public:
12 using formats::json::parser::TypedParser<Number>::TypedParser;
13
14protected:
15 void Int64(int64_t value) override { this->SetResult(value); }
16
17 void Uint64(uint64_t value) override { this->SetResult(value); }
18
19 void Double(double value) override { this->SetResult(std::move(value)); }
20
21 std::string Expected() const override { return "number"; }
22
23 std::string GetPathItem() const override { return {}; }
24};
25
26using DoubleParser = NumberParser<double>;
27
28using FloatParser = NumberParser<float>;
29
30} // namespace formats::json::parser
31
32USERVER_NAMESPACE_END