aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/json/writer
diff options
context:
space:
mode:
authorivanmorozov <ivanmorozov@yandex-team.ru>2022-02-10 16:47:34 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:34 +0300
commit464ba3814a83db4f2d5327393b0b6eaf0c86bfd7 (patch)
treec0748b5dcbade83af788c0abfa89c0383d6b779c /library/cpp/json/writer
parentcba5d9a444e2cfe105f55ccda66cd21d50440017 (diff)
downloadydb-464ba3814a83db4f2d5327393b0b6eaf0c86bfd7.tar.gz
Restoring authorship annotation for <ivanmorozov@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/json/writer')
-rw-r--r--library/cpp/json/writer/json_value.cpp18
-rw-r--r--library/cpp/json/writer/json_value.h10
-rw-r--r--library/cpp/json/writer/json_value_ut.cpp32
3 files changed, 30 insertions, 30 deletions
diff --git a/library/cpp/json/writer/json_value.cpp b/library/cpp/json/writer/json_value.cpp
index fe9ae61505..c61e8d1dc4 100644
--- a/library/cpp/json/writer/json_value.cpp
+++ b/library/cpp/json/writer/json_value.cpp
@@ -9,7 +9,7 @@
#include <util/stream/output.h>
#include <util/string/cast.h>
#include <util/string/type.h>
-#include <util/string/vector.h>
+#include <util/string/vector.h>
#include <util/system/yassert.h>
#include <util/ysaveload.h>
#include <util/generic/bt_exception.h>
@@ -850,7 +850,7 @@ namespace NJson {
}
return currentJson;
- }
+ }
} // anonymous namespace
bool TJsonValue::GetValueByPath(const TStringBuf path, TJsonValue& result, char delimiter) const {
@@ -860,8 +860,8 @@ namespace NJson {
return true;
}
return false;
- }
-
+ }
+
bool TJsonValue::SetValueByPath(const TStringBuf path, const TJsonValue& value, char delimiter) {
TJsonValue* const ptr = GetValuePtrByPath<true>(this, path, delimiter);
if (ptr) {
@@ -886,12 +886,12 @@ namespace NJson {
TJsonValue* TJsonValue::GetValueByPath(const TStringBuf key, char delim) noexcept {
return GetValuePtrByPath<false>(this, key, delim);
- }
+ }
void TJsonValue::DoScan(const TString& path, TJsonValue* parent, IScanCallback& callback) {
if (!callback.Do(path, parent, *this)) {
return;
- }
+ }
if (Type == JSON_MAP) {
for (auto&& i : *Value.Map) {
@@ -901,9 +901,9 @@ namespace NJson {
for (ui32 i = 0; i < Value.Array->size(); ++i) {
(*Value.Array)[i].DoScan(TString::Join(path, "[", ToString(i), "]"), this, callback);
}
- }
- }
-
+ }
+ }
+
void TJsonValue::Scan(IScanCallback& callback) {
DoScan("", nullptr, callback);
}
diff --git a/library/cpp/json/writer/json_value.h b/library/cpp/json/writer/json_value.h
index b41712c5d6..3f0f50bc4c 100644
--- a/library/cpp/json/writer/json_value.h
+++ b/library/cpp/json/writer/json_value.h
@@ -27,13 +27,13 @@ namespace NJson {
class IScanCallback {
public:
virtual ~IScanCallback() = default;
-
+
virtual bool Do(const TString& path, TJsonValue* parent, TJsonValue& value) = 0;
};
-
+
class TJsonValue {
void Clear() noexcept;
-
+
public:
typedef THashMap<TString, TJsonValue> TMapType;
typedef TDeque<TJsonValue> TArray;
@@ -96,7 +96,7 @@ namespace NJson {
// returns NULL on failure
const TJsonValue* GetValueByPath(TStringBuf path, char delimiter = '.') const noexcept;
TJsonValue* GetValueByPath(TStringBuf path, char delimiter = '.') noexcept;
-
+
void EraseValue(TStringBuf key);
void EraseValue(size_t index);
@@ -178,7 +178,7 @@ namespace NJson {
/// Non-robust comparison.
bool operator==(const TJsonValue& rhs) const;
-
+
bool operator!=(const TJsonValue& rhs) const {
return !(*this == rhs);
}
diff --git a/library/cpp/json/writer/json_value_ut.cpp b/library/cpp/json/writer/json_value_ut.cpp
index 40000bd68a..dc7f6affdf 100644
--- a/library/cpp/json/writer/json_value_ut.cpp
+++ b/library/cpp/json/writer/json_value_ut.cpp
@@ -234,22 +234,22 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) {
}
Y_UNIT_TEST(GetValueByPathTest) {
- {
- TJsonValue lhs;
- TJsonValue first;
- TJsonValue second;
- TJsonValue last;
- first.InsertValue("e", "f");
- second.InsertValue("c", first);
- last.InsertValue("a", second);
- lhs.InsertValue("l", last);
-
- TJsonValue result;
+ {
+ TJsonValue lhs;
+ TJsonValue first;
+ TJsonValue second;
+ TJsonValue last;
+ first.InsertValue("e", "f");
+ second.InsertValue("c", first);
+ last.InsertValue("a", second);
+ lhs.InsertValue("l", last);
+
+ TJsonValue result;
UNIT_ASSERT(lhs.GetValueByPath("l/a/c/e", result, '/'));
- UNIT_ASSERT(result.GetStringRobust() == "f");
+ UNIT_ASSERT(result.GetStringRobust() == "f");
UNIT_ASSERT(!lhs.GetValueByPath("l/a/c/se", result, '/'));
UNIT_ASSERT(lhs.GetValueByPath("l/a/c", result, '/'));
- UNIT_ASSERT(result.GetStringRobust() == "{\"e\":\"f\"}");
+ UNIT_ASSERT(result.GetStringRobust() == "{\"e\":\"f\"}");
// faster TStringBuf version
UNIT_ASSERT_EQUAL(*lhs.GetValueByPath("l", '/'), last);
@@ -282,9 +282,9 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) {
UNIT_ASSERT(lhs.SetValueByPath("l/a/c/se", "h", '/'));
UNIT_ASSERT(lhs.GetValueByPath("l/a/c/se", result, '/'));
UNIT_ASSERT(result.GetStringRobust() == "h");
- }
- }
-
+ }
+ }
+
Y_UNIT_TEST(GetValueByPathConstTest) {
TJsonValue lhs;
TJsonValue first;