aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yson_pull/detail/input/buffered.h
blob: 9b1482577f1cda233e62594c5f67803143de4447 (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
#pragma once

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

#include <library/cpp/yson_pull/exceptions.h>
#include <library/cpp/yson_pull/input.h>

#include <cstdio>
#include <memory>

namespace NYsonPull {
    namespace NDetail {
        namespace NInput {
            class TBuffered: public NYsonPull::NInput::IStream {
                TArrayHolder<ui8> buffer_;
                size_t size_;

            public:
                explicit TBuffered(size_t buffer_size)
                    : buffer_{new ui8[buffer_size]}
                    , size_{buffer_size} {
                }

            protected:
                ui8* buffer_data() const {
                    return buffer_.Get();
                }

                size_t buffer_size() const {
                    return size_;
                }
            };
        }
    }     // namespace NDetail
}