aboutsummaryrefslogtreecommitdiffstats
path: root/util/string
diff options
context:
space:
mode:
authorAlexander Fokin <apfokin@gmail.com>2022-02-10 16:45:38 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:38 +0300
commitbf9e69a933f89af083d895185f01ed65e4d90766 (patch)
treeb2cc84ee7850122e7ccf51d0ea21e4fa7e7a5685 /util/string
parent863a59a65247c24db7cb06789bc5cf79d04da32f (diff)
downloadydb-bf9e69a933f89af083d895185f01ed65e4d90766.tar.gz
Restoring authorship annotation for Alexander Fokin <apfokin@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'util/string')
-rw-r--r--util/string/ascii.h40
-rw-r--r--util/string/cast.cpp56
-rw-r--r--util/string/cast.h36
-rw-r--r--util/string/cast_ut.cpp10
-rw-r--r--util/string/escape.h2
-rw-r--r--util/string/split.h62
-rw-r--r--util/string/strip.h2
-rw-r--r--util/string/subst.cpp6
8 files changed, 107 insertions, 107 deletions
diff --git a/util/string/ascii.h b/util/string/ascii.h
index a7010453fd..10344384d3 100644
--- a/util/string/ascii.h
+++ b/util/string/ascii.h
@@ -100,37 +100,37 @@ inline bool IsAsciiPunct(unsigned char c) {
template <class T>
inline bool IsAsciiSpace(T c) {
- return ::NPrivate::RangeOk(c) && IsAsciiSpace(static_cast<unsigned char>(c));
+ return ::NPrivate::RangeOk(c) && IsAsciiSpace(static_cast<unsigned char>(c));
}
template <class T>
inline bool IsAsciiUpper(T c) {
- return ::NPrivate::RangeOk(c) && IsAsciiUpper(static_cast<unsigned char>(c));
+ return ::NPrivate::RangeOk(c) && IsAsciiUpper(static_cast<unsigned char>(c));
}
template <class T>
inline bool IsAsciiLower(T c) {
- return ::NPrivate::RangeOk(c) && IsAsciiLower(static_cast<unsigned char>(c));
+ return ::NPrivate::RangeOk(c) && IsAsciiLower(static_cast<unsigned char>(c));
}
template <class T>
inline bool IsAsciiDigit(T c) {
- return ::NPrivate::RangeOk(c) && IsAsciiDigit(static_cast<unsigned char>(c));
+ return ::NPrivate::RangeOk(c) && IsAsciiDigit(static_cast<unsigned char>(c));
}
template <class T>
inline bool IsAsciiAlpha(T c) {
- return ::NPrivate::RangeOk(c) && IsAsciiAlpha(static_cast<unsigned char>(c));
+ return ::NPrivate::RangeOk(c) && IsAsciiAlpha(static_cast<unsigned char>(c));
}
template <class T>
inline bool IsAsciiAlnum(T c) {
- return ::NPrivate::RangeOk(c) && IsAsciiAlnum(static_cast<unsigned char>(c));
+ return ::NPrivate::RangeOk(c) && IsAsciiAlnum(static_cast<unsigned char>(c));
}
template <class T>
inline bool IsAsciiHex(T c) {
- return ::NPrivate::RangeOk(c) && IsAsciiHex(static_cast<unsigned char>(c));
+ return ::NPrivate::RangeOk(c) && IsAsciiHex(static_cast<unsigned char>(c));
}
template <class T>
@@ -160,12 +160,12 @@ inline ::NPrivate::TDereferenced<T> AsciiToUpper(T c) noexcept {
/**
* ASCII case-insensitive string comparison (for proper UTF8 strings
* case-insensitive comparison consider using @c library/cpp/charset).
- *
+ *
* BUGS: Currently will NOT work properly with strings that contain
* 0-terminator character inside. See IGNIETFERRO-1641 for details.
*
- * @return true iff @c s1 ans @c s2 are case-insensitively equal.
- */
+ * @return true iff @c s1 ans @c s2 are case-insensitively equal.
+ */
static inline bool AsciiEqualsIgnoreCase(const char* s1, const char* s2) noexcept {
return stricmp(s1, s2) == 0;
}
@@ -173,12 +173,12 @@ static inline bool AsciiEqualsIgnoreCase(const char* s1, const char* s2) noexcep
/**
* ASCII case-insensitive string comparison (for proper UTF8 strings
* case-insensitive comparison consider using @c library/cpp/charset).
- *
+ *
* BUGS: Currently will NOT work properly with strings that contain
* 0-terminator character inside. See IGNIETFERRO-1641 for details.
*
- * @return true iff @c s1 ans @c s2 are case-insensitively equal.
- */
+ * @return true iff @c s1 ans @c s2 are case-insensitively equal.
+ */
static inline bool AsciiEqualsIgnoreCase(const TStringBuf s1, const TStringBuf s2) noexcept {
return (s1.size() == s2.size()) && strnicmp(s1.data(), s2.data(), s1.size()) == 0;
}
@@ -186,14 +186,14 @@ static inline bool AsciiEqualsIgnoreCase(const TStringBuf s1, const TStringBuf s
/**
* ASCII case-insensitive string comparison (for proper UTF8 strings
* case-insensitive comparison consider using @c library/cpp/charset).
- *
+ *
* BUGS: Currently will NOT work properly with strings that contain
* 0-terminator character inside. See IGNIETFERRO-1641 for details.
*
- * @return 0 if strings are equal, negative if @c s1 < @c s2
- * and positive otherwise.
- * (same value as @c stricmp does).
- */
+ * @return 0 if strings are equal, negative if @c s1 < @c s2
+ * and positive otherwise.
+ * (same value as @c stricmp does).
+ */
static inline int AsciiCompareIgnoreCase(const char* s1, const char* s2) noexcept {
return stricmp(s1, s2);
}
@@ -201,7 +201,7 @@ static inline int AsciiCompareIgnoreCase(const char* s1, const char* s2) noexcep
/**
* ASCII case-insensitive string comparison (for proper UTF8 strings
* case-insensitive comparison consider using @c library/cpp/charset).
- *
+ *
* BUGS: Currently will NOT work properly with strings that contain
* 0-terminator character inside. See IGNIETFERRO-1641 for details.
*
@@ -210,7 +210,7 @@ static inline int AsciiCompareIgnoreCase(const char* s1, const char* s2) noexcep
* - negative if @c s1 < @c s2
* - positive otherwise,
* similar to stricmp.
- */
+ */
Y_PURE_FUNCTION int AsciiCompareIgnoreCase(const TStringBuf s1, const TStringBuf s2) noexcept;
/**
diff --git a/util/string/cast.cpp b/util/string/cast.cpp
index f70ca427f9..aa1e65a8e9 100644
--- a/util/string/cast.cpp
+++ b/util/string/cast.cpp
@@ -8,9 +8,9 @@
#include <string>
#include <cmath>
-#include <util/string/type.h>
-#include <util/string/cast.h>
-#include <util/string/escape.h>
+#include <util/string/type.h>
+#include <util/string/cast.h>
+#include <util/string/escape.h>
#include <contrib/libs/double-conversion/double-conversion.h>
@@ -18,7 +18,7 @@
#include <util/system/yassert.h>
#include <util/generic/yexception.h>
#include <util/generic/typetraits.h>
-#include <util/generic/ylimits.h>
+#include <util/generic/ylimits.h>
#include <util/generic/singleton.h>
#include <util/generic/utility.h>
@@ -259,19 +259,19 @@ namespace {
return PS_OK;
}
- };
-
+ };
+
template <class T>
struct TBounds {
T PositiveMax;
T NegativeMax;
};
-
+
template <class T, unsigned base, class TChar>
struct TIntParser {
static_assert(1 < base && base < 17, "Expect 1 < base && base < 17.");
static_assert(std::is_integral<T>::value, "T must be an integral type.");
-
+
enum {
IsSigned = std::is_signed<T>::value
};
@@ -431,11 +431,11 @@ namespace {
DEF_INT_SPEC_II(TYPE, ITYPE, 2) \
DEF_INT_SPEC_II(TYPE, ITYPE, 8) \
DEF_INT_SPEC_II(TYPE, ITYPE, 10) \
- DEF_INT_SPEC_II(TYPE, ITYPE, 16)
+ DEF_INT_SPEC_II(TYPE, ITYPE, 16)
#define DEF_INT_SPEC(TYPE) \
DEF_INT_SPEC_I(signed TYPE, i64) \
- DEF_INT_SPEC_I(unsigned TYPE, ui64)
+ DEF_INT_SPEC_I(unsigned TYPE, ui64)
DEF_INT_SPEC(char)
DEF_INT_SPEC(short)
@@ -452,15 +452,15 @@ size_t ToStringImpl<char8_t>(char8_t value, char* buf, size_t len) {
using TCharIType = std::conditional_t<std::is_signed<char>::value, i64, ui64>;
using TWCharIType = std::conditional_t<std::is_signed<wchar_t>::value, i64, ui64>;
-
-DEF_INT_SPEC_I(char, TCharIType)
-DEF_INT_SPEC_I(wchar_t, TWCharIType)
+
+DEF_INT_SPEC_I(char, TCharIType)
+DEF_INT_SPEC_I(wchar_t, TWCharIType)
DEF_INT_SPEC_I(wchar16, ui64) // wchar16 is always unsigned
DEF_INT_SPEC_I(wchar32, ui64) // wchar32 is always unsigned
-
+
#undef DEF_INT_SPEC
-#undef DEF_INT_SPEC_I
-#undef DEF_INT_SPEC_II
+#undef DEF_INT_SPEC_I
+#undef DEF_INT_SPEC_II
#define DEF_FLT_SPEC(type) \
template <> \
@@ -604,31 +604,31 @@ bool TryFromStringImpl<TUtf16String>(const wchar16* data, size_t len, TUtf16Stri
DEF_INT_SPEC_III(CHAR, TYPE, ITYPE, BOUNDS, 2) \
DEF_INT_SPEC_III(CHAR, TYPE, ITYPE, BOUNDS, 8) \
DEF_INT_SPEC_III(CHAR, TYPE, ITYPE, BOUNDS, 10) \
- DEF_INT_SPEC_III(CHAR, TYPE, ITYPE, BOUNDS, 16)
+ DEF_INT_SPEC_III(CHAR, TYPE, ITYPE, BOUNDS, 16)
#define DEF_INT_SPEC_I(TYPE, ITYPE, BOUNDS) \
DEF_INT_SPEC_II(char, TYPE, ITYPE, BOUNDS) \
DEF_INT_SPEC_II(wchar16, TYPE, ITYPE, BOUNDS)
-
+
#define DEF_INT_SPEC(TYPE, ID) \
DEF_INT_SPEC_I(signed TYPE, i64, ID##SBounds) \
- DEF_INT_SPEC_I(unsigned TYPE, ui64, ID##UBounds)
-
+ DEF_INT_SPEC_I(unsigned TYPE, ui64, ID##UBounds)
+
#define DEF_INT_SPEC_FIXED_WIDTH(TYPE, ID) \
DEF_INT_SPEC_I(TYPE, i64, ID##SBounds) \
DEF_INT_SPEC_I(u##TYPE, ui64, ID##UBounds)
DEF_INT_SPEC_FIXED_WIDTH(i8, b)
-DEF_INT_SPEC(short, s)
-DEF_INT_SPEC(int, i)
-DEF_INT_SPEC(long, l)
-DEF_INT_SPEC(long long, ll)
-
+DEF_INT_SPEC(short, s)
+DEF_INT_SPEC(int, i)
+DEF_INT_SPEC(long, l)
+DEF_INT_SPEC(long long, ll)
+
#undef DEF_INT_SPEC_FIXED_WIDTH
#undef DEF_INT_SPEC
-#undef DEF_INT_SPEC_I
-#undef DEF_INT_SPEC_II
-#undef DEF_INT_SPEC_III
+#undef DEF_INT_SPEC_I
+#undef DEF_INT_SPEC_II
+#undef DEF_INT_SPEC_III
#define DEF_FLT_SPEC(type) \
template <> \
diff --git a/util/string/cast.h b/util/string/cast.h
index 14f90a0896..90e925c194 100644
--- a/util/string/cast.h
+++ b/util/string/cast.h
@@ -15,10 +15,10 @@ template <class T>
size_t ToStringImpl(T t, char* buf, size_t len);
/**
- * Converts @c t to string writing not more than @c len bytes to output buffer @c buf.
- * No NULL terminator appended! Throws exception on buffer overflow.
- * @return number of bytes written
- */
+ * Converts @c t to string writing not more than @c len bytes to output buffer @c buf.
+ * No NULL terminator appended! Throws exception on buffer overflow.
+ * @return number of bytes written
+ */
template <class T>
inline size_t ToString(const T& t, char* buf, size_t len) {
using TParam = typename TTypeTraits<T>::TFuncParam;
@@ -26,20 +26,20 @@ inline size_t ToString(const T& t, char* buf, size_t len) {
return ToStringImpl<TParam>(t, buf, len);
}
-/**
- * Floating point to string conversion mode, values are enforced by `dtoa_impl.cpp`.
- */
+/**
+ * Floating point to string conversion mode, values are enforced by `dtoa_impl.cpp`.
+ */
enum EFloatToStringMode {
- /** 0.1f -> "0.1", 0.12345678f -> "0.12345678", ignores ndigits. */
- PREC_AUTO = 0,
-
- /** "%g" mode, writes up to the given number of significant digits:
- * 0.1f -> "0.1", 0.12345678f -> "0.123457" for ndigits=6, 1.2e-06f -> "1.2e-06" */
- PREC_NDIGITS = 2,
-
- /** "%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,
+ /** 0.1f -> "0.1", 0.12345678f -> "0.12345678", ignores ndigits. */
+ PREC_AUTO = 0,
+
+ /** "%g" mode, writes up to the given number of significant digits:
+ * 0.1f -> "0.1", 0.12345678f -> "0.123457" for ndigits=6, 1.2e-06f -> "1.2e-06" */
+ PREC_NDIGITS = 2,
+
+ /** "%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" */
@@ -177,7 +177,7 @@ inline T FromString(const TWtringBuf& s) {
template <class T>
inline T FromString(const TUtf16String& s) {
- return ::FromString<T, wchar16>(s.data(), s.size());
+ return ::FromString<T, wchar16>(s.data(), s.size());
}
namespace NPrivate {
diff --git a/util/string/cast_ut.cpp b/util/string/cast_ut.cpp
index ab25d83fe2..033450c38c 100644
--- a/util/string/cast_ut.cpp
+++ b/util/string/cast_ut.cpp
@@ -222,11 +222,11 @@ Y_UNIT_TEST_SUITE(TCastTest) {
test1(long int, LONG_MIN);
test1(long int, LONG_MAX - 1);
test1(long int, LONG_MIN + 1);
-
- test1(long long int, LLONG_MAX);
- test1(long long int, LLONG_MIN);
- test1(long long int, LLONG_MAX - 1);
- test1(long long int, LLONG_MIN + 1);
+
+ test1(long long int, LLONG_MAX);
+ test1(long long int, LLONG_MIN);
+ test1(long long int, LLONG_MAX - 1);
+ test1(long long int, LLONG_MIN + 1);
}
Y_UNIT_TEST(TestVolatile) {
diff --git a/util/string/escape.h b/util/string/escape.h
index 3814bd729f..b01be65b0e 100644
--- a/util/string/escape.h
+++ b/util/string/escape.h
@@ -52,7 +52,7 @@ static inline TBasicString<TChar> EscapeC(const TChar* str) {
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
+// these two need to be methods, because of TBasicString::Quote implementation
TString EscapeC(const TString& str);
TUtf16String EscapeC(const TUtf16String& str);
diff --git a/util/string/split.h b/util/string/split.h
index b5fcfa4501..bc46d9e64c 100644
--- a/util/string/split.h
+++ b/util/string/split.h
@@ -102,21 +102,21 @@ static inline I* FastStrStr(I* str, I* f, size_t l) noexcept {
}
}
-template <class Char>
+template <class Char>
struct TStringDelimiter {
- inline TStringDelimiter(Char* delim) noexcept
+ inline TStringDelimiter(Char* delim) noexcept
: Delim(delim)
, Len(std::char_traits<Char>::length(delim))
{
}
- inline TStringDelimiter(Char* delim, size_t len) noexcept
+ inline TStringDelimiter(Char* delim, size_t len) noexcept
: Delim(delim)
, Len(len)
{
}
- inline Char* Find(Char*& b, Char* e) const noexcept {
+ inline Char* Find(Char*& b, Char* e) const noexcept {
const auto ret = std::basic_string_view<Char>(b, e - b).find(Delim, 0, Len);
if (ret != std::string::npos) {
@@ -128,26 +128,26 @@ struct TStringDelimiter {
return (b = e);
}
- inline Char* Find(Char*& b) const noexcept {
- Char* ret = FastStrStr(b, Delim, Len);
+ inline Char* Find(Char*& b) const noexcept {
+ Char* ret = FastStrStr(b, Delim, Len);
b = *ret ? ret + Len : ret;
return ret;
}
- Char* Delim;
+ Char* Delim;
const size_t Len;
};
-template <class Char>
+template <class Char>
struct TCharDelimiter {
- inline TCharDelimiter(Char ch) noexcept
+ inline TCharDelimiter(Char ch) noexcept
: Ch(ch)
{
}
- inline Char* Find(Char*& b, Char* e) const noexcept {
+ inline Char* Find(Char*& b, Char* e) const noexcept {
const auto ret = std::basic_string_view<Char>(b, e - b).find(Ch);
if (ret != std::string::npos) {
@@ -159,8 +159,8 @@ struct TCharDelimiter {
return (b = e);
}
- inline Char* Find(Char*& b) const noexcept {
- Char* ret = FastStrChr(b, Ch);
+ inline Char* Find(Char*& b) const noexcept {
+ Char* ret = FastStrChr(b, Ch);
if (*ret) {
b = ret + 1;
@@ -171,19 +171,19 @@ struct TCharDelimiter {
return ret;
}
- Char Ch;
+ Char Ch;
};
-template <class Iterator, class Condition>
+template <class Iterator, class Condition>
struct TFuncDelimiter {
public:
template <class... Args>
- TFuncDelimiter(Args&&... args)
- : Fn(std::forward<Args>(args)...)
+ TFuncDelimiter(Args&&... args)
+ : Fn(std::forward<Args>(args)...)
{
}
- inline Iterator Find(Iterator& b, Iterator e) const noexcept {
+ inline Iterator Find(Iterator& b, Iterator e) const noexcept {
if ((b = std::find_if(b, e, Fn)) != e) {
return b++;
}
@@ -192,18 +192,18 @@ public:
}
private:
- Condition Fn;
+ Condition Fn;
};
-template <class Char>
+template <class Char>
struct TFindFirstOf {
- inline TFindFirstOf(Char* set)
+ inline TFindFirstOf(Char* set)
: Set(set)
{
}
- inline Char* FindFirstOf(Char* b, Char* e) const noexcept {
- Char* ret = b;
+ inline Char* FindFirstOf(Char* b, Char* e) const noexcept {
+ Char* ret = b;
for (; ret != e; ++ret) {
if (NStringSplitPrivate::Find(Set, *ret))
break;
@@ -211,13 +211,13 @@ struct TFindFirstOf {
return ret;
}
- inline Char* FindFirstOf(Char* b) const noexcept {
+ 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();
}
- Char* Set;
+ Char* Set;
};
template <>
@@ -233,12 +233,12 @@ struct TFindFirstOf<const char>: public TCompactStrSpn {
}
};
-template <class Char>
-struct TSetDelimiter: private TFindFirstOf<const Char> {
- using TFindFirstOf<const Char>::TFindFirstOf;
+template <class Char>
+struct TSetDelimiter: private TFindFirstOf<const Char> {
+ using TFindFirstOf<const Char>::TFindFirstOf;
- inline Char* Find(Char*& b, Char* e) const noexcept {
- Char* ret = const_cast<Char*>(this->FindFirstOf(b, e));
+ inline Char* Find(Char*& b, Char* e) const noexcept {
+ Char* ret = const_cast<Char*>(this->FindFirstOf(b, e));
if (ret != e) {
b = ret + 1;
@@ -248,8 +248,8 @@ struct TSetDelimiter: private TFindFirstOf<const Char> {
return (b = e);
}
- inline Char* Find(Char*& b) const noexcept {
- Char* ret = const_cast<Char*>(this->FindFirstOf(b));
+ inline Char* Find(Char*& b) const noexcept {
+ Char* ret = const_cast<Char*>(this->FindFirstOf(b));
if (*ret) {
b = ret + 1;
diff --git a/util/string/strip.h b/util/string/strip.h
index 3db606cc24..d5ef6da96d 100644
--- a/util/string/strip.h
+++ b/util/string/strip.h
@@ -86,7 +86,7 @@ struct TStripImpl {
auto e = from.end();
if (StripRange(b, e, criterion)) {
- to = T(b, e - b);
+ to = T(b, e - b);
return true;
}
diff --git a/util/string/subst.cpp b/util/string/subst.cpp
index f9036f8ef6..b2df328dc1 100644
--- a/util/string/subst.cpp
+++ b/util/string/subst.cpp
@@ -43,9 +43,9 @@ static bool IsIntersect(const T& a, const U& b) noexcept {
* Uses two separate implementations (inplace for shrink and append for grow case)
* See IGNIETFERRO-394
**/
-template <class TStringType, typename TStringViewType = TBasicStringBuf<typename TStringType::value_type>>
+template <class TStringType, typename TStringViewType = TBasicStringBuf<typename TStringType::value_type>>
static inline size_t SubstGlobalImpl(TStringType& s, const TStringViewType from, const TStringViewType to, size_t fromPos = 0) {
- if (from.empty()) {
+ if (from.empty()) {
return 0;
}
@@ -174,7 +174,7 @@ size_t SubstGlobal(TUtf32String& text, const TUtf32StringBuf what, const TUtf32S
}
size_t SubstGlobal(std::u16string& text, const TWtringBuf what, const TWtringBuf with, size_t from) {
- return SubstGlobalImpl(text,
+ return SubstGlobalImpl(text,
std::u16string_view(reinterpret_cast<const char16_t*>(what.data()), what.size()),
std::u16string_view(reinterpret_cast<const char16_t*>(with.data()), with.size()),
from);