diff options
author | ignat <ignat@yandex-team.ru> | 2022-02-10 16:48:20 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:20 +0300 |
commit | 12d7840a194f4a6e4ea77a405f980074cf43e942 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/yt/string | |
parent | c8b279dd21ddcb47e755028d81281f113a0f4a11 (diff) | |
download | ydb-12d7840a194f4a6e4ea77a405f980074cf43e942.tar.gz |
Restoring authorship annotation for <ignat@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/yt/string')
-rw-r--r-- | library/cpp/yt/string/enum.cpp | 12 | ||||
-rw-r--r-- | library/cpp/yt/string/enum.h | 6 | ||||
-rw-r--r-- | library/cpp/yt/string/format-inl.h | 228 | ||||
-rw-r--r-- | library/cpp/yt/string/guid.cpp | 42 | ||||
-rw-r--r-- | library/cpp/yt/string/guid.h | 28 | ||||
-rw-r--r-- | library/cpp/yt/string/string.cpp | 260 | ||||
-rw-r--r-- | library/cpp/yt/string/string.h | 36 | ||||
-rw-r--r-- | library/cpp/yt/string/string_builder-inl.h | 10 | ||||
-rw-r--r-- | library/cpp/yt/string/unittests/enum_ut.cpp | 8 | ||||
-rw-r--r-- | library/cpp/yt/string/unittests/format_ut.cpp | 4 | ||||
-rw-r--r-- | library/cpp/yt/string/unittests/guid_ut.cpp | 8 | ||||
-rw-r--r-- | library/cpp/yt/string/unittests/string_ut.cpp | 2 | ||||
-rw-r--r-- | library/cpp/yt/string/unittests/ya.make | 32 | ||||
-rw-r--r-- | library/cpp/yt/string/ya.make | 52 |
14 files changed, 364 insertions, 364 deletions
diff --git a/library/cpp/yt/string/enum.cpp b/library/cpp/yt/string/enum.cpp index 145f0f1185d..7cb8e5c6b6a 100644 --- a/library/cpp/yt/string/enum.cpp +++ b/library/cpp/yt/string/enum.cpp @@ -1,6 +1,6 @@ -#include "enum.h" +#include "enum.h" -#include "format.h" +#include "format.h" namespace NYT { @@ -9,12 +9,12 @@ namespace NYT { TString DecodeEnumValue(TStringBuf value) { auto camelValue = UnderscoreCaseToCamelCase(value); - auto underscoreValue = CamelCaseToUnderscoreCase(camelValue); - if (value != underscoreValue) { + auto underscoreValue = CamelCaseToUnderscoreCase(camelValue); + if (value != underscoreValue) { throw TSimpleException(Format("Enum value %Qv is not in a proper underscore case; did you mean %Qv?", - value, + value, underscoreValue)); - } + } return camelValue; } diff --git a/library/cpp/yt/string/enum.h b/library/cpp/yt/string/enum.h index 3f376603d56..10dc02610f7 100644 --- a/library/cpp/yt/string/enum.h +++ b/library/cpp/yt/string/enum.h @@ -1,10 +1,10 @@ #pragma once -#include "string.h" +#include "string.h" -#include <library/cpp/yt/misc/enum.h> +#include <library/cpp/yt/misc/enum.h> -#include <optional> +#include <optional> namespace NYT { diff --git a/library/cpp/yt/string/format-inl.h b/library/cpp/yt/string/format-inl.h index fa48e442de4..5484d4a216c 100644 --- a/library/cpp/yt/string/format-inl.h +++ b/library/cpp/yt/string/format-inl.h @@ -8,13 +8,13 @@ #include "string.h" #include <library/cpp/yt/assert/assert.h> - + #include <library/cpp/yt/small_containers/compact_vector.h> - + #include <library/cpp/yt/misc/enum.h> - + #include <cctype> -#include <optional> +#include <optional> namespace NYT { @@ -22,11 +22,11 @@ namespace NYT { static const char GenericSpecSymbol = 'v'; -inline bool IsQuotationSpecSymbol(char symbol) -{ - return symbol == 'Q' || symbol == 'q'; -} - +inline bool IsQuotationSpecSymbol(char symbol) +{ + return symbol == 'Q' || symbol == 'q'; +} + // TStringBuf inline void FormatValue(TStringBuilderBase* builder, TStringBuf value, TStringBuf format) { @@ -137,7 +137,7 @@ inline void FormatValue(TStringBuilderBase* builder, bool value, TStringBuf form if (*current == 'l') { ++current; lowercase = true; - } else if (IsQuotationSpecSymbol(*current)) { + } else if (IsQuotationSpecSymbol(*current)) { ++current; } else break; @@ -178,7 +178,7 @@ struct TValueFormatter<TEnum, typename std::enable_if<TEnumTraits<TEnum>::IsEnum if (*current == 'l') { ++current; lowercase = true; - } else if (IsQuotationSpecSymbol(*current)) { + } else if (IsQuotationSpecSymbol(*current)) { ++current; } else { break; @@ -237,27 +237,27 @@ void FormatRange(TStringBuilderBase* builder, const TRange& range, const TFormat builder->AppendChar(']'); } -template <class TRange, class TFormatter> +template <class TRange, class TFormatter> void FormatKeyValueRange(TStringBuilderBase* builder, const TRange& range, const TFormatter& formatter, size_t limit = std::numeric_limits<size_t>::max()) -{ - builder->AppendChar('{'); +{ + builder->AppendChar('{'); size_t index = 0; - for (const auto& item : range) { + for (const auto& item : range) { if (index > 0) { - builder->AppendString(DefaultJoinToStringDelimiter); - } + builder->AppendString(DefaultJoinToStringDelimiter); + } if (index == limit) { - builder->AppendString(DefaultRangeEllipsisFormat); - break; - } - formatter(builder, item.first); - builder->AppendString(DefaultKeyValueDelimiter); - formatter(builder, item.second); + builder->AppendString(DefaultRangeEllipsisFormat); + break; + } + formatter(builder, item.first); + builder->AppendString(DefaultKeyValueDelimiter); + formatter(builder, item.second); ++index; - } - builder->AppendChar('}'); -} - + } + builder->AppendChar('}'); +} + // TFormattableView template <class TRange, class TFormatter> struct TValueFormatter<TFormattableView<TRange, TFormatter>> @@ -317,26 +317,26 @@ struct TValueFormatter<std::set<T>> } }; -// std::map -template <class K, class V> -struct TValueFormatter<std::map<K, V>> -{ +// std::map +template <class K, class V> +struct TValueFormatter<std::map<K, V>> +{ static void Do(TStringBuilderBase* builder, const std::map<K, V>& collection, TStringBuf /*format*/) - { - FormatKeyValueRange(builder, collection, TDefaultFormatter()); - } -}; - -// std::multimap -template <class K, class V> -struct TValueFormatter<std::multimap<K, V>> -{ + { + FormatKeyValueRange(builder, collection, TDefaultFormatter()); + } +}; + +// std::multimap +template <class K, class V> +struct TValueFormatter<std::multimap<K, V>> +{ static void Do(TStringBuilderBase* builder, const std::multimap<K, V>& collection, TStringBuf /*format*/) - { - FormatKeyValueRange(builder, collection, TDefaultFormatter()); - } -}; - + { + FormatKeyValueRange(builder, collection, TDefaultFormatter()); + } +}; + // THashSet template <class T> struct TValueFormatter<THashSet<T>> @@ -357,26 +357,26 @@ struct TValueFormatter<THashMultiSet<T>> } }; -// THashMap -template <class K, class V> -struct TValueFormatter<THashMap<K, V>> -{ +// THashMap +template <class K, class V> +struct TValueFormatter<THashMap<K, V>> +{ static void Do(TStringBuilderBase* builder, const THashMap<K, V>& collection, TStringBuf /*format*/) - { - FormatKeyValueRange(builder, collection, TDefaultFormatter()); - } -}; - -// THashMultiMap -template <class K, class V> -struct TValueFormatter<THashMultiMap<K, V>> -{ + { + FormatKeyValueRange(builder, collection, TDefaultFormatter()); + } +}; + +// THashMultiMap +template <class K, class V> +struct TValueFormatter<THashMultiMap<K, V>> +{ static void Do(TStringBuilderBase* builder, const THashMultiMap<K, V>& collection, TStringBuf /*format*/) - { - FormatKeyValueRange(builder, collection, TDefaultFormatter()); - } -}; - + { + FormatKeyValueRange(builder, collection, TDefaultFormatter()); + } +}; + // TEnumIndexedVector template <class E, class T> struct TValueFormatter<TEnumIndexedVector<E, T>> @@ -439,37 +439,37 @@ auto FormatValue(TStringBuilderBase* builder, const TValue& value, TStringBuf fo } template <class TValue> -void FormatValueViaSprintf( +void FormatValueViaSprintf( TStringBuilderBase* builder, - TValue value, + TValue value, TStringBuf format, TStringBuf genericSpec) { constexpr int MaxFormatSize = 64; constexpr int SmallResultSize = 64; - auto copyFormat = [] (char* destination, const char* source, int length) { - int position = 0; + auto copyFormat = [] (char* destination, const char* source, int length) { + int position = 0; for (int index = 0; index < length; ++index) { - if (IsQuotationSpecSymbol(source[index])) { - continue; - } - destination[position] = source[index]; - ++position; - } - return destination + position; - }; - + if (IsQuotationSpecSymbol(source[index])) { + continue; + } + destination[position] = source[index]; + ++position; + } + return destination + position; + }; + char formatBuf[MaxFormatSize]; YT_VERIFY(format.length() >= 1 && format.length() <= MaxFormatSize - 2); // one for %, one for \0 formatBuf[0] = '%'; if (format[format.length() - 1] == GenericSpecSymbol) { - char* formatEnd = copyFormat(formatBuf + 1, format.begin(), format.length() - 1); + char* formatEnd = copyFormat(formatBuf + 1, format.begin(), format.length() - 1); ::memcpy(formatEnd, genericSpec.begin(), genericSpec.length()); - formatEnd[genericSpec.length()] = '\0'; + formatEnd[genericSpec.length()] = '\0'; } else { - char* formatEnd = copyFormat(formatBuf + 1, format.begin(), format.length()); - *formatEnd = '\0'; + char* formatEnd = copyFormat(formatBuf + 1, format.begin(), format.length()); + *formatEnd = '\0'; } char* result = builder->Preallocate(SmallResultSize); @@ -481,27 +481,27 @@ void FormatValueViaSprintf( builder->Advance(resultSize); } -template <class TValue> -char* WriteIntToBufferBackwards(char* buffer, TValue value); - -template <class TValue> +template <class TValue> +char* WriteIntToBufferBackwards(char* buffer, TValue value); + +template <class TValue> void FormatValueViaHelper(TStringBuilderBase* builder, TValue value, TStringBuf format, TStringBuf genericSpec) -{ +{ if (format == TStringBuf("v")) { - const int MaxResultSize = 64; - char buffer[MaxResultSize]; - char* end = buffer + MaxResultSize; - char* start = WriteIntToBufferBackwards(end, value); - builder->AppendString(TStringBuf(start, end)); - } else { - FormatValueViaSprintf(builder, value, format, genericSpec); - } -} - -#define XX(valueType, castType, genericSpec) \ + const int MaxResultSize = 64; + char buffer[MaxResultSize]; + char* end = buffer + MaxResultSize; + char* start = WriteIntToBufferBackwards(end, value); + builder->AppendString(TStringBuf(start, end)); + } else { + FormatValueViaSprintf(builder, value, format, genericSpec); + } +} + +#define XX(valueType, castType, genericSpec) \ inline void FormatValue(TStringBuilderBase* builder, valueType value, TStringBuf format) \ { \ - FormatValueViaHelper(builder, static_cast<castType>(value), format, genericSpec); \ + FormatValueViaHelper(builder, static_cast<castType>(value), format, genericSpec); \ } XX(i8, int, TStringBuf("d")) @@ -513,32 +513,32 @@ XX(ui32, unsigned int, TStringBuf("u")) XX(long, long, TStringBuf("ld")) XX(unsigned long, unsigned long, TStringBuf("lu")) -#undef XX +#undef XX -#define XX(valueType, castType, genericSpec) \ +#define XX(valueType, castType, genericSpec) \ inline void FormatValue(TStringBuilderBase* builder, valueType value, TStringBuf format) \ - { \ - FormatValueViaSprintf(builder, static_cast<castType>(value), format, genericSpec); \ - } - + { \ + FormatValueViaSprintf(builder, static_cast<castType>(value), format, genericSpec); \ + } + XX(double, double, TStringBuf("lf")) XX(float, float, TStringBuf("f")) - -#undef XX - + +#undef XX + // Pointer -template <class T> +template <class T> void FormatValue(TStringBuilderBase* builder, T* value, TStringBuf format) -{ +{ FormatValueViaSprintf(builder, value, format, TStringBuf("p")); -} - -// TDuration (specialize for performance reasons) +} + +// TDuration (specialize for performance reasons) inline void FormatValue(TStringBuilderBase* builder, TDuration value, TStringBuf /*format*/) -{ +{ builder->AppendFormat("%vus", value.MicroSeconds()); -} - +} + // TInstant (specialize for TFormatTraits) inline void FormatValue(TStringBuilderBase* builder, TInstant value, TStringBuf format) { diff --git a/library/cpp/yt/string/guid.cpp b/library/cpp/yt/string/guid.cpp index 7db913fede4..6c133a97789 100644 --- a/library/cpp/yt/string/guid.cpp +++ b/library/cpp/yt/string/guid.cpp @@ -1,22 +1,22 @@ -#include "guid.h" - -namespace NYT { - -//////////////////////////////////////////////////////////////////////////////// - -void FormatValue(TStringBuilderBase* builder, TGuid value, TStringBuf /*format*/) -{ +#include "guid.h" + +namespace NYT { + +//////////////////////////////////////////////////////////////////////////////// + +void FormatValue(TStringBuilderBase* builder, TGuid value, TStringBuf /*format*/) +{ char* begin = builder->Preallocate(MaxGuidStringSize); - char* end = WriteGuidToBuffer(begin, value); - builder->Advance(end - begin); -} - -TString ToString(TGuid guid) -{ - return ToStringViaBuilder(guid); -} - -//////////////////////////////////////////////////////////////////////////////// - -} // namespace NYT - + char* end = WriteGuidToBuffer(begin, value); + builder->Advance(end - begin); +} + +TString ToString(TGuid guid) +{ + return ToStringViaBuilder(guid); +} + +//////////////////////////////////////////////////////////////////////////////// + +} // namespace NYT + diff --git a/library/cpp/yt/string/guid.h b/library/cpp/yt/string/guid.h index e46b3a5db08..75edbce5dbb 100644 --- a/library/cpp/yt/string/guid.h +++ b/library/cpp/yt/string/guid.h @@ -1,14 +1,14 @@ -#include <library/cpp/yt/misc/guid.h> - -#include "format.h" - -namespace NYT { - -//////////////////////////////////////////////////////////////////////////////// - -void FormatValue(TStringBuilderBase* builder, TGuid value, TStringBuf /*format*/); -TString ToString(TGuid guid); - -//////////////////////////////////////////////////////////////////////////////// - -} // namespace NYT +#include <library/cpp/yt/misc/guid.h> + +#include "format.h" + +namespace NYT { + +//////////////////////////////////////////////////////////////////////////////// + +void FormatValue(TStringBuilderBase* builder, TGuid value, TStringBuf /*format*/); +TString ToString(TGuid guid); + +//////////////////////////////////////////////////////////////////////////////// + +} // namespace NYT diff --git a/library/cpp/yt/string/string.cpp b/library/cpp/yt/string/string.cpp index 24ea4a6ba3d..7440ac3fdd1 100644 --- a/library/cpp/yt/string/string.cpp +++ b/library/cpp/yt/string/string.cpp @@ -2,9 +2,9 @@ #include "format.h" #include <library/cpp/yt/assert/assert.h> - + #include <util/generic/hash.h> - + #include <util/string/ascii.h> namespace NYT { @@ -103,117 +103,117 @@ TString Trim(const TString& str, const TString& whitespaces) //////////////////////////////////////////////////////////////////////////////// -namespace { - -ui16 DecimalDigits2[100] = { - 12336, 12592, 12848, 13104, 13360, 13616, 13872, 14128, 14384, 14640, - 12337, 12593, 12849, 13105, 13361, 13617, 13873, 14129, 14385, 14641, - 12338, 12594, 12850, 13106, 13362, 13618, 13874, 14130, 14386, 14642, - 12339, 12595, 12851, 13107, 13363, 13619, 13875, 14131, 14387, 14643, - 12340, 12596, 12852, 13108, 13364, 13620, 13876, 14132, 14388, 14644, - 12341, 12597, 12853, 13109, 13365, 13621, 13877, 14133, 14389, 14645, - 12342, 12598, 12854, 13110, 13366, 13622, 13878, 14134, 14390, 14646, - 12343, 12599, 12855, 13111, 13367, 13623, 13879, 14135, 14391, 14647, - 12344, 12600, 12856, 13112, 13368, 13624, 13880, 14136, 14392, 14648, - 12345, 12601, 12857, 13113, 13369, 13625, 13881, 14137, 14393, 14649 -}; - -template <class T> +namespace { + +ui16 DecimalDigits2[100] = { + 12336, 12592, 12848, 13104, 13360, 13616, 13872, 14128, 14384, 14640, + 12337, 12593, 12849, 13105, 13361, 13617, 13873, 14129, 14385, 14641, + 12338, 12594, 12850, 13106, 13362, 13618, 13874, 14130, 14386, 14642, + 12339, 12595, 12851, 13107, 13363, 13619, 13875, 14131, 14387, 14643, + 12340, 12596, 12852, 13108, 13364, 13620, 13876, 14132, 14388, 14644, + 12341, 12597, 12853, 13109, 13365, 13621, 13877, 14133, 14389, 14645, + 12342, 12598, 12854, 13110, 13366, 13622, 13878, 14134, 14390, 14646, + 12343, 12599, 12855, 13111, 13367, 13623, 13879, 14135, 14391, 14647, + 12344, 12600, 12856, 13112, 13368, 13624, 13880, 14136, 14392, 14648, + 12345, 12601, 12857, 13113, 13369, 13625, 13881, 14137, 14393, 14649 +}; + +template <class T> char* WriteSignedIntToBufferBackwardsImpl(char* ptr, T value, TStringBuf min) -{ - if (value == 0) { - --ptr; - *ptr = '0'; - return ptr; - } - - // The negative value handling code below works incorrectly for min values. - if (value == std::numeric_limits<T>::min()) { - ptr -= min.length(); +{ + if (value == 0) { + --ptr; + *ptr = '0'; + return ptr; + } + + // The negative value handling code below works incorrectly for min values. + if (value == std::numeric_limits<T>::min()) { + ptr -= min.length(); ::memcpy(ptr, min.begin(), min.length()); - return ptr; - } - - bool negative = false; - if (value < 0) { - negative = true; - value = -value; - } - - while (value >= 10) { - i64 rem = value % 100; - i64 quot = value / 100; - ptr -= 2; + return ptr; + } + + bool negative = false; + if (value < 0) { + negative = true; + value = -value; + } + + while (value >= 10) { + i64 rem = value % 100; + i64 quot = value / 100; + ptr -= 2; ::memcpy(ptr, &DecimalDigits2[rem], 2); - value = quot; - } - - if (value > 0) { - --ptr; - *ptr = ('0' + value); - } - - if (negative) { - --ptr; - *ptr = '-'; - } - - return ptr; -} - -template <class T> -char* WriteUnsignedIntToBufferBackwardsImpl(char* ptr, T value) -{ - if (value == 0) { - --ptr; - *ptr = '0'; - return ptr; - } - - while (value >= 10) { - i64 rem = value % 100; - i64 quot = value / 100; - ptr -= 2; + value = quot; + } + + if (value > 0) { + --ptr; + *ptr = ('0' + value); + } + + if (negative) { + --ptr; + *ptr = '-'; + } + + return ptr; +} + +template <class T> +char* WriteUnsignedIntToBufferBackwardsImpl(char* ptr, T value) +{ + if (value == 0) { + --ptr; + *ptr = '0'; + return ptr; + } + + while (value >= 10) { + i64 rem = value % 100; + i64 quot = value / 100; + ptr -= 2; ::memcpy(ptr, &DecimalDigits2[rem], 2); - value = quot; - } - - if (value > 0) { - --ptr; - *ptr = ('0' + value); - } - - return ptr; -} - -} // namespace - -template <> -char* WriteIntToBufferBackwards(char* ptr, i32 value) -{ + value = quot; + } + + if (value > 0) { + --ptr; + *ptr = ('0' + value); + } + + return ptr; +} + +} // namespace + +template <> +char* WriteIntToBufferBackwards(char* ptr, i32 value) +{ return WriteSignedIntToBufferBackwardsImpl(ptr, value, TStringBuf("-2147483647")); -} - -template <> -char* WriteIntToBufferBackwards(char* ptr, i64 value) -{ +} + +template <> +char* WriteIntToBufferBackwards(char* ptr, i64 value) +{ return WriteSignedIntToBufferBackwardsImpl(ptr, value, TStringBuf("-9223372036854775808")); -} - -template <> -char* WriteIntToBufferBackwards(char* ptr, ui32 value) -{ - return WriteUnsignedIntToBufferBackwardsImpl(ptr, value); -} - -template <> -char* WriteIntToBufferBackwards(char* ptr, ui64 value) -{ - return WriteUnsignedIntToBufferBackwardsImpl(ptr, value); -} - -//////////////////////////////////////////////////////////////////////////////// - +} + +template <> +char* WriteIntToBufferBackwards(char* ptr, ui32 value) +{ + return WriteUnsignedIntToBufferBackwardsImpl(ptr, value); +} + +template <> +char* WriteIntToBufferBackwards(char* ptr, ui64 value) +{ + return WriteUnsignedIntToBufferBackwardsImpl(ptr, value); +} + +//////////////////////////////////////////////////////////////////////////////// + size_t TCaseInsensitiveStringHasher::operator()(TStringBuf arg) const { auto compute = [&] (char* buffer) { @@ -240,33 +240,33 @@ bool TCaseInsensitiveStringEqualityComparer::operator()(TStringBuf lhs, TStringB //////////////////////////////////////////////////////////////////////////////// bool TryParseBool(TStringBuf value, bool* result) -{ - if (value == "true" || value == "1") { +{ + if (value == "true" || value == "1") { *result = true; - return true; - } else if (value == "false" || value == "0") { + return true; + } else if (value == "false" || value == "0") { *result = false; - return true; - } else { - return false; - } -} - + return true; + } else { + return false; + } +} + bool ParseBool(TStringBuf value) -{ - bool result; +{ + bool result; if (!TryParseBool(value, &result)) { throw TSimpleException(Format("Error parsing boolean value %Qv", value)); - } - return result; -} - -TStringBuf FormatBool(bool value) -{ - return value ? TStringBuf("true") : TStringBuf("false"); -} - -//////////////////////////////////////////////////////////////////////////////// - + } + return result; +} + +TStringBuf FormatBool(bool value) +{ + return value ? TStringBuf("true") : TStringBuf("false"); +} + +//////////////////////////////////////////////////////////////////////////////// + } // namespace NYT diff --git a/library/cpp/yt/string/string.h b/library/cpp/yt/string/string.h index 584cc6c2e04..ae6c99caab0 100644 --- a/library/cpp/yt/string/string.h +++ b/library/cpp/yt/string/string.h @@ -4,16 +4,16 @@ #include <library/cpp/yt/exception/exception.h> -#include <util/datetime/base.h> - -#include <util/generic/string.h> - +#include <util/datetime/base.h> + +#include <util/generic/string.h> + #include <util/string/strip.h> -#include <vector> -#include <set> -#include <map> - +#include <vector> +#include <set> +#include <map> + namespace NYT { //////////////////////////////////////////////////////////////////////////////// @@ -194,12 +194,12 @@ TString Trim(const TString& str, const TString& whitespaces); //////////////////////////////////////////////////////////////////////////////// -//! Implemented for |[u]i(32|64)|. -template <class T> -char* WriteIntToBufferBackwards(char* ptr, T value); - -//////////////////////////////////////////////////////////////////////////////// - +//! Implemented for |[u]i(32|64)|. +template <class T> +char* WriteIntToBufferBackwards(char* ptr, T value); + +//////////////////////////////////////////////////////////////////////////////// + struct TCaseInsensitiveStringHasher { size_t operator()(TStringBuf arg) const; @@ -214,8 +214,8 @@ struct TCaseInsensitiveStringEqualityComparer bool TryParseBool(TStringBuf value, bool* result); bool ParseBool(TStringBuf value); -TStringBuf FormatBool(bool value); - -//////////////////////////////////////////////////////////////////////////////// - +TStringBuf FormatBool(bool value); + +//////////////////////////////////////////////////////////////////////////////// + } // namespace NYT diff --git a/library/cpp/yt/string/string_builder-inl.h b/library/cpp/yt/string/string_builder-inl.h index 71787fe072a..151fcabf7f0 100644 --- a/library/cpp/yt/string/string_builder-inl.h +++ b/library/cpp/yt/string/string_builder-inl.h @@ -46,11 +46,11 @@ inline void TStringBuilderBase::AppendChar(char ch) inline void TStringBuilderBase::AppendChar(char ch, int n) { YT_ASSERT(n >= 0); - if (Y_LIKELY(0 != n)) { - char* dst = Preallocate(n); - ::memset(dst, ch, n); - Advance(n); - } + if (Y_LIKELY(0 != n)) { + char* dst = Preallocate(n); + ::memset(dst, ch, n); + Advance(n); + } } inline void TStringBuilderBase::AppendString(TStringBuf str) diff --git a/library/cpp/yt/string/unittests/enum_ut.cpp b/library/cpp/yt/string/unittests/enum_ut.cpp index 94009eac128..b8076fd8eed 100644 --- a/library/cpp/yt/string/unittests/enum_ut.cpp +++ b/library/cpp/yt/string/unittests/enum_ut.cpp @@ -1,7 +1,7 @@ -#include <library/cpp/testing/gtest/gtest.h> +#include <library/cpp/testing/gtest/gtest.h> -#include <library/cpp/yt/string/enum.h> -#include <library/cpp/yt/string/format.h> +#include <library/cpp/yt/string/enum.h> +#include <library/cpp/yt/string/format.h> #include <limits> @@ -58,4 +58,4 @@ TEST(TFormatTest, Enum) } // namespace } // namespace NYT - + diff --git a/library/cpp/yt/string/unittests/format_ut.cpp b/library/cpp/yt/string/unittests/format_ut.cpp index 356c8552096..ee069bb2c09 100644 --- a/library/cpp/yt/string/unittests/format_ut.cpp +++ b/library/cpp/yt/string/unittests/format_ut.cpp @@ -1,9 +1,9 @@ -#include <library/cpp/testing/gtest/gtest.h> +#include <library/cpp/testing/gtest/gtest.h> #include <library/cpp/yt/string/format.h> #include <library/cpp/yt/small_containers/compact_vector.h> - + #include <limits> namespace NYT { diff --git a/library/cpp/yt/string/unittests/guid_ut.cpp b/library/cpp/yt/string/unittests/guid_ut.cpp index a54ca206d37..4b5eebea16e 100644 --- a/library/cpp/yt/string/unittests/guid_ut.cpp +++ b/library/cpp/yt/string/unittests/guid_ut.cpp @@ -1,7 +1,7 @@ -#include <library/cpp/testing/gtest/gtest.h> +#include <library/cpp/testing/gtest/gtest.h> -#include <library/cpp/yt/string/guid.h> -#include <library/cpp/yt/string/format.h> +#include <library/cpp/yt/string/guid.h> +#include <library/cpp/yt/string/format.h> #include <util/string/hex.h> @@ -10,7 +10,7 @@ namespace { //////////////////////////////////////////////////////////////////////////////// -static_assert(TFormatTraits<TGuid>::HasCustomFormatValue); +static_assert(TFormatTraits<TGuid>::HasCustomFormatValue); TString CanonicalToString(TGuid value) { diff --git a/library/cpp/yt/string/unittests/string_ut.cpp b/library/cpp/yt/string/unittests/string_ut.cpp index 5671b25710e..3e12312af0b 100644 --- a/library/cpp/yt/string/unittests/string_ut.cpp +++ b/library/cpp/yt/string/unittests/string_ut.cpp @@ -1,4 +1,4 @@ -#include <library/cpp/testing/gtest/gtest.h> +#include <library/cpp/testing/gtest/gtest.h> #include <library/cpp/yt/string/string.h> diff --git a/library/cpp/yt/string/unittests/ya.make b/library/cpp/yt/string/unittests/ya.make index 36aecb0857f..9d539758d12 100644 --- a/library/cpp/yt/string/unittests/ya.make +++ b/library/cpp/yt/string/unittests/ya.make @@ -1,17 +1,17 @@ -GTEST(unittester-library-string-helpers) - -OWNER(g:yt) - -SRCS( - enum_ut.cpp - format_ut.cpp - guid_ut.cpp - string_ut.cpp -) - -PEERDIR( +GTEST(unittester-library-string-helpers) + +OWNER(g:yt) + +SRCS( + enum_ut.cpp + format_ut.cpp + guid_ut.cpp + string_ut.cpp +) + +PEERDIR( library/cpp/yt/string - library/cpp/testing/gtest -) - -END() + library/cpp/testing/gtest +) + +END() diff --git a/library/cpp/yt/string/ya.make b/library/cpp/yt/string/ya.make index 61a4ba45d26..83efd5eb2f9 100644 --- a/library/cpp/yt/string/ya.make +++ b/library/cpp/yt/string/ya.make @@ -1,30 +1,30 @@ -LIBRARY() - -SRCS( - enum.cpp - guid.cpp - string.cpp -) - -PEERDIR( +LIBRARY() + +SRCS( + enum.cpp + guid.cpp + string.cpp +) + +PEERDIR( library/cpp/yt/assert library/cpp/yt/exception - library/cpp/yt/misc -) - -CHECK_DEPENDENT_DIRS( - ALLOW_ONLY ALL - build - contrib - library - util + library/cpp/yt/misc +) + +CHECK_DEPENDENT_DIRS( + ALLOW_ONLY ALL + build + contrib + library + util library/cpp/yt/assert - library/cpp/yt/misc + library/cpp/yt/misc library/cpp/yt/small_containers -) - -END() - -RECURSE_FOR_TESTS( - unittests -) +) + +END() + +RECURSE_FOR_TESTS( + unittests +) |