defs.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #pragma once
  2. #include <util/generic/strbuf.h>
  3. #include <util/generic/yexception.h>
  4. namespace NJson {
  5. class TJsonException: public yexception {
  6. };
  7. class TJsonCallbacks {
  8. public:
  9. explicit TJsonCallbacks(bool throwException = false)
  10. : ThrowException(throwException)
  11. {
  12. }
  13. virtual ~TJsonCallbacks();
  14. virtual bool OnNull();
  15. virtual bool OnBoolean(bool);
  16. virtual bool OnInteger(long long);
  17. virtual bool OnUInteger(unsigned long long);
  18. virtual bool OnDouble(double);
  19. virtual bool OnString(const TStringBuf&);
  20. virtual bool OnOpenMap();
  21. virtual bool OnMapKey(const TStringBuf&);
  22. virtual bool OnCloseMap();
  23. virtual bool OnOpenArray();
  24. virtual bool OnCloseArray();
  25. virtual bool OnStringNoCopy(const TStringBuf& s);
  26. virtual bool OnMapKeyNoCopy(const TStringBuf& s);
  27. virtual bool OnEnd();
  28. virtual void OnError(size_t off, TStringBuf reason);
  29. bool GetHaveErrors() const {
  30. return HaveErrors;
  31. }
  32. protected:
  33. bool ThrowException;
  34. bool HaveErrors = false;
  35. };
  36. }