aboutsummaryrefslogtreecommitdiffstats
path: root/util/string/split.h
diff options
context:
space:
mode:
authoreeight <eeight@yandex-team.ru>2022-02-10 16:46:19 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:19 +0300
commitbd085aee9b4f7a0bee302ce687964ffb7098f986 (patch)
tree1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /util/string/split.h
parent475c0a46f28166e83fd263badc7546377cddcabe (diff)
downloadydb-bd085aee9b4f7a0bee302ce687964ffb7098f986.tar.gz
Restoring authorship annotation for <eeight@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/string/split.h')
-rw-r--r--util/string/split.h104
1 files changed, 52 insertions, 52 deletions
diff --git a/util/string/split.h b/util/string/split.h
index 951b3cc7d4..bc46d9e64c 100644
--- a/util/string/split.h
+++ b/util/string/split.h
@@ -21,7 +21,7 @@
// NOTE: Check StringSplitter below to get more convenient split string interface.
-namespace NStringSplitPrivate {
+namespace NStringSplitPrivate {
template <class T, class I, class = void>
struct TIsConsumer: std::false_type {};
@@ -36,21 +36,21 @@ namespace NStringSplitPrivate {
template <class T, class I>
constexpr bool TIsConsumerV = TIsConsumer<T, I>::value;
- template <class T>
- T* Find(T* str, std::common_type_t<T> ch) {
- for (; *str; ++str) {
- if (*str == ch) {
- return str;
- }
- }
-
- return nullptr;
- }
-
+ template <class T>
+ T* Find(T* str, std::common_type_t<T> ch) {
+ for (; *str; ++str) {
+ if (*str == ch) {
+ return str;
+ }
+ }
+
+ return nullptr;
+ }
+
}
template <class I, class TDelim, class TConsumer>
-std::enable_if_t<::NStringSplitPrivate::TIsConsumerV<TConsumer, I>>
+std::enable_if_t<::NStringSplitPrivate::TIsConsumerV<TConsumer, I>>
SplitString(I b, I e, const TDelim& d, TConsumer&& c) {
I l, i;
@@ -61,7 +61,7 @@ SplitString(I b, I e, const TDelim& d, TConsumer&& c) {
}
template <class I, class TDelim, class TConsumer>
-std::enable_if_t<::NStringSplitPrivate::TIsConsumerV<TConsumer, I>>
+std::enable_if_t<::NStringSplitPrivate::TIsConsumerV<TConsumer, I>>
SplitString(I b, const TDelim& d, TConsumer&& c) {
I l, i;
@@ -73,7 +73,7 @@ SplitString(I b, const TDelim& d, TConsumer&& c) {
template <class I1, class I2>
static inline I1* FastStrChr(I1* str, I2 f) noexcept {
- I1* ret = NStringSplitPrivate::Find(str, f);
+ I1* ret = NStringSplitPrivate::Find(str, f);
if (!ret) {
ret = str + std::char_traits<I1>::length(str);
@@ -84,21 +84,21 @@ static inline I1* FastStrChr(I1* str, I2 f) noexcept {
template <class I>
static inline I* FastStrStr(I* str, I* f, size_t l) noexcept {
- std::basic_string_view<I> strView(str);
- const auto ret = strView.find(*f);
-
- if (ret != std::string::npos) {
- std::basic_string_view<I> fView(f, l);
- strView = strView.substr(ret);
- for (; strView.size() >= l; strView = strView.substr(1)) {
- if (strView.substr(0, l) == fView) {
- break;
- }
- }
-
- return strView.size() >= l ? strView.data() : strView.data() + strView.size();
- } else {
- return strView.data() + strView.size();
+ std::basic_string_view<I> strView(str);
+ const auto ret = strView.find(*f);
+
+ if (ret != std::string::npos) {
+ std::basic_string_view<I> fView(f, l);
+ strView = strView.substr(ret);
+ for (; strView.size() >= l; strView = strView.substr(1)) {
+ if (strView.substr(0, l) == fView) {
+ break;
+ }
+ }
+
+ return strView.size() >= l ? strView.data() : strView.data() + strView.size();
+ } else {
+ return strView.data() + strView.size();
}
}
@@ -117,12 +117,12 @@ struct TStringDelimiter {
}
inline Char* Find(Char*& b, Char* e) const noexcept {
- const auto ret = std::basic_string_view<Char>(b, e - b).find(Delim, 0, Len);
+ const auto ret = std::basic_string_view<Char>(b, e - b).find(Delim, 0, Len);
- if (ret != std::string::npos) {
- const auto result = b + ret;
- b = result + Len;
- return result;
+ if (ret != std::string::npos) {
+ const auto result = b + ret;
+ b = result + Len;
+ return result;
}
return (b = e);
@@ -131,7 +131,7 @@ struct TStringDelimiter {
inline Char* Find(Char*& b) const noexcept {
Char* ret = FastStrStr(b, Delim, Len);
- b = *ret ? ret + Len : ret;
+ b = *ret ? ret + Len : ret;
return ret;
}
@@ -148,12 +148,12 @@ struct TCharDelimiter {
}
inline Char* Find(Char*& b, Char* e) const noexcept {
- const auto ret = std::basic_string_view<Char>(b, e - b).find(Ch);
+ const auto ret = std::basic_string_view<Char>(b, e - b).find(Ch);
- if (ret != std::string::npos) {
- const auto result = b + ret;
- b = result + 1;
- return result;
+ if (ret != std::string::npos) {
+ const auto result = b + ret;
+ b = result + 1;
+ return result;
}
return (b = e);
@@ -205,16 +205,16 @@ struct TFindFirstOf {
inline Char* FindFirstOf(Char* b, Char* e) const noexcept {
Char* ret = b;
for (; ret != e; ++ret) {
- if (NStringSplitPrivate::Find(Set, *ret))
+ if (NStringSplitPrivate::Find(Set, *ret))
break;
}
return ret;
}
inline Char* FindFirstOf(Char* b) const noexcept {
- const std::basic_string_view<Char> bView(b);
- const auto ret = bView.find_first_of(Set);
- return ret != std::string::npos ? b + ret : b + bView.size();
+ const std::basic_string_view<Char> bView(b);
+ const auto ret = bView.find_first_of(Set);
+ return ret != std::string::npos ? b + ret : b + bView.size();
}
Char* Set;
@@ -489,7 +489,7 @@ void Split(TStringBuf s, D delim, P1& p1, P2& p2, Other&... other) {
* \endcode
*/
-namespace NStringSplitPrivate {
+namespace NStringSplitPrivate {
Y_HAS_MEMBER(push_back, PushBack);
Y_HAS_MEMBER(insert, Insert);
Y_HAS_MEMBER(data, Data);
@@ -1042,30 +1042,30 @@ namespace NStringSplitPrivate {
template <class Iterator>
auto StringSplitter(Iterator begin, Iterator end) {
- return ::NStringSplitPrivate::MakeStringSplitter(TIteratorRange<Iterator>(begin, end));
+ return ::NStringSplitPrivate::MakeStringSplitter(TIteratorRange<Iterator>(begin, end));
}
template <class Char>
auto StringSplitter(const Char* begin, const Char* end) {
- return ::NStringSplitPrivate::MakeStringSplitter(TBasicStringBuf<Char>(begin, end));
+ return ::NStringSplitPrivate::MakeStringSplitter(TBasicStringBuf<Char>(begin, end));
}
template <class Char>
auto StringSplitter(const Char* begin, size_t len) {
- return ::NStringSplitPrivate::MakeStringSplitter(TBasicStringBuf<Char>(begin, len));
+ return ::NStringSplitPrivate::MakeStringSplitter(TBasicStringBuf<Char>(begin, len));
}
template <class Char>
auto StringSplitter(const Char* str) {
- return ::NStringSplitPrivate::MakeStringSplitter(TBasicStringBuf<Char>(str));
+ return ::NStringSplitPrivate::MakeStringSplitter(TBasicStringBuf<Char>(str));
}
template <class String, std::enable_if_t<!std::is_pointer<std::remove_reference_t<String>>::value, int> = 0>
auto StringSplitter(String& s) {
- return ::NStringSplitPrivate::MakeStringSplitter(::NStringSplitPrivate::TStringBufOf<String>(s.data(), s.size()));
+ return ::NStringSplitPrivate::MakeStringSplitter(::NStringSplitPrivate::TStringBufOf<String>(s.data(), s.size()));
}
template <class String, std::enable_if_t<!std::is_pointer<std::remove_reference_t<String>>::value, int> = 0>
auto StringSplitter(String&& s) {
- return ::NStringSplitPrivate::MakeStringSplitter(std::move(s));
+ return ::NStringSplitPrivate::MakeStringSplitter(std::move(s));
}