aboutsummaryrefslogtreecommitdiffstats
path: root/util/string/split.h
diff options
context:
space:
mode:
authorAlexander Smirnov <alex@ydb.tech>2024-10-16 12:11:24 +0000
committerAlexander Smirnov <alex@ydb.tech>2024-10-16 12:11:24 +0000
commit40811e93f3fdf9342a9295369994012420fac548 (patch)
treea8d85e094a9c21e10aa250f537c101fc2016a049 /util/string/split.h
parent30ebe5357bb143648c6be4d151ecd4944af81ada (diff)
parent28a0c4a9f297064538a018c512cd9bbd00a1a35d (diff)
downloadydb-40811e93f3fdf9342a9295369994012420fac548.tar.gz
Merge branch 'rightlib' into mergelibs-241016-1210
Diffstat (limited to 'util/string/split.h')
-rw-r--r--util/string/split.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/util/string/split.h b/util/string/split.h
index aa53da0475..2000498591 100644
--- a/util/string/split.h
+++ b/util/string/split.h
@@ -660,6 +660,15 @@ namespace NStringSplitPrivate {
using TIterator = TIteratorOf<String>;
friend class TStringSplitter<String>;
+ template <typename S = String, std::enable_if_t<THasData<S>::value, int> = 0>
+ TIterState(const String& string) noexcept
+ : TStringBufType()
+ , DelimiterEnd_(string.data())
+ , OriginEnd_(string.data() + string.size())
+ {
+ }
+
+ template <typename S = String, std::enable_if_t<!THasData<S>::value, int> = 0>
TIterState(const String& string) noexcept
: TStringBufType()
, DelimiterEnd_(std::begin(string))
@@ -700,6 +709,11 @@ namespace NStringSplitPrivate {
return TokenDelim() == DelimiterEnd_;
}
+ void MarkExhausted() noexcept {
+ UpdateParentBuf(OriginEnd_, OriginEnd_);
+ DelimiterEnd_ = OriginEnd_;
+ }
+
private:
TIterator DelimiterEnd_;
const TIterator OriginEnd_;
@@ -845,6 +859,24 @@ namespace NStringSplitPrivate {
{
}
+ TSplitRangeBase(const TSplitRangeBase& other)
+ : String_(other.String_)
+ , State_(String_)
+ , Delimiter_(other.Delimiter_)
+ {
+ }
+
+ TSplitRangeBase(TSplitRangeBase&& other)
+ : String_(std::move(other.String_))
+ , State_(String_)
+ , Delimiter_(std::move(other.Delimiter_))
+ {
+ other.State_.MarkExhausted();
+ }
+
+ TSplitRangeBase& operator=(const TSplitRangeBase& other) = delete;
+ TSplitRangeBase& operator=(TSplitRangeBase&& other) = delete;
+
inline TIteratorState* Next() {
if (State_.DelimiterIsEmpty()) {
return nullptr;