aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/dbg_output
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:15 +0300
commit72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch)
treeda2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /library/cpp/dbg_output
parent778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff)
downloadydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/dbg_output')
-rw-r--r--library/cpp/dbg_output/DONT_COMMIT.h14
-rw-r--r--library/cpp/dbg_output/auto.h12
-rw-r--r--library/cpp/dbg_output/colorscheme.h122
-rw-r--r--library/cpp/dbg_output/dump.cpp2
-rw-r--r--library/cpp/dbg_output/dump.h166
-rw-r--r--library/cpp/dbg_output/dumpers.cpp2
-rw-r--r--library/cpp/dbg_output/dumpers.h250
-rw-r--r--library/cpp/dbg_output/engine.cpp62
-rw-r--r--library/cpp/dbg_output/engine.h308
-rw-r--r--library/cpp/dbg_output/ut/dbg_output_ut.cpp60
-rw-r--r--library/cpp/dbg_output/ya.make20
11 files changed, 509 insertions, 509 deletions
diff --git a/library/cpp/dbg_output/DONT_COMMIT.h b/library/cpp/dbg_output/DONT_COMMIT.h
index e7b3182c20..4a106d5cfb 100644
--- a/library/cpp/dbg_output/DONT_COMMIT.h
+++ b/library/cpp/dbg_output/DONT_COMMIT.h
@@ -4,13 +4,13 @@
// The latter is allowed only locally, so this file is named
// in such a way that including it prevents from committing the #include via ARC-1205.
-#define DBGDUMP_INLINE_IF_INCLUDED inline
-
-#include "dump.cpp"
-#include "dumpers.cpp"
-#include "engine.cpp"
-
+#define DBGDUMP_INLINE_IF_INCLUDED inline
+
+#include "dump.cpp"
+#include "dumpers.cpp"
+#include "engine.cpp"
+
#include <library/cpp/colorizer/colors.cpp>
#include <library/cpp/colorizer/output.cpp>
-#undef DBGDUMP_INLINE_IF_INCLUDED
+#undef DBGDUMP_INLINE_IF_INCLUDED
diff --git a/library/cpp/dbg_output/auto.h b/library/cpp/dbg_output/auto.h
index 8d96167f6a..99961bfa6b 100644
--- a/library/cpp/dbg_output/auto.h
+++ b/library/cpp/dbg_output/auto.h
@@ -10,13 +10,13 @@
// Usage: struct TMyStruct { int A, B; }; DEFINE_DUMPER(TMyStruct, A, B); Cout << TMyStruct{3, 4};
// yields {"A": 3, "B": 4}
-#define DEFINE_DUMPER(C, ...) \
- template <> \
- struct TDumper<C> { \
- template <class S> \
- static inline void Dump(S& s, const C& v) { \
+#define DEFINE_DUMPER(C, ...) \
+ template <> \
+ struct TDumper<C> { \
+ template <class S> \
+ static inline void Dump(S& s, const C& v) { \
s << DumpRaw("{") Y_PASS_VA_ARGS(Y_MAP_ARGS_WITH_LAST(__DEFINE_DUMPER_NONLAST__, __DEFINE_DUMPER_IMPL__, __VA_ARGS__)) << DumpRaw("}"); \
- } \
+ } \
};
#define __DEFINE_DUMPER_IMPL__(x) << DumpRaw("\"" #x "\": ") << v.x
#define __DEFINE_DUMPER_NONLAST__(x) __DEFINE_DUMPER_IMPL__(x) << DumpRaw(", ")
diff --git a/library/cpp/dbg_output/colorscheme.h b/library/cpp/dbg_output/colorscheme.h
index a5b9cf749a..49c4a33a8a 100644
--- a/library/cpp/dbg_output/colorscheme.h
+++ b/library/cpp/dbg_output/colorscheme.h
@@ -4,93 +4,93 @@
#include <library/cpp/colorizer/output.h>
#ifndef DBG_OUTPUT_DEFAULT_COLOR_SCHEME
-#define DBG_OUTPUT_DEFAULT_COLOR_SCHEME NDbgDump::NColorScheme::TPlain
+#define DBG_OUTPUT_DEFAULT_COLOR_SCHEME NDbgDump::NColorScheme::TPlain
#endif
#define DBG_OUTPUT_COLOR_HANDLER(NAME) \
- template <class S> \
+ template <class S> \
inline void NAME(S& stream)
namespace NDbgDump {
- namespace NColorScheme {
- /// Start by copying this one if you want to define a custom color scheme.
- struct TPlain {
- // Foreground color modifiers
- DBG_OUTPUT_COLOR_HANDLER(Markup) {
+ namespace NColorScheme {
+ /// Start by copying this one if you want to define a custom color scheme.
+ struct TPlain {
+ // Foreground color modifiers
+ DBG_OUTPUT_COLOR_HANDLER(Markup) {
Y_UNUSED(stream);
- }
- DBG_OUTPUT_COLOR_HANDLER(String) {
+ }
+ DBG_OUTPUT_COLOR_HANDLER(String) {
Y_UNUSED(stream);
- }
- DBG_OUTPUT_COLOR_HANDLER(Literal) {
+ }
+ DBG_OUTPUT_COLOR_HANDLER(Literal) {
Y_UNUSED(stream);
- }
- DBG_OUTPUT_COLOR_HANDLER(ResetType) {
+ }
+ DBG_OUTPUT_COLOR_HANDLER(ResetType) {
Y_UNUSED(stream);
- }
+ }
- // Background color modifiers
- DBG_OUTPUT_COLOR_HANDLER(Key) {
+ // Background color modifiers
+ DBG_OUTPUT_COLOR_HANDLER(Key) {
Y_UNUSED(stream);
- }
- DBG_OUTPUT_COLOR_HANDLER(Value) {
+ }
+ DBG_OUTPUT_COLOR_HANDLER(Value) {
Y_UNUSED(stream);
- }
- DBG_OUTPUT_COLOR_HANDLER(ResetRole) {
+ }
+ DBG_OUTPUT_COLOR_HANDLER(ResetRole) {
Y_UNUSED(stream);
- }
- };
+ }
+ };
- /// Use this one if you want colors but are lazy enough to define a custom color scheme.
- /// Be careful enough to use DumpRaw for avoiding an endless recursion.
- /// Enforce controls whether colors should be applied even if stdout is not a TTY.
- template <bool Enforce = false>
- class TEyebleed {
- public:
- TEyebleed() {
- if (Enforce) {
- Colors.Enable();
- }
+ /// Use this one if you want colors but are lazy enough to define a custom color scheme.
+ /// Be careful enough to use DumpRaw for avoiding an endless recursion.
+ /// Enforce controls whether colors should be applied even if stdout is not a TTY.
+ template <bool Enforce = false>
+ class TEyebleed {
+ public:
+ TEyebleed() {
+ if (Enforce) {
+ Colors.Enable();
+ }
}
- // Foreground color modifiers
- DBG_OUTPUT_COLOR_HANDLER(Markup) {
- stream << DumpRaw(Colors.LightGreenColor());
- }
- DBG_OUTPUT_COLOR_HANDLER(String) {
- stream << DumpRaw(Colors.YellowColor());
- }
- DBG_OUTPUT_COLOR_HANDLER(Literal) {
- stream << DumpRaw(Colors.LightRedColor());
- }
- DBG_OUTPUT_COLOR_HANDLER(ResetType) {
- stream << DumpRaw(Colors.OldColor());
- }
+ // Foreground color modifiers
+ DBG_OUTPUT_COLOR_HANDLER(Markup) {
+ stream << DumpRaw(Colors.LightGreenColor());
+ }
+ DBG_OUTPUT_COLOR_HANDLER(String) {
+ stream << DumpRaw(Colors.YellowColor());
+ }
+ DBG_OUTPUT_COLOR_HANDLER(Literal) {
+ stream << DumpRaw(Colors.LightRedColor());
+ }
+ DBG_OUTPUT_COLOR_HANDLER(ResetType) {
+ stream << DumpRaw(Colors.OldColor());
+ }
- // Background color modifiers
+ // Background color modifiers
// TODO: support backgrounds in library/cpp/colorizer
- DBG_OUTPUT_COLOR_HANDLER(Key) {
- if (Depth++ == 0 && Colors.IsTTY()) {
+ DBG_OUTPUT_COLOR_HANDLER(Key) {
+ if (Depth++ == 0 && Colors.IsTTY()) {
stream << DumpRaw(TStringBuf("\033[42m"));
- }
+ }
}
- DBG_OUTPUT_COLOR_HANDLER(Value) {
- if (Depth++ == 0 && Colors.IsTTY()) {
+ DBG_OUTPUT_COLOR_HANDLER(Value) {
+ if (Depth++ == 0 && Colors.IsTTY()) {
stream << DumpRaw(TStringBuf("\033[44m"));
- }
+ }
}
- DBG_OUTPUT_COLOR_HANDLER(ResetRole) {
- if (--Depth == 0 && Colors.IsTTY()) {
+ DBG_OUTPUT_COLOR_HANDLER(ResetRole) {
+ if (--Depth == 0 && Colors.IsTTY()) {
stream << DumpRaw(TStringBuf("\033[49m"));
- }
+ }
}
- private:
- NColorizer::TColors Colors;
- size_t Depth = 0;
- };
- }
-}
+ private:
+ NColorizer::TColors Colors;
+ size_t Depth = 0;
+ };
+ }
+}
namespace NPrivate {
template <typename CS>
diff --git a/library/cpp/dbg_output/dump.cpp b/library/cpp/dbg_output/dump.cpp
index ab09a93822..c3e3947008 100644
--- a/library/cpp/dbg_output/dump.cpp
+++ b/library/cpp/dbg_output/dump.cpp
@@ -1 +1 @@
-#include "dump.h"
+#include "dump.h"
diff --git a/library/cpp/dbg_output/dump.h b/library/cpp/dbg_output/dump.h
index c7efa105ee..184df606c1 100644
--- a/library/cpp/dbg_output/dump.h
+++ b/library/cpp/dbg_output/dump.h
@@ -1,106 +1,106 @@
-#pragma once
-
-#include "engine.h"
-#include "dumpers.h"
+#pragma once
+
+#include "engine.h"
+#include "dumpers.h"
#include "auto.h"
#include "colorscheme.h"
-
-#include <util/stream/format.h>
+
+#include <util/stream/format.h>
#include <util/system/type_name.h>
-#include <util/generic/hash_set.h>
+#include <util/generic/hash_set.h>
#include <utility>
-
-/*
- * Cout << DbgDump(any) << Endl;
- * Cout << DbgDumpDeep(any) << Endl;
- * Cout << DbgDump(any).SetIndent(true) << Endl;
- *
- * specialize TDumper<your type> for extending dumper
- */
-
-namespace NPrivate {
- template <class TColorScheme>
- struct TTraitsShallow {
+
+/*
+ * Cout << DbgDump(any) << Endl;
+ * Cout << DbgDumpDeep(any) << Endl;
+ * Cout << DbgDump(any).SetIndent(true) << Endl;
+ *
+ * specialize TDumper<your type> for extending dumper
+ */
+
+namespace NPrivate {
+ template <class TColorScheme>
+ struct TTraitsShallow {
struct TDump: public TDumpBase, public TColorSchemeContainer<TColorScheme> {
- template <typename... Args>
- inline TDump(Args&&... args)
+ template <typename... Args>
+ inline TDump(Args&&... args)
: TDumpBase(std::forward<Args>(args)...)
- {
- }
-
- template <class V>
- inline void Pointer(const V* v) {
- if (v) {
+ {
+ }
+
+ template <class V>
+ inline void Pointer(const V* v) {
+ if (v) {
*this << DumpRaw("(") << DumpRaw(TypeName(v).data()) << DumpRaw(")") << Hex((size_t)v);
- } else {
+ } else {
*this << DumpRaw("(") << DumpRaw(TypeName<V>().data()) << DumpRaw("*)nullptr");
- }
- }
- };
- };
-
- template <class TColorScheme>
- struct TTraitsDeep {
+ }
+ }
+ };
+ };
+
+ template <class TColorScheme>
+ struct TTraitsDeep {
struct TDump: public TDumpBase, public TColorSchemeContainer<TColorScheme> {
- template <typename... Args>
- inline TDump(Args&&... args)
+ template <typename... Args>
+ inline TDump(Args&&... args)
: TDumpBase(std::forward<Args>(args)...)
- {
- }
-
- template <class V>
- inline void Pointer(const V* v) {
+ {
+ }
+
+ template <class V>
+ inline void Pointer(const V* v) {
if (v && !Visited.contains((size_t)v)) {
- Visited.insert((size_t)v);
+ Visited.insert((size_t)v);
*this << DumpRaw("(") << DumpRaw(TypeName(v).data()) << DumpRaw(")") << Hex((size_t)v) << DumpRaw(" -> ") << *v;
- Visited.erase((size_t)v);
- } else {
+ Visited.erase((size_t)v);
+ } else {
*this << DumpRaw("(") << DumpRaw(TypeName<V>().data()) << DumpRaw("*)nullptr");
- }
- }
-
+ }
+ }
+
THashSet<size_t> Visited;
- };
- };
-
- template <class T, class TTraits>
- struct TDbgDump {
- inline TDbgDump(const T* t)
- : T_(t)
- , Indent(false)
- {
- }
-
+ };
+ };
+
+ template <class T, class TTraits>
+ struct TDbgDump {
+ inline TDbgDump(const T* t)
+ : T_(t)
+ , Indent(false)
+ {
+ }
+
inline void DumpTo(IOutputStream& out) const {
- typename TTraits::TDump d(out, Indent);
-
- d << *T_;
- }
-
+ typename TTraits::TDump d(out, Indent);
+
+ d << *T_;
+ }
+
inline TDbgDump& SetIndent(bool v) noexcept {
- Indent = v;
-
- return *this;
- }
-
- const T* T_;
- bool Indent;
- };
-
- template <class T, class TTraits>
+ Indent = v;
+
+ return *this;
+ }
+
+ const T* T_;
+ bool Indent;
+ };
+
+ template <class T, class TTraits>
static inline IOutputStream& operator<<(IOutputStream& out, const TDbgDump<T, TTraits>& d) {
- d.DumpTo(out);
-
- return out;
- }
-}
-
+ d.DumpTo(out);
+
+ return out;
+ }
+}
+
template <class T, class TColorScheme = DBG_OUTPUT_DEFAULT_COLOR_SCHEME>
static inline ::NPrivate::TDbgDump<T, ::NPrivate::TTraitsShallow<TColorScheme>> DbgDump(const T& t) {
return {std::addressof(t)};
-}
-
+}
+
template <class T, class TColorScheme = DBG_OUTPUT_DEFAULT_COLOR_SCHEME>
static inline ::NPrivate::TDbgDump<T, ::NPrivate::TTraitsDeep<TColorScheme>> DbgDumpDeep(const T& t) {
return {std::addressof(t)};
-}
+}
diff --git a/library/cpp/dbg_output/dumpers.cpp b/library/cpp/dbg_output/dumpers.cpp
index b85d15755b..0f1775ef37 100644
--- a/library/cpp/dbg_output/dumpers.cpp
+++ b/library/cpp/dbg_output/dumpers.cpp
@@ -1 +1 @@
-#include "dumpers.h"
+#include "dumpers.h"
diff --git a/library/cpp/dbg_output/dumpers.h b/library/cpp/dbg_output/dumpers.h
index 4868e97da0..cb4ea68126 100644
--- a/library/cpp/dbg_output/dumpers.h
+++ b/library/cpp/dbg_output/dumpers.h
@@ -1,52 +1,52 @@
-#pragma once
-
-#include "engine.h"
-
-#include <util/generic/fwd.h>
-#include <util/generic/strbuf.h>
+#pragma once
+
+#include "engine.h"
+
+#include <util/generic/fwd.h>
+#include <util/generic/strbuf.h>
#include <util/generic/string.h>
-
-//smart pointers
-template <class T, class D>
-struct TDumper<TAutoPtr<T, D>> {
- template <class S>
- static inline void Dump(S& s, const TAutoPtr<T, D>& v) {
- s << DumpRaw("TAutoPtr(") << v.Get() << DumpRaw(")");
- }
-};
-
-template <class T, class D>
-struct TDumper<THolder<T, D>> {
- template <class S>
- static inline void Dump(S& s, const THolder<T, D>& v) {
- s << DumpRaw("THolder(") << v.Get() << DumpRaw(")");
- }
-};
-
-template <class T, class Ops>
-struct TDumper<TIntrusivePtr<T, Ops>> {
- template <class S>
- static inline void Dump(S& s, const TIntrusivePtr<T, Ops>& v) {
- s << DumpRaw("TIntrusivePtr(") << v.Get() << DumpRaw(")");
- }
-};
-
-template <class T, class C, class D>
-struct TDumper<TSharedPtr<T, C, D>> {
- template <class S>
- static inline void Dump(S& s, const TSharedPtr<T, C, D>& v) {
- s << DumpRaw("TSharedPtr(") << v.Get() << DumpRaw(")");
- }
-};
-
-template <class T, class C, class D>
-struct TDumper<TCopyPtr<T, C, D>> {
- template <class S>
- static inline void Dump(S& s, const TCopyPtr<T, C, D>& v) {
- s << DumpRaw("TCopyPtr(") << v.Get() << DumpRaw(")");
- }
-};
-
+
+//smart pointers
+template <class T, class D>
+struct TDumper<TAutoPtr<T, D>> {
+ template <class S>
+ static inline void Dump(S& s, const TAutoPtr<T, D>& v) {
+ s << DumpRaw("TAutoPtr(") << v.Get() << DumpRaw(")");
+ }
+};
+
+template <class T, class D>
+struct TDumper<THolder<T, D>> {
+ template <class S>
+ static inline void Dump(S& s, const THolder<T, D>& v) {
+ s << DumpRaw("THolder(") << v.Get() << DumpRaw(")");
+ }
+};
+
+template <class T, class Ops>
+struct TDumper<TIntrusivePtr<T, Ops>> {
+ template <class S>
+ static inline void Dump(S& s, const TIntrusivePtr<T, Ops>& v) {
+ s << DumpRaw("TIntrusivePtr(") << v.Get() << DumpRaw(")");
+ }
+};
+
+template <class T, class C, class D>
+struct TDumper<TSharedPtr<T, C, D>> {
+ template <class S>
+ static inline void Dump(S& s, const TSharedPtr<T, C, D>& v) {
+ s << DumpRaw("TSharedPtr(") << v.Get() << DumpRaw(")");
+ }
+};
+
+template <class T, class C, class D>
+struct TDumper<TCopyPtr<T, C, D>> {
+ template <class S>
+ static inline void Dump(S& s, const TCopyPtr<T, C, D>& v) {
+ s << DumpRaw("TCopyPtr(") << v.Get() << DumpRaw(")");
+ }
+};
+
//small ints
// Default dumper prints them via IOutputStream << (value), which results in raw
// chars, not integer values. Cast to a bigger int type to force printing as
@@ -60,20 +60,20 @@ template <>
struct TDumper<i8>: public TDumper<i32> {
};
-//chars
-template <>
-struct TDumper<char>: public TCharDumper {
-};
-
-template <>
-struct TDumper<wchar16>: public TCharDumper {
-};
-
-//pairs
-template <class A, class B>
-struct TDumper<std::pair<A, B>> {
- template <class S>
- static inline void Dump(S& s, const std::pair<A, B>& v) {
+//chars
+template <>
+struct TDumper<char>: public TCharDumper {
+};
+
+template <>
+struct TDumper<wchar16>: public TCharDumper {
+};
+
+//pairs
+template <class A, class B>
+struct TDumper<std::pair<A, B>> {
+ template <class S>
+ static inline void Dump(S& s, const std::pair<A, B>& v) {
s.ColorScheme.Key(s);
s.ColorScheme.Literal(s);
s << v.first;
@@ -86,18 +86,18 @@ struct TDumper<std::pair<A, B>> {
s << v.second;
s.ColorScheme.ResetType(s);
s.ColorScheme.ResetRole(s);
- }
-};
-
-//sequences
-template <class T, class A>
+ }
+};
+
+//sequences
+template <class T, class A>
struct TDumper<TVector<T, A>>: public TSeqDumper {
-};
-
-template <class T, class A>
-struct TDumper<std::vector<T, A>>: public TSeqDumper {
-};
-
+};
+
+template <class T, class A>
+struct TDumper<std::vector<T, A>>: public TSeqDumper {
+};
+
template <class T>
struct TDumper<TArrayRef<T>>: public TSeqDumper {
};
@@ -106,68 +106,68 @@ template <class T, size_t N>
struct TDumper<std::array<T, N>>: public TSeqDumper {
};
-template <class T, class A>
+template <class T, class A>
struct TDumper<TDeque<T, A>>: public TSeqDumper {
-};
-
-template <class T, class A>
+};
+
+template <class T, class A>
struct TDumper<TList<T, A>>: public TSeqDumper {
-};
-
-//associatives
-template <class K, class V, class P, class A>
+};
+
+//associatives
+template <class K, class V, class P, class A>
struct TDumper<TMap<K, V, P, A>>: public TAssocDumper {
-};
-
-template <class K, class V, class P, class A>
+};
+
+template <class K, class V, class P, class A>
struct TDumper<TMultiMap<K, V, P, A>>: public TAssocDumper {
-};
-
-template <class T, class P, class A>
+};
+
+template <class T, class P, class A>
struct TDumper<TSet<T, P, A>>: public TAssocDumper {
-};
-
-template <class T, class P, class A>
+};
+
+template <class T, class P, class A>
struct TDumper<TMultiSet<T, P, A>>: public TAssocDumper {
-};
-
-template <class K, class V, class H, class P, class A>
+};
+
+template <class K, class V, class H, class P, class A>
struct TDumper<THashMap<K, V, H, P, A>>: public TAssocDumper {
-};
-
-template <class K, class V, class H, class P, class A>
+};
+
+template <class K, class V, class H, class P, class A>
struct TDumper<THashMultiMap<K, V, H, P, A>>: public TAssocDumper {
-};
-
-template <class T, class H, class P, class A>
+};
+
+template <class T, class H, class P, class A>
struct TDumper<THashSet<T, H, P, A>>: public TAssocDumper {
-};
-
-template <class T, class H, class P, class A>
+};
+
+template <class T, class H, class P, class A>
struct TDumper<THashMultiSet<T, H, P, A>>: public TAssocDumper {
-};
-
-//strings
-template <>
+};
+
+//strings
+template <>
struct TDumper<TString>: public TStrDumper {
-};
-
-template <>
-struct TDumper<const char*>: public TStrDumper {
-};
-
-template <>
+};
+
+template <>
+struct TDumper<const char*>: public TStrDumper {
+};
+
+template <>
struct TDumper<TUtf16String>: public TStrDumper {
-};
-
-template <>
-struct TDumper<const wchar16*>: public TStrDumper {
-};
-
-template <class C, class T, class A>
-struct TDumper<std::basic_string<C, T, A>>: public TStrDumper {
-};
-
-template <class TChar>
+};
+
+template <>
+struct TDumper<const wchar16*>: public TStrDumper {
+};
+
+template <class C, class T, class A>
+struct TDumper<std::basic_string<C, T, A>>: public TStrDumper {
+};
+
+template <class TChar>
struct TDumper<TBasicStringBuf<TChar>>: public TStrDumper {
-};
+};
diff --git a/library/cpp/dbg_output/engine.cpp b/library/cpp/dbg_output/engine.cpp
index dcb9f02522..3b6003bb1a 100644
--- a/library/cpp/dbg_output/engine.cpp
+++ b/library/cpp/dbg_output/engine.cpp
@@ -1,33 +1,33 @@
-#include "engine.h"
-
-#include <util/string/cast.h>
-#include <util/string/escape.h>
-
-#if !defined(DBGDUMP_INLINE_IF_INCLUDED)
-#define DBGDUMP_INLINE_IF_INCLUDED
-#endif
-
-DBGDUMP_INLINE_IF_INCLUDED void TDumpBase::String(const TStringBuf& s) {
- if (s) {
+#include "engine.h"
+
+#include <util/string/cast.h>
+#include <util/string/escape.h>
+
+#if !defined(DBGDUMP_INLINE_IF_INCLUDED)
+#define DBGDUMP_INLINE_IF_INCLUDED
+#endif
+
+DBGDUMP_INLINE_IF_INCLUDED void TDumpBase::String(const TStringBuf& s) {
+ if (s) {
Raw(TString(s).Quote());
- } else {
- Raw("(empty)");
- }
-}
-
-DBGDUMP_INLINE_IF_INCLUDED void TDumpBase::String(const TWtringBuf& s) {
- Raw("w");
- String(ToString(s));
-}
-
-DBGDUMP_INLINE_IF_INCLUDED void TDumpBase::Raw(const TStringBuf& s) {
+ } else {
+ Raw("(empty)");
+ }
+}
+
+DBGDUMP_INLINE_IF_INCLUDED void TDumpBase::String(const TWtringBuf& s) {
+ Raw("w");
+ String(ToString(s));
+}
+
+DBGDUMP_INLINE_IF_INCLUDED void TDumpBase::Raw(const TStringBuf& s) {
Stream().Write(s.data(), s.size());
-}
-
-DBGDUMP_INLINE_IF_INCLUDED void TDumpBase::Char(char ch) {
- Raw("'" + EscapeC(&ch, 1) + "'");
-}
-
-DBGDUMP_INLINE_IF_INCLUDED void TDumpBase::Char(wchar16 ch) {
- Raw("w'" + ToString(EscapeC(&ch, 1)) + "'");
-}
+}
+
+DBGDUMP_INLINE_IF_INCLUDED void TDumpBase::Char(char ch) {
+ Raw("'" + EscapeC(&ch, 1) + "'");
+}
+
+DBGDUMP_INLINE_IF_INCLUDED void TDumpBase::Char(wchar16 ch) {
+ Raw("w'" + ToString(EscapeC(&ch, 1)) + "'");
+}
diff --git a/library/cpp/dbg_output/engine.h b/library/cpp/dbg_output/engine.h
index f13c728c39..cacd9c0a8f 100644
--- a/library/cpp/dbg_output/engine.h
+++ b/library/cpp/dbg_output/engine.h
@@ -1,180 +1,180 @@
-#pragma once
-
-#include <util/stream/output.h>
-
+#pragma once
+
+#include <util/stream/output.h>
+
#include <utility>
-#include <util/generic/strbuf.h>
-
-template <class T>
-struct TDumper {
- template <class S>
- static inline void Dump(S& s, const T& t) {
- s.Stream() << t;
- }
-};
-
-namespace NDumpPrivate {
- template <class T, class V>
- inline void Dump(T& t, const V& v) {
- ::TDumper<V>::Dump(t, v);
- }
-
- template <class T, class V>
- inline T&& operator<<(T&& t, V&& v) {
- Dump(t, v);
-
+#include <util/generic/strbuf.h>
+
+template <class T>
+struct TDumper {
+ template <class S>
+ static inline void Dump(S& s, const T& t) {
+ s.Stream() << t;
+ }
+};
+
+namespace NDumpPrivate {
+ template <class T, class V>
+ inline void Dump(T& t, const V& v) {
+ ::TDumper<V>::Dump(t, v);
+ }
+
+ template <class T, class V>
+ inline T&& operator<<(T&& t, V&& v) {
+ Dump(t, v);
+
return std::forward<T>(t);
- }
-
- struct TADLBase {
- };
-}
-
-struct TDumpBase: public ::NDumpPrivate::TADLBase {
+ }
+
+ struct TADLBase {
+ };
+}
+
+struct TDumpBase: public ::NDumpPrivate::TADLBase {
inline TDumpBase(IOutputStream& out, bool indent) noexcept
- : Out(&out)
- , IndentLevel(0)
- , Indent(indent)
- {
- }
-
+ : Out(&out)
+ , IndentLevel(0)
+ , Indent(indent)
+ {
+ }
+
inline IOutputStream& Stream() const noexcept {
- return *Out;
- }
-
- void Char(char ch);
- void Char(wchar16 ch);
-
- void String(const TStringBuf& s);
- void String(const TWtringBuf& s);
-
- void Raw(const TStringBuf& s);
-
+ return *Out;
+ }
+
+ void Char(char ch);
+ void Char(wchar16 ch);
+
+ void String(const TStringBuf& s);
+ void String(const TWtringBuf& s);
+
+ void Raw(const TStringBuf& s);
+
IOutputStream* Out;
- size_t IndentLevel;
- bool Indent;
-};
-
-struct TIndentScope {
- inline TIndentScope(TDumpBase& d)
- : D(&d)
- {
- ++(D->IndentLevel);
- }
-
+ size_t IndentLevel;
+ bool Indent;
+};
+
+struct TIndentScope {
+ inline TIndentScope(TDumpBase& d)
+ : D(&d)
+ {
+ ++(D->IndentLevel);
+ }
+
inline ~TIndentScope() {
- --(D->IndentLevel);
- }
-
- TDumpBase* D;
-};
-
-template <class TChar>
-struct TRawLiteral {
+ --(D->IndentLevel);
+ }
+
+ TDumpBase* D;
+};
+
+template <class TChar>
+struct TRawLiteral {
const TBasicStringBuf<TChar> S;
-};
-
-template <class TChar>
+};
+
+template <class TChar>
static inline TRawLiteral<TChar> DumpRaw(const TBasicStringBuf<TChar>& s) noexcept {
return {s};
}
template <class TChar>
static inline TRawLiteral<TChar> DumpRaw(const TChar* s) noexcept {
- return {s};
-}
-
-template <class C>
-struct TDumper<TRawLiteral<C>> {
- template <class S>
- static inline void Dump(S& s, const TRawLiteral<C>& v) {
- s.Raw(v.S);
- }
-};
-
-struct TIndentNewLine {
-};
-
+ return {s};
+}
+
+template <class C>
+struct TDumper<TRawLiteral<C>> {
+ template <class S>
+ static inline void Dump(S& s, const TRawLiteral<C>& v) {
+ s.Raw(v.S);
+ }
+};
+
+struct TIndentNewLine {
+};
+
static inline TIndentNewLine IndentNewLine() noexcept {
- return {};
-}
-
-template <>
-struct TDumper<TIndentNewLine> {
- template <class S>
- static inline void Dump(S& s, const TIndentNewLine&) {
- if (s.Indent) {
+ return {};
+}
+
+template <>
+struct TDumper<TIndentNewLine> {
+ template <class S>
+ static inline void Dump(S& s, const TIndentNewLine&) {
+ if (s.Indent) {
s << DumpRaw("\n") << DumpRaw(TString(s.IndentLevel * 4, ' ').data());
- }
- }
-};
-
-template <class P>
-struct TDumper<const P*> {
- template <class S>
- static inline void Dump(S& s, const P* p) {
- s.Pointer(p);
- }
-};
-
-template <class P>
-struct TDumper<P*>: public TDumper<const P*> {
-};
-
-struct TCharDumper {
- template <class S, class V>
- static inline void Dump(S& s, const V& v) {
- s.Char(v);
- }
-};
-
-template <class S, class V>
-static inline void OutSequence(S& s, const V& v, const char* openTag, const char* closeTag) {
+ }
+ }
+};
+
+template <class P>
+struct TDumper<const P*> {
+ template <class S>
+ static inline void Dump(S& s, const P* p) {
+ s.Pointer(p);
+ }
+};
+
+template <class P>
+struct TDumper<P*>: public TDumper<const P*> {
+};
+
+struct TCharDumper {
+ template <class S, class V>
+ static inline void Dump(S& s, const V& v) {
+ s.Char(v);
+ }
+};
+
+template <class S, class V>
+static inline void OutSequence(S& s, const V& v, const char* openTag, const char* closeTag) {
s.ColorScheme.Markup(s);
- s << DumpRaw(openTag);
-
- {
- TIndentScope scope(s);
- size_t cnt = 0;
-
- for (const auto& x : v) {
- if (cnt) {
+ s << DumpRaw(openTag);
+
+ {
+ TIndentScope scope(s);
+ size_t cnt = 0;
+
+ for (const auto& x : v) {
+ if (cnt) {
s.ColorScheme.Markup(s);
- s << DumpRaw(", ");
- }
-
+ s << DumpRaw(", ");
+ }
+
s << IndentNewLine();
s.ColorScheme.Literal(s);
s << x;
- ++cnt;
- }
- }
-
+ ++cnt;
+ }
+ }
+
s << IndentNewLine();
s.ColorScheme.Markup(s);
s << DumpRaw(closeTag);
s.ColorScheme.ResetType(s);
-}
-
-struct TAssocDumper {
- template <class S, class V>
- static inline void Dump(S& s, const V& v) {
- ::OutSequence(s, v, "{", "}");
- }
-};
-
-struct TSeqDumper {
- template <class S, class V>
- static inline void Dump(S& s, const V& v) {
- ::OutSequence(s, v, "[", "]");
- }
-};
-
-struct TStrDumper {
- template <class S, class V>
- static inline void Dump(S& s, const V& v) {
+}
+
+struct TAssocDumper {
+ template <class S, class V>
+ static inline void Dump(S& s, const V& v) {
+ ::OutSequence(s, v, "{", "}");
+ }
+};
+
+struct TSeqDumper {
+ template <class S, class V>
+ static inline void Dump(S& s, const V& v) {
+ ::OutSequence(s, v, "[", "]");
+ }
+};
+
+struct TStrDumper {
+ template <class S, class V>
+ static inline void Dump(S& s, const V& v) {
s.ColorScheme.String(s);
- s.String(v);
+ s.String(v);
s.ColorScheme.ResetType(s);
- }
-};
+ }
+};
diff --git a/library/cpp/dbg_output/ut/dbg_output_ut.cpp b/library/cpp/dbg_output/ut/dbg_output_ut.cpp
index 7b285c84cb..509581e02e 100644
--- a/library/cpp/dbg_output/ut/dbg_output_ut.cpp
+++ b/library/cpp/dbg_output/ut/dbg_output_ut.cpp
@@ -6,24 +6,24 @@
#include <util/string/escape.h>
#include <util/generic/map.h>
-namespace {
- struct TX {
- inline TX() {
- N = this;
- }
-
- TX* N;
- };
-}
-
-template <>
-struct TDumper<TX> {
- template <class S>
- static inline void Dump(S& s, const TX& x) {
- s << DumpRaw("x") << x.N;
- }
-};
-
+namespace {
+ struct TX {
+ inline TX() {
+ N = this;
+ }
+
+ TX* N;
+ };
+}
+
+template <>
+struct TDumper<TX> {
+ template <class S>
+ static inline void Dump(S& s, const TX& x) {
+ s << DumpRaw("x") << x.N;
+ }
+};
+
namespace TMyNS {
struct TMyStruct {
int A, B;
@@ -40,14 +40,14 @@ Y_UNIT_TEST_SUITE(TContainerPrintersTest) {
Y_UNIT_TEST(TestMapCharToCharArray) {
TStringStream out;
-
+
TMap<char, const char*> m;
-
- m['a'] = "SMALL LETTER A";
- m['b'] = nullptr;
-
- out << DbgDump(m);
-
+
+ m['a'] = "SMALL LETTER A";
+ m['b'] = nullptr;
+
+ out << DbgDump(m);
+
UNIT_ASSERT_STRINGS_EQUAL(out.Str(), "{'a' -> \"SMALL LETTER A\", 'b' -> (empty)}");
}
@@ -56,13 +56,13 @@ Y_UNIT_TEST_SUITE(TContainerPrintersTest) {
TVector<TVector<wchar16>> vec(2);
vec[0].push_back(0);
vec[1] = {wchar16('a')};
- out << DbgDump(vec);
+ out << DbgDump(vec);
UNIT_ASSERT_STRINGS_EQUAL(out.Str(), "[[w'\\0'], [w'a']]");
}
-
+
Y_UNIT_TEST(TestInfinite) {
- UNIT_ASSERT(!!(TStringBuilder() << DbgDumpDeep(TX())));
- }
+ UNIT_ASSERT(!!(TStringBuilder() << DbgDumpDeep(TX())));
+ }
Y_UNIT_TEST(TestLabeledDump) {
TStringStream out;
@@ -92,7 +92,7 @@ Y_UNIT_TEST_SUITE(TContainerPrintersTest) {
"\\x1B[22;39m\\x1B[22;39m\\x1B[49m\\x1B[1;32m, \\x1B[1;31m\\x1B[42m\\x1B[1;31m\\x1B[1;33m"
"\\\"b\\\"\\x1B[22;39m\\x1B[22;39m\\x1B[49m\\x1B[1;32m -> "
"\\x1B[44m\\x1B[1;31m\\x1B[1;32m{\\x1B[1;31m\\x1B[1;31m2\\x1B[22;39m\\x1B[1;32m -> "
- "\\x1B[1;31m'6'\\x1B[22;39m\\x1B[1;32m}\\x1B[22;39m\\x1B[22;39m\\x1B[49m\\x1B[1;32m}\\x1B[22;39m");
+ "\\x1B[1;31m'6'\\x1B[22;39m\\x1B[1;32m}\\x1B[22;39m\\x1B[22;39m\\x1B[49m\\x1B[1;32m}\\x1B[22;39m");
}
Y_UNIT_TEST(SmallIntOrChar) {
diff --git a/library/cpp/dbg_output/ya.make b/library/cpp/dbg_output/ya.make
index 7d54108f93..af1ab17c5f 100644
--- a/library/cpp/dbg_output/ya.make
+++ b/library/cpp/dbg_output/ya.make
@@ -1,15 +1,15 @@
-LIBRARY()
-
+LIBRARY()
+
OWNER(pg)
-
+
PEERDIR(
library/cpp/colorizer
)
-SRCS(
- dump.cpp
- dumpers.cpp
- engine.cpp
-)
-
-END()
+SRCS(
+ dump.cpp
+ dumpers.cpp
+ engine.cpp
+)
+
+END()