aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/scheme
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/scheme
parent72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff)
downloadydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/scheme')
-rw-r--r--library/cpp/scheme/domscheme_traits.h46
-rw-r--r--library/cpp/scheme/scheme.cpp290
-rw-r--r--library/cpp/scheme/scheme.h122
-rw-r--r--library/cpp/scheme/scheme_cast.h82
-rw-r--r--library/cpp/scheme/scimpl.h134
-rw-r--r--library/cpp/scheme/scimpl_defs.h34
-rw-r--r--library/cpp/scheme/scimpl_json_read.cpp4
-rw-r--r--library/cpp/scheme/scimpl_json_write.cpp108
-rw-r--r--library/cpp/scheme/scimpl_private.cpp2
-rw-r--r--library/cpp/scheme/scimpl_private.h10
-rw-r--r--library/cpp/scheme/scimpl_protobuf.cpp264
-rw-r--r--library/cpp/scheme/tests/ut/scheme_cast_ut.cpp34
-rw-r--r--library/cpp/scheme/tests/ut/scheme_json_ut.cpp66
-rw-r--r--library/cpp/scheme/tests/ut/scheme_path_ut.cpp44
-rw-r--r--library/cpp/scheme/tests/ut/scheme_proto_ut.cpp206
-rw-r--r--library/cpp/scheme/tests/ut/scheme_ut.cpp28
-rw-r--r--library/cpp/scheme/ut_utils/scheme_ut_utils.cpp16
-rw-r--r--library/cpp/scheme/ut_utils/scheme_ut_utils.h16
18 files changed, 753 insertions, 753 deletions
diff --git a/library/cpp/scheme/domscheme_traits.h b/library/cpp/scheme/domscheme_traits.h
index 29c0bf99a9..a11c4dd444 100644
--- a/library/cpp/scheme/domscheme_traits.h
+++ b/library/cpp/scheme/domscheme_traits.h
@@ -1,6 +1,6 @@
#pragma once
-#include "scheme.h"
+#include "scheme.h"
#include <util/string/cast.h>
struct TSchemeTraits {
@@ -135,28 +135,28 @@ struct TSchemeTraits {
return v->IsTrue() || v->IsExplicitFalse();
}
-#define INTEGER_OPS_EX(type, min, max, isUnsigned) \
- static inline void Get(TConstValueRef v, type def, type& i) { \
- if (isUnsigned) { \
- i = v->IsNumber() && v->GetIntNumber() >= 0 ? v->GetIntNumber() : def; \
- } else { \
- i = v->IsNumber() ? v->GetIntNumber() : def; \
- } \
- } \
- static inline void Get(TConstValueRef v, type& i) { \
- if (isUnsigned) { \
- i = Max<i64>(0, v->GetIntNumber()); \
- } else { \
- i = v->GetIntNumber(); \
- } \
- } \
- static inline bool IsValidPrimitive(const type&, TConstValueRef v) { \
- return v->IsIntNumber() && \
- v->GetIntNumber() >= min && \
- v->GetIntNumber() <= max; \
- } \
- static inline void Set(TValueRef v, type i) { \
- v->SetIntNumber(i); \
+#define INTEGER_OPS_EX(type, min, max, isUnsigned) \
+ static inline void Get(TConstValueRef v, type def, type& i) { \
+ if (isUnsigned) { \
+ i = v->IsNumber() && v->GetIntNumber() >= 0 ? v->GetIntNumber() : def; \
+ } else { \
+ i = v->IsNumber() ? v->GetIntNumber() : def; \
+ } \
+ } \
+ static inline void Get(TConstValueRef v, type& i) { \
+ if (isUnsigned) { \
+ i = Max<i64>(0, v->GetIntNumber()); \
+ } else { \
+ i = v->GetIntNumber(); \
+ } \
+ } \
+ static inline bool IsValidPrimitive(const type&, TConstValueRef v) { \
+ return v->IsIntNumber() && \
+ v->GetIntNumber() >= min && \
+ v->GetIntNumber() <= max; \
+ } \
+ static inline void Set(TValueRef v, type i) { \
+ v->SetIntNumber(i); \
}
#define INTEGER_OPS(type, isUnsigned) INTEGER_OPS_EX(type, Min<type>(), Max<type>(), isUnsigned)
diff --git a/library/cpp/scheme/scheme.cpp b/library/cpp/scheme/scheme.cpp
index 77439119d3..3efd116d4f 100644
--- a/library/cpp/scheme/scheme.cpp
+++ b/library/cpp/scheme/scheme.cpp
@@ -156,7 +156,7 @@ namespace NSc {
TValue& TValue::DoCopyFromImpl(const TValue& other,
NImpl::TSelfLoopContext& otherLoopCtx,
- NImpl::TSelfOverrideContext& selfOverrideCtx) {
+ NImpl::TSelfOverrideContext& selfOverrideCtx) {
if (Same(*this, other)) {
return *this;
}
@@ -176,44 +176,44 @@ namespace NSc {
}
switch (otherCore.ValueType) {
- default:
- Y_ASSERT(false);
+ default:
+ Y_ASSERT(false);
[[fallthrough]];
- case EType::Null:
- break;
- case EType::Bool:
- selfCore.SetBool(otherCore.IntNumber);
- break;
- case EType::IntNumber:
- selfCore.SetIntNumber(otherCore.IntNumber);
- break;
- case EType::FloatNumber:
- selfCore.SetNumber(otherCore.FloatNumber);
- break;
- case EType::String:
+ case EType::Null:
+ break;
+ case EType::Bool:
+ selfCore.SetBool(otherCore.IntNumber);
+ break;
+ case EType::IntNumber:
+ selfCore.SetIntNumber(otherCore.IntNumber);
+ break;
+ case EType::FloatNumber:
+ selfCore.SetNumber(otherCore.FloatNumber);
+ break;
+ case EType::String:
if (selfCore.Pool.Get() == otherCore.Pool.Get()) {
selfCore.SetOwnedString(otherCore.String);
} else {
selfCore.SetString(otherCore.String);
}
- break;
- case EType::Array:
- selfCore.SetArray();
- for (const TValue& e : otherCore.GetArray()) {
+ break;
+ case EType::Array:
+ selfCore.SetArray();
+ for (const TValue& e : otherCore.GetArray()) {
selfCore.Push().DoCopyFromImpl(e, otherLoopCtx, selfOverrideCtx);
- }
- break;
- case EType::Dict: {
+ }
+ break;
+ case EType::Dict: {
TCorePtr tmp = NewCore(selfCore.Pool);
auto& tmpCore = *tmp;
tmpCore.SetDict();
- const TDict& d = otherCore.GetDict();
+ const TDict& d = otherCore.GetDict();
tmpCore.Dict.reserve(d.size());
- for (const TDict::value_type& e : d) {
+ for (const TDict::value_type& e : d) {
tmpCore.Add(e.first).DoCopyFromImpl(e.second, otherLoopCtx, selfOverrideCtx);
- }
+ }
TheCore = std::move(tmp);
- break;
+ break;
}
}
@@ -283,7 +283,7 @@ namespace NSc {
if (itb == dictB.end() || !Equal(ita.second, itb->second)) {
return false;
- }
+ }
}
}
@@ -301,7 +301,7 @@ namespace NSc {
TValue& TValue::DoMergeImpl(const TValue& delta, bool lowPriorityDelta,
NImpl::TSelfLoopContext& otherLoopCtx,
- NImpl::TSelfOverrideContext& selfOverrideGuard) {
+ NImpl::TSelfOverrideContext& selfOverrideGuard) {
if (Same(*this, delta)) {
return *this;
}
@@ -341,48 +341,48 @@ namespace NSc {
const TScCore& core = Core();
switch (core.ValueType) {
- default:
- case EType::Null:
+ default:
+ case EType::Null:
return NJson::TJsonValue(NJson::JSON_NULL);
- case EType::Bool:
- return NJson::TJsonValue(core.GetBool());
- case EType::IntNumber:
- return NJson::TJsonValue(core.GetIntNumber());
- case EType::FloatNumber:
- return NJson::TJsonValue(core.GetNumber());
- case EType::String:
- return NJson::TJsonValue(core.String);
- case EType::Array: {
- NImpl::TSelfLoopContext::TGuard loopGuard(loopCtx, core);
-
- if (!loopGuard.Ok) {
- return NJson::TJsonValue(NJson::JSON_NULL);
- }
-
- NJson::TJsonValue result(NJson::JSON_ARRAY);
- const TArray& arr = core.Array;
-
- for (const auto& item : arr) {
- result.AppendValue(NJson::TJsonValue::UNDEFINED) = item.ToJsonValueImpl(loopCtx);
- }
-
- return result;
+ case EType::Bool:
+ return NJson::TJsonValue(core.GetBool());
+ case EType::IntNumber:
+ return NJson::TJsonValue(core.GetIntNumber());
+ case EType::FloatNumber:
+ return NJson::TJsonValue(core.GetNumber());
+ case EType::String:
+ return NJson::TJsonValue(core.String);
+ case EType::Array: {
+ NImpl::TSelfLoopContext::TGuard loopGuard(loopCtx, core);
+
+ if (!loopGuard.Ok) {
+ return NJson::TJsonValue(NJson::JSON_NULL);
+ }
+
+ NJson::TJsonValue result(NJson::JSON_ARRAY);
+ const TArray& arr = core.Array;
+
+ for (const auto& item : arr) {
+ result.AppendValue(NJson::TJsonValue::UNDEFINED) = item.ToJsonValueImpl(loopCtx);
+ }
+
+ return result;
}
- case EType::Dict: {
- NImpl::TSelfLoopContext::TGuard loopGuard(loopCtx, core);
-
- if (!loopGuard.Ok) {
- return NJson::TJsonValue(NJson::JSON_NULL);
- }
-
- NJson::TJsonValue result(NJson::JSON_MAP);
- const TDict& dict = core.Dict;
-
- for (const auto& item : dict) {
- result.InsertValue(item.first, NJson::TJsonValue::UNDEFINED) = item.second.ToJsonValueImpl(loopCtx);
- }
-
- return result;
+ case EType::Dict: {
+ NImpl::TSelfLoopContext::TGuard loopGuard(loopCtx, core);
+
+ if (!loopGuard.Ok) {
+ return NJson::TJsonValue(NJson::JSON_NULL);
+ }
+
+ NJson::TJsonValue result(NJson::JSON_MAP);
+ const TDict& dict = core.Dict;
+
+ for (const auto& item : dict) {
+ result.InsertValue(item.first, NJson::TJsonValue::UNDEFINED) = item.second.ToJsonValueImpl(loopCtx);
+ }
+
+ return result;
}
}
}
@@ -398,38 +398,38 @@ namespace NSc {
core.SetNull();
switch (val.GetType()) {
- default:
- case NJson::JSON_UNDEFINED:
- case NJson::JSON_NULL:
- break;
- case NJson::JSON_BOOLEAN:
- core.SetBool(val.GetBoolean());
- break;
- case NJson::JSON_INTEGER:
- core.SetIntNumber(val.GetInteger());
- break;
- case NJson::JSON_UINTEGER:
- core.SetIntNumber(val.GetUInteger());
- break;
- case NJson::JSON_DOUBLE:
- core.SetNumber(val.GetDouble());
- break;
- case NJson::JSON_STRING:
+ default:
+ case NJson::JSON_UNDEFINED:
+ case NJson::JSON_NULL:
+ break;
+ case NJson::JSON_BOOLEAN:
+ core.SetBool(val.GetBoolean());
+ break;
+ case NJson::JSON_INTEGER:
+ core.SetIntNumber(val.GetInteger());
+ break;
+ case NJson::JSON_UINTEGER:
+ core.SetIntNumber(val.GetUInteger());
+ break;
+ case NJson::JSON_DOUBLE:
+ core.SetNumber(val.GetDouble());
+ break;
+ case NJson::JSON_STRING:
core.SetString(val.GetString());
- break;
- case NJson::JSON_ARRAY: {
+ break;
+ case NJson::JSON_ARRAY: {
core.SetArray();
- for (const auto& item : val.GetArray()) {
+ for (const auto& item : val.GetArray()) {
FromJsonValue(core.Push(), item);
- }
- break;
+ }
+ break;
}
- case NJson::JSON_MAP: {
+ case NJson::JSON_MAP: {
core.SetDict();
- for (const auto& item : val.GetMap()) {
+ for (const auto& item : val.GetMap()) {
FromJsonValue(core.Add(item.first), item.second);
- }
- break;
+ }
+ break;
}
}
@@ -449,7 +449,7 @@ namespace NSc {
return Default<TDefaults>().Core.Array;
}
- const TDict& TValue::DefaultDict() {
+ const TDict& TValue::DefaultDict() {
return Default<TDefaults>().Core.Dict;
}
@@ -506,69 +506,69 @@ namespace NSc {
}
namespace NPrivate {
- int CompareStr(const NSc::TValue& a, TStringBuf b) {
+ int CompareStr(const NSc::TValue& a, TStringBuf b) {
return a.GetString().compare(b);
- }
+ }
- int CompareInt(const NSc::TValue& a, i64 r) {
- i64 l = a.GetIntNumber();
- return l < r ? -1 : l > r ? 1 : 0;
- }
+ int CompareInt(const NSc::TValue& a, i64 r) {
+ i64 l = a.GetIntNumber();
+ return l < r ? -1 : l > r ? 1 : 0;
+ }
- int CompareFloat(const NSc::TValue& a, double r) {
- double l = a.GetNumber();
- return l < r ? -1 : l > r ? 1 : 0;
- }
+ int CompareFloat(const NSc::TValue& a, double r) {
+ double l = a.GetNumber();
+ return l < r ? -1 : l > r ? 1 : 0;
+ }
}
- bool operator==(const NSc::TValue& a, const NSc::TValue& b) {
+ bool operator==(const NSc::TValue& a, const NSc::TValue& b) {
return NSc::TValue::Equal(a, b);
}
- bool operator!=(const NSc::TValue& a, const NSc::TValue& b) {
+ bool operator!=(const NSc::TValue& a, const NSc::TValue& b) {
return !NSc::TValue::Equal(a, b);
}
#define LIBRARY_SCHEME_DECLARE_TVALUE_OPS_IMPL(T, Impl) \
- bool operator==(const NSc::TValue& a, T b) { \
- return NPrivate::Impl(a, b) == 0; \
- } \
- bool operator==(T b, const NSc::TValue& a) { \
- return NPrivate::Impl(a, b) == 0; \
- } \
- bool operator!=(const NSc::TValue& a, T b) { \
- return NPrivate::Impl(a, b) != 0; \
- } \
- bool operator!=(T b, const NSc::TValue& a) { \
- return NPrivate::Impl(a, b) != 0; \
- } \
- bool operator<=(const NSc::TValue& a, T b) { \
- return NPrivate::Impl(a, b) <= 0; \
- } \
- bool operator<=(T b, const NSc::TValue& a) { \
- return NPrivate::Impl(a, b) >= 0; \
- } \
- bool operator>=(const NSc::TValue& a, T b) { \
- return NPrivate::Impl(a, b) >= 0; \
- } \
- bool operator>=(T b, const NSc::TValue& a) { \
- return NPrivate::Impl(a, b) <= 0; \
- } \
- bool operator<(const NSc::TValue& a, T b) { \
- return NPrivate::Impl(a, b) < 0; \
- } \
- bool operator<(T b, const NSc::TValue& a) { \
- return NPrivate::Impl(a, b) > 0; \
- } \
- bool operator>(const NSc::TValue& a, T b) { \
- return NPrivate::Impl(a, b) > 0; \
- } \
- bool operator>(T b, const NSc::TValue& a) { \
- return NPrivate::Impl(a, b) < 0; \
- }
-
-#define LIBRARY_SCHEME_DECLARE_TVALUE_INT_OPS_IMPL(T) \
+ bool operator==(const NSc::TValue& a, T b) { \
+ return NPrivate::Impl(a, b) == 0; \
+ } \
+ bool operator==(T b, const NSc::TValue& a) { \
+ return NPrivate::Impl(a, b) == 0; \
+ } \
+ bool operator!=(const NSc::TValue& a, T b) { \
+ return NPrivate::Impl(a, b) != 0; \
+ } \
+ bool operator!=(T b, const NSc::TValue& a) { \
+ return NPrivate::Impl(a, b) != 0; \
+ } \
+ bool operator<=(const NSc::TValue& a, T b) { \
+ return NPrivate::Impl(a, b) <= 0; \
+ } \
+ bool operator<=(T b, const NSc::TValue& a) { \
+ return NPrivate::Impl(a, b) >= 0; \
+ } \
+ bool operator>=(const NSc::TValue& a, T b) { \
+ return NPrivate::Impl(a, b) >= 0; \
+ } \
+ bool operator>=(T b, const NSc::TValue& a) { \
+ return NPrivate::Impl(a, b) <= 0; \
+ } \
+ bool operator<(const NSc::TValue& a, T b) { \
+ return NPrivate::Impl(a, b) < 0; \
+ } \
+ bool operator<(T b, const NSc::TValue& a) { \
+ return NPrivate::Impl(a, b) > 0; \
+ } \
+ bool operator>(const NSc::TValue& a, T b) { \
+ return NPrivate::Impl(a, b) > 0; \
+ } \
+ bool operator>(T b, const NSc::TValue& a) { \
+ return NPrivate::Impl(a, b) < 0; \
+ }
+
+#define LIBRARY_SCHEME_DECLARE_TVALUE_INT_OPS_IMPL(T) \
LIBRARY_SCHEME_DECLARE_TVALUE_OPS_IMPL(signed T, CompareInt) \
LIBRARY_SCHEME_DECLARE_TVALUE_OPS_IMPL(unsigned T, CompareInt)
diff --git a/library/cpp/scheme/scheme.h b/library/cpp/scheme/scheme.h
index ca69752b7d..3d7c59f3c9 100644
--- a/library/cpp/scheme/scheme.h
+++ b/library/cpp/scheme/scheme.h
@@ -9,20 +9,20 @@
namespace NSc {
#ifdef _MSC_VER
-#pragma warning(disable : 4521 4522)
+#pragma warning(disable : 4521 4522)
#endif
// todo: try to remove some rarely used methods
class TValue {
public:
enum class EType {
- Null = 0 /* "Null" */,
- Bool /* "Bool" */,
- IntNumber /* "Int" */,
- FloatNumber /* "Float" */,
- String /* "String" */,
- Array /* "Array" */,
- Dict /* "Dict" */
+ Null = 0 /* "Null" */,
+ Bool /* "Bool" */,
+ IntNumber /* "Int" */,
+ FloatNumber /* "Float" */,
+ String /* "String" */,
+ Array /* "Array" */,
+ Dict /* "Dict" */
};
struct TScCore;
@@ -53,7 +53,7 @@ namespace NSc {
inline TValue(long long t);
inline TValue(long t);
inline TValue(int t);
- // inline TValue(bool b);
+ // inline TValue(bool b);
inline TValue(TStringBuf t);
inline TValue(const char*);
@@ -86,7 +86,7 @@ namespace NSc {
inline TValue& operator=(long long t);
inline TValue& operator=(long t);
inline TValue& operator=(int t);
- // inline TValue& operator=(bool t);
+ // inline TValue& operator=(bool t);
inline TValue& operator=(TStringBuf t);
inline TValue& operator=(const char* t);
@@ -101,14 +101,14 @@ namespace NSc {
public:
template <class T> // ui16 or TStringBuf
- inline TValue& operator[](const T& idx) {
- return GetOrAdd(idx);
- }
+ inline TValue& operator[](const T& idx) {
+ return GetOrAdd(idx);
+ }
template <class T> // ui16 or TStringBuf
- inline const TValue& operator[](const T& idx) const {
- return Get(idx);
- }
+ inline const TValue& operator[](const T& idx) const {
+ return Get(idx);
+ }
public: // Data methods ///////////////////////////////////////////////////////////
inline EType GetType() const;
@@ -117,9 +117,9 @@ namespace NSc {
inline TValue& SetNull(); // returns self, will set type to Null
- TValue& Clear() {
- return ClearArray().ClearDict().SetNull();
- }
+ TValue& Clear() {
+ return ClearArray().ClearDict().SetNull();
+ }
public: // Number methods /////////////////////////////////////////////////////////
// Bool, IntNumber and FloatNumber are all compatible.
@@ -179,7 +179,7 @@ namespace NSc {
TString ForceString(const TString& deflt = TString()) const; // Best-effort cast to TString (will do ToString for numeric types)
// todo: remove
- inline bool StringEmpty() const;
+ inline bool StringEmpty() const;
inline size_t StringSize() const;
public: // Array methods //////////////////////////////////////////////////////////
@@ -202,26 +202,26 @@ namespace NSc {
return Push() = std::forward<T>(t);
} // returns new child
- TValue& Insert(ui16 idx) {
- return InsertUnsafe(idx);
- } // creates missing values, returns new child
+ TValue& Insert(ui16 idx) {
+ return InsertUnsafe(idx);
+ } // creates missing values, returns new child
template <class T>
TValue& Insert(ui16 idx, T&& v) {
return InsertUnsafe(idx, std::forward<T>(v));
- } // creates missing values, returns new child
+ } // creates missing values, returns new child
template <class TIt>
inline TValue& AppendAll(TIt begin, TIt end); // Append(vec.begin(), vec.end())
template <class TColl>
- inline TValue& AppendAll(TColl&& coll); // Append(vec)
+ inline TValue& AppendAll(TColl&& coll); // Append(vec)
inline TValue& AppendAll(std::initializer_list<TValue> coll);
- TValue& GetOrAdd(ui16 idx) {
- return GetOrAddUnsafe(idx);
- } // creates missing values, returns new child
+ TValue& GetOrAdd(ui16 idx) {
+ return GetOrAddUnsafe(idx);
+ } // creates missing values, returns new child
inline TValue& InsertUnsafe(size_t idx); // creates missing values, returns new child
@@ -230,17 +230,17 @@ namespace NSc {
return InsertUnsafe(idx) = std::forward<T>(t);
} // creates missing values, returns new child
- inline TValue& GetOrAddUnsafe(size_t idx); // creates missing values, returns new child
+ inline TValue& GetOrAddUnsafe(size_t idx); // creates missing values, returns new child
- inline TValue Pop(); // returns popped value
+ inline TValue Pop(); // returns popped value
inline TValue Delete(size_t idx); // returns deleted value if it existed, NSc::Null() otherwise
- inline TValue& Front() {
- return GetOrAdd(0);
- } // creates missing value, returns child
- inline const TValue& Front() const {
- return Get(0);
- } // returns child or default
+ inline TValue& Front() {
+ return GetOrAdd(0);
+ } // creates missing value, returns child
+ inline const TValue& Front() const {
+ return Get(0);
+ } // returns child or default
inline TValue& Back(); // creates missing value, returns child
inline const TValue& Back() const; // returns child or default
@@ -262,14 +262,14 @@ namespace NSc {
inline const TValue& Get(TStringBuf idx) const;
inline TValue* GetNoAdd(TStringBuf idx); // returns link to existing child or nullptr
- TValue& Add(TStringBuf idx) {
- return GetOrAdd(idx);
- }
+ TValue& Add(TStringBuf idx) {
+ return GetOrAdd(idx);
+ }
template <class T>
TValue& Add(TStringBuf idx, T&& t) {
return Add(idx) = std::forward<T>(t);
- }
+ }
inline TValue& GetOrAdd(TStringBuf idx); // creates missing value, returns child
@@ -291,9 +291,9 @@ namespace NSc {
static const EJsonOpts JO_SORT_KEYS = TJsonOpts::JO_SORT_KEYS;
static const EJsonOpts JO_SKIP_UNSAFE = TJsonOpts::JO_SKIP_UNSAFE; // skip non-utf8 strings
static const EJsonOpts JO_PRETTY = TJsonOpts::JO_PRETTY;
- static const EJsonOpts JO_SAFE = TJsonOpts::JO_SAFE; // JO_SORT_KEYS | JO_SKIP_UNSAFE
+ static const EJsonOpts JO_SAFE = TJsonOpts::JO_SAFE; // JO_SORT_KEYS | JO_SKIP_UNSAFE
static const EJsonOpts JO_PARSER_STRICT_WITH_COMMENTS = TJsonOpts::JO_PARSER_STRICT_WITH_COMMENTS; // strict json + strict utf8
- static const EJsonOpts JO_PARSER_STRICT = TJsonOpts::JO_PARSER_STRICT; // strict json + strict utf8 + comments are disallowed
+ static const EJsonOpts JO_PARSER_STRICT = TJsonOpts::JO_PARSER_STRICT; // strict json + strict utf8 + comments are disallowed
static const EJsonOpts JO_PARSER_DISALLOW_DUPLICATE_KEYS = TJsonOpts::JO_PARSER_DISALLOW_DUPLICATE_KEYS;
static TValue FromJson(TStringBuf, const TJsonOpts& = TJsonOpts());
@@ -321,7 +321,7 @@ namespace NSc {
static TJsonOpts MakeOptsPrettyForSerializer(TJsonOpts = TJsonOpts());
public: // Merge methods ////////////////////////////////////////////////
- /*
+ /*
* LHS.MergeUpdate(RHS):
* 1. Dict <- Dict:
* - Copy all nonconflicting key-value pairs from RHS to LHS.
@@ -347,7 +347,7 @@ namespace NSc {
static bool MergeUpdateJson(TValue&, TStringBuf json); // returns true unless failed to parse the json
static bool ReverseMergeJson(TValue&, TStringBuf json); // returns true unless failed to parse the json
- TValue& MergeUpdate(const TValue& delta); // return self
+ TValue& MergeUpdate(const TValue& delta); // return self
TValue& ReverseMerge(const TValue& delta); // return self
public: // Path methods /////////////////////////////////////////////////////////
@@ -356,9 +356,9 @@ namespace NSc {
static TString EscapeForPath(TStringBuf rawKey); // converts a raw dict key into a valid token for a selector path
- static bool PathValid(TStringBuf path); // returns true if the path is syntactically valid
+ static bool PathValid(TStringBuf path); // returns true if the path is syntactically valid
- bool PathExists(TStringBuf path) const; // returns true if the path is syntactically valid and the target value exists
+ bool PathExists(TStringBuf path) const; // returns true if the path is syntactically valid and the target value exists
const TValue& TrySelect(TStringBuf path) const; // returns the target value
// if the path is syntactically valid and the target value exists
@@ -372,14 +372,14 @@ namespace NSc {
// if the path is syntactically valid and the target value existed
// otherwise returns NSc::Null()
- public: // Copy methods /////////////////////////////////////////////////////////
- TValue Clone() const; // returns deep copy of self (on the separate pool)
+ public: // Copy methods /////////////////////////////////////////////////////////
+ TValue Clone() const; // returns deep copy of self (on the separate pool)
TValue& CopyFrom(const TValue& other); // deep copy other value into self, returns self
TValue& Swap(TValue& v);
- static bool Same(const TValue&, const TValue&); // point to the same core
- static bool Equal(const TValue&, const TValue&); // recursively equal
+ static bool Same(const TValue&, const TValue&); // point to the same core
+ static bool Equal(const TValue&, const TValue&); // recursively equal
static bool SamePool(const TValue&, const TValue&); // share arena
public:
@@ -394,7 +394,7 @@ namespace NSc {
static const TScCore& DefaultCore();
static const TArray& DefaultArray();
- static const TDict& DefaultDict();
+ static const TDict& DefaultDict();
static const TValue& DefaultValue();
static const TValue& Null() {
return DefaultValue();
@@ -434,14 +434,14 @@ namespace NSc {
}
- class TArray: public TDeque<TValue, TPoolAllocator>, TNonCopyable {
- using TParent = TDeque<TValue, TPoolAllocator>;
+ class TArray: public TDeque<TValue, TPoolAllocator>, TNonCopyable {
+ using TParent = TDeque<TValue, TPoolAllocator>;
public:
TArray(TMemoryPool* p)
: TParent(p)
- {
- }
+ {
+ }
template <class TIt>
void AppendAll(TIt begin, TIt end) {
@@ -505,7 +505,7 @@ namespace NSc {
}
const TValue& EnsureIndex(size_t i) const {
- return i < size() ? TParent::operator[](i) : TValue::DefaultValue();
+ return i < size() ? TParent::operator[](i) : TValue::DefaultValue();
}
};
@@ -513,14 +513,14 @@ namespace NSc {
// todo: densehashtable
// todo: allow insertions
// todo: make TDict methods safe
- class TDict: public THashMap<TStringBuf, TValue, THash<TStringBuf>, TEqualTo<TStringBuf>, TPoolAllocator>, TNonCopyable {
+ class TDict: public THashMap<TStringBuf, TValue, THash<TStringBuf>, TEqualTo<TStringBuf>, TPoolAllocator>, TNonCopyable {
using TParent = THashMap<TStringBuf, TValue, THash<TStringBuf>, TEqualTo<TStringBuf>, TPoolAllocator>;
-
+
public:
TDict(TMemoryPool* p)
: TParent(p)
- {
- }
+ {
+ }
template <class TStr>
const TValue& Get(const TStr& key) const {
@@ -534,5 +534,5 @@ namespace NSc {
#include "scheme_cast.h"
#ifdef _MSC_VER
-#pragma warning(default : 4521 4522)
+#pragma warning(default : 4521 4522)
#endif
diff --git a/library/cpp/scheme/scheme_cast.h b/library/cpp/scheme/scheme_cast.h
index a43c4e07d3..00839e8017 100644
--- a/library/cpp/scheme/scheme_cast.h
+++ b/library/cpp/scheme/scheme_cast.h
@@ -8,28 +8,28 @@
#include <util/string/cast.h>
#include <util/generic/yexception.h>
-#include "scheme.h"
+#include "scheme.h"
namespace NJsonConverters {
class IJsonSerializable {
- public:
- virtual NSc::TValue ToTValue() const = 0;
- virtual void FromTValue(const NSc::TValue&, const bool validate) = 0;
+ public:
+ virtual NSc::TValue ToTValue() const = 0;
+ virtual void FromTValue(const NSc::TValue&, const bool validate) = 0;
- const TString ToJson(const bool sort = false) const {
- return ToTValue().ToJson(sort);
- };
+ const TString ToJson(const bool sort = false) const {
+ return ToTValue().ToJson(sort);
+ };
- void FromJson(const TStringBuf& json, const bool validate = false) {
- NSc::TValue v = NSc::TValue::FromJson(json);
- FromTValue(v, validate);
- }
+ void FromJson(const TStringBuf& json, const bool validate = false) {
+ NSc::TValue v = NSc::TValue::FromJson(json);
+ FromTValue(v, validate);
+ }
- virtual ~IJsonSerializable(){};
+ virtual ~IJsonSerializable(){};
};
- //////////////////////////////////////////////////////////////////////
- // fwd declarations
- //////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////
+ // fwd declarations
+ //////////////////////////////////////////////////////////////////////
//TVector
template <typename T, typename A>
@@ -67,13 +67,13 @@ namespace NJsonConverters {
template <class T1, class T2>
void FromTValue(const NSc::TValue& x, std::pair<T1, T2>& out, const bool validate);
- //////////////////////////////////////////////////////////////////////
- // simple From, To helpers
- //////////////////////////////////////////////////////////////////////
- template <typename T, bool HasSerializer>
+ //////////////////////////////////////////////////////////////////////
+ // simple From, To helpers
+ //////////////////////////////////////////////////////////////////////
+ template <typename T, bool HasSerializer>
struct TValueAndStrokaConv {};
- template <typename T>
+ template <typename T>
struct TValueAndStrokaConv<T, 0> {
static NSc::TValue ToTValue(const T& x) {
return NSc::TValue(x);
@@ -92,8 +92,8 @@ namespace NJsonConverters {
}
};
- template <typename T>
- struct TValueAndStrokaConv<T, 1> {
+ template <typename T>
+ struct TValueAndStrokaConv<T, 1> {
static NSc::TValue ToTValue(const T& x) {
return x.ToTValue();
}
@@ -113,12 +113,12 @@ namespace NJsonConverters {
template <typename T>
NSc::TValue ToTValue(const T& x) {
- return TValueAndStrokaConv<T, std::is_base_of<IJsonSerializable, T>::value>::ToTValue(x);
+ return TValueAndStrokaConv<T, std::is_base_of<IJsonSerializable, T>::value>::ToTValue(x);
}
template <typename T>
void FromTValue(const NSc::TValue& x, T& out, const bool validate) {
- return TValueAndStrokaConv<T, std::is_base_of<IJsonSerializable, T>::value>::FromTValue(x, out, validate);
+ return TValueAndStrokaConv<T, std::is_base_of<IJsonSerializable, T>::value>::FromTValue(x, out, validate);
}
template <typename T>
@@ -130,12 +130,12 @@ namespace NJsonConverters {
template <typename T>
TString ToString(const T& x) {
- return TValueAndStrokaConv<T, std::is_base_of<IJsonSerializable, T>::value>::ToString(x);
+ return TValueAndStrokaConv<T, std::is_base_of<IJsonSerializable, T>::value>::ToString(x);
}
template <typename T>
void FromString(const TStringBuf& str, T& res, const bool validate) {
- return TValueAndStrokaConv<T, std::is_base_of<IJsonSerializable, T>::value>::FromString(str, res, validate);
+ return TValueAndStrokaConv<T, std::is_base_of<IJsonSerializable, T>::value>::FromString(str, res, validate);
}
template <typename T>
@@ -200,9 +200,9 @@ namespace NJsonConverters {
}
}
- //////////////////////////////////////////////////////////////////////
- // TVector
- //////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////
+ // TVector
+ //////////////////////////////////////////////////////////////////////
template <typename T, typename A>
NSc::TValue ToTValue(const TVector<T, A>& x) {
NSc::TValue out;
@@ -228,9 +228,9 @@ namespace NJsonConverters {
}
}
- //////////////////////////////////////////////////////////////////////
- // THashMap & TMap
- //////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////
+ // THashMap & TMap
+ //////////////////////////////////////////////////////////////////////
template <class Key, class T, class HashFcn, class EqualKey, class Alloc>
NSc::TValue ToTValue(const THashMap<Key, T, HashFcn, EqualKey, Alloc>& x) {
return NPrivate::ToTValueDict(x);
@@ -251,9 +251,9 @@ namespace NJsonConverters {
NPrivate::FromTValueDict(x, out, validate);
}
- //////////////////////////////////////////////////////////////////////
- // THashSet & TSet
- //////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////
+ // THashSet & TSet
+ //////////////////////////////////////////////////////////////////////
template <class V, class H, class E, class A>
NSc::TValue ToTValue(const THashSet<V, H, E, A>& x) {
return NPrivate::ToTValueSet(x);
@@ -274,9 +274,9 @@ namespace NJsonConverters {
NPrivate::FromTValueSet(x, out, validate);
}
- //////////////////////////////////////////////////////////////////////
- // std::pair
- //////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////
+ // std::pair
+ //////////////////////////////////////////////////////////////////////
template <class T1, class T2>
NSc::TValue ToTValue(const std::pair<T1, T2>& x) {
NSc::TValue out;
@@ -303,9 +303,9 @@ namespace NJsonConverters {
}
}
- //////////////////////////////////////////////////////////////////////
- // global user functions
- //////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////
+ // global user functions
+ //////////////////////////////////////////////////////////////////////
template <typename T>
TString ToJson(const T& val, const bool sort = false) {
return NJsonConverters::ToTValue(val).ToJson(sort);
diff --git a/library/cpp/scheme/scimpl.h b/library/cpp/scheme/scimpl.h
index fafea0826a..4f68f16290 100644
--- a/library/cpp/scheme/scimpl.h
+++ b/library/cpp/scheme/scimpl.h
@@ -18,8 +18,8 @@ namespace NSc {
: Pool(p)
, Dict(Pool->Get())
, Array(Pool->Get())
- {
- }
+ {
+ }
bool IsNull() const {
return TValue::EType::Null == ValueType;
@@ -101,17 +101,17 @@ namespace NSc {
double& GetNumberMutable(double defaultnum) {
switch (ValueType) {
- case TValue::EType::Bool:
- SetNumber(bool(IntNumber));
- break;
- case TValue::EType::IntNumber:
- SetNumber(IntNumber);
- break;
- case TValue::EType::FloatNumber:
- break;
- default:
- SetNumber(defaultnum);
- break;
+ case TValue::EType::Bool:
+ SetNumber(bool(IntNumber));
+ break;
+ case TValue::EType::IntNumber:
+ SetNumber(IntNumber);
+ break;
+ case TValue::EType::FloatNumber:
+ break;
+ default:
+ SetNumber(defaultnum);
+ break;
}
return FloatNumber;
@@ -119,17 +119,17 @@ namespace NSc {
i64& GetIntNumberMutable(i64 defaultnum) {
switch (ValueType) {
- case TValue::EType::Bool:
- SetIntNumber(bool(IntNumber));
- break;
- case TValue::EType::IntNumber:
- break;
- case TValue::EType::FloatNumber:
- SetIntNumber(FloatNumber);
- break;
- default:
- SetIntNumber(defaultnum);
- break;
+ case TValue::EType::Bool:
+ SetIntNumber(bool(IntNumber));
+ break;
+ case TValue::EType::IntNumber:
+ break;
+ case TValue::EType::FloatNumber:
+ SetIntNumber(FloatNumber);
+ break;
+ default:
+ SetIntNumber(defaultnum);
+ break;
}
return IntNumber;
@@ -153,27 +153,27 @@ namespace NSc {
double GetNumber(double d = 0) const {
switch (ValueType) {
- case TValue::EType::Bool:
- return (bool)IntNumber;
- case TValue::EType::IntNumber:
- return IntNumber;
- case TValue::EType::FloatNumber:
- return FloatNumber;
- default:
- return d;
+ case TValue::EType::Bool:
+ return (bool)IntNumber;
+ case TValue::EType::IntNumber:
+ return IntNumber;
+ case TValue::EType::FloatNumber:
+ return FloatNumber;
+ default:
+ return d;
}
}
i64 GetIntNumber(i64 n = 0) const {
switch (ValueType) {
- case TValue::EType::Bool:
- return (bool)IntNumber;
- case TValue::EType::IntNumber:
- return IntNumber;
- case TValue::EType::FloatNumber:
- return FloatNumber;
- default:
- return n;
+ case TValue::EType::Bool:
+ return (bool)IntNumber;
+ case TValue::EType::IntNumber:
+ return IntNumber;
+ case TValue::EType::FloatNumber:
+ return FloatNumber;
+ default:
+ return n;
}
}
@@ -399,14 +399,14 @@ namespace NSc {
TValue::TValue(TValue& v)
: TheCore(v.TheCore)
, CopyOnWrite(v.CopyOnWrite)
- {
- }
+ {
+ }
TValue::TValue(const TValue& v)
: TheCore(v.TheCore)
, CopyOnWrite(true)
- {
- }
+ {
+ }
TValue::TValue(TValue&& v) noexcept
: TheCore(std::move(v.TheCore))
@@ -609,13 +609,13 @@ namespace NSc {
template <class TIt>
TValue& TValue::AppendAll(TIt begin, TIt end) {
- GetArrayMutable().AppendAll(begin, end);
- return *this;
+ GetArrayMutable().AppendAll(begin, end);
+ return *this;
}
template <class TColl>
TValue& TValue::AppendAll(TColl&& coll) {
- return AppendAll(std::begin(coll), std::end(coll));
+ return AppendAll(std::begin(coll), std::end(coll));
}
TValue& TValue::AppendAll(std::initializer_list<TValue> coll) {
@@ -810,30 +810,30 @@ namespace NSc {
int CompareFloat(const NSc::TValue& a, double r);
}
- bool operator==(const TValue& a, const TValue& b);
+ bool operator==(const TValue& a, const TValue& b);
- bool operator!=(const TValue& a, const TValue& b);
+ bool operator!=(const TValue& a, const TValue& b);
- bool operator<=(const TValue&, const TValue&) = delete;
- bool operator>=(const TValue&, const TValue&) = delete;
- bool operator<(const TValue&, const TValue&) = delete;
- bool operator>(const TValue&, const TValue&) = delete;
+ bool operator<=(const TValue&, const TValue&) = delete;
+ bool operator>=(const TValue&, const TValue&) = delete;
+ bool operator<(const TValue&, const TValue&) = delete;
+ bool operator>(const TValue&, const TValue&) = delete;
#define LIBRARY_SCHEME_DECLARE_TVALUE_OPS(T, Impl) \
- bool operator==(const NSc::TValue& a, T b); \
- bool operator==(T b, const NSc::TValue& a); \
- bool operator!=(const NSc::TValue& a, T b); \
- bool operator!=(T b, const NSc::TValue& a); \
- bool operator<=(const NSc::TValue& a, T b); \
- bool operator<=(T b, const NSc::TValue& a); \
- bool operator>=(const NSc::TValue& a, T b); \
- bool operator>=(T b, const NSc::TValue& a); \
- bool operator<(const NSc::TValue& a, T b); \
- bool operator<(T b, const NSc::TValue& a); \
- bool operator>(const NSc::TValue& a, T b); \
- bool operator>(T b, const NSc::TValue& a);
-
-#define LIBRARY_SCHEME_DECLARE_TVALUE_INT_OPS(T) \
+ bool operator==(const NSc::TValue& a, T b); \
+ bool operator==(T b, const NSc::TValue& a); \
+ bool operator!=(const NSc::TValue& a, T b); \
+ bool operator!=(T b, const NSc::TValue& a); \
+ bool operator<=(const NSc::TValue& a, T b); \
+ bool operator<=(T b, const NSc::TValue& a); \
+ bool operator>=(const NSc::TValue& a, T b); \
+ bool operator>=(T b, const NSc::TValue& a); \
+ bool operator<(const NSc::TValue& a, T b); \
+ bool operator<(T b, const NSc::TValue& a); \
+ bool operator>(const NSc::TValue& a, T b); \
+ bool operator>(T b, const NSc::TValue& a);
+
+#define LIBRARY_SCHEME_DECLARE_TVALUE_INT_OPS(T) \
LIBRARY_SCHEME_DECLARE_TVALUE_OPS(signed T, CompareInt) \
LIBRARY_SCHEME_DECLARE_TVALUE_OPS(unsigned T, CompareInt)
diff --git a/library/cpp/scheme/scimpl_defs.h b/library/cpp/scheme/scimpl_defs.h
index e6420194c8..f3dd66b437 100644
--- a/library/cpp/scheme/scimpl_defs.h
+++ b/library/cpp/scheme/scimpl_defs.h
@@ -20,17 +20,17 @@ namespace NSc {
namespace NDefinitions {
const size_t POOL_BLOCK_SIZE = 4000; // leave 96 bytes for overhead
- struct TPool: public TAtomicRefCount<TPool> {
+ struct TPool: public TAtomicRefCount<TPool> {
TMemoryPool Pool;
TPool(size_t blsz = POOL_BLOCK_SIZE, TMemoryPool::IGrowPolicy* grow = TMemoryPool::TExpGrow::Instance())
: Pool(blsz, grow)
- {
- }
+ {
+ }
- TMemoryPool* Get() {
- return &Pool;
- }
+ TMemoryPool* Get() {
+ return &Pool;
+ }
TStringBuf AppendBuf(const TStringBuf& strb) {
return Pool.AppendCString(strb);
@@ -59,11 +59,11 @@ namespace NSc {
TSchemeParseException(size_t off, const TString& reason)
: Offset(off)
, Reason(reason)
- {
- }
+ {
+ }
};
- struct TJsonOpts: public NJson::TJsonReaderConfig {
+ struct TJsonOpts: public NJson::TJsonReaderConfig {
enum EJsonOpts {
JO_DEFAULT = 0, // just dump json, used to be default, actually
JO_SORT_KEYS = 1, // sort dict keys to make output more predictable
@@ -71,8 +71,8 @@ namespace NSc {
// will skip nonunicode dict keys and replace nonunicode values with nulls
JO_FORMAT = 8, // format json
- JO_PARSER_STRICT_JSON = 16, // strict standard json
- JO_PARSER_STRICT_UTF8 = 32, // strict utf8
+ JO_PARSER_STRICT_JSON = 16, // strict standard json
+ JO_PARSER_STRICT_UTF8 = 32, // strict utf8
JO_PARSER_DISALLOW_COMMENTS = 64,
JO_PARSER_DISALLOW_DUPLICATE_KEYS = 128,
@@ -107,14 +107,14 @@ namespace NSc {
public:
static bool NumberPolicySafe(double&); // skip if nan or inf
- static bool NumberPolicyUnsafe(double&) {
- return true;
- }
+ static bool NumberPolicyUnsafe(double&) {
+ return true;
+ }
static bool StringPolicySafe(TStringBuf&); // skip if not utf8
- static bool StringPolicyUnsafe(TStringBuf&) {
- return true;
- }
+ static bool StringPolicyUnsafe(TStringBuf&) {
+ return true;
+ }
};
struct TProtoOpts {
diff --git a/library/cpp/scheme/scimpl_json_read.cpp b/library/cpp/scheme/scimpl_json_read.cpp
index 8f289a8344..8a29cc7739 100644
--- a/library/cpp/scheme/scimpl_json_read.cpp
+++ b/library/cpp/scheme/scimpl_json_read.cpp
@@ -19,8 +19,8 @@ namespace NSc {
TContainer(TValue& v)
: Container(&v)
, ExpectKey(v.IsDict())
- {
- }
+ {
+ }
bool Add(TStringBuf v, bool allowDuplicated) {
if (!ExpectKey || Y_UNLIKELY(!Container->IsDict()))
diff --git a/library/cpp/scheme/scimpl_json_write.cpp b/library/cpp/scheme/scimpl_json_write.cpp
index 79a1e3cef3..aadd7e6cd5 100644
--- a/library/cpp/scheme/scimpl_json_write.cpp
+++ b/library/cpp/scheme/scimpl_json_write.cpp
@@ -40,7 +40,7 @@ namespace NSc {
template <typename TDictKeys>
static inline void WriteDict(IOutputStream& out, const TDictKeys& keys, const TDict& dict,
- const TJsonOpts& jopts, NImpl::TKeySortContext& sortCtx, NImpl::TSelfLoopContext& loopCtx) {
+ const TJsonOpts& jopts, NImpl::TKeySortContext& sortCtx, NImpl::TSelfLoopContext& loopCtx) {
using const_iterator = typename TDictKeys::const_iterator;
const_iterator begin = keys.begin();
const_iterator end = keys.end();
@@ -64,7 +64,7 @@ namespace NSc {
}
void TValue::DoWriteJsonImpl(IOutputStream& out, const TJsonOpts& jopts,
- NImpl::TKeySortContext& sortCtx, NImpl::TSelfLoopContext& loopCtx) const {
+ NImpl::TKeySortContext& sortCtx, NImpl::TSelfLoopContext& loopCtx) const {
const TScCore& core = Core();
NImpl::TSelfLoopContext::TGuard loopCheck(loopCtx, core);
@@ -75,67 +75,67 @@ namespace NSc {
}
switch (core.ValueType) {
- default: {
- Y_ASSERT(false);
+ default: {
+ Y_ASSERT(false);
[[fallthrough]]; /* no break */
}
- case EType::Null: {
+ case EType::Null: {
out << TStringBuf("null");
- break;
+ break;
}
- case EType::Bool: {
+ case EType::Bool: {
out << (core.IntNumber ? TStringBuf("true") : TStringBuf("false"));
- break;
- }
- case EType::IntNumber: {
- out << core.IntNumber;
- break;
- }
- case EType::FloatNumber: {
- double d = core.FloatNumber;
- if (!jopts.NumberPolicy || jopts.NumberPolicy(d)) {
- out << d;
- } else {
+ break;
+ }
+ case EType::IntNumber: {
+ out << core.IntNumber;
+ break;
+ }
+ case EType::FloatNumber: {
+ double d = core.FloatNumber;
+ if (!jopts.NumberPolicy || jopts.NumberPolicy(d)) {
+ out << d;
+ } else {
out << TStringBuf("null");
}
- break;
- }
- case EType::String: {
- TStringBuf s = core.String;
- if (!jopts.StringPolicy || jopts.StringPolicy(s)) {
- WriteString(out, s);
- } else {
+ break;
+ }
+ case EType::String: {
+ TStringBuf s = core.String;
+ if (!jopts.StringPolicy || jopts.StringPolicy(s)) {
+ WriteString(out, s);
+ } else {
out << TStringBuf("null");
- }
- break;
- }
- case EType::Array: {
- out << '[';
- const TArray& a = core.GetArray();
- for (TArray::const_iterator it = a.begin(); it != a.end(); ++it) {
- if (it != a.begin()) {
- out << ',';
- }
-
- it->DoWriteJsonImpl(out, jopts, sortCtx, loopCtx);
- }
- out << ']';
- break;
+ }
+ break;
+ }
+ case EType::Array: {
+ out << '[';
+ const TArray& a = core.GetArray();
+ for (TArray::const_iterator it = a.begin(); it != a.end(); ++it) {
+ if (it != a.begin()) {
+ out << ',';
+ }
+
+ it->DoWriteJsonImpl(out, jopts, sortCtx, loopCtx);
+ }
+ out << ']';
+ break;
}
- case EType::Dict: {
- out << '{';
-
- const TDict& dict = core.GetDict();
-
- if (jopts.SortKeys) {
- NImpl::TKeySortContext::TGuard keys(sortCtx, dict);
- WriteDict(out, keys, dict, jopts, sortCtx, loopCtx);
- } else {
- WriteDict(out, dict, dict, jopts, sortCtx, loopCtx);
- }
-
- out << '}';
- break;
+ case EType::Dict: {
+ out << '{';
+
+ const TDict& dict = core.GetDict();
+
+ if (jopts.SortKeys) {
+ NImpl::TKeySortContext::TGuard keys(sortCtx, dict);
+ WriteDict(out, keys, dict, jopts, sortCtx, loopCtx);
+ } else {
+ WriteDict(out, dict, dict, jopts, sortCtx, loopCtx);
+ }
+
+ out << '}';
+ break;
}
}
}
diff --git a/library/cpp/scheme/scimpl_private.cpp b/library/cpp/scheme/scimpl_private.cpp
index 417e27c49a..024bf8cc3b 100644
--- a/library/cpp/scheme/scimpl_private.cpp
+++ b/library/cpp/scheme/scimpl_private.cpp
@@ -62,7 +62,7 @@ namespace NSc {
break;
case EMode::Stderr:
Cerr << "REFERENCE LOOP DETECTED: " << JoinStrings(Vector.begin(), Vector.end(), ", ")
- << " AND " << ToString((const void*)&self) << Endl;
+ << " AND " << ToString((const void*)&self) << Endl;
break;
}
}
diff --git a/library/cpp/scheme/scimpl_private.h b/library/cpp/scheme/scimpl_private.h
index 77f61e6bc4..b92badabde 100644
--- a/library/cpp/scheme/scimpl_private.h
+++ b/library/cpp/scheme/scimpl_private.h
@@ -16,7 +16,7 @@ namespace NSc {
using TElement = typename TContext::TElement;
using TTarget = typename TContext::TTarget;
using TVectorType = TVector<TElement>;
-
+
public:
TContextGuard(TContext& ctx, TTarget& target)
: Ctx(ctx)
@@ -64,14 +64,14 @@ namespace NSc {
using TElement = TElem;
using TTarget = TTgt;
- TBasicContext() {
+ TBasicContext() {
Vector.reserve(64);
}
TVector<TElement> Vector;
};
- class TKeySortContext: public TBasicContext<TStringBuf, const TDict> {
+ class TKeySortContext: public TBasicContext<TStringBuf, const TDict> {
public:
using TGuard = TContextGuard<TKeySortContext>;
@@ -82,7 +82,7 @@ namespace NSc {
}
};
- class TSelfOverrideContext: public TBasicContext<TValue, TValue::TScCore> {
+ class TSelfOverrideContext: public TBasicContext<TValue, TValue::TScCore> {
public:
using TGuard = TContextGuard<TSelfOverrideContext>;
@@ -93,7 +93,7 @@ namespace NSc {
}
};
- class TSelfLoopContext: public TBasicContext<const void*, const TValue::TScCore> {
+ class TSelfLoopContext: public TBasicContext<const void*, const TValue::TScCore> {
public:
enum class EMode {
Assert, Throw, Abort, Stderr
diff --git a/library/cpp/scheme/scimpl_protobuf.cpp b/library/cpp/scheme/scimpl_protobuf.cpp
index 32f73451e0..0c99122c69 100644
--- a/library/cpp/scheme/scimpl_protobuf.cpp
+++ b/library/cpp/scheme/scimpl_protobuf.cpp
@@ -50,38 +50,38 @@ namespace NSc {
const Reflection* r = msg.GetReflection();
switch (field->cpp_type()) {
- case FieldDescriptor::CPPTYPE_INT32:
- v = r->GetInt32(msg, field);
- break;
- case FieldDescriptor::CPPTYPE_INT64:
- v = r->GetInt64(msg, field);
- break;
- case FieldDescriptor::CPPTYPE_UINT32:
- v = r->GetUInt32(msg, field);
- break;
- case FieldDescriptor::CPPTYPE_UINT64:
- v = r->GetUInt64(msg, field);
- break;
- case FieldDescriptor::CPPTYPE_DOUBLE:
- v = r->GetDouble(msg, field);
- break;
- case FieldDescriptor::CPPTYPE_FLOAT:
- v = r->GetFloat(msg, field);
- break;
- case FieldDescriptor::CPPTYPE_BOOL:
- v.SetBool(r->GetBool(msg, field));
- break;
- case FieldDescriptor::CPPTYPE_ENUM:
- v = r->GetEnum(msg, field)->name();
- break;
- case FieldDescriptor::CPPTYPE_STRING:
- v = r->GetString(msg, field);
- break;
- case FieldDescriptor::CPPTYPE_MESSAGE:
- v = From(r->GetMessage(msg, field));
- break;
- default:
- ythrow TSchemeException() << "field " << field->full_name() << " unexpected type " << (int)field->cpp_type();
+ case FieldDescriptor::CPPTYPE_INT32:
+ v = r->GetInt32(msg, field);
+ break;
+ case FieldDescriptor::CPPTYPE_INT64:
+ v = r->GetInt64(msg, field);
+ break;
+ case FieldDescriptor::CPPTYPE_UINT32:
+ v = r->GetUInt32(msg, field);
+ break;
+ case FieldDescriptor::CPPTYPE_UINT64:
+ v = r->GetUInt64(msg, field);
+ break;
+ case FieldDescriptor::CPPTYPE_DOUBLE:
+ v = r->GetDouble(msg, field);
+ break;
+ case FieldDescriptor::CPPTYPE_FLOAT:
+ v = r->GetFloat(msg, field);
+ break;
+ case FieldDescriptor::CPPTYPE_BOOL:
+ v.SetBool(r->GetBool(msg, field));
+ break;
+ case FieldDescriptor::CPPTYPE_ENUM:
+ v = r->GetEnum(msg, field)->name();
+ break;
+ case FieldDescriptor::CPPTYPE_STRING:
+ v = r->GetString(msg, field);
+ break;
+ case FieldDescriptor::CPPTYPE_MESSAGE:
+ v = From(r->GetMessage(msg, field));
+ break;
+ default:
+ ythrow TSchemeException() << "field " << field->full_name() << " unexpected type " << (int)field->cpp_type();
}
return v;
@@ -92,38 +92,38 @@ namespace NSc {
const Reflection* r = msg.GetReflection();
switch (field->cpp_type()) {
- case FieldDescriptor::CPPTYPE_INT32:
- v = r->GetRepeatedInt32(msg, field, index);
- break;
- case FieldDescriptor::CPPTYPE_INT64:
- v = r->GetRepeatedInt64(msg, field, index);
- break;
- case FieldDescriptor::CPPTYPE_UINT32:
- v = r->GetRepeatedUInt32(msg, field, index);
- break;
- case FieldDescriptor::CPPTYPE_UINT64:
- v = r->GetRepeatedUInt64(msg, field, index);
- break;
- case FieldDescriptor::CPPTYPE_DOUBLE:
- v = r->GetRepeatedDouble(msg, field, index);
- break;
- case FieldDescriptor::CPPTYPE_FLOAT:
- v = r->GetRepeatedFloat(msg, field, index);
- break;
- case FieldDescriptor::CPPTYPE_BOOL:
- v.SetBool(r->GetRepeatedBool(msg, field, index));
- break;
- case FieldDescriptor::CPPTYPE_ENUM:
- v = r->GetRepeatedEnum(msg, field, index)->name();
- break;
- case FieldDescriptor::CPPTYPE_STRING:
- v = r->GetRepeatedString(msg, field, index);
- break;
- case FieldDescriptor::CPPTYPE_MESSAGE:
- v = From(r->GetRepeatedMessage(msg, field, index));
- break;
- default:
- ythrow TSchemeException() << "field " << field->full_name() << " unexpected type " << (int)field->cpp_type();
+ case FieldDescriptor::CPPTYPE_INT32:
+ v = r->GetRepeatedInt32(msg, field, index);
+ break;
+ case FieldDescriptor::CPPTYPE_INT64:
+ v = r->GetRepeatedInt64(msg, field, index);
+ break;
+ case FieldDescriptor::CPPTYPE_UINT32:
+ v = r->GetRepeatedUInt32(msg, field, index);
+ break;
+ case FieldDescriptor::CPPTYPE_UINT64:
+ v = r->GetRepeatedUInt64(msg, field, index);
+ break;
+ case FieldDescriptor::CPPTYPE_DOUBLE:
+ v = r->GetRepeatedDouble(msg, field, index);
+ break;
+ case FieldDescriptor::CPPTYPE_FLOAT:
+ v = r->GetRepeatedFloat(msg, field, index);
+ break;
+ case FieldDescriptor::CPPTYPE_BOOL:
+ v.SetBool(r->GetRepeatedBool(msg, field, index));
+ break;
+ case FieldDescriptor::CPPTYPE_ENUM:
+ v = r->GetRepeatedEnum(msg, field, index)->name();
+ break;
+ case FieldDescriptor::CPPTYPE_STRING:
+ v = r->GetRepeatedString(msg, field, index);
+ break;
+ case FieldDescriptor::CPPTYPE_MESSAGE:
+ v = From(r->GetRepeatedMessage(msg, field, index));
+ break;
+ default:
+ ythrow TSchemeException() << "field " << field->full_name() << " unexpected type " << (int)field->cpp_type();
}
return v;
@@ -165,40 +165,40 @@ namespace NSc {
const Reflection* reflection = msg.GetReflection();
switch (field->cpp_type()) {
- case FieldDescriptor::CPPTYPE_INT32:
- reflection->SetInt32(&msg, field, value.ForceIntNumber());
- break;
- case FieldDescriptor::CPPTYPE_INT64:
- reflection->SetInt64(&msg, field, value.ForceIntNumber());
- break;
- case FieldDescriptor::CPPTYPE_UINT32:
- reflection->SetUInt32(&msg, field, value.ForceIntNumber());
- break;
- case FieldDescriptor::CPPTYPE_UINT64:
- reflection->SetUInt64(&msg, field, value.ForceIntNumber());
- break;
- case FieldDescriptor::CPPTYPE_DOUBLE:
- reflection->SetDouble(&msg, field, value.ForceNumber());
- break;
- case FieldDescriptor::CPPTYPE_FLOAT:
- reflection->SetFloat(&msg, field, value.ForceNumber());
- break;
- case FieldDescriptor::CPPTYPE_BOOL:
- reflection->SetBool(&msg, field, value.IsTrue());
- break;
- case FieldDescriptor::CPPTYPE_STRING:
- reflection->SetString(&msg, field, value.ForceString());
- break;
- case FieldDescriptor::CPPTYPE_ENUM:
+ case FieldDescriptor::CPPTYPE_INT32:
+ reflection->SetInt32(&msg, field, value.ForceIntNumber());
+ break;
+ case FieldDescriptor::CPPTYPE_INT64:
+ reflection->SetInt64(&msg, field, value.ForceIntNumber());
+ break;
+ case FieldDescriptor::CPPTYPE_UINT32:
+ reflection->SetUInt32(&msg, field, value.ForceIntNumber());
+ break;
+ case FieldDescriptor::CPPTYPE_UINT64:
+ reflection->SetUInt64(&msg, field, value.ForceIntNumber());
+ break;
+ case FieldDescriptor::CPPTYPE_DOUBLE:
+ reflection->SetDouble(&msg, field, value.ForceNumber());
+ break;
+ case FieldDescriptor::CPPTYPE_FLOAT:
+ reflection->SetFloat(&msg, field, value.ForceNumber());
+ break;
+ case FieldDescriptor::CPPTYPE_BOOL:
+ reflection->SetBool(&msg, field, value.IsTrue());
+ break;
+ case FieldDescriptor::CPPTYPE_STRING:
+ reflection->SetString(&msg, field, value.ForceString());
+ break;
+ case FieldDescriptor::CPPTYPE_ENUM:
value.ToEnumField(msg, field, opts);
- break;
- case FieldDescriptor::CPPTYPE_MESSAGE:
+ break;
+ case FieldDescriptor::CPPTYPE_MESSAGE:
value.To(*reflection->MutableMessage(&msg, field), opts);
- break;
- default:
- ythrow TSchemeException()
- << "field " << field->full_name()
- << " unexpected type " << (int)field->cpp_type();
+ break;
+ default:
+ ythrow TSchemeException()
+ << "field " << field->full_name()
+ << " unexpected type " << (int)field->cpp_type();
}
}
@@ -212,8 +212,8 @@ namespace NSc {
const EnumDescriptor* enumField = field->enum_type();
const EnumValueDescriptor* enumFieldValue = IsString()
- ? enumField->FindValueByName(ForceString())
- : enumField->FindValueByNumber(ForceIntNumber());
+ ? enumField->FindValueByName(ForceString())
+ : enumField->FindValueByNumber(ForceIntNumber());
if (!enumFieldValue) {
if (opts.UnknownEnumValueIsDefault) {
@@ -250,42 +250,42 @@ namespace NSc {
const Reflection* reflection = msg.GetReflection();
- for (const TValue& value : fieldValue.GetArray()) {
+ for (const TValue& value : fieldValue.GetArray()) {
switch (field->cpp_type()) {
- case FieldDescriptor::CPPTYPE_INT32:
- reflection->AddInt32(&msg, field, value.ForceIntNumber());
- break;
- case FieldDescriptor::CPPTYPE_INT64:
- reflection->AddInt64(&msg, field, value.ForceIntNumber());
- break;
- case FieldDescriptor::CPPTYPE_UINT32:
- reflection->AddUInt32(&msg, field, value.ForceIntNumber());
- break;
- case FieldDescriptor::CPPTYPE_UINT64:
- reflection->AddUInt64(&msg, field, value.ForceIntNumber());
- break;
- case FieldDescriptor::CPPTYPE_DOUBLE:
- reflection->AddDouble(&msg, field, value.ForceNumber());
- break;
- case FieldDescriptor::CPPTYPE_FLOAT:
- reflection->AddFloat(&msg, field, value.ForceNumber());
- break;
- case FieldDescriptor::CPPTYPE_BOOL:
- reflection->AddBool(&msg, field, value.IsTrue());
- break;
- case FieldDescriptor::CPPTYPE_STRING:
- reflection->AddString(&msg, field, value.ForceString());
- break;
- case FieldDescriptor::CPPTYPE_ENUM:
+ case FieldDescriptor::CPPTYPE_INT32:
+ reflection->AddInt32(&msg, field, value.ForceIntNumber());
+ break;
+ case FieldDescriptor::CPPTYPE_INT64:
+ reflection->AddInt64(&msg, field, value.ForceIntNumber());
+ break;
+ case FieldDescriptor::CPPTYPE_UINT32:
+ reflection->AddUInt32(&msg, field, value.ForceIntNumber());
+ break;
+ case FieldDescriptor::CPPTYPE_UINT64:
+ reflection->AddUInt64(&msg, field, value.ForceIntNumber());
+ break;
+ case FieldDescriptor::CPPTYPE_DOUBLE:
+ reflection->AddDouble(&msg, field, value.ForceNumber());
+ break;
+ case FieldDescriptor::CPPTYPE_FLOAT:
+ reflection->AddFloat(&msg, field, value.ForceNumber());
+ break;
+ case FieldDescriptor::CPPTYPE_BOOL:
+ reflection->AddBool(&msg, field, value.IsTrue());
+ break;
+ case FieldDescriptor::CPPTYPE_STRING:
+ reflection->AddString(&msg, field, value.ForceString());
+ break;
+ case FieldDescriptor::CPPTYPE_ENUM:
value.ToEnumField(msg, field, opts);
- break;
- case FieldDescriptor::CPPTYPE_MESSAGE:
- value.To(*reflection->AddMessage(&msg, field));
- break;
- default:
- ythrow TSchemeException()
- << "field " << field->full_name()
- << " unexpected type " << (int)field->cpp_type();
+ break;
+ case FieldDescriptor::CPPTYPE_MESSAGE:
+ value.To(*reflection->AddMessage(&msg, field));
+ break;
+ default:
+ ythrow TSchemeException()
+ << "field " << field->full_name()
+ << " unexpected type " << (int)field->cpp_type();
}
}
}
diff --git a/library/cpp/scheme/tests/ut/scheme_cast_ut.cpp b/library/cpp/scheme/tests/ut/scheme_cast_ut.cpp
index a57b77e566..4f907157e9 100644
--- a/library/cpp/scheme/tests/ut/scheme_cast_ut.cpp
+++ b/library/cpp/scheme/tests/ut/scheme_cast_ut.cpp
@@ -26,13 +26,13 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) {
TVI y(FromJson<TVI>(ToJson(v)));
UNIT_ASSERT_VALUES_EQUAL(v.size(), y.size());
- UNIT_ASSERT(std::equal(v.begin(), v.end(), y.begin()));
+ UNIT_ASSERT(std::equal(v.begin(), v.end(), y.begin()));
}
Y_UNIT_TEST(TestYHash) {
THI h;
for (int i = 0; i < 3; ++i)
- h[i] = i * i;
+ h[i] = i * i;
const TString etalon = "{\"0\":0,\"1\":1,\"2\":4}";
UNIT_ASSERT_VALUES_EQUAL(etalon, ToJson(h, true));
@@ -44,7 +44,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) {
Y_UNIT_TEST(TestYMap) {
TMI h;
for (int i = 0; i < 3; ++i)
- h[i] = i * i;
+ h[i] = i * i;
const TString etalon = "{\"0\":0,\"1\":1,\"2\":4}";
UNIT_ASSERT_VALUES_EQUAL(etalon, ToJson(h, true));
@@ -56,7 +56,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) {
Y_UNIT_TEST(TestYHashSet) {
THSI h;
for (int i = 0; i < 3; ++i)
- h.insert(i * i);
+ h.insert(i * i);
const TString etalon = "{\"0\":null,\"1\":null,\"4\":null}";
UNIT_ASSERT_VALUES_EQUAL(etalon, ToJson(h, true));
@@ -68,7 +68,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) {
Y_UNIT_TEST(TestYSet) {
TSI h;
for (int i = 0; i < 3; ++i)
- h.insert(i * i);
+ h.insert(i * i);
const TString etalon = "{\"0\":null,\"1\":null,\"4\":null}";
UNIT_ASSERT_VALUES_EQUAL(etalon, ToJson(h, true));
@@ -78,7 +78,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) {
}
Y_UNIT_TEST(TestTPair) {
- TPI p(1, 1);
+ TPI p(1, 1);
const TString etalon = "[1,1]";
UNIT_ASSERT_VALUES_EQUAL(etalon, ToJson(p, true));
@@ -89,14 +89,14 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) {
struct TCustom: public IJsonSerializable {
int A, B;
- TCustom()
- : A(0)
- , B(0){};
- TCustom(int a, int b)
- : A(a)
- , B(b)
- {
- }
+ TCustom()
+ : A(0)
+ , B(0){};
+ TCustom(int a, int b)
+ : A(a)
+ , B(b)
+ {
+ }
NSc::TValue ToTValue() const override {
NSc::TValue res;
res["a"] = A;
@@ -108,7 +108,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) {
B = v["b"].GetNumber();
}
- bool operator<(const TCustom& rhs) const {
+ bool operator<(const TCustom& rhs) const {
return A < rhs.A;
}
};
@@ -128,7 +128,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) {
TVPI v;
for (int i = 0; i < 3; ++i)
- v.push_back(TPI(i, i * i));
+ v.push_back(TPI(i, i * i));
const TString etalon = "[[0,0],[1,1],[2,4]]";
UNIT_ASSERT_VALUES_EQUAL(etalon, ToJson(v, true));
@@ -140,7 +140,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) {
Y_UNIT_TEST(TestSetOfCustom) {
typedef TSet<TCustom> TSC;
TSC s;
- s.insert(TCustom(2, 3));
+ s.insert(TCustom(2, 3));
const TString etalon = "{\"{\\\"a\\\":2,\\\"b\\\":3}\":null}";
UNIT_ASSERT_VALUES_EQUAL(etalon, ToJson(s, true));
diff --git a/library/cpp/scheme/tests/ut/scheme_json_ut.cpp b/library/cpp/scheme/tests/ut/scheme_json_ut.cpp
index 561829ffab..daeb2654f9 100644
--- a/library/cpp/scheme/tests/ut/scheme_json_ut.cpp
+++ b/library/cpp/scheme/tests/ut/scheme_json_ut.cpp
@@ -14,12 +14,12 @@ using namespace std::string_view_literals;
Y_UNIT_TEST_SUITE(TSchemeJsonTest) {
Y_UNIT_TEST(TestJson) {
const char* json = "[\n"
- " {\n"
- " \"url\":\"foo\",\n"
- " \"title\":\"bar\",\n"
- " \"passages\":[\"foo\", \"bar\"],\n"
- " }\n"
- "]";
+ " {\n"
+ " \"url\":\"foo\",\n"
+ " \"title\":\"bar\",\n"
+ " \"passages\":[\"foo\", \"bar\"],\n"
+ " }\n"
+ "]";
{
const NSc::TValue& v = NSc::TValue::FromJson(json);
@@ -84,32 +84,32 @@ Y_UNIT_TEST_SUITE(TSchemeJsonTest) {
UNIT_ASSERT_VALUES_EQUAL("{\"xxx\":null}", v.ToJson(NSc::TValue::JO_SAFE));
UNIT_ASSERT_VALUES_EQUAL("{"
- "\"\\u0000\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007\\b\\t\\n\\u000B\\f\\r"
- "\\u000E\\u000F\\u0010\\u0011\\u0012\\u0013\\u0014\\u0015\\u0016\\u0017\\u0018"
- "\\u0019\\u001A\\u001B\\u001C\\u001D\\u001E\\u001F !\\\"#$%&'()*+,-./0123456789"
- ":;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\\u007F"
- "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93"
- "\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7"
- "\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB"
- "\xBC\xBD\xBE\xBF\\xC0\\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE"
- "\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1"
- "\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4"
- "\\xF5\\xF6\\xF7\\xF8\\xF9\\xFA\\xFB\\xFC\\xFD\\xFE\\xFF\":"
- "\"xxx\","
- "\"xxx\":"
- "\"\\u0000\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007\\b\\t\\n\\u000B\\f\\r"
- "\\u000E\\u000F\\u0010\\u0011\\u0012\\u0013\\u0014\\u0015\\u0016\\u0017\\u0018"
- "\\u0019\\u001A\\u001B\\u001C\\u001D\\u001E\\u001F !\\\"#$%&'()*+,-./0123456789"
- ":;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\\u007F"
- "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93"
- "\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7"
- "\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB"
- "\xBC\xBD\xBE\xBF\\xC0\\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE"
- "\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1"
- "\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4"
- "\\xF5\\xF6\\xF7\\xF8\\xF9\\xFA\\xFB\\xFC\\xFD\\xFE\\xFF\""
- "}",
- v.ToJson(NSc::TValue::JO_SORT_KEYS));
+ "\"\\u0000\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007\\b\\t\\n\\u000B\\f\\r"
+ "\\u000E\\u000F\\u0010\\u0011\\u0012\\u0013\\u0014\\u0015\\u0016\\u0017\\u0018"
+ "\\u0019\\u001A\\u001B\\u001C\\u001D\\u001E\\u001F !\\\"#$%&'()*+,-./0123456789"
+ ":;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\\u007F"
+ "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93"
+ "\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7"
+ "\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB"
+ "\xBC\xBD\xBE\xBF\\xC0\\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE"
+ "\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1"
+ "\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4"
+ "\\xF5\\xF6\\xF7\\xF8\\xF9\\xFA\\xFB\\xFC\\xFD\\xFE\\xFF\":"
+ "\"xxx\","
+ "\"xxx\":"
+ "\"\\u0000\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007\\b\\t\\n\\u000B\\f\\r"
+ "\\u000E\\u000F\\u0010\\u0011\\u0012\\u0013\\u0014\\u0015\\u0016\\u0017\\u0018"
+ "\\u0019\\u001A\\u001B\\u001C\\u001D\\u001E\\u001F !\\\"#$%&'()*+,-./0123456789"
+ ":;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\\u007F"
+ "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93"
+ "\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7"
+ "\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB"
+ "\xBC\xBD\xBE\xBF\\xC0\\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE"
+ "\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1"
+ "\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4"
+ "\\xF5\\xF6\\xF7\\xF8\\xF9\\xFA\\xFB\\xFC\\xFD\\xFE\\xFF\""
+ "}",
+ v.ToJson(NSc::TValue::JO_SORT_KEYS));
UNIT_ASSERT(NSc::TValue::Equal(v, NSc::TValue::FromJson(v.ToJson())));
{
@@ -152,7 +152,7 @@ Y_UNIT_TEST_SUITE(TSchemeJsonTest) {
}
Y_UNIT_TEST(TestDuplicateKeys) {
- const TStringBuf duplicatedKeys = "{\"a\":[{\"b\":1, \"b\":42}]}";
+ const TStringBuf duplicatedKeys = "{\"a\":[{\"b\":1, \"b\":42}]}";
UNIT_ASSERT_NO_EXCEPTION(NSc::TValue::FromJsonThrow(duplicatedKeys));
UNIT_ASSERT_EXCEPTION(NSc::TValue::FromJsonThrow(duplicatedKeys, NSc::TValue::JO_PARSER_DISALLOW_DUPLICATE_KEYS), yexception);
UNIT_ASSERT(NSc::TValue::FromJson(duplicatedKeys).IsDict());
diff --git a/library/cpp/scheme/tests/ut/scheme_path_ut.cpp b/library/cpp/scheme/tests/ut/scheme_path_ut.cpp
index 45cd19a4be..0d4d79d483 100644
--- a/library/cpp/scheme/tests/ut/scheme_path_ut.cpp
+++ b/library/cpp/scheme/tests/ut/scheme_path_ut.cpp
@@ -34,21 +34,21 @@ Y_UNIT_TEST_SUITE(TSchemePathTest) {
UNIT_ASSERT(v.PathExists("//"));
UNIT_ASSERT(NSc::TValue::Same(v, *v.TrySelectOrAdd("//")));
- NSc::NUt::AssertSchemeJson("null", v);
+ NSc::NUt::AssertSchemeJson("null", v);
UNIT_ASSERT(NSc::TValue::Same(v.TrySelectAndDelete("//"), NSc::Null()));
- NSc::NUt::AssertSchemeJson("null", v);
+ NSc::NUt::AssertSchemeJson("null", v);
v.SetDict();
UNIT_ASSERT(NSc::TValue::Same(v, *v.TrySelectOrAdd("//")));
- NSc::NUt::AssertSchemeJson("{}", v);
+ NSc::NUt::AssertSchemeJson("{}", v);
UNIT_ASSERT(NSc::TValue::Same(v.TrySelectAndDelete("//"), NSc::Null()));
- NSc::NUt::AssertSchemeJson("{}", v);
+ NSc::NUt::AssertSchemeJson("{}", v);
v.SetArray();
UNIT_ASSERT(NSc::TValue::Same(v, *v.TrySelectOrAdd("//")));
- NSc::NUt::AssertSchemeJson("[]", v);
+ NSc::NUt::AssertSchemeJson("[]", v);
UNIT_ASSERT(NSc::TValue::Same(v.TrySelectAndDelete("//"), NSc::Null()));
- NSc::NUt::AssertSchemeJson("[]", v);
+ NSc::NUt::AssertSchemeJson("[]", v);
DoTestSelect("[]", "{'':1}", "{}");
DoTestSelect("[ ]", "{' ':1}", "{}");
@@ -69,27 +69,27 @@ Y_UNIT_TEST_SUITE(TSchemePathTest) {
}
Y_UNIT_TEST(TestPathEscapes) {
- UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath("a"), "a");
- UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath(""), R"=("")=");
- UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath("[]"), R"=("[]")=");
+ UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath("a"), "a");
+ UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath(""), R"=("")=");
+ UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath("[]"), R"=("[]")=");
UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath("[]ab"), R"=("[]ab")=");
UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath("a[]b"), R"=("a[]b")=");
UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath("ab[]"), R"=("ab[]")=");
UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath("[ab]"), R"=("[ab]")=");
- UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath("[ab"), R"=("[ab")=");
- UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath("a[b"), R"=("a[b")=");
- UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath("ab["), R"=("ab[")=");
- UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath("]ab"), R"=("]ab")=");
- UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath("a]b"), R"=("a]b")=");
- UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath("ab]"), R"=("ab]")=");
- UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath(R"=(\)="), R"=("\\")=");
+ UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath("[ab"), R"=("[ab")=");
+ UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath("a[b"), R"=("a[b")=");
+ UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath("ab["), R"=("ab[")=");
+ UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath("]ab"), R"=("]ab")=");
+ UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath("a]b"), R"=("a]b")=");
+ UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath("ab]"), R"=("ab]")=");
+ UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath(R"=(\)="), R"=("\\")=");
UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath(R"=(\\)="), R"=("\\\\")=");
- UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath("/"), R"=("/")=");
- UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath("//"), R"=("//")=");
- UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath("///"), R"=("///")=");
- UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath("/ab"), R"=("/ab")=");
- UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath("a/b"), R"=("a/b")=");
- UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath("ab/"), R"=("ab/")=");
+ UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath("/"), R"=("/")=");
+ UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath("//"), R"=("//")=");
+ UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath("///"), R"=("///")=");
+ UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath("/ab"), R"=("/ab")=");
+ UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath("a/b"), R"=("a/b")=");
+ UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath("ab/"), R"=("ab/")=");
UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath("//ab"), R"=("//ab")=");
UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath("a//b"), R"=("a//b")=");
UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::EscapeForPath("ab//"), R"=("ab//")=");
diff --git a/library/cpp/scheme/tests/ut/scheme_proto_ut.cpp b/library/cpp/scheme/tests/ut/scheme_proto_ut.cpp
index 502c74b15b..e711a0d092 100644
--- a/library/cpp/scheme/tests/ut/scheme_proto_ut.cpp
+++ b/library/cpp/scheme/tests/ut/scheme_proto_ut.cpp
@@ -36,22 +36,22 @@ Y_UNIT_TEST_SUITE(TSchemeProtoTest) {
void DoTestProtobuf(bool fromProto, bool mapAsDict) {
NSc::TMessage m;
NSc::TValue v;
- m.SetDouble((double)1 / 3), v["Double"] = (double)1 / 3;
- m.SetFloat((float)1 / 3), v["Float"] = (float)1 / 3;
- m.SetInt32(1000000), v["Int32"] = 1000000;
- m.SetInt64(1000000000000LL), v["Int64"] = 1000000000000LL;
- m.SetUInt32(555555), v["UInt32"] = 555555;
- m.SetUInt64(555555555555LL), v["UInt64"] = 555555555555LL;
- m.SetSInt32(-555555), v["SInt32"] = -555555;
- m.SetSInt64(-555555555555LL), v["SInt64"] = -555555555555LL;
- m.SetFixed32(123456), v["Fixed32"] = 123456;
- m.SetFixed64(123456123456LL), v["Fixed64"] = 123456123456LL;
- m.SetSFixed32(-123456), v["SFixed32"] = -123456;
- m.SetSFixed64(-123456123456LL), v["SFixed64"] = -123456123456LL;
- m.SetBool(true), v["Bool"] = true;
- m.SetString("String"), v["String"] = "String";
- m.SetBytes("Bytes"), v["Bytes"] = "Bytes";
- m.SetEnum(NSc::VALUE1), v["Enum"] = "VALUE1";
+ m.SetDouble((double)1 / 3), v["Double"] = (double)1 / 3;
+ m.SetFloat((float)1 / 3), v["Float"] = (float)1 / 3;
+ m.SetInt32(1000000), v["Int32"] = 1000000;
+ m.SetInt64(1000000000000LL), v["Int64"] = 1000000000000LL;
+ m.SetUInt32(555555), v["UInt32"] = 555555;
+ m.SetUInt64(555555555555LL), v["UInt64"] = 555555555555LL;
+ m.SetSInt32(-555555), v["SInt32"] = -555555;
+ m.SetSInt64(-555555555555LL), v["SInt64"] = -555555555555LL;
+ m.SetFixed32(123456), v["Fixed32"] = 123456;
+ m.SetFixed64(123456123456LL), v["Fixed64"] = 123456123456LL;
+ m.SetSFixed32(-123456), v["SFixed32"] = -123456;
+ m.SetSFixed64(-123456123456LL), v["SFixed64"] = -123456123456LL;
+ m.SetBool(true), v["Bool"] = true;
+ m.SetString("String"), v["String"] = "String";
+ m.SetBytes("Bytes"), v["Bytes"] = "Bytes";
+ m.SetEnum(NSc::VALUE1), v["Enum"] = "VALUE1";
auto& mapDoublesP = *m.mutable_mapdoubles();
auto& mapDoublesV = v["MapDoubles"];
@@ -83,129 +83,129 @@ Y_UNIT_TEST_SUITE(TSchemeProtoTest) {
AddMapPair(mapStringV, "deep", "blue", mapAsDict);
}
- m.AddDoubles((double)1 / 3), v["Doubles"][0] = (double)1 / 3;
- m.AddDoubles((double)1 / 4), v["Doubles"][1] = (double)1 / 4;
+ m.AddDoubles((double)1 / 3), v["Doubles"][0] = (double)1 / 3;
+ m.AddDoubles((double)1 / 4), v["Doubles"][1] = (double)1 / 4;
- m.AddFloats((float)1 / 3), v["Floats"][0] = (float)1 / 3;
- m.AddFloats((float)1 / 4), v["Floats"][1] = (float)1 / 4;
+ m.AddFloats((float)1 / 3), v["Floats"][0] = (float)1 / 3;
+ m.AddFloats((float)1 / 4), v["Floats"][1] = (float)1 / 4;
- m.AddInt32s(1000000), v["Int32s"][0] = 1000000;
- m.AddInt32s(2000000), v["Int32s"][1] = 2000000;
+ m.AddInt32s(1000000), v["Int32s"][0] = 1000000;
+ m.AddInt32s(2000000), v["Int32s"][1] = 2000000;
- m.AddInt64s(1000000000000LL), v["Int64s"][0] = 1000000000000LL;
- m.AddInt64s(2000000000000LL), v["Int64s"][1] = 2000000000000LL;
+ m.AddInt64s(1000000000000LL), v["Int64s"][0] = 1000000000000LL;
+ m.AddInt64s(2000000000000LL), v["Int64s"][1] = 2000000000000LL;
- m.AddUInt32s(555555), v["UInt32s"][0] = 555555;
- m.AddUInt32s(655555), v["UInt32s"][1] = 655555;
+ m.AddUInt32s(555555), v["UInt32s"][0] = 555555;
+ m.AddUInt32s(655555), v["UInt32s"][1] = 655555;
- m.AddUInt64s(555555555555LL);
- v["UInt64s"][0] = 555555555555LL;
- m.AddUInt64s(655555555555LL);
- v["UInt64s"][1] = 655555555555LL;
+ m.AddUInt64s(555555555555LL);
+ v["UInt64s"][0] = 555555555555LL;
+ m.AddUInt64s(655555555555LL);
+ v["UInt64s"][1] = 655555555555LL;
- m.AddSInt32s(-555555), v["SInt32s"][0] = -555555;
- m.AddSInt32s(-655555), v["SInt32s"][1] = -655555;
+ m.AddSInt32s(-555555), v["SInt32s"][0] = -555555;
+ m.AddSInt32s(-655555), v["SInt32s"][1] = -655555;
- m.AddSInt64s(-555555555555LL), v["SInt64s"][0] = -555555555555LL;
- m.AddSInt64s(-655555555555LL), v["SInt64s"][1] = -655555555555LL;
+ m.AddSInt64s(-555555555555LL), v["SInt64s"][0] = -555555555555LL;
+ m.AddSInt64s(-655555555555LL), v["SInt64s"][1] = -655555555555LL;
- m.AddFixed32s(123456), v["Fixed32s"][0] = 123456;
- m.AddFixed32s(223456), v["Fixed32s"][1] = 223456;
+ m.AddFixed32s(123456), v["Fixed32s"][0] = 123456;
+ m.AddFixed32s(223456), v["Fixed32s"][1] = 223456;
- m.AddFixed64s(123456123456LL), v["Fixed64s"][0] = 123456123456LL;
- m.AddFixed64s(223456123456LL), v["Fixed64s"][1] = 223456123456LL;
+ m.AddFixed64s(123456123456LL), v["Fixed64s"][0] = 123456123456LL;
+ m.AddFixed64s(223456123456LL), v["Fixed64s"][1] = 223456123456LL;
- m.AddSFixed32s(-123456), v["SFixed32s"][0] = -123456;
- m.AddSFixed32s(-223456), v["SFixed32s"][1] = -223456;
+ m.AddSFixed32s(-123456), v["SFixed32s"][0] = -123456;
+ m.AddSFixed32s(-223456), v["SFixed32s"][1] = -223456;
- m.AddSFixed64s(-123456123456LL), v["SFixed64s"][0] = -123456123456LL;
- m.AddSFixed64s(-223456123456LL), v["SFixed64s"][1] = -223456123456LL;
+ m.AddSFixed64s(-123456123456LL), v["SFixed64s"][0] = -123456123456LL;
+ m.AddSFixed64s(-223456123456LL), v["SFixed64s"][1] = -223456123456LL;
- m.AddBools(false), v["Bools"][0] = false;
- m.AddBools(true), v["Bools"][1] = true;
+ m.AddBools(false), v["Bools"][0] = false;
+ m.AddBools(true), v["Bools"][1] = true;
- m.AddStrings("String1"), v["Strings"][0] = "String1";
- m.AddStrings("String2"), v["Strings"][1] = "String2";
+ m.AddStrings("String1"), v["Strings"][0] = "String1";
+ m.AddStrings("String2"), v["Strings"][1] = "String2";
- m.AddBytess("Bytes1"), v["Bytess"][0] = "Bytes1";
- m.AddBytess("Bytes2"), v["Bytess"][1] = "Bytes2";
+ m.AddBytess("Bytes1"), v["Bytess"][0] = "Bytes1";
+ m.AddBytess("Bytes2"), v["Bytess"][1] = "Bytes2";
- m.AddEnums(NSc::VALUE1), v["Enums"][0] = "VALUE1";
- m.AddEnums(NSc::VALUE2), v["Enums"][1] = "VALUE2";
+ m.AddEnums(NSc::VALUE1), v["Enums"][0] = "VALUE1";
+ m.AddEnums(NSc::VALUE2), v["Enums"][1] = "VALUE2";
NSc::TMessage2 m2;
NSc::TValue v2;
- m2.SetDouble((double)1 / 3), v2["Double"] = (double)1 / 3;
- m2.SetFloat((float)1 / 3), v2["Float"] = (float)1 / 3;
- m2.SetInt32(1000000), v2["Int32"] = 1000000;
- m2.SetInt64(1000000000000LL), v2["Int64"] = 1000000000000LL;
- m2.SetUInt32(555555), v2["UInt32"] = 555555;
- m2.SetUInt64(555555555555LL), v2["UInt64"] = 555555555555LL;
- m2.SetSInt32(-555555), v2["SInt32"] = -555555;
- m2.SetSInt64(-555555555555LL), v2["SInt64"] = -555555555555LL;
- m2.SetFixed32(123456), v2["Fixed32"] = 123456;
- m2.SetFixed64(123456123456LL), v2["Fixed64"] = 123456123456LL;
- m2.SetSFixed32(-123456), v2["SFixed32"] = -123456;
- m2.SetSFixed64(-123456123456LL), v2["SFixed64"] = -123456123456LL;
- m2.SetBool(true), v2["Bool"] = true;
- m2.SetString("String"), v2["String"] = "String";
- m2.SetBytes("Bytes"), v2["Bytes"] = "Bytes";
- m2.SetEnum(NSc::VALUE1), v2["Enum"] = "VALUE1";
+ m2.SetDouble((double)1 / 3), v2["Double"] = (double)1 / 3;
+ m2.SetFloat((float)1 / 3), v2["Float"] = (float)1 / 3;
+ m2.SetInt32(1000000), v2["Int32"] = 1000000;
+ m2.SetInt64(1000000000000LL), v2["Int64"] = 1000000000000LL;
+ m2.SetUInt32(555555), v2["UInt32"] = 555555;
+ m2.SetUInt64(555555555555LL), v2["UInt64"] = 555555555555LL;
+ m2.SetSInt32(-555555), v2["SInt32"] = -555555;
+ m2.SetSInt64(-555555555555LL), v2["SInt64"] = -555555555555LL;
+ m2.SetFixed32(123456), v2["Fixed32"] = 123456;
+ m2.SetFixed64(123456123456LL), v2["Fixed64"] = 123456123456LL;
+ m2.SetSFixed32(-123456), v2["SFixed32"] = -123456;
+ m2.SetSFixed64(-123456123456LL), v2["SFixed64"] = -123456123456LL;
+ m2.SetBool(true), v2["Bool"] = true;
+ m2.SetString("String"), v2["String"] = "String";
+ m2.SetBytes("Bytes"), v2["Bytes"] = "Bytes";
+ m2.SetEnum(NSc::VALUE1), v2["Enum"] = "VALUE1";
- m2.AddDoubles((double)1 / 3), v2["Doubles"][0] = (double)1 / 3;
- m2.AddDoubles((double)1 / 4), v2["Doubles"][1] = (double)1 / 4;
+ m2.AddDoubles((double)1 / 3), v2["Doubles"][0] = (double)1 / 3;
+ m2.AddDoubles((double)1 / 4), v2["Doubles"][1] = (double)1 / 4;
- m2.AddFloats((float)1 / 3), v2["Floats"][0] = (float)1 / 3;
- m2.AddFloats((float)1 / 4), v2["Floats"][1] = (float)1 / 4;
+ m2.AddFloats((float)1 / 3), v2["Floats"][0] = (float)1 / 3;
+ m2.AddFloats((float)1 / 4), v2["Floats"][1] = (float)1 / 4;
- m2.AddInt32s(1000000), v2["Int32s"][0] = 1000000;
- m2.AddInt32s(2000000), v2["Int32s"][1] = 2000000;
+ m2.AddInt32s(1000000), v2["Int32s"][0] = 1000000;
+ m2.AddInt32s(2000000), v2["Int32s"][1] = 2000000;
- m2.AddInt64s(1000000000000LL), v2["Int64s"][0] = 1000000000000LL;
- m2.AddInt64s(2000000000000LL), v2["Int64s"][1] = 2000000000000LL;
+ m2.AddInt64s(1000000000000LL), v2["Int64s"][0] = 1000000000000LL;
+ m2.AddInt64s(2000000000000LL), v2["Int64s"][1] = 2000000000000LL;
- m2.AddUInt32s(555555), v2["UInt32s"][0] = 555555;
- m2.AddUInt32s(655555), v2["UInt32s"][1] = 655555;
+ m2.AddUInt32s(555555), v2["UInt32s"][0] = 555555;
+ m2.AddUInt32s(655555), v2["UInt32s"][1] = 655555;
- m2.AddUInt64s(555555555555LL);
- v2["UInt64s"][0] = 555555555555LL;
- m2.AddUInt64s(655555555555LL);
- v2["UInt64s"][1] = 655555555555LL;
+ m2.AddUInt64s(555555555555LL);
+ v2["UInt64s"][0] = 555555555555LL;
+ m2.AddUInt64s(655555555555LL);
+ v2["UInt64s"][1] = 655555555555LL;
- m2.AddSInt32s(-555555), v2["SInt32s"][0] = -555555;
- m2.AddSInt32s(-655555), v2["SInt32s"][1] = -655555;
+ m2.AddSInt32s(-555555), v2["SInt32s"][0] = -555555;
+ m2.AddSInt32s(-655555), v2["SInt32s"][1] = -655555;
- m2.AddSInt64s(-555555555555LL), v2["SInt64s"][0] = -555555555555LL;
- m2.AddSInt64s(-655555555555LL), v2["SInt64s"][1] = -655555555555LL;
+ m2.AddSInt64s(-555555555555LL), v2["SInt64s"][0] = -555555555555LL;
+ m2.AddSInt64s(-655555555555LL), v2["SInt64s"][1] = -655555555555LL;
- m2.AddFixed32s(123456), v2["Fixed32s"][0] = 123456;
- m2.AddFixed32s(223456), v2["Fixed32s"][1] = 223456;
+ m2.AddFixed32s(123456), v2["Fixed32s"][0] = 123456;
+ m2.AddFixed32s(223456), v2["Fixed32s"][1] = 223456;
- m2.AddFixed64s(123456123456LL), v2["Fixed64s"][0] = 123456123456LL;
- m2.AddFixed64s(223456123456LL), v2["Fixed64s"][1] = 223456123456LL;
+ m2.AddFixed64s(123456123456LL), v2["Fixed64s"][0] = 123456123456LL;
+ m2.AddFixed64s(223456123456LL), v2["Fixed64s"][1] = 223456123456LL;
- m2.AddSFixed32s(-123456), v2["SFixed32s"][0] = -123456;
- m2.AddSFixed32s(-223456), v2["SFixed32s"][1] = -223456;
+ m2.AddSFixed32s(-123456), v2["SFixed32s"][0] = -123456;
+ m2.AddSFixed32s(-223456), v2["SFixed32s"][1] = -223456;
- m2.AddSFixed64s(-123456123456LL), v2["SFixed64s"][0] = -123456123456LL;
- m2.AddSFixed64s(-223456123456LL), v2["SFixed64s"][1] = -223456123456LL;
+ m2.AddSFixed64s(-123456123456LL), v2["SFixed64s"][0] = -123456123456LL;
+ m2.AddSFixed64s(-223456123456LL), v2["SFixed64s"][1] = -223456123456LL;
- m2.AddBools(false), v2["Bools"][0] = false;
- m2.AddBools(true), v2["Bools"][1] = true;
+ m2.AddBools(false), v2["Bools"][0] = false;
+ m2.AddBools(true), v2["Bools"][1] = true;
- m2.AddStrings("String1"), v2["Strings"][0] = "String1";
- m2.AddStrings("String2"), v2["Strings"][1] = "String2";
+ m2.AddStrings("String1"), v2["Strings"][0] = "String1";
+ m2.AddStrings("String2"), v2["Strings"][1] = "String2";
- m2.AddBytess("Bytes1"), v2["Bytess"][0] = "Bytes1";
- m2.AddBytess("Bytes2"), v2["Bytess"][1] = "Bytes2";
+ m2.AddBytess("Bytes1"), v2["Bytess"][0] = "Bytes1";
+ m2.AddBytess("Bytes2"), v2["Bytess"][1] = "Bytes2";
- m2.AddEnums(NSc::VALUE1), v2["Enums"][0] = "VALUE1";
- m2.AddEnums(NSc::VALUE2), v2["Enums"][1] = "VALUE2";
+ m2.AddEnums(NSc::VALUE1), v2["Enums"][0] = "VALUE1";
+ m2.AddEnums(NSc::VALUE2), v2["Enums"][1] = "VALUE2";
- *(m.MutableMessage()) = m2, v["Message"] = v2;
+ *(m.MutableMessage()) = m2, v["Message"] = v2;
- *(m.AddMessages()) = m2, v["Messages"][0] = v2;
- *(m.AddMessages()) = m2, v["Messages"][1] = v2;
+ *(m.AddMessages()) = m2, v["Messages"][0] = v2;
+ *(m.AddMessages()) = m2, v["Messages"][1] = v2;
if (fromProto) {
UNIT_ASSERT(NSc::TValue::Equal(v, NSc::TValue::From(m, mapAsDict)));
diff --git a/library/cpp/scheme/tests/ut/scheme_ut.cpp b/library/cpp/scheme/tests/ut/scheme_ut.cpp
index a6bfc7d843..1a5d07c31b 100644
--- a/library/cpp/scheme/tests/ut/scheme_ut.cpp
+++ b/library/cpp/scheme/tests/ut/scheme_ut.cpp
@@ -134,11 +134,11 @@ Y_UNIT_TEST_SUITE(TSchemeTest) {
UNIT_ASSERT_VALUES_EQUAL_C(i64(t), NSc::TValue(i64(t)).ForceIntNumber(), ToString(t));
UNIT_ASSERT_VALUES_EQUAL_C(double(t), NSc::TValue(double(t)).ForceNumber(), ToString(t));
- UNIT_ASSERT_VALUES_EQUAL_C(i64(t), NSc::TValue(TStringBuf(ToString(i64(t)))).ForceIntNumber(), ToString(t));
- UNIT_ASSERT_VALUES_EQUAL_C(ToString(double(t)), ToString(NSc::TValue(TStringBuf(ToString(double(t)))).ForceNumber()), ToString(t));
+ UNIT_ASSERT_VALUES_EQUAL_C(i64(t), NSc::TValue(TStringBuf(ToString(i64(t)))).ForceIntNumber(), ToString(t));
+ UNIT_ASSERT_VALUES_EQUAL_C(ToString(double(t)), ToString(NSc::TValue(TStringBuf(ToString(double(t)))).ForceNumber()), ToString(t));
- UNIT_ASSERT_VALUES_EQUAL_C(ToString(i64(t)), NSc::TValue(TStringBuf(ToString(i64(t)))).ForceString(), ToString(t));
- UNIT_ASSERT_VALUES_EQUAL_C(ToString(double(t)), NSc::TValue(TStringBuf(ToString(double(t)))).ForceString(), ToString(t));
+ UNIT_ASSERT_VALUES_EQUAL_C(ToString(i64(t)), NSc::TValue(TStringBuf(ToString(i64(t)))).ForceString(), ToString(t));
+ UNIT_ASSERT_VALUES_EQUAL_C(ToString(double(t)), NSc::TValue(TStringBuf(ToString(double(t)))).ForceString(), ToString(t));
}
Y_UNIT_TEST(TestForce) {
@@ -258,8 +258,8 @@ Y_UNIT_TEST_SUITE(TSchemeTest) {
DoCheckAssignmentNum<double>(i, iless, imore, ii, "double");
}
- // DoCheckAssignment<bool>(true, true, true, "true", "bool");
- // DoCheckAssignment<bool>(false, false, false, "false", "bool");
+ // DoCheckAssignment<bool>(true, true, true, "true", "bool");
+ // DoCheckAssignment<bool>(false, false, false, "false", "bool");
for (int i = 1; i < 3; ++i) {
TString ii = ToString(i);
@@ -299,12 +299,12 @@ Y_UNIT_TEST_SUITE(TSchemeTest) {
DoCheckAssignment<const char*>("www", "wwa", "wwz", "\"www\"", "const char*");
DoCheckAssignmentArr("xxx", "xxa", "xxz", "\"xxx\"", "const char[]");
DoCheckAssignment<TStringBuf>("yyy", "yya", "yyz", "\"yyy\"", "TStringBuf");
-
-#if defined(_MSC_VER)
- //TODO
-#else
+
+#if defined(_MSC_VER)
+ //TODO
+#else
DoCheckAssignment<TString>("ttt", "tta", "ttz", "\"ttt\"", "TString");
-#endif
+#endif
NSc::TValue v;
v.SetDict();
@@ -351,10 +351,10 @@ Y_UNIT_TEST_SUITE(TSchemeTest) {
v.Insert(2, "c");
UNIT_ASSERT_VALUES_EQUAL(v.ToJson(), R"(["a","b","c","d"])");
- v.AppendAll({1, 2, 3});
+ v.AppendAll({1, 2, 3});
UNIT_ASSERT_VALUES_EQUAL(v.ToJson(), R"(["a","b","c","d",1,2,3])");
- TVector<int> d{4, 5, 6};
+ TVector<int> d{4, 5, 6};
v.AppendAll(d);
UNIT_ASSERT_VALUES_EQUAL(v.ToJson(), R"(["a","b","c","d",1,2,3,4,5,6])");
UNIT_ASSERT_VALUES_EQUAL(d.size(), 3u);
@@ -365,7 +365,7 @@ Y_UNIT_TEST_SUITE(TSchemeTest) {
UNIT_ASSERT_VALUES_EQUAL(v.Clone().Clear().AppendAll(s).ToJson(), R"(["x","y","z"])");
UNIT_ASSERT_VALUES_EQUAL(v.Clone().Clear().AppendAll(TVector<TStringBuf>()).ToJson(), R"([])");
- v.AddAll({{"a", "b"}, {"c", "d"}});
+ v.AddAll({{"a", "b"}, {"c", "d"}});
UNIT_ASSERT_VALUES_EQUAL(v.ToJson(), R"({"a":"b","c":"d"})");
}
diff --git a/library/cpp/scheme/ut_utils/scheme_ut_utils.cpp b/library/cpp/scheme/ut_utils/scheme_ut_utils.cpp
index 9ffd03bfbe..0bbdab10e8 100644
--- a/library/cpp/scheme/ut_utils/scheme_ut_utils.cpp
+++ b/library/cpp/scheme/ut_utils/scheme_ut_utils.cpp
@@ -12,18 +12,18 @@ namespace NSc {
} catch (const TSchemeParseException& e) {
TStringStream s;
NColorizer::TColors colors;
- s << "\n"
- << colors.YellowColor() << "Reason:" << colors.OldColor() << "\n"
- << e.Reason;
- s << "\n"
- << colors.YellowColor() << "Where:" << colors.OldColor() << "\n"
- << val.SubStr(0, e.Offset) << colors.RedColor() << val.SubStr(e.Offset) << colors.OldColor() << "\n";
+ s << "\n"
+ << colors.YellowColor() << "Reason:" << colors.OldColor() << "\n"
+ << e.Reason;
+ s << "\n"
+ << colors.YellowColor() << "Where:" << colors.OldColor() << "\n"
+ << val.SubStr(0, e.Offset) << colors.RedColor() << val.SubStr(e.Offset) << colors.OldColor() << "\n";
UNIT_FAIL_IMPL("could not parse json", s.Str());
return NSc::Null();
} catch (const yexception& e) {
TStringStream s;
- s << '\n'
- << val;
+ s << '\n'
+ << val;
UNIT_FAIL_IMPL("could not parse json", s.Str());
return NSc::Null();
}
diff --git a/library/cpp/scheme/ut_utils/scheme_ut_utils.h b/library/cpp/scheme/ut_utils/scheme_ut_utils.h
index 351dafe4f8..eb3ea15b2a 100644
--- a/library/cpp/scheme/ut_utils/scheme_ut_utils.h
+++ b/library/cpp/scheme/ut_utils/scheme_ut_utils.h
@@ -24,16 +24,16 @@ namespace NSc {
return AssertFromJson(val).ToJson(true);
}
-#define UNIT_ASSERT_JSON_EQ_JSON_C(A, B, c) \
- do { \
- const TString _a = NSc::NUt::NormalizeJson(A); \
- const TString _b = NSc::NUt::NormalizeJson(B); \
- if (_a != _b) { \
- UNIT_FAIL_IMPL( \
- "json values are different (" #A " != " #B ")", \
+#define UNIT_ASSERT_JSON_EQ_JSON_C(A, B, c) \
+ do { \
+ const TString _a = NSc::NUt::NormalizeJson(A); \
+ const TString _b = NSc::NUt::NormalizeJson(B); \
+ if (_a != _b) { \
+ UNIT_FAIL_IMPL( \
+ "json values are different (" #A " != " #B ")", \
Sprintf("%s\n!=\n%s\n%s\n%s", _a.data(), _b.data(), \
::NUnitTest::ColoredDiff(NJson::PrettifyJson(_a), NJson::PrettifyJson(_b), " \t\n,:\"{}[]").data(), ToString(c).data())); \
- } \
+ } \
} while (false)
#define UNIT_ASSERT_JSON_EQ_JSON(A, B) UNIT_ASSERT_JSON_EQ_JSON_C(A, B, "")