aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/json/common/defs.h
blob: ae3985508be572e0117420093d3cea2c938e1cb1 (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
#pragma once

#include <util/generic/strbuf.h>
#include <util/generic/yexception.h>

namespace NJson {
    class TJsonException: public yexception {
    };

    class TJsonCallbacks {
    public:
        explicit TJsonCallbacks(bool throwException = false)
            : ThrowException(throwException)
        {
        }

        virtual ~TJsonCallbacks();

        virtual bool OnNull();
        virtual bool OnBoolean(bool);
        virtual bool OnInteger(long long);
        virtual bool OnUInteger(unsigned long long);
        virtual bool OnDouble(double);
        virtual bool OnString(const TStringBuf&);
        virtual bool OnOpenMap();
        virtual bool OnMapKey(const TStringBuf&);
        virtual bool OnCloseMap();
        virtual bool OnOpenArray();
        virtual bool OnCloseArray();
        virtual bool OnStringNoCopy(const TStringBuf& s);
        virtual bool OnMapKeyNoCopy(const TStringBuf& s);
        virtual bool OnEnd();
        virtual void OnError(size_t off, TStringBuf reason);

        bool GetHaveErrors() const {
            return HaveErrors;
        }
    protected:
        bool ThrowException;
        bool HaveErrors = false;
    };
}