value_builder.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #pragma once
  2. #include "type_builder.h"
  3. #include "proto_builder.h"
  4. #include <yql/essentials/public/udf/udf_value.h>
  5. #include <google/protobuf/message.h>
  6. namespace NYql {
  7. namespace NUdf {
  8. class TProtobufValue : public TBoxedValue {
  9. public:
  10. TProtobufValue(const TProtoInfo& info);
  11. ~TProtobufValue() override;
  12. TUnboxedValue Run(
  13. const IValueBuilder* valueBuilder,
  14. const TUnboxedValuePod* args) const override;
  15. virtual TAutoPtr<NProtoBuf::Message> Parse(const TStringBuf& data) const = 0;
  16. protected:
  17. const TProtoInfo Info_;
  18. };
  19. class TProtobufSerialize : public TBoxedValue {
  20. public:
  21. TProtobufSerialize(const TProtoInfo& info);
  22. ~TProtobufSerialize() override;
  23. TUnboxedValue Run(
  24. const IValueBuilder* valueBuilder,
  25. const TUnboxedValuePod* args) const override;
  26. virtual TMaybe<TString> Serialize(const NProtoBuf::Message& proto) const = 0;
  27. virtual TAutoPtr<NProtoBuf::Message> MakeProto() const = 0;
  28. protected:
  29. const TProtoInfo Info_;
  30. };
  31. TUnboxedValue FillValueFromProto(
  32. const NProtoBuf::Message& proto,
  33. const IValueBuilder* valueBuilder,
  34. const TProtoInfo& info);
  35. } // namespace NUdf
  36. } // namespace NYql