blob: b5e7c49d4d81320bddbeaec0df0d9889cf38085c (
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
|
#include "yson2json_adapter.h"
namespace NYT {
TYson2JsonCallbacksAdapter::TYson2JsonCallbacksAdapter(::NYson::TYsonConsumerBase* impl, bool throwException)
: NJson::TJsonCallbacks(throwException)
, Impl_(impl)
{
}
bool TYson2JsonCallbacksAdapter::OnNull() {
WrapIfListItem();
Impl_->OnEntity();
return true;
}
bool TYson2JsonCallbacksAdapter::OnBoolean(bool val) {
WrapIfListItem();
Impl_->OnBooleanScalar(val);
return true;
}
bool TYson2JsonCallbacksAdapter::OnInteger(long long val) {
WrapIfListItem();
Impl_->OnInt64Scalar(val);
return true;
}
bool TYson2JsonCallbacksAdapter::OnUInteger(unsigned long long val) {
WrapIfListItem();
Impl_->OnUint64Scalar(val);
return true;
}
bool TYson2JsonCallbacksAdapter::OnString(const TStringBuf& val) {
WrapIfListItem();
Impl_->OnStringScalar(val);
return true;
}
bool TYson2JsonCallbacksAdapter::OnDouble(double val) {
WrapIfListItem();
Impl_->OnDoubleScalar(val);
return true;
}
bool TYson2JsonCallbacksAdapter::OnOpenArray() {
WrapIfListItem();
State_.ContextStack.push(true);
Impl_->OnBeginList();
return true;
}
bool TYson2JsonCallbacksAdapter::OnCloseArray() {
State_.ContextStack.pop();
Impl_->OnEndList();
return true;
}
bool TYson2JsonCallbacksAdapter::OnOpenMap() {
WrapIfListItem();
State_.ContextStack.push(false);
Impl_->OnBeginMap();
return true;
}
bool TYson2JsonCallbacksAdapter::OnCloseMap() {
State_.ContextStack.pop();
Impl_->OnEndMap();
return true;
}
bool TYson2JsonCallbacksAdapter::OnMapKey(const TStringBuf& val) {
Impl_->OnKeyedItem(val);
return true;
}
void TYson2JsonCallbacksAdapter::WrapIfListItem() {
if (!State_.ContextStack.empty() && State_.ContextStack.top()) {
Impl_->OnListItem();
}
}
}
|