diff --git a/internal/tlcodegen/test/gen/cases_cpp/benchmarks/details.cpp b/internal/tlcodegen/test/gen/cases_cpp/benchmarks/details.cpp index 897bd542..5d783054 100644 --- a/internal/tlcodegen/test/gen/cases_cpp/benchmarks/details.cpp +++ b/internal/tlcodegen/test/gen/cases_cpp/benchmarks/details.cpp @@ -317,10 +317,8 @@ void tl2::details::BenchmarksVrutoyPositionsReset(::tl2::benchmarks::VrutoyPosit } bool tl2::details::BenchmarksVrutoyPositionsWriteJSON(std::ostream& s, const ::tl2::benchmarks::VrutoyPositions& item, uint32_t nat_n) { - auto add_comma = false; s << "{"; if ((item.next_positions.size() != 0) || (nat_n != 0)) { - add_comma = true; s << "\"next_positions\":"; if (!::tl2::details::BuiltinTupleBenchmarksVruPositionWriteJSON(s, item.next_positions, nat_n)) { return false; } } @@ -378,9 +376,7 @@ void tl2::details::BenchmarksVrutoyTopLevelContainerReset(::tl2::benchmarks::Vru } bool tl2::details::BenchmarksVrutoyTopLevelContainerWriteJSON(std::ostream& s, const ::tl2::benchmarks::VrutoyTopLevelContainer& item) { - auto add_comma = false; s << "{"; - add_comma = true; s << "\"value\":"; if (!::tl2::details::BenchmarksVrutoyTopLevelUnionWriteJSON(s, item.value)) { return false; } s << "}"; @@ -574,10 +570,8 @@ void tl2::details::BenchmarksVrutoytopLevelUnionBigReset(::tl2::benchmarks::Vrut } bool tl2::details::BenchmarksVrutoytopLevelUnionBigWriteJSON(std::ostream& s, const ::tl2::benchmarks::VrutoytopLevelUnionBig& item) { - auto add_comma = false; s << "{"; if (item.next_positions.size() != 0) { - add_comma = true; s << "\"next_positions\":"; if (!::tl2::details::BuiltinVectorBenchmarksVruPositionWriteJSON(s, item.next_positions)) { return false; } } diff --git a/internal/tlcodegen/test/gen/cases_cpp/cases/details.cpp b/internal/tlcodegen/test/gen/cases_cpp/cases/details.cpp index 7c7950b7..8c251eec 100644 --- a/internal/tlcodegen/test/gen/cases_cpp/cases/details.cpp +++ b/internal/tlcodegen/test/gen/cases_cpp/cases/details.cpp @@ -1178,10 +1178,8 @@ void tl2::details::CasesTestDictAnyReset(::tl2::cases::TestDictAny& item) { } bool tl2::details::CasesTestDictAnyWriteJSON(std::ostream& s, const ::tl2::cases::TestDictAny& item) { - auto add_comma = false; s << "{"; if (item.dict.size() != 0) { - add_comma = true; s << "\"dict\":"; if (!::tl2::details::DictionaryAnyDoubleIntWriteJSON(s, item.dict)) { return false; } } @@ -1239,10 +1237,8 @@ void tl2::details::CasesTestDictIntReset(::tl2::cases::TestDictInt& item) { } bool tl2::details::CasesTestDictIntWriteJSON(std::ostream& s, const ::tl2::cases::TestDictInt& item) { - auto add_comma = false; s << "{"; if (item.dict.size() != 0) { - add_comma = true; s << "\"dict\":"; if (!::tl2::details::BuiltinVectorDictionaryFieldAnyIntIntWriteJSON(s, item.dict)) { return false; } } @@ -1300,10 +1296,8 @@ void tl2::details::CasesTestDictStringReset(::tl2::cases::TestDictString& item) } bool tl2::details::CasesTestDictStringWriteJSON(std::ostream& s, const ::tl2::cases::TestDictString& item) { - auto add_comma = false; s << "{"; if (item.dict.size() != 0) { - add_comma = true; s << "\"dict\":"; if (!::tl2::details::DictionaryIntWriteJSON(s, item.dict)) { return false; } } @@ -1571,9 +1565,7 @@ void tl2::details::CasesTestEnumContainerReset(::tl2::cases::TestEnumContainer& } bool tl2::details::CasesTestEnumContainerWriteJSON(std::ostream& s, const ::tl2::cases::TestEnumContainer& item) { - auto add_comma = false; s << "{"; - add_comma = true; s << "\"value\":"; if (!::tl2::details::CasesTestEnumWriteJSON(s, item.value)) { return false; } s << "}"; @@ -1742,10 +1734,8 @@ void tl2::details::CasesTestMaybeReset(::tl2::cases::TestMaybe& item) { } bool tl2::details::CasesTestMaybeWriteJSON(std::ostream& s, const ::tl2::cases::TestMaybe& item) { - auto add_comma = false; s << "{"; if (item.value.has_value()) { - add_comma = true; s << "\"value\":"; if (!::tl2::details::IntMaybeWriteJSON(s, item.value)) { return false; } } @@ -2106,9 +2096,7 @@ void tl2::details::CasesTestTupleReset(::tl2::cases::TestTuple& item) { } bool tl2::details::CasesTestTupleWriteJSON(std::ostream& s, const ::tl2::cases::TestTuple& item) { - auto add_comma = false; s << "{"; - add_comma = true; s << "\"tpl\":"; if (!::tl2::details::BuiltinTuple4IntWriteJSON(s, item.tpl)) { return false; } s << "}"; @@ -2240,10 +2228,8 @@ void tl2::details::CasesTestUnion1Reset(::tl2::cases::TestUnion1& item) { } bool tl2::details::CasesTestUnion1WriteJSON(std::ostream& s, const ::tl2::cases::TestUnion1& item) { - auto add_comma = false; s << "{"; if (item.value != 0) { - add_comma = true; s << "\"value\":"; s << item.value; } @@ -2301,10 +2287,8 @@ void tl2::details::CasesTestUnion2Reset(::tl2::cases::TestUnion2& item) { } bool tl2::details::CasesTestUnion2WriteJSON(std::ostream& s, const ::tl2::cases::TestUnion2& item) { - auto add_comma = false; s << "{"; if (item.value.size() != 0) { - add_comma = true; s << "\"value\":"; s << "\"" << item.value << "\""; } @@ -2362,9 +2346,7 @@ void tl2::details::CasesTestUnionContainerReset(::tl2::cases::TestUnionContainer } bool tl2::details::CasesTestUnionContainerWriteJSON(std::ostream& s, const ::tl2::cases::TestUnionContainer& item) { - auto add_comma = false; s << "{"; - add_comma = true; s << "\"value\":"; if (!::tl2::details::CasesTestUnionWriteJSON(s, item.value)) { return false; } s << "}"; @@ -2421,10 +2403,8 @@ void tl2::details::CasesTestVectorReset(::tl2::cases::TestVector& item) { } bool tl2::details::CasesTestVectorWriteJSON(std::ostream& s, const ::tl2::cases::TestVector& item) { - auto add_comma = false; s << "{"; if (item.arr.size() != 0) { - add_comma = true; s << "\"arr\":"; if (!::tl2::details::BuiltinVectorIntWriteJSON(s, item.arr)) { return false; } } @@ -2456,7 +2436,7 @@ bool tl2::details::IntMaybeWriteJSON(std::ostream & s, const std::optional>& item) { - auto add_comma = false; s << "{"; if (item.value != 0) { - add_comma = true; s << "\"value\":"; s << item.value; } @@ -3024,9 +2988,7 @@ void tl2::details::LeftService6ErrorVectorService6FindResultRowReset(::tl2::Left } bool tl2::details::LeftService6ErrorVectorService6FindResultRowWriteJSON(std::ostream& s, const ::tl2::Left<::tl2::service6::Error, std::vector<::tl2::service6::FindResultRow>>& item) { - auto add_comma = false; s << "{"; - add_comma = true; s << "\"value\":"; if (!::tl2::details::Service6ErrorWriteJSON(s, item.value)) { return false; } s << "}"; @@ -3188,9 +3150,7 @@ void tl2::details::MyBoxedArrayReset(::tl2::MyBoxedArray& item) { } bool tl2::details::MyBoxedArrayWriteJSON(std::ostream& s, const ::tl2::MyBoxedArray& item) { - auto add_comma = false; s << "{"; - add_comma = true; s << "\"data\":"; if (!::tl2::details::BuiltinTuple2IntBoxedWriteJSON(s, item.data)) { return false; } s << "}"; @@ -3323,10 +3283,8 @@ void tl2::details::MyBoxedVectorSliceReset(::tl2::MyBoxedVectorSlice& item) { } bool tl2::details::MyBoxedVectorSliceWriteJSON(std::ostream& s, const ::tl2::MyBoxedVectorSlice& item) { - auto add_comma = false; s << "{"; if (item.data.size() != 0) { - add_comma = true; s << "\"data\":"; if (!::tl2::details::BuiltinVectorIntBoxedWriteJSON(s, item.data)) { return false; } } @@ -3446,10 +3404,8 @@ void tl2::details::MyIntReset(::tl2::MyInt& item) { } bool tl2::details::MyIntWriteJSON(std::ostream& s, const ::tl2::MyInt& item) { - auto add_comma = false; s << "{"; if (item.val1 != 0) { - add_comma = true; s << "\"val1\":"; s << item.val1; } @@ -3567,9 +3523,7 @@ void tl2::details::MyMcValueReset(::tl2::MyMcValue& item) { } bool tl2::details::MyMcValueWriteJSON(std::ostream& s, const ::tl2::MyMcValue& item) { - auto add_comma = false; s << "{"; - add_comma = true; s << "\"x\":"; if (!::tl2::details::Service1ValueWriteJSON(s, item.x)) { return false; } s << "}"; @@ -3626,9 +3580,7 @@ void tl2::details::MyMcValueTupleReset(::tl2::MyMcValueTuple& item) { } bool tl2::details::MyMcValueTupleWriteJSON(std::ostream& s, const ::tl2::MyMcValueTuple& item) { - auto add_comma = false; s << "{"; - add_comma = true; s << "\"xs\":"; if (!::tl2::details::BuiltinTuple3Service1ValueWriteJSON(s, item.xs)) { return false; } s << "}"; @@ -3685,10 +3637,8 @@ void tl2::details::MyMcValueVectorReset(::tl2::MyMcValueVector& item) { } bool tl2::details::MyMcValueVectorWriteJSON(std::ostream& s, const ::tl2::MyMcValueVector& item) { - auto add_comma = false; s << "{"; if (item.xs.size() != 0) { - add_comma = true; s << "\"xs\":"; if (!::tl2::details::BuiltinVectorService1ValueWriteJSON(s, item.xs)) { return false; } } @@ -3746,10 +3696,8 @@ void tl2::details::MyStringReset(::tl2::MyString& item) { } bool tl2::details::MyStringWriteJSON(std::ostream& s, const ::tl2::MyString& item) { - auto add_comma = false; s << "{"; if (item.val2.size() != 0) { - add_comma = true; s << "\"val2\":"; s << "\"" << item.val2 << "\""; } @@ -4068,10 +4016,8 @@ void tl2::details::RightIntVectorService6FindWithBoundsResultReset(::tl2::Right< } bool tl2::details::RightIntVectorService6FindWithBoundsResultWriteJSON(std::ostream& s, const ::tl2::Right>& item) { - auto add_comma = false; s << "{"; if (item.value.size() != 0) { - add_comma = true; s << "\"value\":"; if (!::tl2::details::BuiltinVectorService6FindWithBoundsResultWriteJSON(s, item.value)) { return false; } } @@ -4104,10 +4050,8 @@ void tl2::details::RightService6ErrorVectorService6FindResultRowReset(::tl2::Rig } bool tl2::details::RightService6ErrorVectorService6FindResultRowWriteJSON(std::ostream& s, const ::tl2::Right<::tl2::service6::Error, std::vector<::tl2::service6::FindResultRow>>& item) { - auto add_comma = false; s << "{"; if (item.value.size() != 0) { - add_comma = true; s << "\"value\":"; if (!::tl2::details::BuiltinVectorService6FindResultRowWriteJSON(s, item.value)) { return false; } } diff --git a/internal/tlcodegen/test/gen/schema_cpp/antispam/details.cpp b/internal/tlcodegen/test/gen/schema_cpp/antispam/details.cpp index c94a2182..1cd89422 100644 --- a/internal/tlcodegen/test/gen/schema_cpp/antispam/details.cpp +++ b/internal/tlcodegen/test/gen/schema_cpp/antispam/details.cpp @@ -34,10 +34,8 @@ void tl2::details::AntispamGetPatternReset(::tl2::antispam::GetPattern& item) { } bool tl2::details::AntispamGetPatternWriteJSON(std::ostream& s, const ::tl2::antispam::GetPattern& item) { - auto add_comma = false; s << "{"; if (item.id != 0) { - add_comma = true; s << "\"id\":"; s << item.id; } diff --git a/internal/tlcodegen/test/gen/schema_cpp/pkg2/details.cpp b/internal/tlcodegen/test/gen/schema_cpp/pkg2/details.cpp index 546ca96b..124c1ac8 100644 --- a/internal/tlcodegen/test/gen/schema_cpp/pkg2/details.cpp +++ b/internal/tlcodegen/test/gen/schema_cpp/pkg2/details.cpp @@ -33,10 +33,8 @@ void tl2::details::Pkg2FooReset(::tl2::pkg2::Foo& item) { } bool tl2::details::Pkg2FooWriteJSON(std::ostream& s, const ::tl2::pkg2::Foo& item) { - auto add_comma = false; s << "{"; if (item.x != 0) { - add_comma = true; s << "\"x\":"; s << item.x; } @@ -94,9 +92,7 @@ void tl2::details::Pkg2T1Reset(::tl2::pkg2::T1& item) { } bool tl2::details::Pkg2T1WriteJSON(std::ostream& s, const ::tl2::pkg2::T1& item) { - auto add_comma = false; s << "{"; - add_comma = true; s << "\"x\":"; if (!::tl2::details::Pkg2FooWriteJSON(s, item.x)) { return false; } s << "}"; diff --git a/internal/tlcodegen/test/gen/schema_cpp/service1/details.cpp b/internal/tlcodegen/test/gen/schema_cpp/service1/details.cpp index 8adafceb..adc8d76a 100644 --- a/internal/tlcodegen/test/gen/schema_cpp/service1/details.cpp +++ b/internal/tlcodegen/test/gen/schema_cpp/service1/details.cpp @@ -1128,10 +1128,8 @@ void tl2::details::Service1DeleteReset(::tl2::service1::Delete& item) { } bool tl2::details::Service1DeleteWriteJSON(std::ostream& s, const ::tl2::service1::Delete& item) { - auto add_comma = false; s << "{"; if (item.key.size() != 0) { - add_comma = true; s << "\"key\":"; s << "\"" << item.key << "\""; } @@ -1205,10 +1203,8 @@ void tl2::details::Service1DisableExpirationReset(::tl2::service1::DisableExpira } bool tl2::details::Service1DisableExpirationWriteJSON(std::ostream& s, const ::tl2::service1::DisableExpiration& item) { - auto add_comma = false; s << "{"; if (item.prefix.size() != 0) { - add_comma = true; s << "\"prefix\":"; s << "\"" << item.prefix << "\""; } @@ -1282,10 +1278,8 @@ void tl2::details::Service1DisableKeysStatReset(::tl2::service1::DisableKeysStat } bool tl2::details::Service1DisableKeysStatWriteJSON(std::ostream& s, const ::tl2::service1::DisableKeysStat& item) { - auto add_comma = false; s << "{"; if (item.period != 0) { - add_comma = true; s << "\"period\":"; s << item.period; } @@ -1359,10 +1353,8 @@ void tl2::details::Service1EnableExpirationReset(::tl2::service1::EnableExpirati } bool tl2::details::Service1EnableExpirationWriteJSON(std::ostream& s, const ::tl2::service1::EnableExpiration& item) { - auto add_comma = false; s << "{"; if (item.prefix.size() != 0) { - add_comma = true; s << "\"prefix\":"; s << "\"" << item.prefix << "\""; } @@ -1436,10 +1428,8 @@ void tl2::details::Service1EnableKeysStatReset(::tl2::service1::EnableKeysStat& } bool tl2::details::Service1EnableKeysStatWriteJSON(std::ostream& s, const ::tl2::service1::EnableKeysStat& item) { - auto add_comma = false; s << "{"; if (item.period != 0) { - add_comma = true; s << "\"period\":"; s << item.period; } @@ -1513,10 +1503,8 @@ void tl2::details::Service1ExistsReset(::tl2::service1::Exists& item) { } bool tl2::details::Service1ExistsWriteJSON(std::ostream& s, const ::tl2::service1::Exists& item) { - auto add_comma = false; s << "{"; if (item.key.size() != 0) { - add_comma = true; s << "\"key\":"; s << "\"" << item.key << "\""; } @@ -1590,10 +1578,8 @@ void tl2::details::Service1GetReset(::tl2::service1::Get& item) { } bool tl2::details::Service1GetWriteJSON(std::ostream& s, const ::tl2::service1::Get& item) { - auto add_comma = false; s << "{"; if (item.key.size() != 0) { - add_comma = true; s << "\"key\":"; s << "\"" << item.key << "\""; } @@ -1667,10 +1653,8 @@ void tl2::details::Service1GetExpireTimeReset(::tl2::service1::GetExpireTime& it } bool tl2::details::Service1GetExpireTimeWriteJSON(std::ostream& s, const ::tl2::service1::GetExpireTime& item) { - auto add_comma = false; s << "{"; if (item.key.size() != 0) { - add_comma = true; s << "\"key\":"; s << "\"" << item.key << "\""; } @@ -1744,10 +1728,8 @@ void tl2::details::Service1GetKeysStatReset(::tl2::service1::GetKeysStat& item) } bool tl2::details::Service1GetKeysStatWriteJSON(std::ostream& s, const ::tl2::service1::GetKeysStat& item) { - auto add_comma = false; s << "{"; if (item.period != 0) { - add_comma = true; s << "\"period\":"; s << item.period; } @@ -1890,10 +1872,8 @@ void tl2::details::Service1GetWildcardReset(::tl2::service1::GetWildcard& item) } bool tl2::details::Service1GetWildcardWriteJSON(std::ostream& s, const ::tl2::service1::GetWildcard& item) { - auto add_comma = false; s << "{"; if (item.prefix.size() != 0) { - add_comma = true; s << "\"prefix\":"; s << "\"" << item.prefix << "\""; } @@ -1969,10 +1949,8 @@ void tl2::details::Service1GetWildcardDictReset(::tl2::service1::GetWildcardDict } bool tl2::details::Service1GetWildcardDictWriteJSON(std::ostream& s, const ::tl2::service1::GetWildcardDict& item) { - auto add_comma = false; s << "{"; if (item.prefix.size() != 0) { - add_comma = true; s << "\"prefix\":"; s << "\"" << item.prefix << "\""; } @@ -2046,10 +2024,8 @@ void tl2::details::Service1GetWildcardListReset(::tl2::service1::GetWildcardList } bool tl2::details::Service1GetWildcardListWriteJSON(std::ostream& s, const ::tl2::service1::GetWildcardList& item) { - auto add_comma = false; s << "{"; if (item.prefix.size() != 0) { - add_comma = true; s << "\"prefix\":"; s << "\"" << item.prefix << "\""; } @@ -2125,10 +2101,8 @@ void tl2::details::Service1GetWildcardWithFlagsReset(::tl2::service1::GetWildcar } bool tl2::details::Service1GetWildcardWithFlagsWriteJSON(std::ostream& s, const ::tl2::service1::GetWildcardWithFlags& item) { - auto add_comma = false; s << "{"; if (item.prefix.size() != 0) { - add_comma = true; s << "\"prefix\":"; s << "\"" << item.prefix << "\""; } diff --git a/internal/tlcodegen/test/gen/schema_cpp/service2/details.cpp b/internal/tlcodegen/test/gen/schema_cpp/service2/details.cpp index d458cb88..55d89f24 100644 --- a/internal/tlcodegen/test/gen/schema_cpp/service2/details.cpp +++ b/internal/tlcodegen/test/gen/schema_cpp/service2/details.cpp @@ -445,10 +445,8 @@ void tl2::details::Service2ObjectIdReset(::tl2::service2::ObjectId& item) { } bool tl2::details::Service2ObjectIdWriteJSON(std::ostream& s, const ::tl2::service2::ObjectId& item, uint32_t nat_objectIdLength) { - auto add_comma = false; s << "{"; if ((item.id.size() != 0) || (nat_objectIdLength != 0)) { - add_comma = true; s << "\"id\":"; if (!::tl2::details::BuiltinTupleIntWriteJSON(s, item.id, nat_objectIdLength)) { return false; } } diff --git a/internal/tlcodegen/test/gen/schema_cpp/service3/details.cpp b/internal/tlcodegen/test/gen/schema_cpp/service3/details.cpp index a832c7c0..013f3c4f 100644 --- a/internal/tlcodegen/test/gen/schema_cpp/service3/details.cpp +++ b/internal/tlcodegen/test/gen/schema_cpp/service3/details.cpp @@ -794,10 +794,8 @@ void tl2::details::Service3GetLastVisitTimestampReset(::tl2::service3::GetLastVi } bool tl2::details::Service3GetLastVisitTimestampWriteJSON(std::ostream& s, const ::tl2::service3::GetLastVisitTimestamp& item) { - auto add_comma = false; s << "{"; if (item.user_id != 0) { - add_comma = true; s << "\"user_id\":"; s << item.user_id; } @@ -2259,9 +2257,7 @@ void tl2::details::Service3SetLimitsReset(::tl2::service3::SetLimits& item) { } bool tl2::details::Service3SetLimitsWriteJSON(std::ostream& s, const ::tl2::service3::SetLimits& item) { - auto add_comma = false; s << "{"; - add_comma = true; s << "\"limits\":"; if (!::tl2::details::Service3LimitsWriteJSON(s, item.limits)) { return false; } s << "}"; @@ -2424,7 +2420,7 @@ bool tl2::details::VectorService3Product0MaybeWriteJSON(std::ostream & s, const s << "{"; if (item) { s << "\"ok\":true"; - if(*item.size() != 0) { + if((*item).size() != 0) { s << ",\"value\":"; if (!::tl2::details::BuiltinVectorService3Product0WriteJSON(s, *item)) { return false; } } @@ -2458,7 +2454,7 @@ bool tl2::details::VectorService3ProductMaybeWriteJSON(std::ostream & s, const s s << "{"; if (item) { s << "\"ok\":true"; - if(*item.size() != 0) { + if((*item).size() != 0) { s << ",\"value\":"; if (!::tl2::details::BuiltinVectorService3ProductWriteJSON(s, *item, nat_t)) { return false; } } @@ -2521,7 +2517,7 @@ bool tl2::details::VectorService3ProductStatsOldMaybeWriteJSON(std::ostream & s, s << "{"; if (item) { s << "\"ok\":true"; - if(*item.size() != 0) { + if((*item).size() != 0) { s << ",\"value\":"; if (!::tl2::details::BuiltinVectorService3ProductStatsOldWriteJSON(s, *item)) { return false; } } diff --git a/internal/tlcodegen/test/gen/schema_cpp/service5/details.cpp b/internal/tlcodegen/test/gen/schema_cpp/service5/details.cpp index f37c0356..d5b5b253 100644 --- a/internal/tlcodegen/test/gen/schema_cpp/service5/details.cpp +++ b/internal/tlcodegen/test/gen/schema_cpp/service5/details.cpp @@ -338,10 +338,8 @@ void tl2::details::Service5PerformQueryReset(::tl2::service5::PerformQuery& item } bool tl2::details::Service5PerformQueryWriteJSON(std::ostream& s, const ::tl2::service5::PerformQuery& item) { - auto add_comma = false; s << "{"; if (item.query.size() != 0) { - add_comma = true; s << "\"query\":"; s << "\"" << item.query << "\""; } diff --git a/internal/tlcodegen/test/gen/schema_cpp/service6/details.cpp b/internal/tlcodegen/test/gen/schema_cpp/service6/details.cpp index 84e2e123..e9ebd764 100644 --- a/internal/tlcodegen/test/gen/schema_cpp/service6/details.cpp +++ b/internal/tlcodegen/test/gen/schema_cpp/service6/details.cpp @@ -111,10 +111,8 @@ void tl2::details::Service6ErrorReset(::tl2::service6::Error& item) { } bool tl2::details::Service6ErrorWriteJSON(std::ostream& s, const ::tl2::service6::Error& item) { - auto add_comma = false; s << "{"; if (item.code != 0) { - add_comma = true; s << "\"code\":"; s << item.code; } @@ -172,10 +170,8 @@ void tl2::details::Service6FindResultRowReset(::tl2::service6::FindResultRow& it } bool tl2::details::Service6FindResultRowWriteJSON(std::ostream& s, const ::tl2::service6::FindResultRow& item) { - auto add_comma = false; s << "{"; if (item.x != 0) { - add_comma = true; s << "\"x\":"; s << item.x; } @@ -233,10 +229,8 @@ void tl2::details::Service6FindWithBoundsResultReset(::tl2::service6::FindWithBo } bool tl2::details::Service6FindWithBoundsResultWriteJSON(std::ostream& s, const ::tl2::service6::FindWithBoundsResult& item) { - auto add_comma = false; s << "{"; if (item.x != 0) { - add_comma = true; s << "\"x\":"; s << item.x; } @@ -395,10 +389,8 @@ void tl2::details::Service6MultiFindWithBoundsReset(::tl2::service6::MultiFindWi } bool tl2::details::Service6MultiFindWithBoundsWriteJSON(std::ostream& s, const ::tl2::service6::MultiFindWithBounds& item) { - auto add_comma = false; s << "{"; if (item.clusters.size() != 0) { - add_comma = true; s << "\"clusters\":"; if (!::tl2::details::BuiltinVectorIntWriteJSON(s, item.clusters)) { return false; } } diff --git a/internal/tlcodegen/test/gen/schema_cpp/tree_stats/details.cpp b/internal/tlcodegen/test/gen/schema_cpp/tree_stats/details.cpp index 6eb693ff..99749f47 100644 --- a/internal/tlcodegen/test/gen/schema_cpp/tree_stats/details.cpp +++ b/internal/tlcodegen/test/gen/schema_cpp/tree_stats/details.cpp @@ -35,11 +35,11 @@ bool tl2::details::TreeStatsObjectLimitValueWriteJSON(std::ostream & s, const :: s << "\"type\":"; s << "\"" << TreeStatsObjectLimitValue_tbl_tl_name[item.value.index()] << "\""; switch (item.value.index()) { - if (std::get<1>(item.value) != 0) { case 1: - s << ",\"value\":"; - if (!::tl2::details::TreeStatsObjectLimitValueDoubleWriteJSON(s, std::get<1>(item.value))) { return false; } - } + if (std::get<1>(item.value) != 0) { + s << ",\"value\":"; + if (!::tl2::details::TreeStatsObjectLimitValueDoubleWriteJSON(s, std::get<1>(item.value))) { return false; } + } break; } s << "}"; diff --git a/internal/tlcodegen/test/gen/schema_cpp/unique/details.cpp b/internal/tlcodegen/test/gen/schema_cpp/unique/details.cpp index cde36784..ec8aad80 100644 --- a/internal/tlcodegen/test/gen/schema_cpp/unique/details.cpp +++ b/internal/tlcodegen/test/gen/schema_cpp/unique/details.cpp @@ -33,10 +33,8 @@ void tl2::details::UniqueGetReset(::tl2::unique::Get& item) { } bool tl2::details::UniqueGetWriteJSON(std::ostream& s, const ::tl2::unique::Get& item) { - auto add_comma = false; s << "{"; if (item.key.size() != 0) { - add_comma = true; s << "\"key\":"; s << "\"" << item.key << "\""; } @@ -110,10 +108,8 @@ void tl2::details::UniqueStringToIntReset(::tl2::unique::StringToInt& item) { } bool tl2::details::UniqueStringToIntWriteJSON(std::ostream& s, const ::tl2::unique::StringToInt& item) { - auto add_comma = false; s << "{"; if (item.key.size() != 0) { - add_comma = true; s << "\"key\":"; s << "\"" << item.key << "\""; } diff --git a/internal/tlcodegen/type_rw_union_cpp.go b/internal/tlcodegen/type_rw_union_cpp.go index 401b7149..54e5bddb 100644 --- a/internal/tlcodegen/type_rw_union_cpp.go +++ b/internal/tlcodegen/type_rw_union_cpp.go @@ -476,21 +476,25 @@ func (trw *TypeRWUnion) CPPWriteJSONFields(bytesVersion bool) string { `, trw.wr.goGlobalName)) for fieldIndex, field := range trw.Fields { + indent := 1 if !field.t.IsTrueType() { + s.WriteString(fmt.Sprintf("%scase %d:\n", strings.Repeat("\t", indent), fieldIndex)) + indent++ emptyCondition := field.t.trw.CPPTypeJSONEmptyCondition(bytesVersion, fmt.Sprintf("std::get<%d>(item.value)", fieldIndex), field.recursive, nil) if emptyCondition != "" { - s.WriteString(fmt.Sprintf("\tif (%s) {\n", emptyCondition)) + s.WriteString(fmt.Sprintf("%sif (%s) {\n", strings.Repeat("\t", indent), emptyCondition)) + indent++ } - s.WriteString(fmt.Sprintf("\tcase %d:\n", fieldIndex)) - s.WriteString(` s << ",\"value\":"; -`) - s.WriteString("\t" + + s.WriteString(fmt.Sprintf(`%ss << ",\"value\":"; +`, strings.Repeat("\t", indent))) + s.WriteString(strings.Repeat("\t", indent-1) + field.t.trw.CPPTypeWritingJsonCode(bytesVersion, addAsterisk(field.recursive, fmt.Sprintf("std::get<%d>(item.value)", fieldIndex)), true, formatNatArgsCPP(trw.Fields, field.natArgs), false) + "\n") if emptyCondition != "" { - s.WriteString(fmt.Sprintf("\t}\n")) + indent-- + s.WriteString(fmt.Sprintf("%s}\n", strings.Repeat("\t", indent))) } - s.WriteString("\t\tbreak;\n") + s.WriteString(fmt.Sprintf("%sbreak;\n", strings.Repeat("\t", indent))) } } s.WriteString(` }