diff options
author | yazevnul <yazevnul@yandex-team.ru> | 2022-02-10 16:46:46 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:46 +0300 |
commit | 8cbc307de0221f84c80c42dcbe07d40727537e2c (patch) | |
tree | 625d5a673015d1df891e051033e9fcde5c7be4e5 /library/cpp/cgiparam | |
parent | 30d1ef3941e0dc835be7609de5ebee66958f215a (diff) | |
download | ydb-8cbc307de0221f84c80c42dcbe07d40727537e2c.tar.gz |
Restoring authorship annotation for <yazevnul@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/cgiparam')
-rw-r--r-- | library/cpp/cgiparam/cgiparam.cpp | 22 | ||||
-rw-r--r-- | library/cpp/cgiparam/cgiparam.h | 20 | ||||
-rw-r--r-- | library/cpp/cgiparam/cgiparam_ut.cpp | 42 |
3 files changed, 42 insertions, 42 deletions
diff --git a/library/cpp/cgiparam/cgiparam.cpp b/library/cpp/cgiparam/cgiparam.cpp index f3277b8e4b..c9bf98a357 100644 --- a/library/cpp/cgiparam/cgiparam.cpp +++ b/library/cpp/cgiparam/cgiparam.cpp @@ -17,7 +17,7 @@ const TString& TCgiParameters::Get(const TStringBuf name, size_t numOfValue) con return end() == it ? Default<TString>() : it->second; } -bool TCgiParameters::Erase(const TStringBuf name, size_t pos) { +bool TCgiParameters::Erase(const TStringBuf name, size_t pos) { const auto pair = equal_range(name); for (auto it = pair.first; it != pair.second; ++it, --pos) { @@ -46,7 +46,7 @@ bool TCgiParameters::Erase(const TStringBuf name, const TStringBuf val) { return found; } -size_t TCgiParameters::EraseAll(const TStringBuf name) { +size_t TCgiParameters::EraseAll(const TStringBuf name) { size_t num = 0; const auto pair = equal_range(name); @@ -89,36 +89,36 @@ static inline TString DoUnescape(const TStringBuf s) { return res; } -void TCgiParameters::InsertEscaped(const TStringBuf name, const TStringBuf value) { +void TCgiParameters::InsertEscaped(const TStringBuf name, const TStringBuf value) { InsertUnescaped(DoUnescape(name), DoUnescape(value)); } template <bool addAll, class F> -static inline void DoScan(const TStringBuf s, F& f) { +static inline void DoScan(const TStringBuf s, F& f) { ScanKeyValue<addAll, '&', '='>(s, f); } struct TAddEscaped { TCgiParameters* C; - inline void operator()(const TStringBuf key, const TStringBuf val) { + inline void operator()(const TStringBuf key, const TStringBuf val) { C->InsertEscaped(key, val); } }; -void TCgiParameters::Scan(const TStringBuf query, bool form) { +void TCgiParameters::Scan(const TStringBuf query, bool form) { Flush(); form ? ScanAdd(query) : ScanAddAll(query); } -void TCgiParameters::ScanAdd(const TStringBuf query) { +void TCgiParameters::ScanAdd(const TStringBuf query) { TAddEscaped f = {this}; DoScan<false>(query, f); } -void TCgiParameters::ScanAddUnescaped(const TStringBuf query) { - auto f = [this](const TStringBuf key, const TStringBuf val) { +void TCgiParameters::ScanAddUnescaped(const TStringBuf query) { + auto f = [this](const TStringBuf key, const TStringBuf val) { this->InsertUnescaped(key, val); }; @@ -133,7 +133,7 @@ void TCgiParameters::ScanAddAllUnescaped(const TStringBuf query) { DoScan<true>(query, f); } -void TCgiParameters::ScanAddAll(const TStringBuf query) { +void TCgiParameters::ScanAddAll(const TStringBuf query) { TAddEscaped f = {this}; DoScan<true>(query, f); @@ -172,7 +172,7 @@ char* TCgiParameters::Print(char* res) const { size_t TCgiParameters::PrintSize() const noexcept { size_t res = size(); // for '&' - for (const auto& i : *this) { + for (const auto& i : *this) { res += CgiEscapeBufLen(i.first.size() + i.second.size()); // extra zero will be used for '=' } diff --git a/library/cpp/cgiparam/cgiparam.h b/library/cpp/cgiparam/cgiparam.h index 87d1ab0ad4..c14ddbf6f2 100644 --- a/library/cpp/cgiparam/cgiparam.h +++ b/library/cpp/cgiparam/cgiparam.h @@ -20,7 +20,7 @@ class TCgiParameters: public TMultiMap<TString, TString> { public: TCgiParameters() = default; - explicit TCgiParameters(const TStringBuf cgiParamStr) { + explicit TCgiParameters(const TStringBuf cgiParamStr) { Scan(cgiParamStr); } @@ -30,7 +30,7 @@ public: erase(begin(), end()); } - size_t EraseAll(const TStringBuf name); + size_t EraseAll(const TStringBuf name); size_t NumOfValues(const TStringBuf name) const noexcept { return count(name); @@ -40,11 +40,11 @@ public: return Print(); } - void Scan(const TStringBuf cgiParStr, bool form = true); - void ScanAdd(const TStringBuf cgiParStr); - void ScanAddUnescaped(const TStringBuf cgiParStr); + void Scan(const TStringBuf cgiParStr, bool form = true); + void ScanAdd(const TStringBuf cgiParStr); + void ScanAddUnescaped(const TStringBuf cgiParStr); void ScanAddAllUnescaped(const TStringBuf cgiParStr); - void ScanAddAll(const TStringBuf cgiParStr); + void ScanAddAll(const TStringBuf cgiParStr); /// Returns the string representation of all the stored parameters /** @@ -85,7 +85,7 @@ public: Y_PURE_FUNCTION const TString& Get(const TStringBuf name, size_t numOfValue = 0) const noexcept; - void InsertEscaped(const TStringBuf name, const TStringBuf value); + void InsertEscaped(const TStringBuf name, const TStringBuf value); #if !defined(__GLIBCXX__) template <typename TName, typename TValue> @@ -119,14 +119,14 @@ public: // if val is a [possibly empty] non-NULL string, append it as well void JoinUnescaped(const TStringBuf key, char sep, TStringBuf val = TStringBuf()); - bool Erase(const TStringBuf name, size_t numOfValue = 0); + bool Erase(const TStringBuf name, size_t numOfValue = 0); bool Erase(const TStringBuf name, const TStringBuf val); - inline const char* FormField(const TStringBuf name, size_t numOfValue = 0) const { + inline const char* FormField(const TStringBuf name, size_t numOfValue = 0) const { const_iterator it = Find(name, numOfValue); if (it == end()) { - return nullptr; + return nullptr; } return it->second.data(); diff --git a/library/cpp/cgiparam/cgiparam_ut.cpp b/library/cpp/cgiparam/cgiparam_ut.cpp index a562342084..c9946462f9 100644 --- a/library/cpp/cgiparam/cgiparam_ut.cpp +++ b/library/cpp/cgiparam/cgiparam_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -Y_UNIT_TEST_SUITE(TCgiParametersTest) { - Y_UNIT_TEST(TestScan1) { +Y_UNIT_TEST_SUITE(TCgiParametersTest) { + Y_UNIT_TEST(TestScan1) { TCgiParameters C; C.Scan("aaa=b%62b&ccc=ddd&ag0="); UNIT_ASSERT_EQUAL(C.Get("aaa") == "bbb", true); @@ -38,7 +38,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT(!C.Has("aaa")); } - Y_UNIT_TEST(TestScan2) { + Y_UNIT_TEST(TestScan2) { const TString parsee("=000&aaa=bbb&ag0=&ccc=ddd"); TCgiParameters c; c.Scan(parsee); @@ -46,7 +46,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Print(), parsee); } - Y_UNIT_TEST(TestScan3) { + Y_UNIT_TEST(TestScan3) { const TString parsee("aaa=bbb&ag0=&ccc=ddd"); TCgiParameters c; c.Scan(parsee); @@ -56,7 +56,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Print(), parsee + "&d=xxx"); } - Y_UNIT_TEST(TestScanAddAll1) { + Y_UNIT_TEST(TestScanAddAll1) { TCgiParameters c; c.ScanAddAll("qw"); @@ -64,7 +64,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT(c.Get("qw").empty()); } - Y_UNIT_TEST(TestScanAddAll2) { + Y_UNIT_TEST(TestScanAddAll2) { TCgiParameters c; c.ScanAddAll("qw&"); @@ -72,7 +72,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT(c.Get("qw").empty()); } - Y_UNIT_TEST(TestScanAddAll3) { + Y_UNIT_TEST(TestScanAddAll3) { TCgiParameters c; c.ScanAddAll("qw=1&x"); @@ -81,7 +81,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT(c.Get("x").empty()); } - Y_UNIT_TEST(TestScanAddAll4) { + Y_UNIT_TEST(TestScanAddAll4) { TCgiParameters c; c.ScanAddAll("ccc=1&aaa=1&ccc=3&bbb&ccc=2"); @@ -111,7 +111,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Get("text"), "%D0%9F%D1%80%D0%B8%D0%B2%D0%B5%D1%82%2C"); } - Y_UNIT_TEST(TestEraseAll) { + Y_UNIT_TEST(TestEraseAll) { TCgiParameters c; c.ScanAddAll("par=1&aaa=1&par=2&bbb&par=3"); c.EraseAll("par"); @@ -119,7 +119,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Print(), "aaa=1&bbb="); } - Y_UNIT_TEST(TestErase) { + Y_UNIT_TEST(TestErase) { TCgiParameters c; c.ScanAddAll("par=1&aaa=1&par=2&bbb&par=3&par=1"); @@ -130,7 +130,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Print(), "aaa=1&bbb=&par=3"); } - Y_UNIT_TEST(TestReplaceUnescaped1) { + Y_UNIT_TEST(TestReplaceUnescaped1) { TCgiParameters c; c.ScanAddAll("many_keys=1&aaa=1&many_keys=2&bbb&many_keys=3"); c.ReplaceUnescaped("many_keys", "new_value"); @@ -138,7 +138,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Print(), "aaa=1&bbb=&many_keys=new_value"); } - Y_UNIT_TEST(TestReplaceUnescaped2) { + Y_UNIT_TEST(TestReplaceUnescaped2) { TCgiParameters c; c.ScanAddAll("par=1&only_one=1&par=2&bbb&par=3"); c.ReplaceUnescaped("only_one", "new_value"); @@ -146,7 +146,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Print(), "bbb=&only_one=new_value&par=1&par=2&par=3"); } - Y_UNIT_TEST(TestReplaceUnescaped3) { + Y_UNIT_TEST(TestReplaceUnescaped3) { TCgiParameters c; c.ScanAddAll("par=1&aaa=1&par=2&bbb&par=3"); c.ReplaceUnescaped("no_such_key", "new_value"); @@ -154,7 +154,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Print(), "aaa=1&bbb=&no_such_key=new_value&par=1&par=2&par=3"); } - Y_UNIT_TEST(TestReplaceUnescapedRange1) { + Y_UNIT_TEST(TestReplaceUnescapedRange1) { TCgiParameters c; c.ScanAddAll("par=1&aaa=1&par=2&bbb&par=3"); c.ReplaceUnescaped("par", {"x", "y", "z"}); // 3 old values, 3 new values @@ -162,7 +162,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Print(), "aaa=1&bbb=&par=x&par=y&par=z"); } - Y_UNIT_TEST(TestReplaceUnescapedRange2) { + Y_UNIT_TEST(TestReplaceUnescapedRange2) { TCgiParameters c; c.ScanAddAll("par=1&aaa=1&par=2&bbb"); c.ReplaceUnescaped("par", {"x", "y", "z"}); // 2 old values, 3 new values @@ -170,7 +170,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Print(), "aaa=1&bbb=&par=x&par=y&par=z"); } - Y_UNIT_TEST(TestReplaceUnescapedRange3) { + Y_UNIT_TEST(TestReplaceUnescapedRange3) { TCgiParameters c; c.ScanAddAll("par=1&aaa=1&par=2&bbb&par=3"); c.ReplaceUnescaped("par", {"x", "y"}); // 3 old values, 2 new values @@ -178,23 +178,23 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Print(), "aaa=1&bbb=&par=x&par=y"); } - Y_UNIT_TEST(TestNumOfValues) { + Y_UNIT_TEST(TestNumOfValues) { TCgiParameters c; c.ScanAddAll("par=1&aaa=1&par=2&bbb&par=3"); UNIT_ASSERT_VALUES_EQUAL(c.NumOfValues("par"), 3u); } - Y_UNIT_TEST(TestUnscape) { + Y_UNIT_TEST(TestUnscape) { TCgiParameters c("f=1&t=%84R%84%7C%84%80%84%7E&reqenc=SHIFT_JIS&p=0"); UNIT_ASSERT_VALUES_EQUAL(c.Get("t"), "\x84R\x84\x7C\x84\x80\x84\x7E"); } - Y_UNIT_TEST(TestEmpty) { + Y_UNIT_TEST(TestEmpty) { UNIT_ASSERT(TCgiParameters().Print().empty()); } - Y_UNIT_TEST(TestJoinUnescaped) { + Y_UNIT_TEST(TestJoinUnescaped) { TCgiParameters c; c.Scan("foo=1&foo=2"); @@ -203,7 +203,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Print(), "foo=1;2;0"); } - Y_UNIT_TEST(TestContInit) { + Y_UNIT_TEST(TestContInit) { TCgiParameters c = {std::make_pair("a", "a1"), std::make_pair("b", "b1"), std::make_pair("a", "a2")}; UNIT_ASSERT_VALUES_EQUAL(c.NumOfValues("a"), 2u); |