aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/protobuf/json/json_value_output.cpp
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:17 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:17 +0300
commitd3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch)
treedd4bd3ca0f36b817e96812825ffaf10d645803f2 /library/cpp/protobuf/json/json_value_output.cpp
parent72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff)
downloadydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/protobuf/json/json_value_output.cpp')
-rw-r--r--library/cpp/protobuf/json/json_value_output.cpp198
1 files changed, 99 insertions, 99 deletions
diff --git a/library/cpp/protobuf/json/json_value_output.cpp b/library/cpp/protobuf/json/json_value_output.cpp
index 3ac95354d6..d845cc1c74 100644
--- a/library/cpp/protobuf/json/json_value_output.cpp
+++ b/library/cpp/protobuf/json/json_value_output.cpp
@@ -3,104 +3,104 @@
#include <library/cpp/json/json_reader.h>
namespace NProtobufJson {
- template <typename T>
- void TJsonValueOutput::WriteImpl(const T& t) {
- Y_ASSERT(Context.top().Type == TContext::JSON_ARRAY || Context.top().Type == TContext::JSON_AFTER_KEY);
-
- if (Context.top().Type == TContext::JSON_AFTER_KEY) {
- Context.top().Value = t;
- Context.pop();
- } else {
- Context.top().Value.AppendValue(t);
- }
- }
-
- void TJsonValueOutput::DoWrite(const TStringBuf& s) {
- WriteImpl(s);
- }
-
- void TJsonValueOutput::DoWrite(const TString& s) {
- WriteImpl(s);
- }
-
- void TJsonValueOutput::DoWrite(int i) {
- WriteImpl(i);
- }
-
- void TJsonValueOutput::DoWrite(unsigned int i) {
- WriteImpl(i);
- }
-
- void TJsonValueOutput::DoWrite(long long i) {
- WriteImpl(i);
- }
-
- void TJsonValueOutput::DoWrite(unsigned long long i) {
- WriteImpl(i);
- }
-
- void TJsonValueOutput::DoWrite(float f) {
- WriteImpl(f);
- }
-
- void TJsonValueOutput::DoWrite(double f) {
- WriteImpl(f);
- }
-
- void TJsonValueOutput::DoWrite(bool b) {
- WriteImpl(b);
- }
-
- void TJsonValueOutput::DoWriteNull() {
- WriteImpl(NJson::JSON_NULL);
- }
-
- void TJsonValueOutput::DoBeginList() {
- Y_ASSERT(Context.top().Type == TContext::JSON_ARRAY || Context.top().Type == TContext::JSON_AFTER_KEY);
-
- if (Context.top().Type == TContext::JSON_AFTER_KEY) {
- Context.top().Type = TContext::JSON_ARRAY;
- Context.top().Value.SetType(NJson::JSON_ARRAY);
- } else {
- Context.emplace(TContext::JSON_ARRAY, Context.top().Value.AppendValue(NJson::JSON_ARRAY));
- }
- }
-
- void TJsonValueOutput::DoEndList() {
- Y_ASSERT(Context.top().Type == TContext::JSON_ARRAY);
- Context.pop();
- }
-
- void TJsonValueOutput::DoBeginObject() {
- Y_ASSERT(Context.top().Type == TContext::JSON_ARRAY || Context.top().Type == TContext::JSON_AFTER_KEY);
-
- if (Context.top().Type == TContext::JSON_AFTER_KEY) {
- Context.top().Type = TContext::JSON_MAP;
- Context.top().Value.SetType(NJson::JSON_MAP);
- } else {
- Context.emplace(TContext::JSON_MAP, Context.top().Value.AppendValue(NJson::JSON_MAP));
- }
- }
-
- void TJsonValueOutput::DoWriteKey(const TStringBuf& key) {
- Y_ASSERT(Context.top().Type == TContext::JSON_MAP);
- Context.emplace(TContext::JSON_AFTER_KEY, Context.top().Value[key]);
- }
-
- void TJsonValueOutput::DoEndObject() {
- Y_ASSERT(Context.top().Type == TContext::JSON_MAP);
- Context.pop();
- }
-
- void TJsonValueOutput::DoWriteRawJson(const TStringBuf& str) {
- Y_ASSERT(Context.top().Type == TContext::JSON_ARRAY || Context.top().Type == TContext::JSON_AFTER_KEY);
-
- if (Context.top().Type == TContext::JSON_AFTER_KEY) {
- NJson::ReadJsonTree(str, &Context.top().Value);
- Context.pop();
- } else {
- NJson::ReadJsonTree(str, &Context.top().Value.AppendValue(NJson::JSON_UNDEFINED));
- }
- }
+ template <typename T>
+ void TJsonValueOutput::WriteImpl(const T& t) {
+ Y_ASSERT(Context.top().Type == TContext::JSON_ARRAY || Context.top().Type == TContext::JSON_AFTER_KEY);
+
+ if (Context.top().Type == TContext::JSON_AFTER_KEY) {
+ Context.top().Value = t;
+ Context.pop();
+ } else {
+ Context.top().Value.AppendValue(t);
+ }
+ }
+
+ void TJsonValueOutput::DoWrite(const TStringBuf& s) {
+ WriteImpl(s);
+ }
+
+ void TJsonValueOutput::DoWrite(const TString& s) {
+ WriteImpl(s);
+ }
+
+ void TJsonValueOutput::DoWrite(int i) {
+ WriteImpl(i);
+ }
+
+ void TJsonValueOutput::DoWrite(unsigned int i) {
+ WriteImpl(i);
+ }
+
+ void TJsonValueOutput::DoWrite(long long i) {
+ WriteImpl(i);
+ }
+
+ void TJsonValueOutput::DoWrite(unsigned long long i) {
+ WriteImpl(i);
+ }
+
+ void TJsonValueOutput::DoWrite(float f) {
+ WriteImpl(f);
+ }
+
+ void TJsonValueOutput::DoWrite(double f) {
+ WriteImpl(f);
+ }
+
+ void TJsonValueOutput::DoWrite(bool b) {
+ WriteImpl(b);
+ }
+
+ void TJsonValueOutput::DoWriteNull() {
+ WriteImpl(NJson::JSON_NULL);
+ }
+
+ void TJsonValueOutput::DoBeginList() {
+ Y_ASSERT(Context.top().Type == TContext::JSON_ARRAY || Context.top().Type == TContext::JSON_AFTER_KEY);
+
+ if (Context.top().Type == TContext::JSON_AFTER_KEY) {
+ Context.top().Type = TContext::JSON_ARRAY;
+ Context.top().Value.SetType(NJson::JSON_ARRAY);
+ } else {
+ Context.emplace(TContext::JSON_ARRAY, Context.top().Value.AppendValue(NJson::JSON_ARRAY));
+ }
+ }
+
+ void TJsonValueOutput::DoEndList() {
+ Y_ASSERT(Context.top().Type == TContext::JSON_ARRAY);
+ Context.pop();
+ }
+
+ void TJsonValueOutput::DoBeginObject() {
+ Y_ASSERT(Context.top().Type == TContext::JSON_ARRAY || Context.top().Type == TContext::JSON_AFTER_KEY);
+
+ if (Context.top().Type == TContext::JSON_AFTER_KEY) {
+ Context.top().Type = TContext::JSON_MAP;
+ Context.top().Value.SetType(NJson::JSON_MAP);
+ } else {
+ Context.emplace(TContext::JSON_MAP, Context.top().Value.AppendValue(NJson::JSON_MAP));
+ }
+ }
+
+ void TJsonValueOutput::DoWriteKey(const TStringBuf& key) {
+ Y_ASSERT(Context.top().Type == TContext::JSON_MAP);
+ Context.emplace(TContext::JSON_AFTER_KEY, Context.top().Value[key]);
+ }
+
+ void TJsonValueOutput::DoEndObject() {
+ Y_ASSERT(Context.top().Type == TContext::JSON_MAP);
+ Context.pop();
+ }
+
+ void TJsonValueOutput::DoWriteRawJson(const TStringBuf& str) {
+ Y_ASSERT(Context.top().Type == TContext::JSON_ARRAY || Context.top().Type == TContext::JSON_AFTER_KEY);
+
+ if (Context.top().Type == TContext::JSON_AFTER_KEY) {
+ NJson::ReadJsonTree(str, &Context.top().Value);
+ Context.pop();
+ } else {
+ NJson::ReadJsonTree(str, &Context.top().Value.AppendValue(NJson::JSON_UNDEFINED));
+ }
+ }
}