aboutsummaryrefslogtreecommitdiffstats
path: root/util/string
diff options
context:
space:
mode:
authorVlad Yaroslavlev <vladon@vladon.com>2022-02-10 16:46:23 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:23 +0300
commit706b83ed7de5a473436620367af31fc0ceecde07 (patch)
tree103305d30dec77e8f6367753367f59b3cd68f9f1 /util/string
parent918e8a1574070d0ec733f0b76cfad8f8892ad2e5 (diff)
downloadydb-706b83ed7de5a473436620367af31fc0ceecde07.tar.gz
Restoring authorship annotation for Vlad Yaroslavlev <vladon@vladon.com>. Commit 1 of 2.
Diffstat (limited to 'util/string')
-rw-r--r--util/string/ascii.h2
-rw-r--r--util/string/ascii_ut.cpp14
-rw-r--r--util/string/benchmark/float_to_string/main.cpp4
-rw-r--r--util/string/benchmark/join/main.cpp2
-rw-r--r--util/string/benchmark/subst_global/main.cpp16
-rw-r--r--util/string/builder.cpp2
-rw-r--r--util/string/builder.h4
-rw-r--r--util/string/builder_ut.cpp12
-rw-r--r--util/string/cast.cpp18
-rw-r--r--util/string/cast.h72
-rw-r--r--util/string/cast_ut.cpp20
-rw-r--r--util/string/escape.cpp26
-rw-r--r--util/string/escape.h18
-rw-r--r--util/string/escape_ut.cpp52
-rw-r--r--util/string/fuzzing/collapse/main.cpp4
-rw-r--r--util/string/hex.cpp8
-rw-r--r--util/string/hex.h10
-rw-r--r--util/string/join.h8
-rw-r--r--util/string/join_ut.cpp14
-rw-r--r--util/string/printf.cpp10
-rw-r--r--util/string/printf.h8
-rw-r--r--util/string/printf_ut.cpp10
-rw-r--r--util/string/split.cpp8
-rw-r--r--util/string/split.h26
-rw-r--r--util/string/split_ut.cpp96
-rw-r--r--util/string/strip.cpp6
-rw-r--r--util/string/strip.h46
-rw-r--r--util/string/strip_ut.cpp28
-rw-r--r--util/string/strspn.h16
-rw-r--r--util/string/subst.h30
-rw-r--r--util/string/subst_ut.cpp156
-rw-r--r--util/string/type.cpp2
-rw-r--r--util/string/type_ut.cpp4
-rw-r--r--util/string/util.cpp10
-rw-r--r--util/string/util.h16
-rw-r--r--util/string/util_ut.cpp2
-rw-r--r--util/string/vector.cpp10
-rw-r--r--util/string/vector.h42
-rw-r--r--util/string/vector_ut.cpp16
39 files changed, 424 insertions, 424 deletions
diff --git a/util/string/ascii.h b/util/string/ascii.h
index 10344384d3..67c4e35a71 100644
--- a/util/string/ascii.h
+++ b/util/string/ascii.h
@@ -2,7 +2,7 @@
#include <util/system/defaults.h>
#include <util/system/compat.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
// ctype.h-like functions, locale-independent:
// IsAscii{Upper,Lower,Digit,Alpha,Alnum,Space} and
diff --git a/util/string/ascii_ut.cpp b/util/string/ascii_ut.cpp
index 89069fee50..5b0617a8b5 100644
--- a/util/string/ascii_ut.cpp
+++ b/util/string/ascii_ut.cpp
@@ -65,15 +65,15 @@ Y_UNIT_TEST_SUITE(TAsciiTest) {
Y_UNIT_TEST(CompareTest) {
UNIT_ASSERT(AsciiEqualsIgnoreCase("qqq", "qQq"));
UNIT_ASSERT(AsciiEqualsIgnoreCase("qqq", TStringBuf("qQq")));
- TString qq = "qq";
- TString qQ = "qQ";
+ TString qq = "qq";
+ TString qQ = "qQ";
UNIT_ASSERT(AsciiEqualsIgnoreCase(qq, qQ));
- TString x = "qqqA";
- TString y = "qQqB";
- TString z = "qQnB";
- TString zz = "qQqq";
- TString zzz = "qQqqq";
+ TString x = "qqqA";
+ TString y = "qQqB";
+ TString z = "qQnB";
+ TString zz = "qQqq";
+ TString zzz = "qQqqq";
TStringBuf xs = TStringBuf(x.data(), 3);
TStringBuf ys = TStringBuf(y.data(), 3);
TStringBuf zs = TStringBuf(z.data(), 3);
diff --git a/util/string/benchmark/float_to_string/main.cpp b/util/string/benchmark/float_to_string/main.cpp
index 1c7c0684a3..b52a5e5ab1 100644
--- a/util/string/benchmark/float_to_string/main.cpp
+++ b/util/string/benchmark/float_to_string/main.cpp
@@ -34,7 +34,7 @@ namespace {
template <typename T, size_t N>
struct TExamplesHolder {
- TVector<TExample<T>> Examples;
+ TVector<TExample<T>> Examples;
TExamplesHolder()
: Examples(N)
@@ -49,7 +49,7 @@ namespace {
template <typename T, size_t N>
struct TNearZeroExamplesHolder {
- TVector<TExample<T>> Examples;
+ TVector<TExample<T>> Examples;
TNearZeroExamplesHolder()
: Examples(N)
diff --git a/util/string/benchmark/join/main.cpp b/util/string/benchmark/join/main.cpp
index 1a8633d3a8..cca2331a33 100644
--- a/util/string/benchmark/join/main.cpp
+++ b/util/string/benchmark/join/main.cpp
@@ -46,7 +46,7 @@ namespace {
template <size_t N, typename... T>
struct TExamplesHolder {
- using TExamples = TVector<std::tuple<T...>>;
+ using TExamples = TVector<std::tuple<T...>>;
TExamples Examples;
TExamplesHolder()
diff --git a/util/string/benchmark/subst_global/main.cpp b/util/string/benchmark/subst_global/main.cpp
index e0decfa042..0cce508f08 100644
--- a/util/string/benchmark/subst_global/main.cpp
+++ b/util/string/benchmark/subst_global/main.cpp
@@ -2,7 +2,7 @@
#include <util/generic/cast.h>
#include <util/generic/singleton.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/xrange.h>
#include <util/random/fast.h>
#include <util/string/cast.h>
@@ -15,7 +15,7 @@ namespace {
WHAT = What,
WITH = With
};
- TString Str;
+ TString Str;
TNoMatches() {
for (const auto dummy : xrange(N)) {
@@ -31,7 +31,7 @@ namespace {
WHAT = What,
WITH = With
};
- TString Str;
+ TString Str;
TOneMatchInTheBeginning() {
if (!N) {
@@ -54,7 +54,7 @@ namespace {
WHAT = What,
WITH = With
};
- TString Str;
+ TString Str;
TOneMatchInTheEnd() {
if (!N) {
@@ -77,7 +77,7 @@ namespace {
WHAT = What,
WITH = With
};
- TString Str;
+ TString Str;
TOneMatchInTheMiddle() {
if (!N) {
@@ -100,7 +100,7 @@ namespace {
WHAT = What,
WITH = With
};
- TString Str;
+ TString Str;
TFirstHalfMatches() {
for (size_t i = 0; i < N / 2; ++i) {
@@ -118,7 +118,7 @@ namespace {
WHAT = What,
WITH = With
};
- TString Str;
+ TString Str;
TSecondHalfMatches() {
for (size_t i = 0; i < N / 2; ++i) {
@@ -136,7 +136,7 @@ namespace {
WHAT = What,
WITH = With
};
- TString Str;
+ TString Str;
TEveryKth() {
TFastRng<ui64> prng{N * K * 101};
diff --git a/util/string/builder.cpp b/util/string/builder.cpp
index a3821d3399..205b4475f9 100644
--- a/util/string/builder.cpp
+++ b/util/string/builder.cpp
@@ -4,5 +4,5 @@
template <>
void Out<TStringBuilder>(IOutputStream& os, const TStringBuilder& sb) {
- os << static_cast<const TString&>(sb);
+ os << static_cast<const TString&>(sb);
}
diff --git a/util/string/builder.h b/util/string/builder.h
index 7b54821151..eb800b807f 100644
--- a/util/string/builder.h
+++ b/util/string/builder.h
@@ -2,10 +2,10 @@
#include <util/stream/str.h>
#include <utility>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
namespace NPrivateStringBuilder {
- class TStringBuilder: public TString {
+ class TStringBuilder: public TString {
public:
inline TStringBuilder()
: Out(*this)
diff --git a/util/string/builder_ut.cpp b/util/string/builder_ut.cpp
index 22def683ec..ff6395ca22 100644
--- a/util/string/builder_ut.cpp
+++ b/util/string/builder_ut.cpp
@@ -2,15 +2,15 @@
#include <library/cpp/testing/unittest/registar.h>
-static void TestEquals(const TString& expected, const TString& actual) {
+static void TestEquals(const TString& expected, const TString& actual) {
UNIT_ASSERT_VALUES_EQUAL(expected, actual);
}
struct TClassWithStreamOperator {
ui32 Id;
- TString Name;
+ TString Name;
- TClassWithStreamOperator(ui32 id, const TString& name)
+ TClassWithStreamOperator(ui32 id, const TString& name)
: Id(id)
, Name(name)
{
@@ -30,7 +30,7 @@ Y_UNIT_TEST_SUITE(TStringBuilderTest) {
}
Y_UNIT_TEST(TestStringBuilderOut) {
- TString s;
+ TString s;
TStringOutput out(s);
TStringBuilder sb;
sb << "a";
@@ -40,11 +40,11 @@ Y_UNIT_TEST_SUITE(TStringBuilderTest) {
Y_UNIT_TEST(TestStringBuilderRValue) {
struct TRValueAcceptTester {
- static bool IsRValue(const TString&) {
+ static bool IsRValue(const TString&) {
return false;
}
- static bool IsRValue(TString&&) {
+ static bool IsRValue(TString&&) {
return true;
}
};
diff --git a/util/string/cast.cpp b/util/string/cast.cpp
index aa1e65a8e9..21f4a35157 100644
--- a/util/string/cast.cpp
+++ b/util/string/cast.cpp
@@ -14,7 +14,7 @@
#include <contrib/libs/double-conversion/double-conversion.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/system/yassert.h>
#include <util/generic/yexception.h>
#include <util/generic/typetraits.h>
@@ -517,8 +517,8 @@ bool FromStringImpl<bool>(const char* data, size_t len) {
}
template <>
-TString FromStringImpl<TString>(const char* data, size_t len) {
- return TString(data, len);
+TString FromStringImpl<TString>(const char* data, size_t len) {
+ return TString(data, len);
}
template <>
@@ -532,8 +532,8 @@ std::string FromStringImpl<std::string>(const char* data, size_t len) {
}
template <>
-TUtf16String FromStringImpl<TUtf16String>(const wchar16* data, size_t len) {
- return TUtf16String(data, len);
+TUtf16String FromStringImpl<TUtf16String>(const wchar16* data, size_t len) {
+ return TUtf16String(data, len);
}
template <>
@@ -549,8 +549,8 @@ bool TryFromStringImpl<TStringBuf>(const char* data, size_t len, TStringBuf& res
}
template <>
-bool TryFromStringImpl<TString>(const char* data, size_t len, TString& result) {
- result = TString(data, len);
+bool TryFromStringImpl<TString>(const char* data, size_t len, TString& result) {
+ result = TString(data, len);
return true;
}
@@ -567,8 +567,8 @@ bool TryFromStringImpl<TWtringBuf>(const wchar16* data, size_t len, TWtringBuf&
}
template <>
-bool TryFromStringImpl<TUtf16String>(const wchar16* data, size_t len, TUtf16String& result) {
- result = TUtf16String(data, len);
+bool TryFromStringImpl<TUtf16String>(const wchar16* data, size_t len, TUtf16String& result) {
+ result = TUtf16String(data, len);
return true;
}
diff --git a/util/string/cast.h b/util/string/cast.h
index 90e925c194..b6c78b5f48 100644
--- a/util/string/cast.h
+++ b/util/string/cast.h
@@ -2,7 +2,7 @@
#include <util/system/defaults.h>
#include <util/stream/str.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/strbuf.h>
#include <util/generic/typetraits.h>
#include <util/generic/yexception.h>
@@ -40,35 +40,35 @@ enum EFloatToStringMode {
/** "%f" mode, writes the given number of digits after decimal point:
* 0.1f -> "0.100000", 1.2e-06f -> "0.000001" for ndigits=6 */
PREC_POINT_DIGITS = 3,
-
- /** same as PREC_POINT_DIGITS, but stripping trailing zeroes:
- * 0.1f for ndgigits=6 -> "0.1" */
- PREC_POINT_DIGITS_STRIP_ZEROES = 4
+
+ /** same as PREC_POINT_DIGITS, but stripping trailing zeroes:
+ * 0.1f for ndgigits=6 -> "0.1" */
+ PREC_POINT_DIGITS_STRIP_ZEROES = 4
};
size_t FloatToString(float t, char* buf, size_t len, EFloatToStringMode mode = PREC_AUTO, int ndigits = 0);
size_t FloatToString(double t, char* buf, size_t len, EFloatToStringMode mode = PREC_AUTO, int ndigits = 0);
template <typename T>
-inline TString FloatToString(const T& t, EFloatToStringMode mode = PREC_AUTO, int ndigits = 0) {
+inline TString FloatToString(const T& t, EFloatToStringMode mode = PREC_AUTO, int ndigits = 0) {
char buf[512]; // Max<double>() with mode = PREC_POINT_DIGITS has 309 digits before the decimal point
size_t count = FloatToString(t, buf, sizeof(buf), mode, ndigits);
- return TString(buf, count);
+ return TString(buf, count);
}
namespace NPrivate {
template <class T, bool isSimple>
struct TToString {
- static inline TString Cvt(const T& t) {
+ static inline TString Cvt(const T& t) {
char buf[512];
- return TString(buf, ToString<T>(t, buf, sizeof(buf)));
+ return TString(buf, ToString<T>(t, buf, sizeof(buf)));
}
};
template <class T>
struct TToString<T, false> {
- static inline TString Cvt(const T& t) {
+ static inline TString Cvt(const T& t) {
TString s;
TStringOutput o(s);
o << t;
@@ -81,25 +81,25 @@ namespace NPrivate {
* some clever implementations...
*/
template <class T>
-inline TString ToString(const T& t) {
+inline TString ToString(const T& t) {
using TR = std::remove_cv_t<T>;
return ::NPrivate::TToString<TR, std::is_arithmetic<TR>::value>::Cvt((const TR&)t);
}
-inline const TString& ToString(const TString& s) noexcept {
+inline const TString& ToString(const TString& s) noexcept {
return s;
}
-inline const TString& ToString(TString& s) noexcept {
+inline const TString& ToString(TString& s) noexcept {
return s;
}
-inline TString ToString(const char* s) {
+inline TString ToString(const char* s) {
return s;
}
-inline TString ToString(char* s) {
+inline TString ToString(char* s) {
return s;
}
@@ -107,15 +107,15 @@ inline TString ToString(char* s) {
* Wrapper for wide strings.
*/
template <class T>
-inline TUtf16String ToWtring(const T& t) {
- return TUtf16String::FromAscii(ToString(t));
+inline TUtf16String ToWtring(const T& t) {
+ return TUtf16String::FromAscii(ToString(t));
}
-inline const TUtf16String& ToWtring(const TUtf16String& w) {
+inline const TUtf16String& ToWtring(const TUtf16String& w) {
return w;
}
-inline const TUtf16String& ToWtring(TUtf16String& w) {
+inline const TUtf16String& ToWtring(TUtf16String& w) {
return w;
}
@@ -156,7 +156,7 @@ inline T FromString(const TStringBuf& s) {
}
template <class T>
-inline T FromString(const TString& s) {
+inline T FromString(const TString& s) {
return ::FromString<T>(s.data(), s.size());
}
@@ -166,7 +166,7 @@ inline T FromString(const std::string& s) {
}
template <>
-inline TString FromString<TString>(const TString& s) {
+inline TString FromString<TString>(const TString& s) {
return s;
}
@@ -176,7 +176,7 @@ inline T FromString(const TWtringBuf& s) {
}
template <class T>
-inline T FromString(const TUtf16String& s) {
+inline T FromString(const TUtf16String& s) {
return ::FromString<T, wchar16>(s.data(), s.size());
}
@@ -251,7 +251,7 @@ inline bool TryFromString(const TStringBuf& s, T& result) {
}
template <class T>
-inline bool TryFromString(const TString& s, T& result) {
+inline bool TryFromString(const TString& s, T& result) {
return TryFromString<T>(s.data(), s.size(), result);
}
@@ -266,12 +266,12 @@ inline bool TryFromString(const TWtringBuf& s, T& result) {
}
template <class T>
-inline bool TryFromString(const TUtf16String& s, T& result) {
+inline bool TryFromString(const TUtf16String& s, T& result) {
return TryFromString<T>(s.data(), s.size(), result);
}
-template <class T, class TStringType>
-inline bool TryFromStringWithDefault(const TStringType& s, T& result, const T& def) {
+template <class T, class TStringType>
+inline bool TryFromStringWithDefault(const TStringType& s, T& result, const T& def) {
return TryFromString<T>(s.data(), s.size(), result, def);
}
@@ -280,8 +280,8 @@ inline bool TryFromStringWithDefault(const char* s, T& result, const T& def) {
return TryFromStringWithDefault<T>(TStringBuf(s), result, def);
}
-template <class T, class TStringType>
-inline bool TryFromStringWithDefault(const TStringType& s, T& result) {
+template <class T, class TStringType>
+inline bool TryFromStringWithDefault(const TStringType& s, T& result) {
return TryFromStringWithDefault<T>(s, result, T());
}
@@ -293,8 +293,8 @@ inline T FromString(const TChar* data, const size_t len, const T& def) {
return result;
}
-template <class T, class TStringType>
-inline T FromStringWithDefault(const TStringType& s, const T& def) {
+template <class T, class TStringType>
+inline T FromStringWithDefault(const TStringType& s, const T& def) {
return FromString<T>(s.data(), s.size(), def);
}
@@ -303,8 +303,8 @@ inline T FromStringWithDefault(const char* s, const T& def) {
return FromStringWithDefault<T>(TStringBuf(s), def);
}
-template <class T, class TStringType>
-inline T FromStringWithDefault(const TStringType& s) {
+template <class T, class TStringType>
+inline T FromStringWithDefault(const TStringType& s) {
return FromStringWithDefault<T>(s, T());
}
@@ -315,19 +315,19 @@ template <int base, class T>
size_t IntToString(T t, char* buf, size_t len);
template <int base, class T>
-inline TString IntToString(T t) {
+inline TString IntToString(T t) {
static_assert(std::is_arithmetic<std::remove_cv_t<T>>::value, "expect std::is_arithmetic<std::remove_cv_t<T>>::value");
char buf[256];
- return TString(buf, IntToString<base>(t, buf, sizeof(buf)));
+ return TString(buf, IntToString<base>(t, buf, sizeof(buf)));
}
template <int base, class TInt, class TChar>
bool TryIntFromString(const TChar* data, size_t len, TInt& result);
-template <int base, class TInt, class TStringType>
-inline bool TryIntFromString(const TStringType& s, TInt& result) {
+template <int base, class TInt, class TStringType>
+inline bool TryIntFromString(const TStringType& s, TInt& result) {
return TryIntFromString<base>(s.data(), s.size(), result);
}
diff --git a/util/string/cast_ut.cpp b/util/string/cast_ut.cpp
index 033450c38c..31212fff12 100644
--- a/util/string/cast_ut.cpp
+++ b/util/string/cast_ut.cpp
@@ -43,12 +43,12 @@
template <class A>
struct TRet {
template <int base>
- inline A IntFromStringForCheck(const TString& str) {
+ inline A IntFromStringForCheck(const TString& str) {
return IntFromString<A, base>(str);
}
template <int base>
- inline bool TryIntFromStringForCheck(const TString& str, A& result) {
+ inline bool TryIntFromStringForCheck(const TString& str, A& result) {
return TryIntFromString<base>(str, result);
}
@@ -126,7 +126,7 @@ inline TRet<A> F() {
#if 0
template <class T>
-inline void CheckConvertToBuffer(const T& value, const size_t size, const TString& canonValue) {
+inline void CheckConvertToBuffer(const T& value, const size_t size, const TString& canonValue) {
const size_t maxSize = 256;
char buffer[maxSize];
const char magic = 0x7F;
@@ -262,7 +262,7 @@ Y_UNIT_TEST_SUITE(TCastTest) {
UNIT_ASSERT_VALUES_EQUAL(FloatToString(0.12345678f, PREC_POINT_DIGITS, 6), "0.123457");
UNIT_ASSERT_VALUES_EQUAL(FloatToString(1e-20f, PREC_POINT_DIGITS, 6), "0.000000");
UNIT_ASSERT_VALUES_EQUAL(FloatToString(12.34f, PREC_POINT_DIGITS, 0), "12"); // rounding to integers drops '.'
- // strip trailing zeroes
+ // strip trailing zeroes
UNIT_ASSERT_VALUES_EQUAL(FloatToString(0.1f, PREC_POINT_DIGITS_STRIP_ZEROES, 6), "0.1");
UNIT_ASSERT_VALUES_EQUAL(FloatToString(0.12345678f, PREC_POINT_DIGITS_STRIP_ZEROES, 6), "0.123457");
UNIT_ASSERT_VALUES_EQUAL(FloatToString(1e-20f, PREC_POINT_DIGITS_STRIP_ZEROES, 6), "0");
@@ -321,7 +321,7 @@ Y_UNIT_TEST_SUITE(TCastTest) {
}
Y_UNIT_TEST(TestFromStringStringBuf) {
- TString a = "xyz";
+ TString a = "xyz";
TStringBuf b = FromString<TStringBuf>(a);
UNIT_ASSERT_VALUES_EQUAL(a, b);
UNIT_ASSERT_VALUES_EQUAL((void*)a.data(), (void*)b.data());
@@ -375,7 +375,7 @@ Y_UNIT_TEST_SUITE(TCastTest) {
size_t res = 0;
const size_t def1 = 42;
- TString s1("100500");
+ TString s1("100500");
UNIT_ASSERT_VALUES_EQUAL(TryFromStringWithDefault(s1, res, def1), true);
UNIT_ASSERT_VALUES_EQUAL(res, 100500);
@@ -390,7 +390,7 @@ Y_UNIT_TEST_SUITE(TCastTest) {
UNIT_ASSERT_VALUES_EQUAL(FromStringWithDefault<size_t>(s1), 100500);
UNIT_ASSERT_VALUES_EQUAL(FromStringWithDefault("100500", def1), 100500);
- TString s2("100q500");
+ TString s2("100q500");
UNIT_ASSERT_VALUES_EQUAL(TryFromStringWithDefault(s2, res), false);
UNIT_ASSERT_VALUES_EQUAL(res, size_t());
@@ -453,7 +453,7 @@ Y_UNIT_TEST_SUITE(TCastTest) {
UNIT_ASSERT_DOUBLES_EQUAL((float)FromString("0.0001"), 0.0001, EPS);
UNIT_ASSERT_DOUBLES_EQUAL((double)FromString("0.0015", sizeof("0.0015") - 2), 0.001, EPS);
UNIT_ASSERT_DOUBLES_EQUAL((long double)FromString(TStringBuf("0.0001")), 0.0001, EPS);
- UNIT_ASSERT_DOUBLES_EQUAL((float)FromString(TString("10E-5")), 10E-5, EPS);
+ UNIT_ASSERT_DOUBLES_EQUAL((float)FromString(TString("10E-5")), 10E-5, EPS);
UNIT_ASSERT_VALUES_EQUAL((bool)FromString("da"), true);
UNIT_ASSERT_VALUES_EQUAL((bool)FromString("no"), false);
UNIT_ASSERT_VALUES_EQUAL((short)FromString(u"9000"), 9000);
@@ -465,7 +465,7 @@ Y_UNIT_TEST_SUITE(TCastTest) {
}
static void CheckMessage(TFromStringException& exc, const TString& phrase) {
- TString message = exc.what();
+ TString message = exc.what();
if (!message.Contains(phrase)) {
Cerr << message << Endl;
UNIT_ASSERT(false);
@@ -536,7 +536,7 @@ Y_UNIT_TEST_SUITE(TCastTest) {
UNIT_ASSERT_VALUES_EQUAL(hello, out);
}
{
- const TUtf16String empty;
+ const TUtf16String empty;
TWtringBuf out;
UNIT_ASSERT(TryFromString(empty, out));
UNIT_ASSERT_VALUES_EQUAL(empty, out);
diff --git a/util/string/escape.cpp b/util/string/escape.cpp
index cd09a7dbd0..92a28b63ec 100644
--- a/util/string/escape.cpp
+++ b/util/string/escape.cpp
@@ -174,8 +174,8 @@ TBasicString<TChar>& EscapeCImpl(const TChar* str, size_t len, TBasicString<TCha
return r;
}
-template TString& EscapeCImpl<TString::TChar>(const TString::TChar* str, size_t len, TString& r);
-template TUtf16String& EscapeCImpl<TUtf16String::TChar>(const TUtf16String::TChar* str, size_t len, TUtf16String& r);
+template TString& EscapeCImpl<TString::TChar>(const TString::TChar* str, size_t len, TString& r);
+template TUtf16String& EscapeCImpl<TUtf16String::TChar>(const TUtf16String::TChar* str, size_t len, TUtf16String& r);
namespace {
template <class TStr>
@@ -358,8 +358,8 @@ TChar* UnescapeC(const TChar* str, size_t len, TChar* buf) {
return DoUnescapeC(str, len, bufbuf).P;
}
-template TString& UnescapeCImpl<TString::TChar>(const TString::TChar* str, size_t len, TString& r);
-template TUtf16String& UnescapeCImpl<TUtf16String::TChar>(const TUtf16String::TChar* str, size_t len, TUtf16String& r);
+template TString& UnescapeCImpl<TString::TChar>(const TString::TChar* str, size_t len, TString& r);
+template TUtf16String& UnescapeCImpl<TUtf16String::TChar>(const TUtf16String::TChar* str, size_t len, TUtf16String& r);
template char* UnescapeC<char>(const char* str, size_t len, char* buf);
@@ -398,36 +398,36 @@ size_t UnescapeCCharLen(const TChar* begin, const TChar* end) {
}
template size_t UnescapeCCharLen<char>(const char* begin, const char* end);
-template size_t UnescapeCCharLen<TUtf16String::TChar>(const TUtf16String::TChar* begin, const TUtf16String::TChar* end);
+template size_t UnescapeCCharLen<TUtf16String::TChar>(const TUtf16String::TChar* begin, const TUtf16String::TChar* end);
-TString& EscapeC(const TStringBuf str, TString& s) {
+TString& EscapeC(const TStringBuf str, TString& s) {
return EscapeC(str.data(), str.size(), s);
}
-TUtf16String& EscapeC(const TWtringBuf str, TUtf16String& w) {
+TUtf16String& EscapeC(const TWtringBuf str, TUtf16String& w) {
return EscapeC(str.data(), str.size(), w);
}
-TString EscapeC(const TString& str) {
+TString EscapeC(const TString& str) {
return EscapeC(str.data(), str.size());
}
-TUtf16String EscapeC(const TUtf16String& str) {
+TUtf16String EscapeC(const TUtf16String& str) {
return EscapeC(str.data(), str.size());
}
-TString& UnescapeC(const TStringBuf str, TString& s) {
+TString& UnescapeC(const TStringBuf str, TString& s) {
return UnescapeC(str.data(), str.size(), s);
}
-TUtf16String& UnescapeC(const TWtringBuf str, TUtf16String& w) {
+TUtf16String& UnescapeC(const TWtringBuf str, TUtf16String& w) {
return UnescapeC(str.data(), str.size(), w);
}
-TString UnescapeC(const TStringBuf str) {
+TString UnescapeC(const TStringBuf str) {
return UnescapeC(str.data(), str.size());
}
-TUtf16String UnescapeC(const TWtringBuf str) {
+TUtf16String UnescapeC(const TWtringBuf str) {
return UnescapeC(str.data(), str.size());
}
diff --git a/util/string/escape.h b/util/string/escape.h
index b01be65b0e..47f3c7447b 100644
--- a/util/string/escape.h
+++ b/util/string/escape.h
@@ -1,6 +1,6 @@
#pragma once
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/strbuf.h>
template <class TChar>
@@ -49,18 +49,18 @@ static inline TBasicString<TChar> EscapeC(const TChar* str) {
return EscapeC(str, std::char_traits<TChar>::length(str));
}
-TString& EscapeC(const TStringBuf str, TString& res);
-TUtf16String& EscapeC(const TWtringBuf str, TUtf16String& res);
+TString& EscapeC(const TStringBuf str, TString& res);
+TUtf16String& EscapeC(const TWtringBuf str, TUtf16String& res);
// these two need to be methods, because of TBasicString::Quote implementation
-TString EscapeC(const TString& str);
-TUtf16String EscapeC(const TUtf16String& str);
+TString EscapeC(const TString& str);
+TUtf16String EscapeC(const TUtf16String& str);
-TString& UnescapeC(const TStringBuf str, TString& res);
-TUtf16String& UnescapeC(const TWtringBuf str, TUtf16String& res);
+TString& UnescapeC(const TStringBuf str, TString& res);
+TUtf16String& UnescapeC(const TWtringBuf str, TUtf16String& res);
-TString UnescapeC(const TStringBuf str);
-TUtf16String UnescapeC(const TWtringBuf wtr);
+TString UnescapeC(const TStringBuf str);
+TUtf16String UnescapeC(const TWtringBuf wtr);
/// Returns number of chars in escape sequence.
/// - 0, if begin >= end
diff --git a/util/string/escape_ut.cpp b/util/string/escape_ut.cpp
index cd38ecffd3..b2a9fdd807 100644
--- a/util/string/escape_ut.cpp
+++ b/util/string/escape_ut.cpp
@@ -2,15 +2,15 @@
#include <library/cpp/testing/unittest/registar.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/charset/wide.h>
using namespace std::string_view_literals;
namespace {
struct TExample {
- TString Expected;
- TString Source;
+ TString Expected;
+ TString Source;
TExample(const TStringBuf expected, const TStringBuf source)
: Expected{expected}
@@ -49,42 +49,42 @@ static const TExample CommonTestData[] = {
Y_UNIT_TEST_SUITE(TEscapeCTest) {
Y_UNIT_TEST(TestStrokaEscapeC) {
for (const auto& e : CommonTestData) {
- TString expected(e.Expected);
- TString source(e.Source);
- TString actual(EscapeC(e.Source));
- TString actual2(UnescapeC(e.Expected));
+ TString expected(e.Expected);
+ TString source(e.Source);
+ TString actual(EscapeC(e.Source));
+ TString actual2(UnescapeC(e.Expected));
UNIT_ASSERT_VALUES_EQUAL(e.Expected, actual);
UNIT_ASSERT_VALUES_EQUAL(e.Source, actual2);
}
- UNIT_ASSERT_VALUES_EQUAL("http://ya.ru/\\x17\\n\\xAB", EscapeC(TString("http://ya.ru/\x17\n\xab")));
- UNIT_ASSERT_VALUES_EQUAL("http://ya.ru/\x17\n\xab", UnescapeC(TString("http://ya.ru/\\x17\\n\\xAB")));
+ UNIT_ASSERT_VALUES_EQUAL("http://ya.ru/\\x17\\n\\xAB", EscapeC(TString("http://ya.ru/\x17\n\xab")));
+ UNIT_ASSERT_VALUES_EQUAL("http://ya.ru/\x17\n\xab", UnescapeC(TString("http://ya.ru/\\x17\\n\\xAB")));
UNIT_ASSERT_VALUES_EQUAL("h", EscapeC('h'));
- UNIT_ASSERT_VALUES_EQUAL("h", UnescapeC(TString("h")));
+ UNIT_ASSERT_VALUES_EQUAL("h", UnescapeC(TString("h")));
UNIT_ASSERT_VALUES_EQUAL("\\xFF", EscapeC('\xFF'));
- UNIT_ASSERT_VALUES_EQUAL("\xFF", UnescapeC(TString("\\xFF")));
+ UNIT_ASSERT_VALUES_EQUAL("\xFF", UnescapeC(TString("\\xFF")));
- UNIT_ASSERT_VALUES_EQUAL("\\377f", EscapeC(TString("\xff"
+ UNIT_ASSERT_VALUES_EQUAL("\\377f", EscapeC(TString("\xff"
"f")));
UNIT_ASSERT_VALUES_EQUAL("\xff"
"f",
- UnescapeC(TString("\\377f")));
- UNIT_ASSERT_VALUES_EQUAL("\\xFFg", EscapeC(TString("\xff"
+ UnescapeC(TString("\\377f")));
+ UNIT_ASSERT_VALUES_EQUAL("\\xFFg", EscapeC(TString("\xff"
"g")));
UNIT_ASSERT_VALUES_EQUAL("\xff"
"g",
- UnescapeC(TString("\\xFFg")));
- UNIT_ASSERT_VALUES_EQUAL("\xEA\x9A\x96", UnescapeC(TString("\\uA696")));
- UNIT_ASSERT_VALUES_EQUAL("Странный компроматтест", UnescapeC(TString("\\u0421\\u0442\\u0440\\u0430\\u043d\\u043d\\u044b\\u0439 \\u043a\\u043e\\u043c\\u043f\\u0440\\u043e\\u043c\\u0430\\u0442тест")));
+ UnescapeC(TString("\\xFFg")));
+ UNIT_ASSERT_VALUES_EQUAL("\xEA\x9A\x96", UnescapeC(TString("\\uA696")));
+ UNIT_ASSERT_VALUES_EQUAL("Странный компроматтест", UnescapeC(TString("\\u0421\\u0442\\u0440\\u0430\\u043d\\u043d\\u044b\\u0439 \\u043a\\u043e\\u043c\\u043f\\u0440\\u043e\\u043c\\u0430\\u0442тест")));
}
Y_UNIT_TEST(TestWtrokaEscapeC) {
for (const auto& e : CommonTestData) {
- TUtf16String expected(UTF8ToWide(e.Expected));
- TUtf16String source(UTF8ToWide(e.Source));
- TUtf16String actual(EscapeC(source));
- TUtf16String actual2(UnescapeC(expected));
+ TUtf16String expected(UTF8ToWide(e.Expected));
+ TUtf16String source(UTF8ToWide(e.Source));
+ TUtf16String actual(EscapeC(source));
+ TUtf16String actual2(UnescapeC(expected));
UNIT_ASSERT_VALUES_EQUAL(expected, actual);
UNIT_ASSERT_VALUES_EQUAL(source, actual2);
@@ -96,12 +96,12 @@ Y_UNIT_TEST_SUITE(TEscapeCTest) {
}
Y_UNIT_TEST(TestEscapeTrigraphs) {
- UNIT_ASSERT_VALUES_EQUAL("?", EscapeC(TString("?")));
- UNIT_ASSERT_VALUES_EQUAL("\\x3F?", EscapeC(TString("??")));
- UNIT_ASSERT_VALUES_EQUAL("\\x3F\\x3F?", EscapeC(TString("???")));
+ UNIT_ASSERT_VALUES_EQUAL("?", EscapeC(TString("?")));
+ UNIT_ASSERT_VALUES_EQUAL("\\x3F?", EscapeC(TString("??")));
+ UNIT_ASSERT_VALUES_EQUAL("\\x3F\\x3F?", EscapeC(TString("???")));
// ok but may cause warning about trigraphs
- // UNIT_ASSERT_VALUES_EQUAL("[x]?z", EscapeC(TString("??(x??)?z")));
- UNIT_ASSERT_VALUES_EQUAL("\\x3F?x\\x3F\\x3F?z", EscapeC(TString("??x???z")));
+ // UNIT_ASSERT_VALUES_EQUAL("[x]?z", EscapeC(TString("??(x??)?z")));
+ UNIT_ASSERT_VALUES_EQUAL("\\x3F?x\\x3F\\x3F?z", EscapeC(TString("??x???z")));
}
Y_UNIT_TEST(TestUnescapeCCharLen) {
diff --git a/util/string/fuzzing/collapse/main.cpp b/util/string/fuzzing/collapse/main.cpp
index e7b09f0f55..f2c2b2d5d6 100644
--- a/util/string/fuzzing/collapse/main.cpp
+++ b/util/string/fuzzing/collapse/main.cpp
@@ -2,10 +2,10 @@
#include <util/charset/wide.h>
extern "C" int LLVMFuzzerTestOneInput(const ui8* data, size_t size) {
- TUtf16String w((const wchar16*)data, size / 2);
+ TUtf16String w((const wchar16*)data, size / 2);
Collapse(w);
- TString s((const char*)data, size);
+ TString s((const char*)data, size);
CollapseInPlace(s);
return 0; // Non-zero return values are reserved for future use.
diff --git a/util/string/hex.cpp b/util/string/hex.cpp
index 667397987f..71eec149a0 100644
--- a/util/string/hex.cpp
+++ b/util/string/hex.cpp
@@ -44,8 +44,8 @@ void* HexDecode(const void* in, size_t len, void* ptr) {
return out;
}
-TString HexEncode(const void* in, size_t len) {
- TString ret;
+TString HexEncode(const void* in, size_t len) {
+ TString ret;
ret.ReserveAndResize(len << 1);
HexEncode(in, len, ret.begin());
@@ -53,8 +53,8 @@ TString HexEncode(const void* in, size_t len) {
return ret;
}
-TString HexDecode(const void* in, size_t len) {
- TString ret;
+TString HexDecode(const void* in, size_t len) {
+ TString ret;
ret.ReserveAndResize(len >> 1);
HexDecode(in, len, ret.begin());
diff --git a/util/string/hex.h b/util/string/hex.h
index af3d2d528f..07d2de8578 100644
--- a/util/string/hex.h
+++ b/util/string/hex.h
@@ -1,6 +1,6 @@
#pragma once
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/yexception.h>
#include <util/system/yassert.h>
@@ -28,9 +28,9 @@ inline static int String2Byte(const char* s) {
char* HexEncode(const void* in, size_t len, char* out);
-TString HexEncode(const void* in, size_t len);
+TString HexEncode(const void* in, size_t len);
-inline TString HexEncode(const TStringBuf h) {
+inline TString HexEncode(const TStringBuf h) {
return HexEncode(h.data(), h.size());
}
@@ -51,9 +51,9 @@ void* HexDecode(const void* in, size_t len, void* ptr);
*
* @example HexDecode("beef", 4) => {190, 239}
*/
-TString HexDecode(const void* in, size_t len);
+TString HexDecode(const void* in, size_t len);
//! Convert an ASCII hex-string (case-insensitive) to the binary form. Note that h.Size() must be even (+h % 2 == 0).
-inline TString HexDecode(const TStringBuf h) {
+inline TString HexDecode(const TStringBuf h) {
return HexDecode(h.data(), h.size());
}
diff --git a/util/string/join.h b/util/string/join.h
index b166fad1f3..6cb09a9251 100644
--- a/util/string/join.h
+++ b/util/string/join.h
@@ -1,6 +1,6 @@
#pragma once
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/typetraits.h>
#include <util/string/cast.h>
#include "cast.h"
@@ -96,8 +96,8 @@ inline void AppendJoin(TString& dst, const TStringBuf delim, const TValues&... v
}
template <typename TFirst, typename... TRest>
-inline TString Join(const TStringBuf delim, const TFirst& f, const TRest&... r) {
- TString ret = ToString(f);
+inline TString Join(const TStringBuf delim, const TFirst& f, const TRest&... r) {
+ TString ret = ToString(f);
AppendJoin(ret, delim, r...);
return ret;
}
@@ -106,7 +106,7 @@ inline TString Join(const TStringBuf delim, const TFirst& f, const TRest&... r)
// but any char value @v will be printed as corresponding numeric code.
// For example, Join('a', 'a', 'a') will print "97a97" (see unit-test).
template <typename... TValues>
-inline TString Join(char cdelim, const TValues&... v) {
+inline TString Join(char cdelim, const TValues&... v) {
return Join(TStringBuf(&cdelim, 1), v...);
}
diff --git a/util/string/join_ut.cpp b/util/string/join_ut.cpp
index 3ed2b2459c..011b5eecbd 100644
--- a/util/string/join_ut.cpp
+++ b/util/string/join_ut.cpp
@@ -6,10 +6,10 @@
#include <util/stream/output.h>
struct TCustomData {
- TVector<int> Ints;
+ TVector<int> Ints;
};
-TString ToString(const TCustomData& d) {
+TString ToString(const TCustomData& d) {
return JoinSeq("__", d.Ints);
}
@@ -17,7 +17,7 @@ Y_UNIT_TEST_SUITE(JoinStringTest) {
Y_UNIT_TEST(ScalarItems) {
UNIT_ASSERT_EQUAL(Join(',', 10, 11.1, "foobar"), "10,11.1,foobar");
UNIT_ASSERT_EQUAL(Join(", ", 10, 11.1, "foobar"), "10, 11.1, foobar");
- UNIT_ASSERT_EQUAL(Join(", ", 10, 11.1, TString("foobar")), "10, 11.1, foobar");
+ UNIT_ASSERT_EQUAL(Join(", ", 10, 11.1, TString("foobar")), "10, 11.1, foobar");
UNIT_ASSERT_EQUAL(Join('#', 0, "a", "foobar", -1.4, TStringBuf("aaa")), "0#a#foobar#-1.4#aaa");
UNIT_ASSERT_EQUAL(Join("", "", ""), "");
@@ -28,7 +28,7 @@ Y_UNIT_TEST_SUITE(JoinStringTest) {
Y_UNIT_TEST(IntContainerItems) {
int v[] = {1, 2, 3};
- TVector<int> vv(v, v + 3);
+ TVector<int> vv(v, v + 3);
UNIT_ASSERT_EQUAL(JoinSeq(" ", vv), "1 2 3");
UNIT_ASSERT_EQUAL(JoinSeq(" ", vv), JoinRange(" ", vv.begin(), vv.end()));
UNIT_ASSERT_EQUAL(JoinRange(" ", v, v + 2), "1 2");
@@ -42,9 +42,9 @@ Y_UNIT_TEST_SUITE(JoinStringTest) {
// try various overloads and template type arguments
static const char* const result = "1 22 333";
static const char* const v[] = {"1", "22", "333"};
- TVector<const char*> vchar(v, v + sizeof(v) / sizeof(v[0]));
- TVector<TStringBuf> vbuf(v, v + sizeof(v) / sizeof(v[0]));
- TVector<TString> vstring(v, v + sizeof(v) / sizeof(v[0]));
+ TVector<const char*> vchar(v, v + sizeof(v) / sizeof(v[0]));
+ TVector<TStringBuf> vbuf(v, v + sizeof(v) / sizeof(v[0]));
+ TVector<TString> vstring(v, v + sizeof(v) / sizeof(v[0]));
// ranges
UNIT_ASSERT_EQUAL(JoinRange(" ", v, v + 3), result);
diff --git a/util/string/printf.cpp b/util/string/printf.cpp
index 5b7c34d4e1..8f90329950 100644
--- a/util/string/printf.cpp
+++ b/util/string/printf.cpp
@@ -3,13 +3,13 @@
#include <util/stream/printf.h>
#include <util/stream/str.h>
-int vsprintf(TString& s, const char* c, va_list params) {
+int vsprintf(TString& s, const char* c, va_list params) {
TStringOutput so(s.remove());
return Printf(so, c, params);
}
-int sprintf(TString& s, const char* c, ...) {
+int sprintf(TString& s, const char* c, ...) {
va_list params;
va_start(params, c);
const int k = vsprintf(s, c, params);
@@ -17,8 +17,8 @@ int sprintf(TString& s, const char* c, ...) {
return k;
}
-TString Sprintf(const char* c, ...) {
- TString s;
+TString Sprintf(const char* c, ...) {
+ TString s;
va_list params;
va_start(params, c);
vsprintf(s, c, params);
@@ -26,7 +26,7 @@ TString Sprintf(const char* c, ...) {
return s;
}
-int fcat(TString& s, const char* c, ...) {
+int fcat(TString& s, const char* c, ...) {
TStringOutput so(s);
va_list params;
diff --git a/util/string/printf.h b/util/string/printf.h
index 925c6edaff..1cd482ed2f 100644
--- a/util/string/printf.h
+++ b/util/string/printf.h
@@ -6,8 +6,8 @@
#include <cstdarg>
/// formatted print. return printed length:
-int Y_PRINTF_FORMAT(2, 0) vsprintf(TString& s, const char* c, va_list params);
+int Y_PRINTF_FORMAT(2, 0) vsprintf(TString& s, const char* c, va_list params);
/// formatted print. return printed length:
-int Y_PRINTF_FORMAT(2, 3) sprintf(TString& s, const char* c, ...);
-TString Y_PRINTF_FORMAT(1, 2) Sprintf(const char* c, ...);
-int Y_PRINTF_FORMAT(2, 3) fcat(TString& s, const char* c, ...);
+int Y_PRINTF_FORMAT(2, 3) sprintf(TString& s, const char* c, ...);
+TString Y_PRINTF_FORMAT(1, 2) Sprintf(const char* c, ...);
+int Y_PRINTF_FORMAT(2, 3) fcat(TString& s, const char* c, ...);
diff --git a/util/string/printf_ut.cpp b/util/string/printf_ut.cpp
index 2b2f980b70..49f02b3da1 100644
--- a/util/string/printf_ut.cpp
+++ b/util/string/printf_ut.cpp
@@ -4,19 +4,19 @@
Y_UNIT_TEST_SUITE(TStringPrintf) {
Y_UNIT_TEST(TestSprintf) {
- TString s;
+ TString s;
int len = sprintf(s, "Hello %s", "world");
- UNIT_ASSERT_EQUAL(s, TString("Hello world"));
+ UNIT_ASSERT_EQUAL(s, TString("Hello world"));
UNIT_ASSERT_EQUAL(len, 11);
}
Y_UNIT_TEST(TestFcat) {
- TString s;
+ TString s;
int len = sprintf(s, "Hello %s", "world");
- UNIT_ASSERT_EQUAL(s, TString("Hello world"));
+ UNIT_ASSERT_EQUAL(s, TString("Hello world"));
UNIT_ASSERT_EQUAL(len, 11);
len = fcat(s, " qwqw%s", "as");
- UNIT_ASSERT_EQUAL(s, TString("Hello world qwqwas"));
+ UNIT_ASSERT_EQUAL(s, TString("Hello world qwqwas"));
UNIT_ASSERT_EQUAL(len, 7);
}
diff --git a/util/string/split.cpp b/util/string/split.cpp
index 7d26857cc7..50099db18b 100644
--- a/util/string/split.cpp
+++ b/util/string/split.cpp
@@ -1,7 +1,7 @@
#include "split.h"
template <class TValue>
-inline size_t Split(const char* ptr, const char* delim, TVector<TValue>& values) {
+inline size_t Split(const char* ptr, const char* delim, TVector<TValue>& values) {
values.erase(values.begin(), values.end());
while (ptr && *ptr) {
ptr += strspn(ptr, delim);
@@ -15,10 +15,10 @@ inline size_t Split(const char* ptr, const char* delim, TVector<TValue>& values)
return values.size();
}
-size_t Split(const char* ptr, const char* delim, TVector<TString>& values) {
- return Split<TString>(ptr, delim, values);
+size_t Split(const char* ptr, const char* delim, TVector<TString>& values) {
+ return Split<TString>(ptr, delim, values);
}
-size_t Split(const TString& in, const TString& delim, TVector<TString>& res) {
+size_t Split(const TString& in, const TString& delim, TVector<TString>& res) {
return Split(in.data(), delim.data(), res);
}
diff --git a/util/string/split.h b/util/string/split.h
index bc46d9e64c..fd516336e1 100644
--- a/util/string/split.h
+++ b/util/string/split.h
@@ -9,7 +9,7 @@
#include <util/generic/iterator_range.h>
#include <util/generic/store_policy.h>
#include <util/generic/strbuf.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/typetraits.h>
#include <util/generic/vector.h>
#include <util/generic/ylimits.h>
@@ -72,7 +72,7 @@ SplitString(I b, const TDelim& d, TConsumer&& c) {
}
template <class I1, class I2>
-static inline I1* FastStrChr(I1* str, I2 f) noexcept {
+static inline I1* FastStrChr(I1* str, I2 f) noexcept {
I1* ret = NStringSplitPrivate::Find(str, f);
if (!ret) {
@@ -83,7 +83,7 @@ static inline I1* FastStrChr(I1* str, I2 f) noexcept {
}
template <class I>
-static inline I* FastStrStr(I* str, I* f, size_t l) noexcept {
+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);
@@ -283,7 +283,7 @@ struct TConsumerBackInserter<T, std::enable_if_t<!NSplitTargetHasPushBack::TClas
template <class T>
struct TContainerConsumer {
- inline TContainerConsumer(T* c) noexcept
+ inline TContainerConsumer(T* c) noexcept
: C(c)
{
}
@@ -300,7 +300,7 @@ struct TContainerConsumer {
template <class T>
struct TContainerConvertingConsumer {
- inline TContainerConvertingConsumer(T* c) noexcept
+ inline TContainerConvertingConsumer(T* c) noexcept
: C(c)
{
}
@@ -317,7 +317,7 @@ struct TContainerConvertingConsumer {
template <class S, class I>
struct TLimitingConsumer {
- inline TLimitingConsumer(size_t cnt, S* slave) noexcept
+ inline TLimitingConsumer(size_t cnt, S* slave) noexcept
: Cnt(cnt ? cnt - 1 : Max<size_t>())
, Slave(slave)
, Last(nullptr)
@@ -343,7 +343,7 @@ struct TLimitingConsumer {
template <class S>
struct TSkipEmptyTokens {
- inline TSkipEmptyTokens(S* slave) noexcept
+ inline TSkipEmptyTokens(S* slave) noexcept
: Slave(slave)
{
}
@@ -362,7 +362,7 @@ struct TSkipEmptyTokens {
template <class S>
struct TKeepDelimiters {
- inline TKeepDelimiters(S* slave) noexcept
+ inline TKeepDelimiters(S* slave) noexcept
: Slave(slave)
{
}
@@ -411,15 +411,15 @@ static inline void Split(char* buf, char ch, T* res) {
/// Old good slow split function.
/// Field delimter is any number of symbols specified in delim (no empty strings in res vector)
/// @return number of elements created
-size_t Split(const char* in, const char* delim, TVector<TString>& res);
-size_t Split(const TString& in, const TString& delim, TVector<TString>& res);
+size_t Split(const char* in, const char* delim, TVector<TString>& res);
+size_t Split(const TString& in, const TString& delim, TVector<TString>& res);
/// Old split reimplemented for TStringBuf using the new code
/// Note that delim can be constructed from char* automatically (it is not cheap though)
-inline size_t Split(const TStringBuf s, const TSetDelimiter<const char>& delim, TVector<TStringBuf>& res) {
+inline size_t Split(const TStringBuf s, const TSetDelimiter<const char>& delim, TVector<TStringBuf>& res) {
res.clear();
- TContainerConsumer<TVector<TStringBuf>> res1(&res);
- TSkipEmptyTokens<TContainerConsumer<TVector<TStringBuf>>> consumer(&res1);
+ TContainerConsumer<TVector<TStringBuf>> res1(&res);
+ TSkipEmptyTokens<TContainerConsumer<TVector<TStringBuf>>> consumer(&res1);
SplitString(s.data(), s.data() + s.size(), delim, consumer);
return res.size();
}
diff --git a/util/string/split_ut.cpp b/util/string/split_ut.cpp
index 43e59f2d75..01996e621b 100644
--- a/util/string/split_ut.cpp
+++ b/util/string/split_ut.cpp
@@ -95,35 +95,35 @@ void TestConsumerOnRange(TResult& good, I* b, I* e, I* d) {
UNIT_ASSERT_EQUAL(good, test);
}
-using TStrokaConsumer = TContainerConsumer<TVector<TString>>;
+using TStrokaConsumer = TContainerConsumer<TVector<TString>>;
-void TestLimitingConsumerOnString(TVector<TString>& good, const char* str, const char* d, size_t n, const char* last) {
- TVector<TString> test;
+void TestLimitingConsumerOnString(TVector<TString>& good, const char* str, const char* d, size_t n, const char* last) {
+ TVector<TString> test;
TStrokaConsumer consumer(&test);
TLimitingConsumer<TStrokaConsumer, const char> limits(n, &consumer);
TCharDelimiter<const char> delim(*d);
SplitString(str, delim, limits);
Cmp(good, test);
UNIT_ASSERT_EQUAL(good, test);
- UNIT_ASSERT_EQUAL(TString(limits.Last), TString(last)); // Quite unobvious behaviour. Why the last token is not added to slave consumer?
+ UNIT_ASSERT_EQUAL(TString(limits.Last), TString(last)); // Quite unobvious behaviour. Why the last token is not added to slave consumer?
}
-void TestLimitingConsumerOnRange(TVector<TString>& good, const char* b, const char* e, const char* d, size_t n, const char* last) {
- TVector<TString> test;
+void TestLimitingConsumerOnRange(TVector<TString>& good, const char* b, const char* e, const char* d, size_t n, const char* last) {
+ TVector<TString> test;
TStrokaConsumer consumer(&test);
TLimitingConsumer<TStrokaConsumer, const char> limits(n, &consumer);
TCharDelimiter<const char> delim(*d);
SplitString(b, e, delim, limits);
Cmp(good, test);
UNIT_ASSERT_EQUAL(good, test);
- UNIT_ASSERT_EQUAL(TString(limits.Last), TString(last));
+ UNIT_ASSERT_EQUAL(TString(limits.Last), TString(last));
}
Y_UNIT_TEST_SUITE(SplitStringTest) {
Y_UNIT_TEST(TestCharSingleDelimiter) {
- TString data("qw ab qwabcab");
- TString canonic[] = {"qw", "ab", "", "qwabcab"};
- TVector<TString> good(canonic, canonic + 4);
+ TString data("qw ab qwabcab");
+ TString canonic[] = {"qw", "ab", "", "qwabcab"};
+ TVector<TString> good(canonic, canonic + 4);
TCharDelimiter<const char> delim(' ');
TestDelimiterOnString<TContainerConsumer>(good, data.data(), delim);
@@ -133,7 +133,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
Y_UNIT_TEST(TestWideSingleDelimiter) {
TUtf16String data(u"qw ab qwabcab");
TUtf16String canonic[] = {u"qw", u"ab", TUtf16String(), u"qwabcab"};
- TVector<TUtf16String> good(canonic, canonic + 4);
+ TVector<TUtf16String> good(canonic, canonic + 4);
TCharDelimiter<const wchar16> delim(' ');
TestDelimiterOnString<TContainerConsumer>(good, data.data(), delim);
@@ -141,9 +141,9 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
}
Y_UNIT_TEST(TestConvertToIntCharSingleDelimiter) {
- TString data("42 4242 -12345 0");
+ TString data("42 4242 -12345 0");
i32 canonic[] = {42, 4242, -12345, 0};
- TVector<i32> good(canonic, canonic + 4);
+ TVector<i32> good(canonic, canonic + 4);
TCharDelimiter<const char> delim(' ');
TestDelimiterOnString<TContainerConvertingConsumer>(good, data.data(), delim);
@@ -151,36 +151,36 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
}
Y_UNIT_TEST(TestCharSkipEmpty) {
- TString data("qw ab qwabcab ");
- TString canonic[] = {"qw", "ab", "qwabcab"};
- TVector<TString> good(canonic, canonic + 3);
+ TString data("qw ab qwabcab ");
+ TString canonic[] = {"qw", "ab", "qwabcab"};
+ TVector<TString> good(canonic, canonic + 3);
TestConsumerOnString<TSkipEmptyTokens<TStrokaConsumer>>(good, data.data(), " ");
TestConsumerOnRange<TSkipEmptyTokens<TStrokaConsumer>>(good, data.data(), data.end(), " ");
}
Y_UNIT_TEST(TestCharKeepDelimiters) {
- TString data("qw ab qwabcab ");
- TString canonic[] = {"qw", " ", "ab", " ", "", " ", "qwabcab", " ", ""};
- TVector<TString> good(canonic, canonic + 9);
+ TString data("qw ab qwabcab ");
+ TString canonic[] = {"qw", " ", "ab", " ", "", " ", "qwabcab", " ", ""};
+ TVector<TString> good(canonic, canonic + 9);
TestConsumerOnString<TKeepDelimiters<TStrokaConsumer>>(good, data.data(), " ");
TestConsumerOnRange<TKeepDelimiters<TStrokaConsumer>>(good, data.data(), data.end(), " ");
}
Y_UNIT_TEST(TestCharLimit) {
- TString data("qw ab qwabcab ");
- TString canonic[] = {"qw", "ab"};
- TVector<TString> good(canonic, canonic + 2);
+ TString data("qw ab qwabcab ");
+ TString canonic[] = {"qw", "ab"};
+ TVector<TString> good(canonic, canonic + 2);
TestLimitingConsumerOnString(good, data.data(), " ", 3, " qwabcab ");
TestLimitingConsumerOnRange(good, data.data(), data.end(), " ", 3, " qwabcab ");
}
Y_UNIT_TEST(TestCharStringDelimiter) {
- TString data("qw ab qwababcab");
- TString canonic[] = {"qw ", " qw", "", "c", ""};
- TVector<TString> good(canonic, canonic + 5);
+ TString data("qw ab qwababcab");
+ TString canonic[] = {"qw ", " qw", "", "c", ""};
+ TVector<TString> good(canonic, canonic + 5);
TStringDelimiter<const char> delim("ab");
TestDelimiterOnString<TContainerConsumer>(good, data.data(), delim);
@@ -190,7 +190,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
Y_UNIT_TEST(TestWideStringDelimiter) {
TUtf16String data(u"qw ab qwababcab");
TUtf16String canonic[] = {u"qw ", u" qw", TUtf16String(), u"c", TUtf16String()};
- TVector<TUtf16String> good(canonic, canonic + 5);
+ TVector<TUtf16String> good(canonic, canonic + 5);
TUtf16String wideDelim(u"ab");
TStringDelimiter<const wchar16> delim(wideDelim.data());
@@ -199,9 +199,9 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
}
Y_UNIT_TEST(TestCharSetDelimiter) {
- TString data("qw ab qwababccab");
- TString canonic[] = {"q", " ab q", "abab", "", "ab"};
- TVector<TString> good(canonic, canonic + 5);
+ TString data("qw ab qwababccab");
+ TString canonic[] = {"q", " ab q", "abab", "", "ab"};
+ TVector<TString> good(canonic, canonic + 5);
TSetDelimiter<const char> delim("wc");
TestDelimiterOnString<TContainerConsumer>(good, data.data(), delim);
@@ -211,7 +211,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
Y_UNIT_TEST(TestWideSetDelimiter) {
TUtf16String data(u"qw ab qwababccab");
TUtf16String canonic[] = {u"q", u" ab q", u"abab", TUtf16String(), u"ab"};
- TVector<TUtf16String> good(canonic, canonic + 5);
+ TVector<TUtf16String> good(canonic, canonic + 5);
TUtf16String wideDelim(u"wc");
TSetDelimiter<const wchar16> delim(wideDelim.data());
@@ -221,17 +221,17 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
Y_UNIT_TEST(TestWideSetDelimiterRange) {
TUtf16String data(u"qw ab qwababccab");
TUtf16String canonic[] = {u"q", u" ab q", u"abab", TUtf16String(), u"ab"};
- TVector<TUtf16String> good(1);
+ TVector<TUtf16String> good(1);
TUtf16String wideDelim(u"wc");
TSetDelimiter<const wchar16> delim(wideDelim.data());
- TVector<TUtf16String> test;
- TContainerConsumer<TVector<TUtf16String>> consumer(&test);
+ TVector<TUtf16String> test;
+ TContainerConsumer<TVector<TUtf16String>> consumer(&test);
SplitString(data.data(), data.data(), delim, consumer); // Empty string is still inserted into consumer
Cmp(good, test);
good.assign(canonic, canonic + 4);
- good.push_back(TUtf16String());
+ good.push_back(TUtf16String());
test.clear();
SplitString(data.data(), data.end() - 2, delim, consumer);
Cmp(good, test);
@@ -239,21 +239,21 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
Y_UNIT_TEST(TestSplit) {
TString data("qw ab qwababcba");
- TString canonic[] = {"qw ", " qw", "c"};
- TVector<TString> good(canonic, canonic + 3);
- TString delim = "ab";
- TVector<TString> test;
+ TString canonic[] = {"qw ", " qw", "c"};
+ TVector<TString> good(canonic, canonic + 3);
+ TString delim = "ab";
+ TVector<TString> test;
Split(data, delim, test);
Cmp(good, test);
- TVector<TStringBuf> test1;
+ TVector<TStringBuf> test1;
Split(data, delim.data(), test1);
Cmp(good, test1);
}
Y_UNIT_TEST(ConvenientSplitTest) {
- TString data("abc 22 33.5 xyz");
- TString str;
+ TString data("abc 22 33.5 xyz");
+ TString str;
int num1 = 0;
double num2 = 0;
TStringBuf strBuf;
@@ -265,8 +265,8 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
}
Y_UNIT_TEST(ConvenientSplitTestWithMaybe) {
- TString data("abc 42");
- TString str;
+ TString data("abc 42");
+ TString str;
TMaybe<double> num2 = 1;
TMaybe<double> maybe = 1;
@@ -278,8 +278,8 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
}
Y_UNIT_TEST(ConvenientSplitTestExceptions) {
- TString data("abc 22 33");
- TString s1, s2, s3, s4;
+ TString data("abc 22 33");
+ TString s1, s2, s3, s4;
UNIT_ASSERT_EXCEPTION(Split(data, ' ', s1, s2), yexception);
UNIT_ASSERT_NO_EXCEPTION(Split(data, ' ', s1, s2, s3));
@@ -287,9 +287,9 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
}
Y_UNIT_TEST(ConvenientSplitTestMaybeExceptions) {
- TString data("abc 22 33");
- TString s1, s2;
- TMaybe<TString> m1, m2;
+ TString data("abc 22 33");
+ TString s1, s2;
+ TMaybe<TString> m1, m2;
UNIT_ASSERT_EXCEPTION(Split(data, ' ', s1, m1), yexception);
UNIT_ASSERT_EXCEPTION(Split(data, ' ', m1, m2), yexception);
diff --git a/util/string/strip.cpp b/util/string/strip.cpp
index c921571cf0..0765806359 100644
--- a/util/string/strip.cpp
+++ b/util/string/strip.cpp
@@ -3,11 +3,11 @@
#include <util/string/reverse.h>
-bool Collapse(const TString& from, TString& to, size_t maxLen) {
- return CollapseImpl<TString, bool (*)(unsigned char)>(from, to, maxLen, IsAsciiSpace);
+bool Collapse(const TString& from, TString& to, size_t maxLen) {
+ return CollapseImpl<TString, bool (*)(unsigned char)>(from, to, maxLen, IsAsciiSpace);
}
-void CollapseText(const TString& from, TString& to, size_t maxLen) {
+void CollapseText(const TString& from, TString& to, size_t maxLen) {
Collapse(from, to, maxLen);
StripInPlace(to);
if (to.size() >= maxLen) {
diff --git a/util/string/strip.h b/util/string/strip.h
index d5ef6da96d..6b9e179b70 100644
--- a/util/string/strip.h
+++ b/util/string/strip.h
@@ -2,13 +2,13 @@
#include "ascii.h"
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/strbuf.h>
#include <utility>
template <class It>
struct TIsAsciiSpaceAdapter {
- bool operator()(const It& it) const noexcept {
+ bool operator()(const It& it) const noexcept {
return IsAsciiSpace(*it);
}
};
@@ -26,7 +26,7 @@ struct TEqualsStripAdapter {
}
template <class It>
- bool operator()(const It& it) const noexcept {
+ bool operator()(const It& it) const noexcept {
return *it == Ch;
}
@@ -39,33 +39,33 @@ TEqualsStripAdapter<TChar> EqualsStripAdapter(TChar ch) {
}
template <class It, class TStripCriterion>
-inline void StripRangeBegin(It& b, const It& e, TStripCriterion&& criterion) noexcept {
+inline void StripRangeBegin(It& b, const It& e, TStripCriterion&& criterion) noexcept {
while (b < e && criterion(b)) {
++b;
}
}
template <class It>
-inline void StripRangeBegin(It& b, const It& e) noexcept {
+inline void StripRangeBegin(It& b, const It& e) noexcept {
StripRangeBegin(b, e, IsAsciiSpaceAdapter(b));
}
template <class It, class TStripCriterion>
-inline void StripRangeEnd(const It& b, It& e, TStripCriterion&& criterion) noexcept {
+inline void StripRangeEnd(const It& b, It& e, TStripCriterion&& criterion) noexcept {
while (b < e && criterion(e - 1)) {
--e;
}
}
template <class It>
-inline void StripRangeEnd(const It& b, It& e) noexcept {
+inline void StripRangeEnd(const It& b, It& e) noexcept {
StripRangeEnd(b, e, IsAsciiSpaceAdapter(b));
}
template <bool stripBeg, bool stripEnd>
struct TStripImpl {
template <class It, class TStripCriterion>
- static inline bool StripRange(It& b, It& e, TStripCriterion&& criterion) noexcept {
+ static inline bool StripRange(It& b, It& e, TStripCriterion&& criterion) noexcept {
const size_t oldLen = e - b;
if (stripBeg) {
@@ -110,17 +110,17 @@ struct TStripImpl {
};
template <class It, class TStripCriterion>
-inline bool StripRange(It& b, It& e, TStripCriterion&& criterion) noexcept {
+inline bool StripRange(It& b, It& e, TStripCriterion&& criterion) noexcept {
return TStripImpl<true, true>::StripRange(b, e, criterion);
}
template <class It>
-inline bool StripRange(It& b, It& e) noexcept {
+inline bool StripRange(It& b, It& e) noexcept {
return StripRange(b, e, IsAsciiSpaceAdapter(b));
}
template <class It, class TStripCriterion>
-inline bool Strip(It& b, size_t& len, TStripCriterion&& criterion) noexcept {
+inline bool Strip(It& b, size_t& len, TStripCriterion&& criterion) noexcept {
It e = b + len;
if (StripRange(b, e, criterion)) {
@@ -133,7 +133,7 @@ inline bool Strip(It& b, size_t& len, TStripCriterion&& criterion) noexcept {
}
template <class It>
-inline bool Strip(It& b, size_t& len) noexcept {
+inline bool Strip(It& b, size_t& len) noexcept {
return Strip(b, len, IsAsciiSpaceAdapter(b));
}
@@ -178,7 +178,7 @@ static inline T StripStringRight(const T& from, TStripCriterion&& criterion) {
}
/// Copies the given string removing leading and trailing spaces.
-static inline bool Strip(const TString& from, TString& to) {
+static inline bool Strip(const TString& from, TString& to) {
return StripString(from, to);
}
@@ -189,9 +189,9 @@ inline TString& StripInPlace(TString& s) {
}
/// Returns a copy of the given string with removed leading and trailing spaces.
-inline TString Strip(const TString& s) Y_WARN_UNUSED_RESULT;
-inline TString Strip(const TString& s) {
- TString ret = s;
+inline TString Strip(const TString& s) Y_WARN_UNUSED_RESULT;
+inline TString Strip(const TString& s) {
+ TString ret = s;
Strip(ret, ret);
return ret;
}
@@ -215,8 +215,8 @@ size_t CollapseImpl(TChar* s, size_t n, const TWhitespaceFunc& isWhitespace) {
return newLen;
}
-template <class TStringType, class TWhitespaceFunc>
-bool CollapseImpl(const TStringType& from, TStringType& to, size_t maxLen, const TWhitespaceFunc& isWhitespace) {
+template <class TStringType, class TWhitespaceFunc>
+bool CollapseImpl(const TStringType& from, TStringType& to, size_t maxLen, const TWhitespaceFunc& isWhitespace) {
to = from;
maxLen = maxLen ? Min(maxLen, to.size()) : to.size();
for (size_t i = 0; i < maxLen; ++i) {
@@ -230,7 +230,7 @@ bool CollapseImpl(const TStringType& from, TStringType& to, size_t maxLen, const
return false;
}
-bool Collapse(const TString& from, TString& to, size_t maxLen = 0);
+bool Collapse(const TString& from, TString& to, size_t maxLen = 0);
/// Replaces several consequtive space symbols with one (processing is limited to maxLen bytes)
inline TString& CollapseInPlace(TString& s, size_t maxLen = 0) {
@@ -241,17 +241,17 @@ inline TString& CollapseInPlace(TString& s, size_t maxLen = 0) {
/// Replaces several consequtive space symbols with one (processing is limited to maxLen bytes)
inline TString Collapse(const TString& s, size_t maxLen = 0) Y_WARN_UNUSED_RESULT;
inline TString Collapse(const TString& s, size_t maxLen) {
- TString ret;
+ TString ret;
Collapse(s, ret, maxLen);
return ret;
}
-void CollapseText(const TString& from, TString& to, size_t maxLen);
+void CollapseText(const TString& from, TString& to, size_t maxLen);
/// The same as Collapse() + truncates the string to maxLen.
/// @details An ellipsis is inserted at the end of the truncated line.
-inline void CollapseText(TString& s, size_t maxLen) {
- TString to;
+inline void CollapseText(TString& s, size_t maxLen) {
+ TString to;
CollapseText(s, to, maxLen);
s = to;
}
diff --git a/util/string/strip_ut.cpp b/util/string/strip_ut.cpp
index d1029d1498..83bfe73a87 100644
--- a/util/string/strip_ut.cpp
+++ b/util/string/strip_ut.cpp
@@ -27,9 +27,9 @@ Y_UNIT_TEST_SUITE(TStripStringTest) {
};
for (const auto& test : tests) {
- TString inputStr(test.Str);
+ TString inputStr(test.Str);
- TString s;
+ TString s;
Strip(inputStr, s);
UNIT_ASSERT_EQUAL(s, test.StripRes);
@@ -58,7 +58,7 @@ Y_UNIT_TEST_SUITE(TStripStringTest) {
for (auto test : tests) {
UNIT_ASSERT_EQUAL(
- StripString(TString(test.Str), EqualsStripAdapter('/')),
+ StripString(TString(test.Str), EqualsStripAdapter('/')),
test.Result);
};
}
@@ -78,10 +78,10 @@ Y_UNIT_TEST_SUITE(TStripStringTest) {
for (const auto& test : tests) {
UNIT_ASSERT_EQUAL(
- StripStringLeft(TString(test.Str), EqualsStripAdapter('/')),
+ StripStringLeft(TString(test.Str), EqualsStripAdapter('/')),
test.ResultLeft);
UNIT_ASSERT_EQUAL(
- StripStringRight(TString(test.Str), EqualsStripAdapter('/')),
+ StripStringRight(TString(test.Str), EqualsStripAdapter('/')),
test.ResultRight);
};
}
@@ -90,7 +90,7 @@ Y_UNIT_TEST_SUITE(TStripStringTest) {
TStringBuf nullString(nullptr, nullptr);
UNIT_ASSERT_EQUAL(
StripString(nullString),
- TString());
+ TString());
}
Y_UNIT_TEST(TestWtrokaStrip) {
@@ -108,14 +108,14 @@ Y_UNIT_TEST_SUITE(TStripStringTest) {
}
Y_UNIT_TEST(TestCollapse) {
- TString s;
- Collapse(TString(" 123 456 "), s);
+ TString s;
+ Collapse(TString(" 123 456 "), s);
UNIT_ASSERT(s == " 123 456 ");
- Collapse(TString(" 123 456 "), s, 10);
+ Collapse(TString(" 123 456 "), s, 10);
UNIT_ASSERT(s == " 123 456 ");
- s = TString(" a b c ");
- TString s2 = s;
+ s = TString(" a b c ");
+ TString s2 = s;
CollapseInPlace(s2);
UNIT_ASSERT(s == s2);
@@ -125,9 +125,9 @@ Y_UNIT_TEST_SUITE(TStripStringTest) {
}
Y_UNIT_TEST(TestCollapseText) {
- TString abs1("Very long description string written in unknown language.");
- TString abs2(abs1);
- TString abs3(abs1);
+ TString abs1("Very long description string written in unknown language.");
+ TString abs2(abs1);
+ TString abs3(abs1);
CollapseText(abs1, 204);
CollapseText(abs2, 54);
CollapseText(abs3, 49);
diff --git a/util/string/strspn.h b/util/string/strspn.h
index 8229e74a9c..c5bce7be46 100644
--- a/util/string/strspn.h
+++ b/util/string/strspn.h
@@ -4,7 +4,7 @@
#include <util/generic/bitmap.h>
-template <class TSetType>
+template <class TSetType>
class TStrSpnImpl {
public:
inline TStrSpnImpl(const char* b, const char* e) {
@@ -17,33 +17,33 @@ public:
//FirstOf
template <class It>
- inline It FindFirstOf(It b, const char* e) const noexcept {
+ inline It FindFirstOf(It b, const char* e) const noexcept {
return FindFirst<false>(b, e);
}
template <class It>
- inline It FindFirstOf(It s) const noexcept {
+ inline It FindFirstOf(It s) const noexcept {
return FindFirst<false>(s, TCStringEndIterator());
}
//FirstNotOf
template <class It>
- inline It FindFirstNotOf(It b, const char* e) const noexcept {
+ inline It FindFirstNotOf(It b, const char* e) const noexcept {
return FindFirst<true>(b, e);
}
template <class It>
- inline It FindFirstNotOf(It s) const noexcept {
+ inline It FindFirstNotOf(It s) const noexcept {
return FindFirst<true>(s, TCStringEndIterator());
}
- inline void Set(ui8 b) noexcept {
+ inline void Set(ui8 b) noexcept {
S_.Set(b);
}
private:
template <bool Result, class It1, class It2>
- inline It1 FindFirst(It1 b, It2 e) const noexcept {
+ inline It1 FindFirst(It1 b, It2 e) const noexcept {
while (b != e && (S_.Get((ui8)*b) == Result)) {
++b;
}
@@ -59,7 +59,7 @@ private:
}
private:
- TSetType S_;
+ TSetType S_;
};
using TCompactStrSpn = TStrSpnImpl<TBitMap<256>>;
diff --git a/util/string/subst.h b/util/string/subst.h
index 45b622fbef..8855e818fa 100644
--- a/util/string/subst.h
+++ b/util/string/subst.h
@@ -36,21 +36,21 @@ size_t SubstGlobal(TUtf32String& text, wchar32 what, wchar32 with, size_t from =
// TODO(yazevnul):
// - rename `SubstGlobal` to `ReplaceAll` for convenience
-// - add `SubstGlobalCopy(TStringBuf)` for convenience
+// - add `SubstGlobalCopy(TStringBuf)` for convenience
// - add `RemoveAll(text, what, from)` as a shortcut for `SubstGlobal(text, what, "", from)`
// - rename file to `replace.h`
-
-/* Replace all occurences of substring or character `what` with string or character `with` starting from position `from`, and return result string.
- *
- * @param text String to modify.
- * @param what Substring/character to replace.
- * @param with Substring/character to use as replacement.
- * @param from Position at with to start replacement.
- *
- * @return Result string
- */
-template <class TStringType, class TPatternType>
+
+/* Replace all occurences of substring or character `what` with string or character `with` starting from position `from`, and return result string.
+ *
+ * @param text String to modify.
+ * @param what Substring/character to replace.
+ * @param with Substring/character to use as replacement.
+ * @param from Position at with to start replacement.
+ *
+ * @return Result string
+ */
+template <class TStringType, class TPatternType>
Y_WARN_UNUSED_RESULT TStringType SubstGlobalCopy(TStringType result, TPatternType what, TPatternType with, size_t from = 0) {
- SubstGlobal(result, what, with, from);
- return result;
-}
+ SubstGlobal(result, what, with, from);
+ return result;
+}
diff --git a/util/string/subst_ut.cpp b/util/string/subst_ut.cpp
index 21eccef779..e1e76a82fe 100644
--- a/util/string/subst_ut.cpp
+++ b/util/string/subst_ut.cpp
@@ -6,11 +6,11 @@
Y_UNIT_TEST_SUITE(TStringSubst) {
static const size_t MIN_FROM_CTX = 4;
- static const TVector<TString> ALL_FROM{TString("F"), TString("FF")};
- static const TVector<TString> ALL_TO{TString(""), TString("T"), TString("TT"), TString("TTT")};
+ static const TVector<TString> ALL_FROM{TString("F"), TString("FF")};
+ static const TVector<TString> ALL_TO{TString(""), TString("T"), TString("TT"), TString("TTT")};
- static void AssertSubstGlobal(const TString& sFrom, const TString& sTo, const TString& from, const TString& to, const size_t fromPos, const size_t numSubst) {
- TString s = sFrom;
+ static void AssertSubstGlobal(const TString& sFrom, const TString& sTo, const TString& from, const TString& to, const size_t fromPos, const size_t numSubst) {
+ TString s = sFrom;
size_t res = SubstGlobal(s, from, to, fromPos);
UNIT_ASSERT_VALUES_EQUAL_C(res, numSubst,
TStringBuilder() << "numSubst=" << numSubst << ", fromPos=" << fromPos << ", " << sFrom << " -> " << sTo);
@@ -31,7 +31,7 @@ Y_UNIT_TEST_SUITE(TStringSubst) {
const size_t maxSz = fromSz + MIN_FROM_CTX;
for (size_t sz = minSz; sz <= maxSz; ++sz) {
for (size_t fromPos = 0; fromPos < sz; ++fromPos) {
- TString s{sz, '.'};
+ TString s{sz, '.'};
for (const auto& to : ALL_TO) {
AssertSubstGlobal(s, s, from, to, fromPos, 0);
}
@@ -49,9 +49,9 @@ Y_UNIT_TEST_SUITE(TStringSubst) {
for (size_t fromPos = 0; fromPos <= sz - fromSz; ++fromPos) {
for (size_t fromBeg = 0; fromBeg < fromPos; ++fromBeg) {
const auto parts = {
- TString{fromBeg, '.'},
- TString{sz - fromSz - fromBeg, '.'}};
- TString s = JoinSeq(from, parts);
+ TString{fromBeg, '.'},
+ TString{sz - fromSz - fromBeg, '.'}};
+ TString s = JoinSeq(from, parts);
for (const auto& to : ALL_TO) {
AssertSubstGlobal(s, s, from, to, fromPos, 0);
}
@@ -62,7 +62,7 @@ Y_UNIT_TEST_SUITE(TStringSubst) {
}
static void DoTestSubstGlobal(TVector<TString>& parts, const size_t minBeg, const size_t sz,
- const TString& from, const size_t fromPos, const size_t numSubst) {
+ const TString& from, const size_t fromPos, const size_t numSubst) {
const size_t numLeft = numSubst - parts.size();
for (size_t fromBeg = minBeg; fromBeg <= sz - numLeft * from.size(); ++fromBeg) {
if (parts.empty()) {
@@ -73,10 +73,10 @@ Y_UNIT_TEST_SUITE(TStringSubst) {
if (numLeft == 1) {
parts.emplace_back(sz - fromBeg - from.size(), '.');
- TString sFrom = JoinSeq(from, parts);
+ TString sFrom = JoinSeq(from, parts);
UNIT_ASSERT_VALUES_EQUAL_C(sFrom.size(), sz, sFrom);
for (const auto& to : ALL_TO) {
- TString sTo = JoinSeq(to, parts);
+ TString sTo = JoinSeq(to, parts);
AssertSubstGlobal(sFrom, sTo, from, to, fromPos, numSubst);
}
parts.pop_back();
@@ -89,7 +89,7 @@ Y_UNIT_TEST_SUITE(TStringSubst) {
}
static void DoTestSubstGlobal(size_t numSubst) {
- TVector<TString> parts;
+ TVector<TString> parts;
for (const auto& from : ALL_FROM) {
const size_t fromSz = from.size();
const size_t minSz = numSubst * fromSz;
@@ -120,132 +120,132 @@ Y_UNIT_TEST_SUITE(TStringSubst) {
}
Y_UNIT_TEST(TestSubstGlobalOld) {
- TString s;
+ TString s;
s = "aaa";
SubstGlobal(s, "a", "bb");
- UNIT_ASSERT_EQUAL(s, TString("bbbbbb"));
+ UNIT_ASSERT_EQUAL(s, TString("bbbbbb"));
s = "aaa";
SubstGlobal(s, "a", "b");
- UNIT_ASSERT_EQUAL(s, TString("bbb"));
+ UNIT_ASSERT_EQUAL(s, TString("bbb"));
s = "aaa";
SubstGlobal(s, "a", "");
- UNIT_ASSERT_EQUAL(s, TString(""));
+ UNIT_ASSERT_EQUAL(s, TString(""));
s = "abcdefbcbcdfb";
SubstGlobal(s, "bc", "bbc", 2);
- UNIT_ASSERT_EQUAL(s, TString("abcdefbbcbbcdfb"));
+ UNIT_ASSERT_EQUAL(s, TString("abcdefbbcbbcdfb"));
s = "Москва ~ Париж";
SubstGlobal(s, " ~ ", " ");
UNIT_ASSERT_EQUAL(s, TString("Москва Париж"));
}
- Y_UNIT_TEST(TestSubstGlobalOldRet) {
- const TString s1 = "aaa";
- const TString s2 = SubstGlobalCopy(s1, "a", "bb");
- UNIT_ASSERT_EQUAL(s2, TString("bbbbbb"));
-
- const TString s3 = "aaa";
- const TString s4 = SubstGlobalCopy(s3, "a", "b");
- UNIT_ASSERT_EQUAL(s4, TString("bbb"));
-
- const TString s5 = "aaa";
- const TString s6 = SubstGlobalCopy(s5, "a", "");
- UNIT_ASSERT_EQUAL(s6, TString(""));
-
- const TString s7 = "abcdefbcbcdfb";
- const TString s8 = SubstGlobalCopy(s7, "bc", "bbc", 2);
- UNIT_ASSERT_EQUAL(s8, TString("abcdefbbcbbcdfb"));
-
- const TString s9 = "Москва ~ Париж";
- const TString s10 = SubstGlobalCopy(s9, " ~ ", " ");
- UNIT_ASSERT_EQUAL(s10, TString("Москва Париж"));
- }
-
+ Y_UNIT_TEST(TestSubstGlobalOldRet) {
+ const TString s1 = "aaa";
+ const TString s2 = SubstGlobalCopy(s1, "a", "bb");
+ UNIT_ASSERT_EQUAL(s2, TString("bbbbbb"));
+
+ const TString s3 = "aaa";
+ const TString s4 = SubstGlobalCopy(s3, "a", "b");
+ UNIT_ASSERT_EQUAL(s4, TString("bbb"));
+
+ const TString s5 = "aaa";
+ const TString s6 = SubstGlobalCopy(s5, "a", "");
+ UNIT_ASSERT_EQUAL(s6, TString(""));
+
+ const TString s7 = "abcdefbcbcdfb";
+ const TString s8 = SubstGlobalCopy(s7, "bc", "bbc", 2);
+ UNIT_ASSERT_EQUAL(s8, TString("abcdefbbcbbcdfb"));
+
+ const TString s9 = "Москва ~ Париж";
+ const TString s10 = SubstGlobalCopy(s9, " ~ ", " ");
+ UNIT_ASSERT_EQUAL(s10, TString("Москва Париж"));
+ }
+
Y_UNIT_TEST(TestSubstCharGlobal) {
TUtf16String w = u"abcdabcd";
SubstGlobal(w, wchar16('b'), wchar16('B'), 3);
UNIT_ASSERT_EQUAL(w, u"abcdaBcd");
- TString s = "aaa";
+ TString s = "aaa";
SubstGlobal(s, 'a', 'b', 1);
- UNIT_ASSERT_EQUAL(s, TString("abb"));
+ UNIT_ASSERT_EQUAL(s, TString("abb"));
}
- Y_UNIT_TEST(TestSubstCharGlobalRet) {
+ Y_UNIT_TEST(TestSubstCharGlobalRet) {
const TUtf16String w1 = u"abcdabcd";
const TUtf16String w2 = SubstGlobalCopy(w1, wchar16('b'), wchar16('B'), 3);
UNIT_ASSERT_EQUAL(w2, u"abcdaBcd");
-
- const TString s1 = "aaa";
- const TString s2 = SubstGlobalCopy(s1, 'a', 'b', 1);
- UNIT_ASSERT_EQUAL(s2, TString("abb"));
- }
-
+
+ const TString s1 = "aaa";
+ const TString s2 = SubstGlobalCopy(s1, 'a', 'b', 1);
+ UNIT_ASSERT_EQUAL(s2, TString("abb"));
+ }
+
Y_UNIT_TEST(TestSubstStdString) {
std::string s = "aaa";
SubstGlobal(s, "a", "b", 1);
UNIT_ASSERT_EQUAL(s, "abb");
}
- Y_UNIT_TEST(TestSubstStdStringRet) {
- const std::string s1 = "aaa";
- const std::string s2 = SubstGlobalCopy(s1, "a", "b", 1);
- UNIT_ASSERT_EQUAL(s2, "abb");
- }
-
+ Y_UNIT_TEST(TestSubstStdStringRet) {
+ const std::string s1 = "aaa";
+ const std::string s2 = SubstGlobalCopy(s1, "a", "b", 1);
+ UNIT_ASSERT_EQUAL(s2, "abb");
+ }
+
Y_UNIT_TEST(TestSubstGlobalChar) {
{
- const TString s = "a";
- const TString st = "b";
- TString ss = s;
+ const TString s = "a";
+ const TString st = "b";
+ TString ss = s;
UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b'));
UNIT_ASSERT_VALUES_EQUAL(st, ss);
}
{
- const TString s = "aa";
- const TString st = "bb";
- TString ss = s;
+ const TString s = "aa";
+ const TString st = "bb";
+ TString ss = s;
UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b'));
UNIT_ASSERT_VALUES_EQUAL(st, ss);
}
{
- const TString s = "aaa";
- const TString st = "bbb";
- TString ss = s;
+ const TString s = "aaa";
+ const TString st = "bbb";
+ TString ss = s;
UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b'));
UNIT_ASSERT_VALUES_EQUAL(st, ss);
}
{
- const TString s = "aaaa";
- const TString st = "bbbb";
- TString ss = s;
+ const TString s = "aaaa";
+ const TString st = "bbbb";
+ TString ss = s;
UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b'));
UNIT_ASSERT_VALUES_EQUAL(st, ss);
}
{
- const TString s = "aaaaa";
- const TString st = "bbbbb";
- TString ss = s;
+ const TString s = "aaaaa";
+ const TString st = "bbbbb";
+ TString ss = s;
UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b'));
UNIT_ASSERT_VALUES_EQUAL(st, ss);
}
{
- const TString s = "aaaaaa";
- const TString st = "bbbbbb";
- TString ss = s;
+ const TString s = "aaaaaa";
+ const TString st = "bbbbbb";
+ TString ss = s;
UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b'));
UNIT_ASSERT_VALUES_EQUAL(st, ss);
}
{
- const TString s = "aaaaaaa";
- const TString st = "bbbbbbb";
- TString ss = s;
+ const TString s = "aaaaaaa";
+ const TString st = "bbbbbbb";
+ TString ss = s;
UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b'));
UNIT_ASSERT_VALUES_EQUAL(st, ss);
}
{
- const TString s = "aaaaaaaa";
- const TString st = "bbbbbbbb";
- TString ss = s;
+ const TString s = "aaaaaaaa";
+ const TString st = "bbbbbbbb";
+ TString ss = s;
UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b'));
UNIT_ASSERT_VALUES_EQUAL(st, ss);
}
diff --git a/util/string/type.cpp b/util/string/type.cpp
index 49671c02c2..b5a660008b 100644
--- a/util/string/type.cpp
+++ b/util/string/type.cpp
@@ -3,7 +3,7 @@
#include <array>
-bool IsSpace(const char* s, size_t len) noexcept {
+bool IsSpace(const char* s, size_t len) noexcept {
if (len == 0) {
return false;
}
diff --git a/util/string/type_ut.cpp b/util/string/type_ut.cpp
index 03e7af62bd..9356282119 100644
--- a/util/string/type_ut.cpp
+++ b/util/string/type_ut.cpp
@@ -62,7 +62,7 @@ Y_UNIT_TEST_SUITE(TStringClassify) {
UNIT_ASSERT(IsHexNumber("1234567890a"));
UNIT_ASSERT(!IsHexNumber("12345xx67890a"));
UNIT_ASSERT(!IsHexNumber("foobar"));
- UNIT_ASSERT(!IsHexNumber(TString()));
+ UNIT_ASSERT(!IsHexNumber(TString()));
UNIT_ASSERT(IsHexNumber(u"0"));
UNIT_ASSERT(IsHexNumber(u"aaaadddAAAAA"));
@@ -71,6 +71,6 @@ Y_UNIT_TEST_SUITE(TStringClassify) {
UNIT_ASSERT(IsHexNumber(u"1234567890a"));
UNIT_ASSERT(!IsHexNumber(u"12345xx67890a"));
UNIT_ASSERT(!IsHexNumber(u"foobar"));
- UNIT_ASSERT(!IsHexNumber(TUtf16String()));
+ UNIT_ASSERT(!IsHexNumber(TUtf16String()));
}
}
diff --git a/util/string/util.cpp b/util/string/util.cpp
index b14f20bf75..a528489b9b 100644
--- a/util/string/util.cpp
+++ b/util/string/util.cpp
@@ -6,7 +6,7 @@
#include <cstdarg>
#include <cstdlib>
-int a2i(const TString& s) {
+int a2i(const TString& s) {
return atoi(s.c_str());
}
@@ -49,20 +49,20 @@ Tr::Tr(const char* from, const char* to) {
}
}
-size_t Tr::FindFirstChangePosition(const TString& str) const {
+size_t Tr::FindFirstChangePosition(const TString& str) const {
for (auto it = str.begin(); it != str.end(); ++it) {
if (ConvertChar(*it) != *it) {
return it - str.begin();
}
}
- return TString::npos;
+ return TString::npos;
}
-void Tr::Do(TString& str) const {
+void Tr::Do(TString& str) const {
const size_t changePosition = FindFirstChangePosition(str);
- if (changePosition == TString::npos) {
+ if (changePosition == TString::npos) {
return;
}
diff --git a/util/string/util.h b/util/string/util.h
index 0d77a5042b..4108a1389a 100644
--- a/util/string/util.h
+++ b/util/string/util.h
@@ -7,12 +7,12 @@
#include <algorithm>
#include <util/system/defaults.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/strbuf.h>
/// @addtogroup Strings_Miscellaneous
/// @{
-int a2i(const TString& s);
+int a2i(const TString& s);
/// Removes the last character if it is equal to c.
template <class T>
@@ -23,7 +23,7 @@ inline void RemoveIfLast(T& s, int c) {
}
/// Adds lastCh symbol to the the of the string if it is not already there.
-inline void addIfNotLast(TString& s, int lastCh) {
+inline void addIfNotLast(TString& s, int lastCh) {
size_t len = s.length();
if (!len || s[len - 1] != lastCh) {
s.append(char(lastCh));
@@ -33,9 +33,9 @@ inline void addIfNotLast(TString& s, int lastCh) {
/// @details Finishes the string with lastCh1 if lastCh2 is not present in the string and lastCh1 is not already at the end of the string.
/// Else, if lastCh2 is not equal to the symbol before the last, it finishes the string with lastCh2.
/// @todo ?? Define, when to apply the function. Is in use several times for URLs parsing.
-inline void addIfAbsent(TString& s, char lastCh1, char lastCh2) {
+inline void addIfAbsent(TString& s, char lastCh1, char lastCh2) {
size_t pos = s.find(lastCh2);
- if (pos == TString::npos) {
+ if (pos == TString::npos) {
//s.append((char)lastCh1);
addIfNotLast(s, lastCh1);
} else if (pos < s.length() - 1) {
@@ -173,18 +173,18 @@ public:
for (size_t i = 0; i < l && s[i]; i++)
s[i] = ConvertChar(s[i]);
}
- void Do(TString& str) const;
+ void Do(TString& str) const;
private:
char Map[256];
- size_t FindFirstChangePosition(const TString& str) const;
+ size_t FindFirstChangePosition(const TString& str) const;
};
// Removes all occurrences of given character from string
template <typename TStringType>
void RemoveAll(TStringType& str, typename TStringType::char_type ch) {
- size_t pos = str.find(ch); // 'find' to avoid cloning of string in 'TString.begin()'
+ size_t pos = str.find(ch); // 'find' to avoid cloning of string in 'TString.begin()'
if (pos == TStringType::npos)
return;
diff --git a/util/string/util_ut.cpp b/util/string/util_ut.cpp
index 18a2d8e195..2d9f5f3579 100644
--- a/util/string/util_ut.cpp
+++ b/util/string/util_ut.cpp
@@ -36,7 +36,7 @@ public:
};
for (const T* t = tests; t != std::end(tests); ++t) {
- TString str(t->Str);
+ TString str(t->Str);
RemoveAll(str, t->Ch);
UNIT_ASSERT_EQUAL(t->Result, str);
}
diff --git a/util/string/vector.cpp b/util/string/vector.cpp
index 9ba401f0a2..eb24bfcf27 100644
--- a/util/string/vector.cpp
+++ b/util/string/vector.cpp
@@ -22,7 +22,7 @@ static inline void DoSplit1(TConsumer& cc, TDelim& d, const TBasicStringBuf<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>;
+ using TStringType = std::conditional_t<std::is_same<TChr, wchar16>::value, TUtf16String, TString>;
res->clear();
if (!str.data()) {
@@ -79,13 +79,13 @@ void ::NPrivate::SplitStringImpl(TVector<TUtf16String>* res, const wchar16* ptr,
return SplitStringImplT<wchar16>(res, TWtringBuf(ptr, len), delimiter, maxFields, options);
}
-TUtf16String JoinStrings(const TVector<TUtf16String>& v, const TWtringBuf delim) {
- return JoinStrings(v.begin(), v.end(), delim);
+TUtf16String JoinStrings(const TVector<TUtf16String>& v, const TWtringBuf delim) {
+ return JoinStrings(v.begin(), v.end(), delim);
}
-TUtf16String JoinStrings(const TVector<TUtf16String>& v, size_t index, size_t count, const TWtringBuf delim) {
+TUtf16String JoinStrings(const TVector<TUtf16String>& v, size_t index, size_t count, const TWtringBuf delim) {
const size_t f = Min(index, v.size());
const size_t l = f + Min(count, v.size() - f);
- return JoinStrings(v.begin() + f, v.begin() + l, delim);
+ return JoinStrings(v.begin() + f, v.begin() + l, delim);
}
diff --git a/util/string/vector.h b/util/string/vector.h
index e36c348bbe..08f2d7e489 100644
--- a/util/string/vector.h
+++ b/util/string/vector.h
@@ -5,7 +5,7 @@
#include <util/generic/map.h>
#include <util/generic/strbuf.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/vector.h>
#include <util/string/cast.h>
#include <util/system/yassert.h>
@@ -67,11 +67,11 @@ SplitString(const typename ::NPrivate::TStringDeducer<C>::type& str, const C* de
}
template <class TIter>
-inline TString JoinStrings(TIter begin, TIter end, const TStringBuf delim) {
+inline TString JoinStrings(TIter begin, TIter end, const TStringBuf delim) {
if (begin == end)
- return TString();
+ return TString();
- TString result = ToString(*begin);
+ TString result = ToString(*begin);
for (++begin; begin != end; ++begin) {
result.append(delim);
@@ -82,11 +82,11 @@ inline TString JoinStrings(TIter begin, TIter end, const TStringBuf delim) {
}
template <class TIter>
-inline TUtf16String JoinStrings(TIter begin, TIter end, const TWtringBuf delim) {
+inline TUtf16String JoinStrings(TIter begin, TIter end, const TWtringBuf delim) {
if (begin == end)
- return TUtf16String();
+ return TUtf16String();
- TUtf16String result = ToWtring(*begin);
+ TUtf16String result = ToWtring(*begin);
for (++begin; begin != end; ++begin) {
result.append(delim);
@@ -96,34 +96,34 @@ inline TUtf16String JoinStrings(TIter begin, TIter end, const TWtringBuf delim)
return result;
}
-/// Concatenates elements of given TVector<TString>.
-inline TString JoinStrings(const TVector<TString>& v, const TStringBuf delim) {
- return JoinStrings(v.begin(), v.end(), delim);
+/// Concatenates elements of given TVector<TString>.
+inline TString JoinStrings(const TVector<TString>& v, const TStringBuf delim) {
+ return JoinStrings(v.begin(), v.end(), delim);
}
-inline TString JoinStrings(const TVector<TString>& v, size_t index, size_t count, const TStringBuf delim) {
- Y_ASSERT(index + count <= v.size() && "JoinStrings(): index or count out of range");
- return JoinStrings(v.begin() + index, v.begin() + index + count, delim);
+inline TString JoinStrings(const TVector<TString>& v, size_t index, size_t count, const TStringBuf delim) {
+ Y_ASSERT(index + count <= v.size() && "JoinStrings(): index or count out of range");
+ return JoinStrings(v.begin() + index, v.begin() + index + count, delim);
}
template <typename T>
-inline TString JoinVectorIntoString(const TVector<T>& v, const TStringBuf delim) {
- return JoinStrings(v.begin(), v.end(), delim);
+inline TString JoinVectorIntoString(const TVector<T>& v, const TStringBuf delim) {
+ return JoinStrings(v.begin(), v.end(), delim);
}
template <typename T>
-inline TString JoinVectorIntoString(const TVector<T>& v, size_t index, size_t count, const TStringBuf delim) {
+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);
+ 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);
+TUtf16String JoinStrings(const TVector<TUtf16String>& v, const TWtringBuf delim);
+TUtf16String JoinStrings(const TVector<TUtf16String>& v, size_t index, size_t count, const TWtringBuf delim);
//! Converts vector of strings to vector of type T variables
template <typename T, typename TStringType>
-TVector<T> Scan(const TVector<TStringType>& input) {
- TVector<T> output;
+TVector<T> Scan(const TVector<TStringType>& input) {
+ TVector<T> output;
output.reserve(input.size());
for (int i = 0; i < input.ysize(); ++i) {
output.push_back(FromString<T>(input[i]));
diff --git a/util/string/vector_ut.cpp b/util/string/vector_ut.cpp
index 817120f268..b6b22a8cf4 100644
--- a/util/string/vector_ut.cpp
+++ b/util/string/vector_ut.cpp
@@ -6,33 +6,33 @@
Y_UNIT_TEST_SUITE(TStringJoinTest) {
Y_UNIT_TEST(Test1) {
- TVector<TUtf16String> v;
+ TVector<TUtf16String> v;
- UNIT_ASSERT_EQUAL(JoinStrings(v, ToWtring("")), ToWtring(""));
+ UNIT_ASSERT_EQUAL(JoinStrings(v, ToWtring("")), ToWtring(""));
}
Y_UNIT_TEST(Test2) {
- TVector<TUtf16String> v;
+ TVector<TUtf16String> v;
v.push_back(ToWtring("1"));
v.push_back(ToWtring("2"));
- UNIT_ASSERT_EQUAL(JoinStrings(v, ToWtring(" ")), ToWtring("1 2"));
+ UNIT_ASSERT_EQUAL(JoinStrings(v, ToWtring(" ")), ToWtring("1 2"));
}
Y_UNIT_TEST(Test3) {
- TVector<TUtf16String> v;
+ TVector<TUtf16String> v;
v.push_back(ToWtring("1"));
v.push_back(ToWtring("2"));
- UNIT_ASSERT_EQUAL(JoinStrings(v, 1, 10, ToWtring(" ")), ToWtring("2"));
+ UNIT_ASSERT_EQUAL(JoinStrings(v, 1, 10, ToWtring(" ")), ToWtring("2"));
}
Y_UNIT_TEST(TestJoinWStrings) {
const TUtf16String str = u"Яндекс";
- const TVector<TUtf16String> v(1, str);
+ const TVector<TUtf16String> v(1, str);
- UNIT_ASSERT_EQUAL(JoinStrings(v, TUtf16String()), str);
+ UNIT_ASSERT_EQUAL(JoinStrings(v, TUtf16String()), str);
}
}