aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yson_pull/consumer.cpp
blob: c238e0a6fb863bc0279f8e2a0de8c70ce66f9e15 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "consumer.h"

#include <library/cpp/yson_pull/detail/macros.h>

using namespace NYsonPull;

void IConsumer::OnScalar(const TScalar& value) {
    switch (value.Type()) {
        case EScalarType::Entity:
            OnEntity();
            break;

        case EScalarType::Boolean:
            OnScalarBoolean(value.AsBoolean());
            break;

        case EScalarType::Int64:
            OnScalarInt64(value.AsInt64());
            break;

        case EScalarType::UInt64:
            OnScalarUInt64(value.AsUInt64());
            break;

        case EScalarType::Float64:
            OnScalarFloat64(value.AsFloat64());
            break;

        case EScalarType::String:
            OnScalarString(value.AsString());
            break;

        default:
            Y_UNREACHABLE();
    }
}

void IConsumer::OnEvent(const TEvent& value) {
    switch (value.Type()) {
        case EEventType::BeginStream:
            OnBeginStream();
            break;

        case EEventType::EndStream:
            OnEndStream();
            break;

        case EEventType::BeginList:
            OnBeginList();
            break;

        case EEventType::EndList:
            OnEndList();
            break;

        case EEventType::BeginMap:
            OnBeginMap();
            break;

        case EEventType::Key:
            OnKey(value.AsString());
            break;

        case EEventType::EndMap:
            OnEndMap();
            break;

        case EEventType::BeginAttributes:
            OnBeginAttributes();
            break;

        case EEventType::EndAttributes:
            OnEndAttributes();
            break;

        case EEventType::Scalar:
            OnScalar(value.AsScalar());
            break;

        default:
            Y_UNREACHABLE();
    }
}