aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yson_pull/reader.h
blob: f839b1907133b446fc49e53fe3eeb8eb254d51f9 (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
#pragma once

#include "event.h"
#include "input.h"
#include "stream_type.h"

#include <util/system/yassert.h>

#include <memory>

namespace NYsonPull {
    namespace NDetail {
        class reader_impl;
    }

    //! \brief YSON reader facade class.
    //!
    //! Owns an input stream.
    class TReader {
        THolder<NInput::IStream> Stream_;
        THolder<NDetail::reader_impl> Impl_;

    public:
        TReader(THolder<NInput::IStream> stream, EStreamType mode);
        TReader(TReader&&) noexcept;
        ~TReader();

        //! \brief Advance stream to next event and return it.
        //!
        //! Any event data is invalidated by a call to NextEvent();
        const TEvent& NextEvent();

        //! \brief Get last returned event.
        const TEvent& LastEvent() const noexcept;
    };

}