aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/lwtrace/symbol.h
diff options
context:
space:
mode:
authorDevtools Arcadia <arcadia-devtools@yandex-team.ru>2022-02-07 18:08:42 +0300
committerDevtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net>2022-02-07 18:08:42 +0300
commit1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch)
treee26c9fed0de5d9873cce7e00bc214573dc2195b7 /library/cpp/lwtrace/symbol.h
downloadydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'library/cpp/lwtrace/symbol.h')
-rw-r--r--library/cpp/lwtrace/symbol.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/library/cpp/lwtrace/symbol.h b/library/cpp/lwtrace/symbol.h
new file mode 100644
index 00000000000..ef9e6cdf940
--- /dev/null
+++ b/library/cpp/lwtrace/symbol.h
@@ -0,0 +1,68 @@
+#pragma once
+
+#include <util/generic/string.h>
+#include <util/string/builder.h>
+#include <util/system/src_location.h>
+
+#define LWTRACE_DEFINE_SYMBOL(variable, text) \
+ static TString variable##_holder(text); \
+ ::NLWTrace::TSymbol variable(&variable##_holder); \
+ /**/
+
+#define LWTRACE_INLINE_SYMBOL(text) \
+ [&] { \
+ static TString _holder(text); \
+ return ::NLWTrace::TSymbol(&_holder); \
+ }() /**/
+
+#define LWTRACE_LOCATION_SYMBOL \
+ [](const char* func) { \
+ static TString _holder(TStringBuilder() << func << " (" << __LOCATION__ << ")"); \
+ return ::NLWTrace::TSymbol(&_holder); \
+ }(Y_FUNC_SIGNATURE) /**/
+
+namespace NLWTrace {
+ struct TSymbol {
+ TString* Str;
+
+ TSymbol()
+ : Str(nullptr)
+ {
+ }
+
+ explicit TSymbol(TString* str)
+ : Str(str)
+ {
+ }
+
+ TSymbol& operator=(const TSymbol& o) {
+ Str = o.Str;
+ return *this;
+ }
+
+ TSymbol(const TSymbol& o)
+ : Str(o.Str)
+ {
+ }
+
+ bool operator<(const TSymbol& rhs) const {
+ return Str < rhs.Str;
+ }
+ bool operator>(const TSymbol& rhs) const {
+ return Str > rhs.Str;
+ }
+ bool operator<=(const TSymbol& rhs) const {
+ return Str <= rhs.Str;
+ }
+ bool operator>=(const TSymbol& rhs) const {
+ return Str >= rhs.Str;
+ }
+ bool operator==(const TSymbol& rhs) const {
+ return Str == rhs.Str;
+ }
+ bool operator!=(const TSymbol& rhs) const {
+ return Str != rhs.Str;
+ }
+ };
+
+}