diff options
author | onpopov <onpopov@yandex-team.ru> | 2022-02-10 16:50:38 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:50:38 +0300 |
commit | 84a29dd4980d5b39615e453f289bd1a81213296d (patch) | |
tree | 5e320f10d6b5863e0d5ab1a8caa9eefbdaa5195f /util/string | |
parent | 1717072c6635948128dad7b015a0ec05acbe913b (diff) | |
download | ydb-84a29dd4980d5b39615e453f289bd1a81213296d.tar.gz |
Restoring authorship annotation for <onpopov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/string')
-rw-r--r-- | util/string/cast.h | 10 | ||||
-rw-r--r-- | util/string/util.cpp | 18 | ||||
-rw-r--r-- | util/string/util.h | 28 |
3 files changed, 28 insertions, 28 deletions
diff --git a/util/string/cast.h b/util/string/cast.h index 90e925c194..6fcdb5676f 100644 --- a/util/string/cast.h +++ b/util/string/cast.h @@ -104,13 +104,13 @@ inline TString ToString(char* s) { } /* - * Wrapper for wide strings. - */ + * Wrapper for wide strings. + */ template <class T> inline TUtf16String ToWtring(const T& t) { return TUtf16String::FromAscii(ToString(t)); -} - +} + inline const TUtf16String& ToWtring(const TUtf16String& w) { return w; } @@ -122,7 +122,7 @@ inline const TUtf16String& ToWtring(TUtf16String& w) { struct TFromStringException: public TBadCastException { }; -/* +/* * specialized for: * bool * short diff --git a/util/string/util.cpp b/util/string/util.cpp index b14f20bf75..faf105b280 100644 --- a/util/string/util.cpp +++ b/util/string/util.cpp @@ -51,22 +51,22 @@ Tr::Tr(const char* from, const char* to) { 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(); - } - } + if (ConvertChar(*it) != *it) { + return it - str.begin(); + } + } return TString::npos; -} - +} + void Tr::Do(TString& str) const { - const size_t changePosition = FindFirstChangePosition(str); + const size_t changePosition = FindFirstChangePosition(str); if (changePosition == TString::npos) { - return; + return; } for (auto it = str.begin() + changePosition; it != str.end(); ++it) { - *it = ConvertChar(*it); + *it = ConvertChar(*it); } } diff --git a/util/string/util.h b/util/string/util.h index 0d77a5042b..2ecafeaae3 100644 --- a/util/string/util.h +++ b/util/string/util.h @@ -152,32 +152,32 @@ protected: }; // an analogue of tr/$from/$to/ -class Tr { -public: +class Tr { +public: Tr(const char* from, const char* to); - - char ConvertChar(char ch) const { - return Map[(ui8)ch]; - } - + + char ConvertChar(char ch) const { + return Map[(ui8)ch]; + } + void Do(char* s) const { for (; *s; s++) - *s = ConvertChar(*s); + *s = ConvertChar(*s); } void Do(const char* src, char* dst) const { for (; *src; src++) - *dst++ = ConvertChar(*src); + *dst++ = ConvertChar(*src); *dst = 0; } void Do(char* s, size_t l) const { for (size_t i = 0; i < l && s[i]; i++) - s[i] = ConvertChar(s[i]); + s[i] = ConvertChar(s[i]); } void Do(TString& str) const; - -private: - char Map[256]; - + +private: + char Map[256]; + size_t FindFirstChangePosition(const TString& str) const; }; |