diff options
author | Dmitry Potapov <potapov.d@gmail.com> | 2022-02-10 16:46:39 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:39 +0300 |
commit | 536101ea75c9ff5df10d01c2f460b1f6e12311b3 (patch) | |
tree | 115291277ad61b2cdcf5044d210fb103b5e1647e /util/string | |
parent | 5036b5f2122001f9aef8a0e4cd85440d73ea6b9f (diff) | |
download | ydb-536101ea75c9ff5df10d01c2f460b1f6e12311b3.tar.gz |
Restoring authorship annotation for Dmitry Potapov <potapov.d@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'util/string')
-rw-r--r-- | util/string/cast.h | 66 | ||||
-rw-r--r-- | util/string/cast_ut.cpp | 4 |
2 files changed, 35 insertions, 35 deletions
diff --git a/util/string/cast.h b/util/string/cast.h index 90e925c194..f1e2f06abb 100644 --- a/util/string/cast.h +++ b/util/string/cast.h @@ -180,41 +180,41 @@ inline T FromString(const TUtf16String& s) { return ::FromString<T, wchar16>(s.data(), s.size()); } -namespace NPrivate { - template <typename TChar> - class TFromString { - const TChar* const Data; - const size_t Len; - - public: - inline TFromString(const TChar* data, size_t len) - : Data(data) - , Len(len) - { - } - - template <typename T> - inline operator T() const { - return FromString<T, TChar>(Data, Len); - } - }; -} - -template <typename TChar> -inline ::NPrivate::TFromString<TChar> FromString(const TChar* data, size_t len) { - return ::NPrivate::TFromString<TChar>(data, len); -} - -template <typename TChar> -inline ::NPrivate::TFromString<TChar> FromString(const TChar* data) { +namespace NPrivate { + template <typename TChar> + class TFromString { + const TChar* const Data; + const size_t Len; + + public: + inline TFromString(const TChar* data, size_t len) + : Data(data) + , Len(len) + { + } + + template <typename T> + inline operator T() const { + return FromString<T, TChar>(Data, Len); + } + }; +} + +template <typename TChar> +inline ::NPrivate::TFromString<TChar> FromString(const TChar* data, size_t len) { + return ::NPrivate::TFromString<TChar>(data, len); +} + +template <typename TChar> +inline ::NPrivate::TFromString<TChar> FromString(const TChar* data) { return ::NPrivate::TFromString<TChar>(data, std::char_traits<TChar>::length(data)); -} - -template <typename T> -inline ::NPrivate::TFromString<typename T::TChar> FromString(const T& s) { +} + +template <typename T> +inline ::NPrivate::TFromString<typename T::TChar> FromString(const T& s) { return ::NPrivate::TFromString<typename T::TChar>(s.data(), s.size()); -} - +} + // Conversion exception free versions template <typename T, typename TChar> bool TryFromStringImpl(const TChar* data, size_t len, T& result); diff --git a/util/string/cast_ut.cpp b/util/string/cast_ut.cpp index 033450c38c..949f09486b 100644 --- a/util/string/cast_ut.cpp +++ b/util/string/cast_ut.cpp @@ -4,7 +4,7 @@ #include <util/charset/wide.h> #include <util/system/defaults.h> - + #include <limits> // positive test (return true or no exception) @@ -319,7 +319,7 @@ Y_UNIT_TEST_SUITE(TCastTest) { Y_UNIT_TEST(TestLiteral) { UNIT_ASSERT_VALUES_EQUAL(ToString("abc"), TString("abc")); } - + Y_UNIT_TEST(TestFromStringStringBuf) { TString a = "xyz"; TStringBuf b = FromString<TStringBuf>(a); |