diff options
author | stanly <stanly@yandex-team.ru> | 2022-02-10 16:46:49 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:49 +0300 |
commit | cde218e65dfef5ce03a48d641fd8f7913cf17b2d (patch) | |
tree | d3349caea4095825a55b5ba24fe758067b29ce6f /library/cpp/deprecated/split | |
parent | 9f813499b4ef585cb3c2bb93de93ef003daf4fc4 (diff) | |
download | ydb-cde218e65dfef5ce03a48d641fd8f7913cf17b2d.tar.gz |
Restoring authorship annotation for <stanly@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/deprecated/split')
-rw-r--r-- | library/cpp/deprecated/split/delim_string_iter.h | 60 | ||||
-rw-r--r-- | library/cpp/deprecated/split/delim_string_iter_ut.cpp | 2 |
2 files changed, 31 insertions, 31 deletions
diff --git a/library/cpp/deprecated/split/delim_string_iter.h b/library/cpp/deprecated/split/delim_string_iter.h index 8e4ca171a0..bcfe07abc6 100644 --- a/library/cpp/deprecated/split/delim_string_iter.h +++ b/library/cpp/deprecated/split/delim_string_iter.h @@ -1,8 +1,8 @@ #pragma once -#include <util/generic/algorithm.h> -#include <util/generic/strbuf.h> -#include <util/generic/yexception.h> +#include <util/generic/algorithm.h> +#include <util/generic/strbuf.h> +#include <util/generic/yexception.h> #include <util/string/cast.h> #include <util/system/yassert.h> @@ -35,9 +35,9 @@ public: } inline explicit operator bool() const { - return IsValid; - } - + return IsValid; + } + // NOTE: this is a potentially unsafe operation (no overrun check) inline TDelimStringIter& operator++() { if (Current.end() != Str.end()) { @@ -51,7 +51,7 @@ public: return *this; } - inline void operator+=(size_t n) { + inline void operator+=(size_t n) { for (; n > 0; --n) { ++(*this); } @@ -65,17 +65,17 @@ public: return !(*this == rhs); } - inline TStringBuf operator*() const { + inline TStringBuf operator*() const { return Current; } - inline const TStringBuf* operator->() const { + inline const TStringBuf* operator->() const { return &Current; } - // Get & advance + // Get & advance template <class T> - inline bool TryNext(T& t) { + inline bool TryNext(T& t) { if (IsValid) { t = FromString<T>(Current); operator++(); @@ -94,46 +94,46 @@ public: } template <class T> - inline T GetNext() { + inline T GetNext() { T res; Next(res); return res; } - inline const char* GetBegin() const { + inline const char* GetBegin() const { return Current.begin(); } - inline const char* GetEnd() const { + inline const char* GetEnd() const { return Current.end(); } - inline bool Valid() const { + inline bool Valid() const { return IsValid; } // contents from next token to the end of string - inline TStringBuf Cdr() const { + inline TStringBuf Cdr() const { return Str.SubStr(Current.length() + Delim.length()); } inline TDelimStringIter IterEnd() const { return TDelimStringIter(); } - -private: - inline void UpdateCurrent() { - // it is much faster than TStringBuf::find + +private: + inline void UpdateCurrent() { + // it is much faster than TStringBuf::find size_t pos = std::search(Str.begin(), Str.end(), Delim.begin(), Delim.end()) - Str.begin(); - Current = Str.Head(pos); - } - -private: - bool IsValid; - - TStringBuf Str; - TStringBuf Current; - TStringBuf Delim; + Current = Str.Head(pos); + } + +private: + bool IsValid; + + TStringBuf Str; + TStringBuf Current; + TStringBuf Delim; }; //example: for (TStringBuf field: TDelimStroka(line, "@@")) { ... } @@ -141,7 +141,7 @@ struct TDelimStroka { TStringBuf S; TStringBuf Delim; - inline TDelimStroka(TStringBuf s, TStringBuf delim) + inline TDelimStroka(TStringBuf s, TStringBuf delim) : S(s) , Delim(delim) { diff --git a/library/cpp/deprecated/split/delim_string_iter_ut.cpp b/library/cpp/deprecated/split/delim_string_iter_ut.cpp index 18a8b2a160..da0ab5c0fd 100644 --- a/library/cpp/deprecated/split/delim_string_iter_ut.cpp +++ b/library/cpp/deprecated/split/delim_string_iter_ut.cpp @@ -9,7 +9,7 @@ static void AssertStringSplit(const TString& str, const TString& delim, const TV // test iterator invariants for (const auto& expectedString : expected) { UNIT_ASSERT(it.Valid()); - UNIT_ASSERT(bool(it)); + UNIT_ASSERT(bool(it)); UNIT_ASSERT_STRINGS_EQUAL(it->ToString(), expectedString); ++it; } |