diff options
author | diver <diver@yandex-team.ru> | 2022-02-10 16:48:07 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:07 +0300 |
commit | e20e2b362f0232ed5a389db887e6e27e7763af18 (patch) | |
tree | b222e5ac2e2e98872661c51ccceee5da0d291e13 /library/cpp/deprecated/split | |
parent | 7629e1f9ef7f9d2a3c345c97e6a4e5a4b32ee786 (diff) | |
download | ydb-e20e2b362f0232ed5a389db887e6e27e7763af18.tar.gz |
Restoring authorship annotation for <diver@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/deprecated/split')
-rw-r--r-- | library/cpp/deprecated/split/delim_string_iter.h | 50 | ||||
-rw-r--r-- | library/cpp/deprecated/split/delim_string_iter_ut.cpp | 14 |
2 files changed, 32 insertions, 32 deletions
diff --git a/library/cpp/deprecated/split/delim_string_iter.h b/library/cpp/deprecated/split/delim_string_iter.h index ccdcbb5b45..8e4ca171a0 100644 --- a/library/cpp/deprecated/split/delim_string_iter.h +++ b/library/cpp/deprecated/split/delim_string_iter.h @@ -9,7 +9,7 @@ #include <iterator> class TDelimStringIter { -public: +public: using value_type = TStringBuf; using difference_type = ptrdiff_t; using pointer = const TStringBuf*; @@ -23,14 +23,14 @@ public: inline TDelimStringIter(TStringBuf str, TStringBuf delim) : IsValid(true) - , Str(str) + , Str(str) , Delim(delim) { - UpdateCurrent(); + UpdateCurrent(); } inline TDelimStringIter() - : IsValid(false) + : IsValid(false) { } @@ -40,12 +40,12 @@ public: // NOTE: this is a potentially unsafe operation (no overrun check) inline TDelimStringIter& operator++() { - if (Current.end() != Str.end()) { - Str.Skip(Current.length() + Delim.length()); - UpdateCurrent(); + if (Current.end() != Str.end()) { + Str.Skip(Current.length() + Delim.length()); + UpdateCurrent(); } else { - Str.Clear(); - Current.Clear(); + Str.Clear(); + Current.Clear(); IsValid = false; } return *this; @@ -58,26 +58,26 @@ public: } inline bool operator==(const TDelimStringIter& rhs) const { - return (IsValid == rhs.IsValid) && (!IsValid || (Current.begin() == rhs.Current.begin())); + return (IsValid == rhs.IsValid) && (!IsValid || (Current.begin() == rhs.Current.begin())); } inline bool operator!=(const TDelimStringIter& rhs) const { - return !(*this == rhs); + return !(*this == rhs); } inline TStringBuf operator*() const { - return Current; + return Current; } inline const TStringBuf* operator->() const { - return &Current; - } - + return &Current; + } + // Get & advance template <class T> inline bool TryNext(T& t) { if (IsValid) { - t = FromString<T>(Current); + t = FromString<T>(Current); operator++(); return true; } else { @@ -95,26 +95,26 @@ public: template <class T> inline T GetNext() { - T res; - Next(res); - return res; - } - + T res; + Next(res); + return res; + } + inline const char* GetBegin() const { - return Current.begin(); + return Current.begin(); } inline const char* GetEnd() const { - return Current.end(); + return Current.end(); } inline bool Valid() const { return IsValid; } - // contents from next token to the end of string + // contents from next token to the end of string inline TStringBuf Cdr() const { - return Str.SubStr(Current.length() + Delim.length()); + return Str.SubStr(Current.length() + Delim.length()); } inline TDelimStringIter IterEnd() const { diff --git a/library/cpp/deprecated/split/delim_string_iter_ut.cpp b/library/cpp/deprecated/split/delim_string_iter_ut.cpp index fece177f4d..18a8b2a160 100644 --- a/library/cpp/deprecated/split/delim_string_iter_ut.cpp +++ b/library/cpp/deprecated/split/delim_string_iter_ut.cpp @@ -10,7 +10,7 @@ static void AssertStringSplit(const TString& str, const TString& delim, const TV for (const auto& expectedString : expected) { UNIT_ASSERT(it.Valid()); UNIT_ASSERT(bool(it)); - UNIT_ASSERT_STRINGS_EQUAL(it->ToString(), expectedString); + UNIT_ASSERT_STRINGS_EQUAL(it->ToString(), expectedString); ++it; } UNIT_ASSERT(!it.Valid()); @@ -30,14 +30,14 @@ Y_UNIT_TEST_SUITE(TDelimStrokaIterTestSuite) { Y_UNIT_TEST(NoDelimitersPresent) { AssertStringSplit("This string could be yours", "\t", {"This string could be yours"}); } - + Y_UNIT_TEST(Cdr) { TDelimStringIter it("a\tc\t", "\t"); - UNIT_ASSERT_STRINGS_EQUAL(*it, "a"); - UNIT_ASSERT_STRINGS_EQUAL(it.Cdr(), "c\t"); - ++it; - UNIT_ASSERT_STRINGS_EQUAL(it.Cdr(), ""); - } + UNIT_ASSERT_STRINGS_EQUAL(*it, "a"); + UNIT_ASSERT_STRINGS_EQUAL(it.Cdr(), "c\t"); + ++it; + UNIT_ASSERT_STRINGS_EQUAL(it.Cdr(), ""); + } Y_UNIT_TEST(ForIter) { TVector<TStringBuf> expected = {"1", "", "3@4", ""}; |