#pragma once #include #include #include namespace NSQLTranslationV1 { class TContext; template class TNullable final: public TPtr { public: // Every pointer is nullable // NOLINTNEXTLINE(google-explicit-constructor) TNullable(TPtr ptr) : TPtr(std::move(ptr)) { } }; template class TNonNull final: public TPtr { public: explicit TNonNull(TPtr ptr) : TPtr(std::move(ptr)) { YQL_ENSURE(*static_cast(this)); } operator bool() = delete; }; enum class ESQLError { Basic, UnsupportedYqlSelect, }; std::unexpected UnsupportedYqlSelect(TContext& ctx, TStringBuf message); template using TSQLResult = std::expected; using TSQLStatus = TSQLResult; template bool IsUnwrappable(const TSQLResult& result) { return result || result.error() == ESQLError::Basic; } template void EnsureUnwrappable(const TSQLResult& result) { YQL_ENSURE( IsUnwrappable(result), "Expected " << "at most " << ESQLError::Basic << " error, " << "but got " << result.error()); } bool Unwrap(TSQLStatus status); } // namespace NSQLTranslationV1