aboutsummaryrefslogtreecommitdiffstats
path: root/yt/yt/core/ypath/token.h
blob: 80f32b70bb133da8d29a5ae325a6310e5cf2e369 (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
#pragma once

#include "public.h"

namespace NYT::NYPath {

////////////////////////////////////////////////////////////////////////////////

extern const TStringBuf ListBeginToken;
extern const TStringBuf ListEndToken;
extern const TStringBuf ListBeforeToken;
extern const TStringBuf ListAfterToken;

DEFINE_ENUM(ETokenType,
    (Literal)
    (Slash)
    (Ampersand)
    (At)
    (Asterisk)
    (StartOfStream)
    (EndOfStream)
    (Range)
);

TString ToYPathLiteral(TStringBuf value);
TString ToYPathLiteral(i64 value);
TString ToYPathLiteral(TGuid value);
template <class E>
    requires TEnumTraits<E>::IsEnum
TString ToYPathLiteral(E value);

template <class T, class TTag>
TString ToYPathLiteral(const TStrongTypedef<T, TTag>& value);

void AppendYPathLiteral(TStringBuilderBase* builder, TStringBuf value);
void AppendYPathLiteral(TStringBuilderBase* builder, i64 value);

TStringBuf ExtractListIndex(TStringBuf token);
int ParseListIndex(TStringBuf token);
std::optional<int> TryAdjustListIndex(int index, int count);

bool IsSpecialListKey(TStringBuf key);
bool IsSpecialCharacter(char ch);

////////////////////////////////////////////////////////////////////////////////

} // namespace NYT::NYPath

#define TOKEN_INL_H_
#include "token-inl.h"
#undef TOKEN_INL_H_