userver: userver/formats/json/parser/int_parser.hpp Source File
Loading...
Searching...
No Matches
int_parser.hpp
1#pragma once
2
3#include <cstdint>
4
5#include <userver/formats/json/parser/typed_parser.hpp>
6
7USERVER_NAMESPACE_BEGIN
8
9namespace formats::json::parser {
10
11template <typename T = int>
12class IntegralParser;
13
14template <>
15class IntegralParser<std::int32_t> final : public TypedParser<std::int32_t> {
16public:
17 using TypedParser<std::int32_t>::TypedParser;
18
19private:
20 void Int64(std::int64_t i) override;
21
22 void Uint64(std::uint64_t i) override;
23
24 void Double(double value) override;
25
26 std::string GetPathItem() const override { return {}; }
27
28 std::string Expected() const override { return "integer"; }
29};
30
31template <>
32class IntegralParser<std::int64_t> final : public TypedParser<std::int64_t> {
33public:
34 using TypedParser<std::int64_t>::TypedParser;
35
36private:
37 void Int64(std::int64_t i) override;
38
39 void Uint64(std::uint64_t i) override;
40
41 void Double(double value) override;
42
43 std::string GetPathItem() const override { return {}; }
44
45 std::string Expected() const override { return "integer"; }
46};
47
48using IntParser = IntegralParser<std::int32_t>;
49using Int32Parser = IntegralParser<std::int32_t>;
50using Int64Parser = IntegralParser<std::int64_t>;
51
52} // namespace formats::json::parser
53
54USERVER_NAMESPACE_END