aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/json/yson/json2yson.h
diff options
context:
space:
mode:
authorelshiko <elshiko@yandex-team.ru>2022-02-10 16:49:20 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:20 +0300
commitdbb5d0d21c8cfc3d59e0f6d3b6f4ab06b58561f1 (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/json/yson/json2yson.h
parent455ab915435b70e433ed91eee2ca84f03122d6cb (diff)
downloadydb-dbb5d0d21c8cfc3d59e0f6d3b6f4ab06b58561f1.tar.gz
Restoring authorship annotation for <elshiko@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/json/yson/json2yson.h')
-rw-r--r--library/cpp/json/yson/json2yson.h328
1 files changed, 164 insertions, 164 deletions
diff --git a/library/cpp/json/yson/json2yson.h b/library/cpp/json/yson/json2yson.h
index 6d2ef4246f..758eb6d0cf 100644
--- a/library/cpp/json/yson/json2yson.h
+++ b/library/cpp/json/yson/json2yson.h
@@ -1,179 +1,179 @@
-#pragma once
-
+#pragma once
+
#include <library/cpp/json/json_reader.h>
#include <library/cpp/json/json_value.h>
#include <library/cpp/yson/writer.h>
-
-namespace NJson2Yson {
+
+namespace NJson2Yson {
class TJsonBuilderImpl: public NYson::TYsonConsumerBase {
- public:
+ public:
TJsonBuilderImpl(NJson::TJsonCallbacks* parserCallbacks)
- : ParserCallbacks_(parserCallbacks)
- {
- }
-
+ : ParserCallbacks_(parserCallbacks)
+ {
+ }
+
void OnStringScalar(TStringBuf value) override {
- ParserCallbacks_->OnString(value);
- }
-
- void OnInt64Scalar(i64 value) override {
- ParserCallbacks_->OnInteger(value);
- }
-
- void OnUint64Scalar(ui64 value) override {
- ParserCallbacks_->OnUInteger(value);
- }
-
- void OnDoubleScalar(double value) override {
- ParserCallbacks_->OnDouble(value);
- }
-
- void OnBooleanScalar(bool value) override {
- ParserCallbacks_->OnBoolean(value);
- }
-
- void OnEntity() override {
- ParserCallbacks_->OnNull();
- }
-
- void OnBeginList() override {
- ParserCallbacks_->OnOpenArray();
- }
-
- void OnListItem() override {
- }
-
- void OnEndList() override {
- ParserCallbacks_->OnCloseArray();
- }
-
- void OnBeginMap() override {
- ParserCallbacks_->OnOpenMap();
- }
-
+ ParserCallbacks_->OnString(value);
+ }
+
+ void OnInt64Scalar(i64 value) override {
+ ParserCallbacks_->OnInteger(value);
+ }
+
+ void OnUint64Scalar(ui64 value) override {
+ ParserCallbacks_->OnUInteger(value);
+ }
+
+ void OnDoubleScalar(double value) override {
+ ParserCallbacks_->OnDouble(value);
+ }
+
+ void OnBooleanScalar(bool value) override {
+ ParserCallbacks_->OnBoolean(value);
+ }
+
+ void OnEntity() override {
+ ParserCallbacks_->OnNull();
+ }
+
+ void OnBeginList() override {
+ ParserCallbacks_->OnOpenArray();
+ }
+
+ void OnListItem() override {
+ }
+
+ void OnEndList() override {
+ ParserCallbacks_->OnCloseArray();
+ }
+
+ void OnBeginMap() override {
+ ParserCallbacks_->OnOpenMap();
+ }
+
void OnKeyedItem(TStringBuf key) override {
- ParserCallbacks_->OnMapKey(key);
- }
-
- void OnEndMap() override {
- ParserCallbacks_->OnCloseMap();
- }
-
- void OnBeginAttributes() override {
- }
-
- void OnEndAttributes() override {
- }
-
- private:
+ ParserCallbacks_->OnMapKey(key);
+ }
+
+ void OnEndMap() override {
+ ParserCallbacks_->OnCloseMap();
+ }
+
+ void OnBeginAttributes() override {
+ }
+
+ void OnEndAttributes() override {
+ }
+
+ private:
NJson::TJsonCallbacks* ParserCallbacks_;
- };
-
- template <typename TBase>
- class TSkipAttributesProxy: public TBase {
- public:
+ };
+
+ template <typename TBase>
+ class TSkipAttributesProxy: public TBase {
+ public:
template <typename... TArgs>
TSkipAttributesProxy<TBase>(TArgs&&... args)
: TBase(std::forward<TArgs>(args)...)
- {
- }
-
+ {
+ }
+
void OnStringScalar(TStringBuf value) override {
- if (AttributesDepth == 0) {
- TBase::OnStringScalar(value);
- }
- }
-
- void OnInt64Scalar(i64 value) override {
- if (AttributesDepth == 0) {
- TBase::OnInt64Scalar(value);
- }
- }
-
- void OnUint64Scalar(ui64 value) override {
- if (AttributesDepth == 0) {
- TBase::OnUint64Scalar(value);
- }
- }
-
- void OnDoubleScalar(double value) override {
- if (AttributesDepth == 0) {
- TBase::OnDoubleScalar(value);
- }
- }
-
- void OnBooleanScalar(bool value) override {
- if (AttributesDepth == 0) {
- TBase::OnBooleanScalar(value);
- }
- }
-
- void OnEntity() override {
- if (AttributesDepth == 0) {
- TBase::OnEntity();
- }
- }
-
- void OnBeginList() override {
- if (AttributesDepth == 0) {
- TBase::OnBeginList();
- }
- }
-
- void OnListItem() override {
- if (AttributesDepth == 0) {
- TBase::OnListItem();
- }
- }
-
- void OnEndList() override {
- if (AttributesDepth == 0) {
- TBase::OnEndList();
- }
- }
-
- void OnBeginMap() override {
- if (AttributesDepth == 0) {
- TBase::OnBeginMap();
- }
- }
-
+ if (AttributesDepth == 0) {
+ TBase::OnStringScalar(value);
+ }
+ }
+
+ void OnInt64Scalar(i64 value) override {
+ if (AttributesDepth == 0) {
+ TBase::OnInt64Scalar(value);
+ }
+ }
+
+ void OnUint64Scalar(ui64 value) override {
+ if (AttributesDepth == 0) {
+ TBase::OnUint64Scalar(value);
+ }
+ }
+
+ void OnDoubleScalar(double value) override {
+ if (AttributesDepth == 0) {
+ TBase::OnDoubleScalar(value);
+ }
+ }
+
+ void OnBooleanScalar(bool value) override {
+ if (AttributesDepth == 0) {
+ TBase::OnBooleanScalar(value);
+ }
+ }
+
+ void OnEntity() override {
+ if (AttributesDepth == 0) {
+ TBase::OnEntity();
+ }
+ }
+
+ void OnBeginList() override {
+ if (AttributesDepth == 0) {
+ TBase::OnBeginList();
+ }
+ }
+
+ void OnListItem() override {
+ if (AttributesDepth == 0) {
+ TBase::OnListItem();
+ }
+ }
+
+ void OnEndList() override {
+ if (AttributesDepth == 0) {
+ TBase::OnEndList();
+ }
+ }
+
+ void OnBeginMap() override {
+ if (AttributesDepth == 0) {
+ TBase::OnBeginMap();
+ }
+ }
+
void OnKeyedItem(TStringBuf key) override {
- if (AttributesDepth == 0) {
- TBase::OnKeyedItem(key);
- }
- }
-
- void OnEndMap() override {
- if (AttributesDepth == 0) {
- TBase::OnEndMap();
- }
- }
-
- void OnBeginAttributes() override {
- ++AttributesDepth;
- }
-
- void OnEndAttributes() override {
- --AttributesDepth;
+ if (AttributesDepth == 0) {
+ TBase::OnKeyedItem(key);
+ }
+ }
+
+ void OnEndMap() override {
+ if (AttributesDepth == 0) {
+ TBase::OnEndMap();
+ }
+ }
+
+ void OnBeginAttributes() override {
+ ++AttributesDepth;
+ }
+
+ void OnEndAttributes() override {
+ --AttributesDepth;
Y_ASSERT(AttributesDepth >= 0);
- }
-
- private:
- int AttributesDepth = 0;
- };
-
- using TJsonBuilder = TSkipAttributesProxy<TJsonBuilderImpl>;
-
- void ConvertYson2Json(IInputStream* inputStream, IOutputStream* outputStream);
- void ConvertYson2Json(TStringBuf yson, IOutputStream* outputStream);
- TString ConvertYson2Json(TStringBuf yson);
-
- bool DeserializeYsonAsJsonValue(IInputStream* inputStream, NJson::TJsonValue* outputValue, bool throwOnError = false);
- bool DeserializeYsonAsJsonValue(TStringBuf str, NJson::TJsonValue* outputValue, bool throwOnError = false);
-
+ }
+
+ private:
+ int AttributesDepth = 0;
+ };
+
+ using TJsonBuilder = TSkipAttributesProxy<TJsonBuilderImpl>;
+
+ void ConvertYson2Json(IInputStream* inputStream, IOutputStream* outputStream);
+ void ConvertYson2Json(TStringBuf yson, IOutputStream* outputStream);
+ TString ConvertYson2Json(TStringBuf yson);
+
+ bool DeserializeYsonAsJsonValue(IInputStream* inputStream, NJson::TJsonValue* outputValue, bool throwOnError = false);
+ bool DeserializeYsonAsJsonValue(TStringBuf str, NJson::TJsonValue* outputValue, bool throwOnError = false);
+
void SerializeJsonValueAsYson(const NJson::TJsonValue& inputValue, NYson::TYsonWriter* ysonWriter);
- void SerializeJsonValueAsYson(const NJson::TJsonValue& inputValue, IOutputStream* outputStream);
- void SerializeJsonValueAsYson(const NJson::TJsonValue& inputValue, TString& result);
- TString SerializeJsonValueAsYson(const NJson::TJsonValue& inputValue);
-}
+ void SerializeJsonValueAsYson(const NJson::TJsonValue& inputValue, IOutputStream* outputStream);
+ void SerializeJsonValueAsYson(const NJson::TJsonValue& inputValue, TString& result);
+ TString SerializeJsonValueAsYson(const NJson::TJsonValue& inputValue);
+}