diff options
author | putilin <putilin@yandex-team.ru> | 2022-02-10 16:49:29 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:29 +0300 |
commit | 3a0b7cd78a1a8366b3944d8d1e11ef9bb52549bf (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /util | |
parent | d85af01a101a46c4381ba0c8d5785a43c8273afd (diff) | |
download | ydb-3a0b7cd78a1a8366b3944d8d1e11ef9bb52549bf.tar.gz |
Restoring authorship annotation for <putilin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util')
-rw-r--r-- | util/string/split.h | 30 | ||||
-rw-r--r-- | util/string/split_ut.cpp | 28 | ||||
-rw-r--r-- | util/string/vector.h | 12 |
3 files changed, 35 insertions, 35 deletions
diff --git a/util/string/split.h b/util/string/split.h index 22cbb8bcda..bc46d9e64c 100644 --- a/util/string/split.h +++ b/util/string/split.h @@ -298,23 +298,23 @@ struct TContainerConsumer { T* C; }; -template <class T> -struct TContainerConvertingConsumer { +template <class T> +struct TContainerConvertingConsumer { inline TContainerConvertingConsumer(T* c) noexcept - : C(c) - { - } - - template <class I> - inline bool Consume(I* b, I* d, I* /*e*/) { + : C(c) + { + } + + template <class I> + inline bool Consume(I* b, I* d, I* /*e*/) { TConsumerBackInserter<T>::DoInsert(C, FromString<typename T::value_type>(TStringBuf(b, d))); - - return true; - } - - T* C; -}; - + + return true; + } + + T* C; +}; + template <class S, class I> struct TLimitingConsumer { inline TLimitingConsumer(size_t cnt, S* slave) noexcept diff --git a/util/string/split_ut.cpp b/util/string/split_ut.cpp index 7bce999d7d..43e59f2d75 100644 --- a/util/string/split_ut.cpp +++ b/util/string/split_ut.cpp @@ -55,19 +55,19 @@ inline void Print(const T& t) { } } -template <template <typename> class TConsumer, typename TResult, typename I, typename TDelimiter> +template <template <typename> class TConsumer, typename TResult, typename I, typename TDelimiter> void TestDelimiterOnString(TResult& good, I* str, const TDelimiter& delim) { TResult test; - TConsumer<TResult> consumer(&test); + TConsumer<TResult> consumer(&test); SplitString(str, delim, consumer); Cmp(good, test); UNIT_ASSERT_EQUAL(good, test); } -template <template <typename> class TConsumer, typename TResult, typename I, typename TDelimiter> +template <template <typename> class TConsumer, typename TResult, typename I, typename TDelimiter> void TestDelimiterOnRange(TResult& good, I* b, I* e, const TDelimiter& delim) { TResult test; - TConsumer<TResult> consumer(&test); + TConsumer<TResult> consumer(&test); SplitString(b, e, delim, consumer); Cmp(good, test); UNIT_ASSERT_EQUAL(good, test); @@ -142,14 +142,14 @@ Y_UNIT_TEST_SUITE(SplitStringTest) { Y_UNIT_TEST(TestConvertToIntCharSingleDelimiter) { TString data("42 4242 -12345 0"); - i32 canonic[] = {42, 4242, -12345, 0}; + i32 canonic[] = {42, 4242, -12345, 0}; TVector<i32> good(canonic, canonic + 4); - TCharDelimiter<const char> delim(' '); - + TCharDelimiter<const char> delim(' '); + TestDelimiterOnString<TContainerConvertingConsumer>(good, data.data(), delim); TestDelimiterOnRange<TContainerConvertingConsumer>(good, data.data(), data.end(), delim); - } - + } + Y_UNIT_TEST(TestCharSkipEmpty) { TString data("qw ab qwabcab "); TString canonic[] = {"qw", "ab", "qwabcab"}; @@ -243,14 +243,14 @@ Y_UNIT_TEST_SUITE(SplitStringTest) { TVector<TString> good(canonic, canonic + 3); TString delim = "ab"; TVector<TString> test; - Split(data, delim, test); - Cmp(good, test); + Split(data, delim, test); + Cmp(good, test); TVector<TStringBuf> test1; Split(data, delim.data(), test1); Cmp(good, test1); - } - + } + Y_UNIT_TEST(ConvenientSplitTest) { TString data("abc 22 33.5 xyz"); TString str; @@ -263,7 +263,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) { UNIT_ASSERT_VALUES_EQUAL(num2, 33.5); UNIT_ASSERT_VALUES_EQUAL(strBuf, "xyz"); } - + Y_UNIT_TEST(ConvenientSplitTestWithMaybe) { TString data("abc 42"); TString str; diff --git a/util/string/vector.h b/util/string/vector.h index 69413a350c..e36c348bbe 100644 --- a/util/string/vector.h +++ b/util/string/vector.h @@ -106,17 +106,17 @@ inline TString JoinStrings(const TVector<TString>& v, size_t index, size_t count return JoinStrings(v.begin() + index, v.begin() + index + count, delim); } -template <typename T> +template <typename T> inline TString JoinVectorIntoString(const TVector<T>& v, const TStringBuf delim) { return JoinStrings(v.begin(), v.end(), delim); -} - -template <typename T> +} + +template <typename T> inline TString JoinVectorIntoString(const TVector<T>& v, size_t index, size_t count, const TStringBuf delim) { Y_ASSERT(index + count <= v.size() && "JoinVectorIntoString(): index or count out of range"); return JoinStrings(v.begin() + index, v.begin() + index + count, delim); -} - +} + TUtf16String JoinStrings(const TVector<TUtf16String>& v, const TWtringBuf delim); TUtf16String JoinStrings(const TVector<TUtf16String>& v, size_t index, size_t count, const TWtringBuf delim); |