error_attribute-inl.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #ifndef ERROR_ATTRIBUTE_INL_H_
  2. #error "Direct inclusion of this file is not allowed, include error_attribute.h"
  3. // For the sake of sane code completion.
  4. #include "error_attribute.h"
  5. #endif
  6. #include "text_yson.h"
  7. namespace NYT {
  8. ////////////////////////////////////////////////////////////////////////////////
  9. namespace NAttributeValueConversionImpl {
  10. template <CPrimitiveConvertible T>
  11. std::string TagInvoke(TTagInvokeTag<ToErrorAttributeValue>, const T& value)
  12. {
  13. if constexpr (std::constructible_from<TStringBuf, const T&>) {
  14. return NDetail::ConvertToTextYsonString(TStringBuf(value));
  15. } else {
  16. return NDetail::ConvertToTextYsonString(value);
  17. }
  18. }
  19. ////////////////////////////////////////////////////////////////////////////////
  20. template <CPrimitiveConvertible T>
  21. T TagInvoke(TFrom<T>, TStringBuf value)
  22. {
  23. YT_VERIFY(!NDetail::IsBinaryYson(value));
  24. return NDetail::ConvertFromTextYsonString<T>(value);
  25. }
  26. } // namespace NAttributeValueConversionImpl
  27. ////////////////////////////////////////////////////////////////////////////////
  28. } // namespace NYT