blob: 201ba57bbe509412e53b9787e092c20e339d0804 (
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
|
#include "scalar.h"
#include <library/cpp/yson_pull/detail/cescape.h>
#include <util/stream/output.h>
using namespace NYsonPull;
template <>
void Out<TScalar>(IOutputStream& out, const TScalar& value) {
out << '(' << value.Type();
if (value.Type() != EScalarType::Entity) {
out << ' ';
}
switch (value.Type()) {
case EScalarType::Boolean:
out << (value.AsBoolean() ? "true" : "false");
break;
case EScalarType::String:
out << NYsonPull::NDetail::NCEscape::quote(value.AsString());
break;
case EScalarType::Int64:
out << value.AsInt64();
break;
case EScalarType::UInt64:
out << value.AsUInt64();
break;
case EScalarType::Float64:
out << value.AsFloat64();
break;
default:
break;
}
out << ')';
}
bool NYsonPull::operator==(const TScalar& left, const TScalar& right) noexcept {
if (left.Type() != right.Type()) {
return false;
}
switch (left.Type()) {
case EScalarType::Boolean:
return left.AsBoolean() == right.AsBoolean();
case EScalarType::String:
return left.AsString() == right.AsString();
case EScalarType::Int64:
return left.AsInt64() == right.AsInt64();
case EScalarType::UInt64:
return left.AsUInt64() == right.AsUInt64();
case EScalarType::Float64:
return left.AsFloat64() == right.AsFloat64();
case EScalarType::Entity:
return true;
default:
Y_UNREACHABLE();
}
}
|