aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yson/node/node_visitor.cpp
diff options
context:
space:
mode:
authormonster <monster@yandex-team.ru>2022-02-10 16:47:19 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:19 +0300
commitb23c1d7a8015c2006a148fd93b84cdeb0aee17a3 (patch)
tree9814fbd1c3effac9b8377c5d604b367b14e2db55 /library/cpp/yson/node/node_visitor.cpp
parentdd76ae1f6213d065375ab296699f764faafbe5bd (diff)
downloadydb-b23c1d7a8015c2006a148fd93b84cdeb0aee17a3.tar.gz
Restoring authorship annotation for <monster@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/yson/node/node_visitor.cpp')
-rw-r--r--library/cpp/yson/node/node_visitor.cpp178
1 files changed, 89 insertions, 89 deletions
diff --git a/library/cpp/yson/node/node_visitor.cpp b/library/cpp/yson/node/node_visitor.cpp
index 824d934867..899fbfa02a 100644
--- a/library/cpp/yson/node/node_visitor.cpp
+++ b/library/cpp/yson/node/node_visitor.cpp
@@ -1,12 +1,12 @@
-#include "node_visitor.h"
-
+#include "node_visitor.h"
+
#include <util/generic/algorithm.h>
#include <util/string/printf.h>
-namespace NYT {
-
-////////////////////////////////////////////////////////////////////////////////
-
+namespace NYT {
+
+////////////////////////////////////////////////////////////////////////////////
+
namespace {
template <typename Fun>
@@ -31,122 +31,122 @@ void Iterate(const TNode::TMapType& nodeMap, bool sortByKey, Fun action)
////////////////////////////////////////////////////////////////////////////////
TNodeVisitor::TNodeVisitor(NYson::IYsonConsumer* consumer, bool sortMapKeys)
- : Consumer_(consumer)
+ : Consumer_(consumer)
, SortMapKeys_(sortMapKeys)
-{ }
-
-void TNodeVisitor::Visit(const TNode& node)
-{
- VisitAny(node);
-}
-
-void TNodeVisitor::VisitAny(const TNode& node)
-{
- if (node.HasAttributes()) {
- Consumer_->OnBeginAttributes();
+{ }
+
+void TNodeVisitor::Visit(const TNode& node)
+{
+ VisitAny(node);
+}
+
+void TNodeVisitor::VisitAny(const TNode& node)
+{
+ if (node.HasAttributes()) {
+ Consumer_->OnBeginAttributes();
Iterate(node.GetAttributes().AsMap(), SortMapKeys_, [&](const std::pair<TString, TNode>& item) {
- Consumer_->OnKeyedItem(item.first);
+ Consumer_->OnKeyedItem(item.first);
if (item.second.IsUndefined()) {
ythrow TNode::TTypeError() << "unable to visit attribute value of type "
<< TNode::EType::Undefined << "; attribute name: `" << item.first << '\'' ;
}
- VisitAny(item.second);
+ VisitAny(item.second);
});
- Consumer_->OnEndAttributes();
- }
-
- switch (node.GetType()) {
+ Consumer_->OnEndAttributes();
+ }
+
+ switch (node.GetType()) {
case TNode::String:
- VisitString(node);
- break;
+ VisitString(node);
+ break;
case TNode::Int64:
- VisitInt64(node);
- break;
+ VisitInt64(node);
+ break;
case TNode::Uint64:
- VisitUint64(node);
- break;
+ VisitUint64(node);
+ break;
case TNode::Double:
- VisitDouble(node);
- break;
+ VisitDouble(node);
+ break;
case TNode::Bool:
- VisitBool(node);
- break;
+ VisitBool(node);
+ break;
case TNode::List:
VisitList(node.AsList());
- break;
+ break;
case TNode::Map:
VisitMap(node.AsMap());
- break;
+ break;
case TNode::Null:
- VisitEntity();
- break;
+ VisitEntity();
+ break;
case TNode::Undefined:
ythrow TNode::TTypeError() << "unable to visit TNode of type " << node.GetType();
default:
Y_FAIL("Unexpected type: %d", node.GetType());
- }
-}
-
-void TNodeVisitor::VisitString(const TNode& node)
-{
- Consumer_->OnStringScalar(node.AsString());
-}
-
-void TNodeVisitor::VisitInt64(const TNode& node)
-{
- Consumer_->OnInt64Scalar(node.AsInt64());
-}
-
-void TNodeVisitor::VisitUint64(const TNode& node)
-{
- Consumer_->OnUint64Scalar(node.AsUint64());
-}
-
-void TNodeVisitor::VisitDouble(const TNode& node)
-{
- Consumer_->OnDoubleScalar(node.AsDouble());
-}
-
-void TNodeVisitor::VisitBool(const TNode& node)
-{
- Consumer_->OnBooleanScalar(node.AsBool());
-}
-
+ }
+}
+
+void TNodeVisitor::VisitString(const TNode& node)
+{
+ Consumer_->OnStringScalar(node.AsString());
+}
+
+void TNodeVisitor::VisitInt64(const TNode& node)
+{
+ Consumer_->OnInt64Scalar(node.AsInt64());
+}
+
+void TNodeVisitor::VisitUint64(const TNode& node)
+{
+ Consumer_->OnUint64Scalar(node.AsUint64());
+}
+
+void TNodeVisitor::VisitDouble(const TNode& node)
+{
+ Consumer_->OnDoubleScalar(node.AsDouble());
+}
+
+void TNodeVisitor::VisitBool(const TNode& node)
+{
+ Consumer_->OnBooleanScalar(node.AsBool());
+}
+
void TNodeVisitor::VisitList(const TNode::TListType& nodeList)
-{
- Consumer_->OnBeginList();
+{
+ Consumer_->OnBeginList();
size_t index = 0;
for (const auto& item : nodeList) {
- Consumer_->OnListItem();
+ Consumer_->OnListItem();
if (item.IsUndefined()) {
ythrow TNode::TTypeError() << "unable to visit list node child of type "
<< TNode::EType::Undefined << "; list index: " << index;
}
- VisitAny(item);
+ VisitAny(item);
++index;
- }
- Consumer_->OnEndList();
-}
-
+ }
+ Consumer_->OnEndList();
+}
+
void TNodeVisitor::VisitMap(const TNode::TMapType& nodeMap)
-{
- Consumer_->OnBeginMap();
+{
+ Consumer_->OnBeginMap();
Iterate(nodeMap, SortMapKeys_, [&](const std::pair<TString, TNode>& item) {
- Consumer_->OnKeyedItem(item.first);
+ Consumer_->OnKeyedItem(item.first);
if (item.second.IsUndefined()) {
ythrow TNode::TTypeError() << "unable to visit map node child of type "
<< TNode::EType::Undefined << "; map key: `" << item.first << '\'' ;
}
- VisitAny(item.second);
+ VisitAny(item.second);
});
- Consumer_->OnEndMap();
-}
-
-void TNodeVisitor::VisitEntity()
-{
- Consumer_->OnEntity();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-
-} // namespace NYT
+ Consumer_->OnEndMap();
+}
+
+void TNodeVisitor::VisitEntity()
+{
+ Consumer_->OnEntity();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+} // namespace NYT