consumer.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #include "consumer.h"
  2. #include <library/cpp/yson_pull/detail/macros.h>
  3. using namespace NYsonPull;
  4. void IConsumer::OnScalar(const TScalar& value) {
  5. switch (value.Type()) {
  6. case EScalarType::Entity:
  7. OnEntity();
  8. break;
  9. case EScalarType::Boolean:
  10. OnScalarBoolean(value.AsBoolean());
  11. break;
  12. case EScalarType::Int64:
  13. OnScalarInt64(value.AsInt64());
  14. break;
  15. case EScalarType::UInt64:
  16. OnScalarUInt64(value.AsUInt64());
  17. break;
  18. case EScalarType::Float64:
  19. OnScalarFloat64(value.AsFloat64());
  20. break;
  21. case EScalarType::String:
  22. OnScalarString(value.AsString());
  23. break;
  24. default:
  25. Y_UNREACHABLE();
  26. }
  27. }
  28. void IConsumer::OnEvent(const TEvent& value) {
  29. switch (value.Type()) {
  30. case EEventType::BeginStream:
  31. OnBeginStream();
  32. break;
  33. case EEventType::EndStream:
  34. OnEndStream();
  35. break;
  36. case EEventType::BeginList:
  37. OnBeginList();
  38. break;
  39. case EEventType::EndList:
  40. OnEndList();
  41. break;
  42. case EEventType::BeginMap:
  43. OnBeginMap();
  44. break;
  45. case EEventType::Key:
  46. OnKey(value.AsString());
  47. break;
  48. case EEventType::EndMap:
  49. OnEndMap();
  50. break;
  51. case EEventType::BeginAttributes:
  52. OnBeginAttributes();
  53. break;
  54. case EEventType::EndAttributes:
  55. OnEndAttributes();
  56. break;
  57. case EEventType::Scalar:
  58. OnScalar(value.AsScalar());
  59. break;
  60. default:
  61. Y_UNREACHABLE();
  62. }
  63. }