aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/cgiparam
diff options
context:
space:
mode:
authormelkov <melkov@yandex-team.ru>2022-02-10 16:48:13 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:13 +0300
commit438546c8737d5c1fdeb31157dcf999717d930eec (patch)
treed29d229abd2f9f889b9b7eb148d635059dc26acf /library/cpp/cgiparam
parent96647fad5355ff5ef45a00a6d85c097028584ab0 (diff)
downloadydb-438546c8737d5c1fdeb31157dcf999717d930eec.tar.gz
Restoring authorship annotation for <melkov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/cgiparam')
-rw-r--r--library/cpp/cgiparam/cgiparam.cpp76
-rw-r--r--library/cpp/cgiparam/cgiparam.h38
-rw-r--r--library/cpp/cgiparam/cgiparam_ut.cpp42
3 files changed, 78 insertions, 78 deletions
diff --git a/library/cpp/cgiparam/cgiparam.cpp b/library/cpp/cgiparam/cgiparam.cpp
index f3277b8e4b..3b1e3c7661 100644
--- a/library/cpp/cgiparam/cgiparam.cpp
+++ b/library/cpp/cgiparam/cgiparam.cpp
@@ -227,47 +227,47 @@ bool TCgiParameters::Has(const TStringBuf name, const TStringBuf value) const no
return false;
}
-
-TQuickCgiParam::TQuickCgiParam(const TStringBuf cgiParamStr) {
+
+TQuickCgiParam::TQuickCgiParam(const TStringBuf cgiParamStr) {
UnescapeBuf.reserve(CgiUnescapeBufLen(cgiParamStr.size()));
- char* buf = UnescapeBuf.begin();
-
- auto f = [this, &buf](const TStringBuf key, const TStringBuf val) {
- TStringBuf name = CgiUnescapeBuf(buf, key);
+ char* buf = UnescapeBuf.begin();
+
+ auto f = [this, &buf](const TStringBuf key, const TStringBuf val) {
+ TStringBuf name = CgiUnescapeBuf(buf, key);
buf += name.size() + 1;
- TStringBuf value = CgiUnescapeBuf(buf, val);
+ TStringBuf value = CgiUnescapeBuf(buf, val);
buf += value.size() + 1;
Y_ASSERT(buf <= UnescapeBuf.begin() + UnescapeBuf.capacity() + 1 /*trailing zero*/);
- emplace(name, value);
- };
-
- DoScan<false>(cgiParamStr, f);
-
- if (buf != UnescapeBuf.begin()) {
- UnescapeBuf.ReserveAndResize(buf - UnescapeBuf.begin() - 1 /*trailing zero*/);
- }
-}
-
+ emplace(name, value);
+ };
+
+ DoScan<false>(cgiParamStr, f);
+
+ if (buf != UnescapeBuf.begin()) {
+ UnescapeBuf.ReserveAndResize(buf - UnescapeBuf.begin() - 1 /*trailing zero*/);
+ }
+}
+
const TStringBuf& TQuickCgiParam::Get(const TStringBuf name, size_t pos) const noexcept {
- const auto pair = equal_range(name);
-
- for (auto it = pair.first; it != pair.second; ++it, --pos) {
- if (0 == pos) {
- return it->second;
- }
- }
-
- return Default<TStringBuf>();
-}
-
+ const auto pair = equal_range(name);
+
+ for (auto it = pair.first; it != pair.second; ++it, --pos) {
+ if (0 == pos) {
+ return it->second;
+ }
+ }
+
+ return Default<TStringBuf>();
+}
+
bool TQuickCgiParam::Has(const TStringBuf name, const TStringBuf value) const noexcept {
- const auto pair = equal_range(name);
-
- for (auto it = pair.first; it != pair.second; ++it) {
- if (value == it->second) {
- return true;
- }
- }
-
- return false;
-}
+ const auto pair = equal_range(name);
+
+ for (auto it = pair.first; it != pair.second; ++it) {
+ if (value == it->second) {
+ return true;
+ }
+ }
+
+ return false;
+}
diff --git a/library/cpp/cgiparam/cgiparam.h b/library/cpp/cgiparam/cgiparam.h
index 87d1ab0ad4..c7102bc40f 100644
--- a/library/cpp/cgiparam/cgiparam.h
+++ b/library/cpp/cgiparam/cgiparam.h
@@ -155,30 +155,30 @@ void TCgiParameters::ReplaceUnescaped(const TStringBuf key, TIter valuesBegin, c
}
}
}
-
-/** TQuickCgiParam is a faster non-editable version of TCgiParameters.
- * Care should be taken when replacing:
- * - note that the result of Get() is invalidated when TQuickCgiParam object is destroyed.
- */
-
-class TQuickCgiParam: public TMultiMap<TStringBuf, TStringBuf> {
-public:
+
+/** TQuickCgiParam is a faster non-editable version of TCgiParameters.
+ * Care should be taken when replacing:
+ * - note that the result of Get() is invalidated when TQuickCgiParam object is destroyed.
+ */
+
+class TQuickCgiParam: public TMultiMap<TStringBuf, TStringBuf> {
+public:
TQuickCgiParam() = default;
-
- explicit TQuickCgiParam(const TStringBuf cgiParamStr);
-
+
+ explicit TQuickCgiParam(const TStringBuf cgiParamStr);
+
Y_PURE_FUNCTION
bool Has(const TStringBuf name, const TStringBuf value) const noexcept;
Y_PURE_FUNCTION
bool Has(const TStringBuf name) const noexcept {
- const auto pair = equal_range(name);
- return pair.first != pair.second;
- }
-
+ const auto pair = equal_range(name);
+ return pair.first != pair.second;
+ }
+
Y_PURE_FUNCTION
const TStringBuf& Get(const TStringBuf name, size_t numOfValue = 0) const noexcept;
-
-private:
- TString UnescapeBuf;
-};
+
+private:
+ TString UnescapeBuf;
+};
diff --git a/library/cpp/cgiparam/cgiparam_ut.cpp b/library/cpp/cgiparam/cgiparam_ut.cpp
index a562342084..eb185b3370 100644
--- a/library/cpp/cgiparam/cgiparam_ut.cpp
+++ b/library/cpp/cgiparam/cgiparam_ut.cpp
@@ -17,27 +17,27 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) {
UNIT_ASSERT(!C.Has("zzzzzz"));
}
- Y_UNIT_TEST(TestQuick) {
- TQuickCgiParam C("aaa=b%62b&ccc=ddd&ag0=");
- UNIT_ASSERT_EQUAL(C.Get("aaa") == "bbb", true);
- UNIT_ASSERT(C.Has("ccc", "ddd"));
- UNIT_ASSERT(C.Has("ag0", ""));
- UNIT_ASSERT(!C.Has("a", "bbb"));
- UNIT_ASSERT(!C.Has("aaa", "bb"));
-
- UNIT_ASSERT(C.Has("ccc"));
- UNIT_ASSERT(!C.Has("zzzzzz"));
-
- TQuickCgiParam D = std::move(C);
- UNIT_ASSERT(D.Has("aaa"));
-
- TQuickCgiParam E("");
- UNIT_ASSERT(!E.Has("aaa"));
-
- C = std::move(E);
- UNIT_ASSERT(!C.Has("aaa"));
- }
-
+ Y_UNIT_TEST(TestQuick) {
+ TQuickCgiParam C("aaa=b%62b&ccc=ddd&ag0=");
+ UNIT_ASSERT_EQUAL(C.Get("aaa") == "bbb", true);
+ UNIT_ASSERT(C.Has("ccc", "ddd"));
+ UNIT_ASSERT(C.Has("ag0", ""));
+ UNIT_ASSERT(!C.Has("a", "bbb"));
+ UNIT_ASSERT(!C.Has("aaa", "bb"));
+
+ UNIT_ASSERT(C.Has("ccc"));
+ UNIT_ASSERT(!C.Has("zzzzzz"));
+
+ TQuickCgiParam D = std::move(C);
+ UNIT_ASSERT(D.Has("aaa"));
+
+ TQuickCgiParam E("");
+ UNIT_ASSERT(!E.Has("aaa"));
+
+ C = std::move(E);
+ UNIT_ASSERT(!C.Has("aaa"));
+ }
+
Y_UNIT_TEST(TestScan2) {
const TString parsee("=000&aaa=bbb&ag0=&ccc=ddd");
TCgiParameters c;