summaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/string
diff options
context:
space:
mode:
authorpechatnov <[email protected]>2025-08-05 12:58:59 +0300
committerpechatnov <[email protected]>2025-08-05 13:13:03 +0300
commit986452bd918bcba07aff4fe904852a9893129408 (patch)
tree2fbe3bd66944cf15e41d625e42651effb3d350b8 /library/cpp/yt/string
parent79b068dcb532d099663707ee1e93faed14da1a2f (diff)
Extract FormatString that can be used with TStringBuilderBase and TRawFormatter
commit_hash:06e3edc032341bfb4f625c2713ce3773fc4c0c9f
Diffstat (limited to 'library/cpp/yt/string')
-rw-r--r--library/cpp/yt/string/format-inl.h90
1 files changed, 49 insertions, 41 deletions
diff --git a/library/cpp/yt/string/format-inl.h b/library/cpp/yt/string/format-inl.h
index 5b49fc5925c..76c06e385bf 100644
--- a/library/cpp/yt/string/format-inl.h
+++ b/library/cpp/yt/string/format-inl.h
@@ -414,47 +414,8 @@ auto MakeLazyMultiValueFormatter(TStringBuf format, TArgs&&... args)
////////////////////////////////////////////////////////////////////////////////
-// Non-container objects.
-
-#define XX(valueType, castType, genericSpec) \
- inline void FormatValue(TStringBuilderBase* builder, valueType value, TStringBuf spec) \
- { \
- NYT::NDetail::FormatIntValue(builder, static_cast<castType>(value), spec, genericSpec); \
- }
-
-XX(i8, i32, TStringBuf("d"))
-XX(ui8, ui32, TStringBuf("u"))
-XX(i16, i32, TStringBuf("d"))
-XX(ui16, ui32, TStringBuf("u"))
-XX(i32, i32, TStringBuf("d"))
-XX(ui32, ui32, TStringBuf("u"))
-XX(long, i64, TStringBuf(PRIdLEAST64))
-XX(long long, i64, TStringBuf(PRIdLEAST64))
-XX(unsigned long, ui64, TStringBuf(PRIuLEAST64))
-XX(unsigned long long, ui64, TStringBuf(PRIuLEAST64))
-
-#undef XX
-
-#define XX(valueType, castType, genericSpec) \
- inline void FormatValue(TStringBuilderBase* builder, valueType value, TStringBuf spec) \
- { \
- NYT::NDetail::FormatValueViaSprintf(builder, static_cast<castType>(value), spec, genericSpec); \
- }
-
-XX(double, double, TStringBuf("lf"))
-XX(float, float, TStringBuf("f"))
-
-#undef XX
-
-// Pointer
-template <class T>
-void FormatValue(TStringBuilderBase* builder, T* value, TStringBuf spec)
-{
- NYT::NDetail::FormatPointerValue(builder, static_cast<const void*>(value), spec);
-}
-
-// TStringBuf
-inline void FormatValue(TStringBuilderBase* builder, TStringBuf value, TStringBuf spec)
+template <class TStringBuilder>
+void FormatString(TStringBuilder* builder, TStringBuf value, TStringBuf spec)
{
if (!spec) {
builder->AppendString(value);
@@ -543,6 +504,53 @@ inline void FormatValue(TStringBuilderBase* builder, TStringBuf value, TStringBu
}
}
+////////////////////////////////////////////////////////////////////////////////
+
+// Non-container objects.
+
+#define XX(valueType, castType, genericSpec) \
+ inline void FormatValue(TStringBuilderBase* builder, valueType value, TStringBuf spec) \
+ { \
+ NYT::NDetail::FormatIntValue(builder, static_cast<castType>(value), spec, genericSpec); \
+ }
+
+XX(i8, i32, TStringBuf("d"))
+XX(ui8, ui32, TStringBuf("u"))
+XX(i16, i32, TStringBuf("d"))
+XX(ui16, ui32, TStringBuf("u"))
+XX(i32, i32, TStringBuf("d"))
+XX(ui32, ui32, TStringBuf("u"))
+XX(long, i64, TStringBuf(PRIdLEAST64))
+XX(long long, i64, TStringBuf(PRIdLEAST64))
+XX(unsigned long, ui64, TStringBuf(PRIuLEAST64))
+XX(unsigned long long, ui64, TStringBuf(PRIuLEAST64))
+
+#undef XX
+
+#define XX(valueType, castType, genericSpec) \
+ inline void FormatValue(TStringBuilderBase* builder, valueType value, TStringBuf spec) \
+ { \
+ NYT::NDetail::FormatValueViaSprintf(builder, static_cast<castType>(value), spec, genericSpec); \
+ }
+
+XX(double, double, TStringBuf("lf"))
+XX(float, float, TStringBuf("f"))
+
+#undef XX
+
+// Pointer
+template <class T>
+void FormatValue(TStringBuilderBase* builder, T* value, TStringBuf spec)
+{
+ NYT::NDetail::FormatPointerValue(builder, static_cast<const void*>(value), spec);
+}
+
+// TStringBuf
+inline void FormatValue(TStringBuilderBase* builder, TStringBuf value, TStringBuf spec)
+{
+ FormatString(builder, value, spec);
+}
+
// TString
inline void FormatValue(TStringBuilderBase* builder, const TString& value, TStringBuf spec)
{