aboutsummaryrefslogtreecommitdiffstats
path: root/util/string/vector.cpp
diff options
context:
space:
mode:
authorkimkim <kimkim@yandex-team.ru>2022-02-10 16:49:27 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:27 +0300
commit13f84424ed9975f6827d9786087c6fe6ea265cda (patch)
treeb94acc282c49a5de96b9e3e19feead21736f3273 /util/string/vector.cpp
parent35f29a67a6b8e50e1826c837330086049114c5ba (diff)
downloadydb-13f84424ed9975f6827d9786087c6fe6ea265cda.tar.gz
Restoring authorship annotation for <kimkim@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/string/vector.cpp')
-rw-r--r--util/string/vector.cpp94
1 files changed, 47 insertions, 47 deletions
diff --git a/util/string/vector.cpp b/util/string/vector.cpp
index 9ba401f0a2..897061d42a 100644
--- a/util/string/vector.cpp
+++ b/util/string/vector.cpp
@@ -1,80 +1,80 @@
-#include "util.h"
-#include "split.h"
+#include "util.h"
+#include "split.h"
#include "vector.h"
#include <util/system/defaults.h>
-template <class TConsumer, class TDelim, typename TChr>
+template <class TConsumer, class TDelim, typename TChr>
static inline void DoSplit2(TConsumer& c, TDelim& d, const TBasicStringBuf<TChr> str, int) {
SplitString(str.data(), str.data() + str.size(), d, c);
-}
-
-template <class TConsumer, class TDelim, typename TChr>
+}
+
+template <class TConsumer, class TDelim, typename TChr>
static inline void DoSplit1(TConsumer& cc, TDelim& d, const TBasicStringBuf<TChr> str, int opts) {
if (opts & KEEP_EMPTY_TOKENS) {
DoSplit2(cc, d, str, opts);
- } else {
- TSkipEmptyTokens<TConsumer> sc(&cc);
-
+ } else {
+ TSkipEmptyTokens<TConsumer> sc(&cc);
+
DoSplit2(sc, d, str, opts);
- }
-}
-
-template <class C, class TDelim, typename TChr>
+ }
+}
+
+template <class C, class TDelim, typename TChr>
static inline void DoSplit0(C* res, const TBasicStringBuf<TChr> str, TDelim& d, size_t maxFields, int options) {
using TStringType = std::conditional_t<std::is_same<TChr, wchar16>::value, TUtf16String, TString>;
- res->clear();
-
+ res->clear();
+
if (!str.data()) {
- return;
- }
-
+ return;
+ }
+
using TConsumer = TContainerConsumer<C>;
- TConsumer cc(res);
-
- if (maxFields) {
- TLimitingConsumer<TConsumer, const TChr> lc(maxFields, &cc);
-
+ TConsumer cc(res);
+
+ if (maxFields) {
+ TLimitingConsumer<TConsumer, const TChr> lc(maxFields, &cc);
+
DoSplit1(lc, d, str, options);
-
- if (lc.Last) {
+
+ if (lc.Last) {
res->push_back(TStringType(lc.Last, str.data() + str.size() - lc.Last));
- }
- } else {
+ }
+ } else {
DoSplit1(cc, d, str, options);
- }
-}
-
-template <typename TChr>
+ }
+}
+
+template <typename TChr>
static void SplitStringImplT(TVector<std::conditional_t<std::is_same<TChr, wchar16>::value, TUtf16String, TString>>* res,
const TBasicStringBuf<TChr> str, const TChr* delim, size_t maxFields, int options) {
- if (!*delim) {
- return;
- }
-
- if (*(delim + 1)) {
+ if (!*delim) {
+ return;
+ }
+
+ if (*(delim + 1)) {
TStringDelimiter<const TChr> d(delim, std::char_traits<TChr>::length(delim));
-
+
DoSplit0(res, str, d, maxFields, options);
- } else {
- TCharDelimiter<const TChr> d(*delim);
-
+ } else {
+ TCharDelimiter<const TChr> d(*delim);
+
DoSplit0(res, str, d, maxFields, options);
- }
-}
-
+ }
+}
+
void ::NPrivate::SplitStringImpl(TVector<TString>* res, const char* ptr, const char* delim, size_t maxFields, int options) {
return SplitStringImplT<char>(res, TStringBuf(ptr), delim, maxFields, options);
-}
-
+}
+
void ::NPrivate::SplitStringImpl(TVector<TString>* res, const char* ptr, size_t len, const char* delim, size_t maxFields, int options) {
return SplitStringImplT<char>(res, TStringBuf(ptr, len), delim, maxFields, options);
}
void ::NPrivate::SplitStringImpl(TVector<TUtf16String>* res, const wchar16* ptr, const wchar16* delimiter, size_t maxFields, int options) {
return SplitStringImplT<wchar16>(res, TWtringBuf(ptr), delimiter, maxFields, options);
-}
-
+}
+
void ::NPrivate::SplitStringImpl(TVector<TUtf16String>* res, const wchar16* ptr, size_t len, const wchar16* delimiter, size_t maxFields, int options) {
return SplitStringImplT<wchar16>(res, TWtringBuf(ptr, len), delimiter, maxFields, options);
}