summaryrefslogtreecommitdiffstats
path: root/library/cpp/json/easy_parse
diff options
context:
space:
mode:
authornae202 <[email protected]>2025-09-23 07:48:35 +0300
committernae202 <[email protected]>2025-09-23 08:03:21 +0300
commit63774bc851bb76e24f369ef4e0328e5f05edbb4b (patch)
treed3226ed9a5f200097949f6001a7e3183aff7adfa /library/cpp/json/easy_parse
parentf4cbf746a0b6649479cfb305eceababced0ac10a (diff)
Style fix
commit_hash:d506e2a0f2770f3662449a3711e976499eb9ccbb
Diffstat (limited to 'library/cpp/json/easy_parse')
-rw-r--r--library/cpp/json/easy_parse/json_easy_parser.cpp78
-rw-r--r--library/cpp/json/easy_parse/json_easy_parser.h2
-rw-r--r--library/cpp/json/easy_parse/json_easy_parser_impl.h4
3 files changed, 51 insertions, 33 deletions
diff --git a/library/cpp/json/easy_parse/json_easy_parser.cpp b/library/cpp/json/easy_parse/json_easy_parser.cpp
index 3c781f544bc..ddd9412955c 100644
--- a/library/cpp/json/easy_parse/json_easy_parser.cpp
+++ b/library/cpp/json/easy_parse/json_easy_parser.cpp
@@ -54,21 +54,26 @@ namespace NJson {
private:
static bool PathElementMatch(const TPathElem& templ, const TPathElem& real) {
- if (templ.Type != real.Type)
+ if (templ.Type != real.Type) {
return false;
- if (templ.Type == NImpl::ARRAY)
+ }
+ if (templ.Type == NImpl::ARRAY) {
return templ.ArrayCounter == -1 || templ.ArrayCounter == real.ArrayCounter;
- if (templ.Type == NImpl::MAP_KEY)
+ }
+ if (templ.Type == NImpl::MAP_KEY) {
return templ.Key == ANY_IDENTIFIER || templ.Key == real.Key;
+ }
return true;
}
bool CheckFilter(const TVector<TPathElem>& path) const {
- if (Stack.size() < path.size())
+ if (Stack.size() < path.size()) {
return false;
+ }
for (size_t n = 0; n < path.size(); ++n) {
- if (!PathElementMatch(path[n], Stack[n]))
+ if (!PathElementMatch(path[n], Stack[n])) {
return false;
+ }
}
return true;
}
@@ -90,8 +95,9 @@ namespace NJson {
void IncreaseArrayCounter() {
if (!Stack.empty() && Stack.back().Type == NImpl::ARRAY) {
++Stack.back().ArrayCounter;
- if (ShouldUpdateOnArrayChange)
+ if (ShouldUpdateOnArrayChange) {
UpdateRule();
+ }
}
}
@@ -114,43 +120,49 @@ namespace NJson {
, HasFormatError(false)
{
for (size_t n = 0; n < Parent.Fields.size(); ++n) {
- if (!Parent.Fields[n].Path.empty() && Parent.Fields[n].Path.back().Type == NImpl::ARRAY)
+ if (!Parent.Fields[n].Path.empty() && Parent.Fields[n].Path.back().Type == NImpl::ARRAY) {
ShouldUpdateOnArrayChange = true;
+ }
}
}
bool OnOpenMap() override {
IncreaseArrayCounter();
Stack.push_back(TPathElem(NImpl::MAP));
- if (CurrentFieldIdx >= 0)
+ if (CurrentFieldIdx >= 0) {
HasFormatError = true;
- else
+ } else {
UpdateRule();
+ }
return true;
}
bool OnOpenArray() override {
IncreaseArrayCounter();
Stack.push_back(TPathElem(-1));
- if (CurrentFieldIdx >= 0)
+ if (CurrentFieldIdx >= 0) {
HasFormatError = true;
- else
+ } else {
UpdateRule();
+ }
return true;
}
bool OnCloseMap() override {
- while (!Stack.empty() && Stack.back().Type != NImpl::MAP)
+ while (!Stack.empty() && Stack.back().Type != NImpl::MAP) {
Pop();
- if (!Stack.empty())
+ }
+ if (!Stack.empty()) {
Pop();
+ }
UpdateRule();
return true;
}
bool OnCloseArray() override {
- if (!Stack.empty())
+ if (!Stack.empty()) {
Pop();
+ }
UpdateRule();
return true;
}
@@ -161,10 +173,11 @@ namespace NJson {
UpdateRule();
}
Stack.push_back(TPathElem(TString{key}));
- if (CurrentFieldIdx >= 0)
+ if (CurrentFieldIdx >= 0) {
HasFormatError = true;
- else
+ } else {
UpdateRule();
+ }
return true;
}
@@ -185,17 +198,21 @@ namespace NJson {
}
bool IsOK() const {
- if (HasFormatError)
+ if (HasFormatError) {
return false;
- for (size_t n = 0; n < FieldValues.size(); ++n)
- if (Parent.Fields[n].NonEmpty && FieldValues[n].empty())
+ }
+ for (size_t n = 0; n < FieldValues.size(); ++n) {
+ if (Parent.Fields[n].NonEmpty && FieldValues[n].empty()) {
return false;
+ }
+ }
return true;
}
void WriteTo(IOutputStream& out) const {
- for (size_t n = 0; n < FieldValues.size(); ++n)
+ for (size_t n = 0; n < FieldValues.size(); ++n) {
out << "\t" << FieldValues[n];
+ }
}
void WriteTo(TVector<TString>* res) const {
@@ -220,17 +237,18 @@ namespace NJson {
if (impl.IsOK()) {
impl.WriteTo(res);
return true;
- } else
+ } else {
return false;
+ }
}
- //struct TTestMe {
- // TTestMe() {
- // TJsonParser worker;
- // worker.AddField("/x/y/z", true);
- // TString ret1 = worker.ConvertToTabDelimited("{ \"x\" : { \"y\" : { \"w\" : 1, \"z\" : 2 } } }");
- // TString ret2 = worker.ConvertToTabDelimited(" [1, 2, 3, 4, 5] ");
- // }
- //} testMe;
+ // struct TTestMe {
+ // TTestMe() {
+ // TJsonParser worker;
+ // worker.AddField("/x/y/z", true);
+ // TString ret1 = worker.ConvertToTabDelimited("{ \"x\" : { \"y\" : { \"w\" : 1, \"z\" : 2 } } }");
+ // TString ret2 = worker.ConvertToTabDelimited(" [1, 2, 3, 4, 5] ");
+ // }
+ // } testMe;
-}
+} // namespace NJson
diff --git a/library/cpp/json/easy_parse/json_easy_parser.h b/library/cpp/json/easy_parse/json_easy_parser.h
index 59d7791ab14..0cd668e6fe6 100644
--- a/library/cpp/json/easy_parse/json_easy_parser.h
+++ b/library/cpp/json/easy_parse/json_easy_parser.h
@@ -43,4 +43,4 @@ namespace NJson {
TString ConvertToTabDelimited(const TString& json) const;
bool Parse(const TString& json, TVector<TString>* res) const;
};
-}
+} // namespace NJson
diff --git a/library/cpp/json/easy_parse/json_easy_parser_impl.h b/library/cpp/json/easy_parse/json_easy_parser_impl.h
index ec55d838b32..3106a11b414 100644
--- a/library/cpp/json/easy_parse/json_easy_parser_impl.h
+++ b/library/cpp/json/easy_parse/json_easy_parser_impl.h
@@ -9,7 +9,7 @@ namespace NJson {
MAP,
MAP_KEY
};
- }
+ } // namespace NImpl
template <class TStringType>
struct TPathElemImpl {
NImpl::EType Type;
@@ -37,4 +37,4 @@ namespace NJson {
};
typedef TPathElemImpl<TString> TPathElem;
-}
+} // namespace NJson