aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yson/node/node.cpp
diff options
context:
space:
mode:
authoralejes <alejes@yandex-team.ru>2022-02-10 16:49:20 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:20 +0300
commitb60afd91b05e759239ecb08faaf494d5c7445d4e (patch)
treea8c3391fc9e065ab7e9ade6768708b244dff85d7 /library/cpp/yson/node/node.cpp
parent523d26598d9784601932189f7fceb34d61bf7641 (diff)
downloadydb-b60afd91b05e759239ecb08faaf494d5c7445d4e.tar.gz
Restoring authorship annotation for <alejes@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/yson/node/node.cpp')
-rw-r--r--library/cpp/yson/node/node.cpp138
1 files changed, 69 insertions, 69 deletions
diff --git a/library/cpp/yson/node/node.cpp b/library/cpp/yson/node/node.cpp
index b39e070718..a6b73d8933 100644
--- a/library/cpp/yson/node/node.cpp
+++ b/library/cpp/yson/node/node.cpp
@@ -22,75 +22,75 @@ bool TNode::TUndefined::operator==(const TUndefined&) const {
////////////////////////////////////////////////////////////////////////////////
-namespace NNodeCmp {
-
-bool IsComparableType(const TNode::EType type) {
- switch (type) {
- case TNode::String:
- case TNode::Int64:
- case TNode::Uint64:
- case TNode::Double:
- case TNode::Bool:
- case TNode::Null:
- case TNode::Undefined:
- return true;
- default:
- return false;
- }
-}
-
-bool operator<(const TNode& lhs, const TNode& rhs)
-{
- if (!lhs.GetAttributes().Empty() || !rhs.GetAttributes().Empty()) {
- ythrow TNode::TTypeError() << "Unsupported attributes comparison";
- }
-
- if (!IsComparableType(lhs.GetType()) || !IsComparableType(rhs.GetType())) {
- ythrow TNode::TTypeError() << "Unsupported types for comparison: " << lhs.GetType() << " with " << rhs.GetType();
- }
-
- if (lhs.GetType() != rhs.GetType()) {
- return lhs.GetType() < rhs.GetType();
- }
-
- switch (lhs.GetType()) {
- case TNode::String:
- return lhs.AsString() < rhs.AsString();
- case TNode::Int64:
- return lhs.AsInt64() < rhs.AsInt64();
- case TNode::Uint64:
- return lhs.AsUint64() < rhs.AsUint64();
- case TNode::Double:
- return lhs.AsDouble() < rhs.AsDouble();
- case TNode::Bool:
- return lhs.AsBool() < rhs.AsBool();
- case TNode::Null:
- case TNode::Undefined:
- return false;
- default:
- Y_FAIL("Unexpected type: %d", lhs.GetType());
- }
-}
-
-bool operator>(const TNode& lhs, const TNode& rhs)
-{
- return rhs < lhs;
-}
-
-bool operator<=(const TNode& lhs, const TNode& rhs)
-{
- return !(lhs > rhs);
-}
-
-bool operator>=(const TNode& lhs, const TNode& rhs)
-{
- return !(lhs < rhs);
-}
-
-} // namespace NNodeCmp
-
-////////////////////////////////////////////////////////////////////////////////
-
+namespace NNodeCmp {
+
+bool IsComparableType(const TNode::EType type) {
+ switch (type) {
+ case TNode::String:
+ case TNode::Int64:
+ case TNode::Uint64:
+ case TNode::Double:
+ case TNode::Bool:
+ case TNode::Null:
+ case TNode::Undefined:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool operator<(const TNode& lhs, const TNode& rhs)
+{
+ if (!lhs.GetAttributes().Empty() || !rhs.GetAttributes().Empty()) {
+ ythrow TNode::TTypeError() << "Unsupported attributes comparison";
+ }
+
+ if (!IsComparableType(lhs.GetType()) || !IsComparableType(rhs.GetType())) {
+ ythrow TNode::TTypeError() << "Unsupported types for comparison: " << lhs.GetType() << " with " << rhs.GetType();
+ }
+
+ if (lhs.GetType() != rhs.GetType()) {
+ return lhs.GetType() < rhs.GetType();
+ }
+
+ switch (lhs.GetType()) {
+ case TNode::String:
+ return lhs.AsString() < rhs.AsString();
+ case TNode::Int64:
+ return lhs.AsInt64() < rhs.AsInt64();
+ case TNode::Uint64:
+ return lhs.AsUint64() < rhs.AsUint64();
+ case TNode::Double:
+ return lhs.AsDouble() < rhs.AsDouble();
+ case TNode::Bool:
+ return lhs.AsBool() < rhs.AsBool();
+ case TNode::Null:
+ case TNode::Undefined:
+ return false;
+ default:
+ Y_FAIL("Unexpected type: %d", lhs.GetType());
+ }
+}
+
+bool operator>(const TNode& lhs, const TNode& rhs)
+{
+ return rhs < lhs;
+}
+
+bool operator<=(const TNode& lhs, const TNode& rhs)
+{
+ return !(lhs > rhs);
+}
+
+bool operator>=(const TNode& lhs, const TNode& rhs)
+{
+ return !(lhs < rhs);
+}
+
+} // namespace NNodeCmp
+
+////////////////////////////////////////////////////////////////////////////////
+
TNode::TNode()
: Value_(TUndefined{})
{ }