aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/string_utils
diff options
context:
space:
mode:
authordanlark <danlark@yandex-team.ru>2022-02-10 16:46:08 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:08 +0300
commit3426a9bc7f169ae9da54cef557ad2a33f6e8eee0 (patch)
tree26154e1e9990f1bb4525d3e3fb5b6dac2c2c1da2 /library/cpp/string_utils
parentcb68f224c46a8ee52ac3fdd2a32534b8bb8dc134 (diff)
downloadydb-3426a9bc7f169ae9da54cef557ad2a33f6e8eee0.tar.gz
Restoring authorship annotation for <danlark@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/string_utils')
-rw-r--r--library/cpp/string_utils/base64/base64.h4
-rw-r--r--library/cpp/string_utils/base64/base64_ut.cpp4
-rw-r--r--library/cpp/string_utils/base64/bench/main.cpp12
-rw-r--r--library/cpp/string_utils/indent_text/indent_text.cpp2
-rw-r--r--library/cpp/string_utils/parse_size/parse_size.cpp6
-rw-r--r--library/cpp/string_utils/quote/quote.cpp30
-rw-r--r--library/cpp/string_utils/quote/quote.h6
-rw-r--r--library/cpp/string_utils/relaxed_escaper/relaxed_escaper.h8
-rw-r--r--library/cpp/string_utils/scan/scan.h4
-rw-r--r--library/cpp/string_utils/url/url.cpp12
10 files changed, 44 insertions, 44 deletions
diff --git a/library/cpp/string_utils/base64/base64.h b/library/cpp/string_utils/base64/base64.h
index f778a6425a..22a1623479 100644
--- a/library/cpp/string_utils/base64/base64.h
+++ b/library/cpp/string_utils/base64/base64.h
@@ -100,11 +100,11 @@ char* Base64Encode(char* outstr, const unsigned char* instr, size_t len);
char* Base64EncodeUrl(char* outstr, const unsigned char* instr, size_t len);
inline TStringBuf Base64Encode(const TStringBuf src, void* tmp) {
- return TStringBuf((const char*)tmp, Base64Encode((char*)tmp, (const unsigned char*)src.data(), src.size()));
+ return TStringBuf((const char*)tmp, Base64Encode((char*)tmp, (const unsigned char*)src.data(), src.size()));
}
inline TStringBuf Base64EncodeUrl(const TStringBuf src, void* tmp) {
- return TStringBuf((const char*)tmp, Base64EncodeUrl((char*)tmp, (const unsigned char*)src.data(), src.size()));
+ return TStringBuf((const char*)tmp, Base64EncodeUrl((char*)tmp, (const unsigned char*)src.data(), src.size()));
}
inline void Base64Encode(const TStringBuf src, TString& dst) {
diff --git a/library/cpp/string_utils/base64/base64_ut.cpp b/library/cpp/string_utils/base64/base64_ut.cpp
index bcc1e65879..fd9384db8a 100644
--- a/library/cpp/string_utils/base64/base64_ut.cpp
+++ b/library/cpp/string_utils/base64/base64_ut.cpp
@@ -57,7 +57,7 @@ using namespace std::string_view_literals;
\
Y_DECLARE_UNUSED \
static inline TStringBuf prefix##Base64Encode(const TStringBuf& src, void* tmp) { \
- return TStringBuf((const char*)tmp, ::NB64Etalon::prefix##Base64Encode((char*)tmp, (const unsigned char*)src.data(), src.size())); \
+ return TStringBuf((const char*)tmp, ::NB64Etalon::prefix##Base64Encode((char*)tmp, (const unsigned char*)src.data(), src.size())); \
} \
\
Y_DECLARE_UNUSED \
@@ -436,7 +436,7 @@ Y_UNIT_TEST_SUITE(TBase64) {
}
buf.assign(Base64EncodeBufSize(x.size()), Max<char>());
- const auto* const xEncEnd = Base64Encode(buf.data(), (const unsigned char*)x.data(), x.size());
+ const auto* const xEncEnd = Base64Encode(buf.data(), (const unsigned char*)x.data(), x.size());
UNIT_ASSERT_VALUES_EQUAL(*xEncEnd, '\0');
}
}
diff --git a/library/cpp/string_utils/base64/bench/main.cpp b/library/cpp/string_utils/base64/bench/main.cpp
index 10e09bc1c7..73e36758b7 100644
--- a/library/cpp/string_utils/base64/bench/main.cpp
+++ b/library/cpp/string_utils/base64/bench/main.cpp
@@ -96,9 +96,9 @@ static inline void BenchEncode(T& d, const NBench::NCpu::TParams& iface) {
for (const auto it : xrange(iface.Iterations())) {
Y_UNUSED(it);
for (size_t i = 0; i < d.Size; ++i) {
- NBench::Escape(d.PlaceToEncode[i].data());
+ NBench::Escape(d.PlaceToEncode[i].data());
Y_DO_NOT_OPTIMIZE_AWAY(
- Base64Encode(d.PlaceToEncode[i].data(), (const unsigned char*)d.Data[i].data(), d.Data[i].size()));
+ Base64Encode(d.PlaceToEncode[i].data(), (const unsigned char*)d.Data[i].data(), d.Data[i].size()));
NBench::Clobber();
}
}
@@ -109,9 +109,9 @@ static inline void BenchEncodeUrl(T& d, const NBench::NCpu::TParams& iface) {
for (const auto it : xrange(iface.Iterations())) {
Y_UNUSED(it);
for (size_t i = 0; i < d.Size; ++i) {
- NBench::Escape(d.PlaceToEncode[i].data());
+ NBench::Escape(d.PlaceToEncode[i].data());
Y_DO_NOT_OPTIMIZE_AWAY(
- Base64EncodeUrl(d.PlaceToEncode[i].data(), (const unsigned char*)d.Data[i].data(), d.Data[i].size()));
+ Base64EncodeUrl(d.PlaceToEncode[i].data(), (const unsigned char*)d.Data[i].data(), d.Data[i].size()));
NBench::Clobber();
}
}
@@ -122,9 +122,9 @@ static inline void BenchDecode(T& d, const NBench::NCpu::TParams& iface) {
for (const auto it : xrange(iface.Iterations())) {
Y_UNUSED(it);
for (size_t i = 0; i < d.Size; ++i) {
- NBench::Escape(d.PlaceToDecode[i].data());
+ NBench::Escape(d.PlaceToDecode[i].data());
Y_DO_NOT_OPTIMIZE_AWAY(
- Base64Decode(d.PlaceToDecode[i].data(), (const char*)d.DataEncoded[i].data(), (const char*)(d.DataEncoded[i].data() + d.DataEncoded[i].size())));
+ Base64Decode(d.PlaceToDecode[i].data(), (const char*)d.DataEncoded[i].data(), (const char*)(d.DataEncoded[i].data() + d.DataEncoded[i].size())));
NBench::Clobber();
}
}
diff --git a/library/cpp/string_utils/indent_text/indent_text.cpp b/library/cpp/string_utils/indent_text/indent_text.cpp
index 09a4f6bca8..6c3c9cc9f4 100644
--- a/library/cpp/string_utils/indent_text/indent_text.cpp
+++ b/library/cpp/string_utils/indent_text/indent_text.cpp
@@ -7,7 +7,7 @@ TString IndentText(TStringBuf text, TStringBuf indent) {
return TString();
TStringStream ss;
- ss.Reserve(text.size() + 20);
+ ss.Reserve(text.size() + 20);
char pc = 0;
for (size_t i = 0; i < text.size(); ++i) {
diff --git a/library/cpp/string_utils/parse_size/parse_size.cpp b/library/cpp/string_utils/parse_size/parse_size.cpp
index 39188d560b..d69d8cbca5 100644
--- a/library/cpp/string_utils/parse_size/parse_size.cpp
+++ b/library/cpp/string_utils/parse_size/parse_size.cpp
@@ -34,9 +34,9 @@ namespace {
namespace NSize {
ui64 ParseSize(TStringBuf str) {
- if (! str.size())
+ if (! str.size())
ythrow yexception() << "Wrong size " << str;
- char suff = tolower(str[str.size() - 1]);
+ char suff = tolower(str[str.size() - 1]);
if (isdigit(suff))
return FromString<ui64>(str);
ui64 shift = 1;
@@ -57,7 +57,7 @@ namespace NSize {
ythrow yexception() << "Unknown suffix " << str;
}
- ui64 value = FromString<ui64>(str.substr(0, str.size() - 1));
+ ui64 value = FromString<ui64>(str.substr(0, str.size() - 1));
if (!TryShiftValue(value, shift)) {
ythrow yexception() << "Value overflow " << str;
diff --git a/library/cpp/string_utils/quote/quote.cpp b/library/cpp/string_utils/quote/quote.cpp
index e523350b80..5f852c4921 100644
--- a/library/cpp/string_utils/quote/quote.cpp
+++ b/library/cpp/string_utils/quote/quote.cpp
@@ -156,16 +156,16 @@ char* CGIEscape(char* to, const char* from, size_t len) {
}
void CGIEscape(TString& url) {
- TTempBuf tempBuf(CgiEscapeBufLen(url.size()));
+ TTempBuf tempBuf(CgiEscapeBufLen(url.size()));
char* to = tempBuf.Data();
- url.AssignNoAlias(to, CGIEscape(to, url.data(), url.size()));
+ url.AssignNoAlias(to, CGIEscape(to, url.data(), url.size()));
}
TString CGIEscapeRet(const TStringBuf url) {
TString to;
- to.ReserveAndResize(CgiEscapeBufLen(url.size()));
- to.resize(CGIEscape(to.begin(), url.data(), url.size()) - to.data());
+ to.ReserveAndResize(CgiEscapeBufLen(url.size()));
+ to.resize(CGIEscape(to.begin(), url.data(), url.size()) - to.data());
return to;
}
@@ -204,11 +204,11 @@ char* Quote(char* to, const char* from, const char* safe) {
}
char* Quote(char* to, const TStringBuf s, const char* safe) {
- return Quote(to, s.data(), s.data() + s.size(), safe);
+ return Quote(to, s.data(), s.data() + s.size(), safe);
}
void Quote(TString& url, const char* safe) {
- TTempBuf tempBuf(CgiEscapeBufLen(url.size()));
+ TTempBuf tempBuf(CgiEscapeBufLen(url.size()));
char* to = tempBuf.Data();
url.AssignNoAlias(to, Quote(to, url, safe));
@@ -237,13 +237,13 @@ void CGIUnescape(TString& url) {
TString CGIUnescapeRet(const TStringBuf from) {
TString to;
- to.ReserveAndResize(CgiUnescapeBufLen(from.size()));
- to.resize(CGIUnescape(to.begin(), from.data(), from.size()) - to.data());
+ to.ReserveAndResize(CgiUnescapeBufLen(from.size()));
+ to.resize(CGIUnescape(to.begin(), from.data(), from.size()) - to.data());
return to;
}
char* UrlUnescape(char* to, TStringBuf from) {
- while (!from.empty()) {
+ while (!from.empty()) {
char ch = from[0];
from.Skip(1);
if ('%' == ch && 2 <= from.length())
@@ -271,8 +271,8 @@ void UrlUnescape(TString& url) {
TString UrlUnescapeRet(const TStringBuf from) {
TString to;
- to.ReserveAndResize(CgiUnescapeBufLen(from.size()));
- to.resize(UrlUnescape(to.begin(), from) - to.data());
+ to.ReserveAndResize(CgiUnescapeBufLen(from.size()));
+ to.resize(UrlUnescape(to.begin(), from) - to.data());
return to;
}
@@ -298,14 +298,14 @@ char* UrlEscape(char* to, const char* from, bool forceEscape) {
}
void UrlEscape(TString& url, bool forceEscape) {
- TTempBuf tempBuf(CgiEscapeBufLen(url.size()));
+ TTempBuf tempBuf(CgiEscapeBufLen(url.size()));
char* to = tempBuf.Data();
- url.AssignNoAlias(to, UrlEscape(to, url.data(), forceEscape));
+ url.AssignNoAlias(to, UrlEscape(to, url.data(), forceEscape));
}
TString UrlEscapeRet(const TStringBuf from, bool forceEscape) {
TString to;
- to.ReserveAndResize(CgiEscapeBufLen(from.size()));
- to.resize(UrlEscape(to.begin(), from.begin(), forceEscape) - to.data());
+ to.ReserveAndResize(CgiEscapeBufLen(from.size()));
+ to.resize(UrlEscape(to.begin(), from.begin(), forceEscape) - to.data());
return to;
}
diff --git a/library/cpp/string_utils/quote/quote.h b/library/cpp/string_utils/quote/quote.h
index 3b7221154e..75fc1ee81a 100644
--- a/library/cpp/string_utils/quote/quote.h
+++ b/library/cpp/string_utils/quote/quote.h
@@ -11,14 +11,14 @@
char* CGIEscape(char* to, const char* from);
char* CGIEscape(char* to, const char* from, size_t len);
inline char* CGIEscape(char* to, const TStringBuf from) {
- return CGIEscape(to, from.data(), from.size());
+ return CGIEscape(to, from.data(), from.size());
}
void CGIEscape(TString& url);
TString CGIEscapeRet(const TStringBuf url);
TString& AppendCgiEscaped(const TStringBuf value, TString& to);
inline TStringBuf CgiEscapeBuf(char* to, const TStringBuf from) {
- return TStringBuf(to, CGIEscape(to, from.data(), from.size()));
+ return TStringBuf(to, CGIEscape(to, from.data(), from.size()));
}
inline TStringBuf CgiEscape(void* tmp, const TStringBuf s) {
return CgiEscapeBuf(static_cast<char*>(tmp), s);
@@ -34,7 +34,7 @@ void CGIUnescape(TString& url);
TString CGIUnescapeRet(const TStringBuf from);
inline TStringBuf CgiUnescapeBuf(char* to, const TStringBuf from) {
- return TStringBuf(to, CGIUnescape(to, from.data(), from.size()));
+ return TStringBuf(to, CGIUnescape(to, from.data(), from.size()));
}
inline TStringBuf CgiUnescape(void* tmp, const TStringBuf s) {
return CgiUnescapeBuf(static_cast<char*>(tmp), s);
diff --git a/library/cpp/string_utils/relaxed_escaper/relaxed_escaper.h b/library/cpp/string_utils/relaxed_escaper/relaxed_escaper.h
index d7ea7c1259..068e8368d9 100644
--- a/library/cpp/string_utils/relaxed_escaper/relaxed_escaper.h
+++ b/library/cpp/string_utils/relaxed_escaper/relaxed_escaper.h
@@ -151,12 +151,12 @@ namespace NEscJ {
template <bool quote, bool tounicode>
inline void EscapeJ(TStringBuf in, IOutputStream& out, TStringBuf safe = TStringBuf(), TStringBuf unsafe = TStringBuf()) {
- TTempBuf b(SuggestBuffer(in.size()) + 2);
+ TTempBuf b(SuggestBuffer(in.size()) + 2);
if (quote)
b.Append("\"", 1);
- b.Proceed(EscapeJ<tounicode>(in.data(), in.size(), b.Current(), safe, unsafe));
+ b.Proceed(EscapeJ<tounicode>(in.data(), in.size(), b.Current(), safe, unsafe));
if (quote)
b.Append("\"", 1);
@@ -166,12 +166,12 @@ namespace NEscJ {
template <bool quote, bool tounicode>
inline void EscapeJ(TStringBuf in, TString& out, TStringBuf safe = TStringBuf(), TStringBuf unsafe = TStringBuf()) {
- TTempBuf b(SuggestBuffer(in.size()) + 2);
+ TTempBuf b(SuggestBuffer(in.size()) + 2);
if (quote)
b.Append("\"", 1);
- b.Proceed(EscapeJ<tounicode>(in.data(), in.size(), b.Current(), safe, unsafe));
+ b.Proceed(EscapeJ<tounicode>(in.data(), in.size(), b.Current(), safe, unsafe));
if (quote)
b.Append("\"", 1);
diff --git a/library/cpp/string_utils/scan/scan.h b/library/cpp/string_utils/scan/scan.h
index 703db54321..d97a4bc7c0 100644
--- a/library/cpp/string_utils/scan/scan.h
+++ b/library/cpp/string_utils/scan/scan.h
@@ -6,10 +6,10 @@ template <bool addAll, char sep, char sepKeyVal, class F>
static inline void ScanKeyValue(TStringBuf s, F&& f) {
TStringBuf key, val;
- while (!s.empty()) {
+ while (!s.empty()) {
val = s.NextTok(sep);
- if (val.empty()) {
+ if (val.empty()) {
continue; // && case
}
diff --git a/library/cpp/string_utils/url/url.cpp b/library/cpp/string_utils/url/url.cpp
index 85f4ac5d69..3658cfbabd 100644
--- a/library/cpp/string_utils/url/url.cpp
+++ b/library/cpp/string_utils/url/url.cpp
@@ -106,7 +106,7 @@ size_t GetSchemePrefixSize(const TStringBuf url) noexcept {
};
const auto& delim = *Singleton<TDelim>();
- const char* n = delim.brk(url.data(), url.end());
+ const char* n = delim.brk(url.data(), url.end());
if (n + 2 >= url.end() || *n != ':' || n[1] != '/' || n[2] != '/') {
return 0;
@@ -140,7 +140,7 @@ static inline TStringBuf GetHostAndPortImpl(const TStringBuf url) {
const char* firstNonHostCharacter = nonHostCharacters.brk(urlNoScheme.begin(), urlNoScheme.end());
if (firstNonHostCharacter != urlNoScheme.end()) {
- return urlNoScheme.substr(0, firstNonHostCharacter - urlNoScheme.data());
+ return urlNoScheme.substr(0, firstNonHostCharacter - urlNoScheme.data());
}
return urlNoScheme;
@@ -250,8 +250,8 @@ TStringBuf GetPathAndQuery(const TStringBuf url, bool trimFragment) noexcept {
// this strange creature returns 2nd level domain, possibly with port
TStringBuf GetDomain(const TStringBuf host) noexcept {
- const char* c = !host ? host.data() : host.end() - 1;
- for (bool wasPoint = false; c != host.data(); --c) {
+ const char* c = !host ? host.data() : host.end() - 1;
+ for (bool wasPoint = false; c != host.data(); --c) {
if (*c == '.') {
if (wasPoint) {
++c;
@@ -278,7 +278,7 @@ TStringBuf GetZone(const TStringBuf host) noexcept {
}
TStringBuf CutWWWPrefix(const TStringBuf url) noexcept {
- if (url.size() >= 4 && url[3] == '.' && !strnicmp(url.data(), "www", 3))
+ if (url.size() >= 4 && url[3] == '.' && !strnicmp(url.data(), "www", 3))
return url.substr(4);
return url;
}
@@ -362,7 +362,7 @@ static inline int Unescape(char* str) {
}
size_t NormalizeUrlName(char* dest, const TStringBuf source, size_t dest_size) {
- if (source.empty() || source[0] == '?')
+ if (source.empty() || source[0] == '?')
return strlcpy(dest, "/", dest_size);
size_t len = Min(dest_size - 1, source.length());
memcpy(dest, source.data(), len);