aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yson/node/node_builder.h
blob: 0190870f9175cb8f1356c6d19c49cd28c92c6111 (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
#pragma once

#include "node.h"

#include <library/cpp/json/json_reader.h>

#include <library/cpp/yson/consumer.h>

#include <util/generic/stack.h>

namespace NYT {

////////////////////////////////////////////////////////////////////////////////

class TNodeBuilder
    : public ::NYson::TYsonConsumerBase
{
public:
    TNodeBuilder(TNode* node);

    void OnStringScalar(TStringBuf) override;
    void OnInt64Scalar(i64) override;
    void OnUint64Scalar(ui64) override;
    void OnDoubleScalar(double) override;
    void OnBooleanScalar(bool) override;
    void OnEntity() override;
    void OnBeginList() override;
    void OnListItem() override;
    void OnEndList() override;
    void OnBeginMap() override;
    void OnKeyedItem(TStringBuf) override;
    void OnEndMap() override;
    void OnBeginAttributes() override;
    void OnEndAttributes() override;
    void OnNode(TNode node);

private:
    TStack<TNode*> Stack_; 

private:
    inline void AddNode(TNode node, bool pop);
};

////////////////////////////////////////////////////////////////////////////////

} // namespace NYT