aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/minikql/mkql_utils.h
blob: c6741502e44b826d417bcd64b924c62546029626 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#pragma once

#include <util/generic/strbuf.h>
#include <util/generic/string.h>

namespace NKikimr {
namespace NMiniKQL {

// TODO: move this class to beter place
class TStatus
{
public:
    inline static const TStatus Ok() {
        return TStatus();
    }

    inline static TStatus Error(const TStringBuf& error) {
        Y_DEBUG_ABORT_UNLESS(!error.empty());
        return TStatus(TString(error));
    }

    inline static TStatus Error(TString&& error) {
        Y_DEBUG_ABORT_UNLESS(!error.empty());
        return TStatus(std::move(error));
    }

    inline static TStatus Error() {
        return TStatus(TString(TStringBuf("Error: ")));
    }

    template <class T>
    inline TStatus& operator<<(const T& t) {
        Error_.append(t);
        return *this;
    }

    inline bool IsOk() const {
        return Error_.empty();
    }

    inline const TString& GetError() const {
        return Error_;
    }

private:
    inline TStatus() = default;

    inline TStatus(TString&& error)
        : Error_(std::move(error))
    {
    }

private:
    TString Error_;
};

} // namespace NMiniKQL
} // namespace NKikimr