diff options
author | filmih <filmih@yandex-team.ru> | 2022-02-10 16:49:59 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:59 +0300 |
commit | 693ca74a6530df8930b0d445102e2ea77b8c4e00 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/unicode/normalization | |
parent | 883c643baf3a1698f0f0a31a8973b61411cd311f (diff) | |
download | ydb-693ca74a6530df8930b0d445102e2ea77b8c4e00.tar.gz |
Restoring authorship annotation for <filmih@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/unicode/normalization')
-rw-r--r-- | library/cpp/unicode/normalization/normalization.h | 82 | ||||
-rw-r--r-- | library/cpp/unicode/normalization/ya.make | 2 |
2 files changed, 42 insertions, 42 deletions
diff --git a/library/cpp/unicode/normalization/normalization.h b/library/cpp/unicode/normalization/normalization.h index 1537054f2a..4f5f57881c 100644 --- a/library/cpp/unicode/normalization/normalization.h +++ b/library/cpp/unicode/normalization/normalization.h @@ -187,10 +187,10 @@ namespace NUnicode { } }; - template <ENormalization N, typename TCharType> - inline bool Normalized(const TCharType* begin, const TCharType* end) { + template <ENormalization N, typename TCharType> + inline bool Normalized(const TCharType* begin, const TCharType* end) { TCombining lastCanonicalClass = 0; - for (const TCharType* i = begin; i != end;) { + for (const TCharType* i = begin; i != end;) { wchar32 ch = ReadSymbolAndAdvance(i, end); TCombining canonicalClass = DecompositionCombining(ch); @@ -244,12 +244,12 @@ namespace NUnicode { } } - static inline void Write(const TBuffer::const_iterator& begin, const TBuffer::const_iterator& end, TUtf32String& out) { // because WriteSymbol from util/charset/wide.h works wrong in this case - for (TBuffer::const_iterator i = begin; i != end; ++i) { - out += i->first; - } - } - + static inline void Write(const TBuffer::const_iterator& begin, const TBuffer::const_iterator& end, TUtf32String& out) { // because WriteSymbol from util/charset/wide.h works wrong in this case + for (TBuffer::const_iterator i = begin; i != end; ++i) { + out += i->first; + } + } + inline void SortBuffer() { if (Buffer.size() < 2) return; @@ -289,11 +289,11 @@ namespace NUnicode { } } - template <class T, typename TCharType> - inline void DoNormalize(const TCharType* begin, const TCharType* end, T& out) { + template <class T, typename TCharType> + inline void DoNormalize(const TCharType* begin, const TCharType* end, T& out) { Buffer.clear(); - for (const TCharType* i = begin; i != end;) { + for (const TCharType* i = begin; i != end;) { AddChar(ReadSymbolAndAdvance(i, end), out); } @@ -313,10 +313,10 @@ namespace NUnicode { { } - template <class T, typename TCharType> - inline void Normalize(const TCharType* begin, const TCharType* end, T& out) { + template <class T, typename TCharType> + inline void Normalize(const TCharType* begin, const TCharType* end, T& out) { if (NPrivate::Normalized<Norm>(begin, end)) { - for (const TCharType* i = begin; i != end; ++i) { + for (const TCharType* i = begin; i != end; ++i) { WriteSymbol(*i, out); } } else { @@ -324,29 +324,29 @@ namespace NUnicode { } } - template <typename TCharType> - inline void Normalize(const TCharType* begin, const TCharType* end, TUtf32String& out) { - if (NPrivate::Normalized<Norm>(begin, end)) { - for (const TCharType* i = begin; i != end;) { - out += ReadSymbolAndAdvance(i, end); - } - } else { - DoNormalize(begin, end, out); - } - } - - template <class T, typename TCharType> - inline void Normalize(const TCharType* begin, size_t len, T& out) { + template <typename TCharType> + inline void Normalize(const TCharType* begin, const TCharType* end, TUtf32String& out) { + if (NPrivate::Normalized<Norm>(begin, end)) { + for (const TCharType* i = begin; i != end;) { + out += ReadSymbolAndAdvance(i, end); + } + } else { + DoNormalize(begin, end, out); + } + } + + template <class T, typename TCharType> + inline void Normalize(const TCharType* begin, size_t len, T& out) { return Normalize(begin, begin + len, out); } - template <typename TCharType> - inline TBasicString<TCharType> Normalize(const TBasicString<TCharType>& src) { + template <typename TCharType> + inline TBasicString<TCharType> Normalize(const TBasicString<TCharType>& src) { if (NPrivate::Normalized<Norm>(src.begin(), src.end())) { // nothing to normalize return src; } else { - TBasicString<TCharType> res; + TBasicString<TCharType> res; res.reserve(src.length()); DoNormalize(src.begin(), src.end(), res); return res; @@ -355,16 +355,16 @@ namespace NUnicode { }; } -//! decompose utf16 or utf32 string to any container supporting push_back or to T* -template <NUnicode::ENormalization Norm, class T, typename TCharType> -inline void Normalize(const TCharType* begin, size_t len, T& out) { +//! decompose utf16 or utf32 string to any container supporting push_back or to T* +template <NUnicode::ENormalization Norm, class T, typename TCharType> +inline void Normalize(const TCharType* begin, size_t len, T& out) { ::NUnicode::TNormalizer<Norm> dec; dec.Normalize(begin, len, out); } -template <NUnicode::ENormalization N, typename TCharType> -inline TBasicString<TCharType> Normalize(const TCharType* str, size_t len) { - TBasicString<TCharType> res; +template <NUnicode::ENormalization N, typename TCharType> +inline TBasicString<TCharType> Normalize(const TCharType* str, size_t len) { + TBasicString<TCharType> res; res.reserve(len); Normalize<N>(str, len, res); @@ -372,13 +372,13 @@ inline TBasicString<TCharType> Normalize(const TCharType* str, size_t len) { return res; } -template <NUnicode::ENormalization N, typename TCharType> -inline TBasicString<TCharType> Normalize(const TBasicString<TCharType>& str) { +template <NUnicode::ENormalization N, typename TCharType> +inline TBasicString<TCharType> Normalize(const TBasicString<TCharType>& str) { ::NUnicode::TNormalizer<N> dec; return dec.Normalize(str); } -template <NUnicode::ENormalization N, typename TCharType> -inline TBasicString<TCharType> Normalize(const TBasicStringBuf<TCharType> str) { +template <NUnicode::ENormalization N, typename TCharType> +inline TBasicString<TCharType> Normalize(const TBasicStringBuf<TCharType> str) { return Normalize<N>(str.data(), str.size()); } diff --git a/library/cpp/unicode/normalization/ya.make b/library/cpp/unicode/normalization/ya.make index f6671ff4bc..95bc93f297 100644 --- a/library/cpp/unicode/normalization/ya.make +++ b/library/cpp/unicode/normalization/ya.make @@ -18,7 +18,7 @@ IF(NOT CATBOOST_OPENSOURCE) PEERDIR( library/cpp/charset ) - GENERATE_ENUM_SERIALIZATION(normalization.h) + GENERATE_ENUM_SERIALIZATION(normalization.h) ENDIF() END() |