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
19 std::string GetPathItem() const override { return {}; }
20
21 std::string Expected() const override { return "integer"; }
22
23 void Int64(std::int64_t i) override;
24
25 void Uint64(std::uint64_t i) override;
26
27 void Double(double value) override;
28};
29
30template <>
31class IntegralParser<std::int64_t> final : public TypedParser<std::int64_t> {
32public:
33 using TypedParser<std::int64_t>::TypedParser;
34
35 std::string GetPathItem() const override { return {}; }
36
37 std::string Expected() const override { return "integer"; }
38
39 void Int64(std::int64_t i) override;
40
41 void Uint64(std::uint64_t i) override;
42
43 void Double(double value) override;
44};
45
46using IntParser = IntegralParser<std::int32_t>;
47using Int32Parser = IntegralParser<std::int32_t>;
48using Int64Parser = IntegralParser<std::int64_t>;
49
50} // namespace formats::json::parser
51
52USERVER_NAMESPACE_END