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