aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/xdelta3/state/state.h
blob: 297824952a27c8384d9d48776c1364b5155e8862 (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 <library/cpp/xdelta3/proto/state_header.pb.h>

#include <google/protobuf/arena.h>

namespace NXdeltaAggregateColumn {

    constexpr auto ArenaMaxSize = 65525;

    class TState {
    public:
        TState(NProtoBuf::Arena& arena, const ui8* data, size_t size);

        const NXdeltaAggregateColumn::TStateHeader& Header() const
        {
            return *HeaderPtr;
        }

        const ui8* PayloadData() const
        {
            return Data;
        }

        size_t PayloadSize() const;
        TStateHeader::EErrorCode Error() const;
        TStateHeader::EType Type() const;

        ui32 CalcHash() const;

    private:
        const ui8* Data = nullptr;
        TStateHeader* HeaderPtr = nullptr;
    };

    size_t SizeOfHeader(const TStateHeader& header);
}