diff options
author | Sergey Polovko <sergey@polovko.me> | 2022-02-10 16:47:03 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:03 +0300 |
commit | 2e714b5ebd40a1f4cc31c27f1ad6e49ca6d895f5 (patch) | |
tree | b83306b6e37edeea782e9eed673d89286c4fef35 /library/cpp/monlib/service/pages/templates.h | |
parent | 3e0b762a82514bac89c1dd6ea7211e381d8aa248 (diff) | |
download | ydb-2e714b5ebd40a1f4cc31c27f1ad6e49ca6d895f5.tar.gz |
Restoring authorship annotation for Sergey Polovko <sergey@polovko.me>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/monlib/service/pages/templates.h')
-rw-r--r-- | library/cpp/monlib/service/pages/templates.h | 160 |
1 files changed, 80 insertions, 80 deletions
diff --git a/library/cpp/monlib/service/pages/templates.h b/library/cpp/monlib/service/pages/templates.h index 356cd13483..b4656f059f 100644 --- a/library/cpp/monlib/service/pages/templates.h +++ b/library/cpp/monlib/service/pages/templates.h @@ -7,76 +7,76 @@ #define WITH_SCOPED_I(var, value, label) \ if (auto var = (value)) { \ - Y_UNUSED(var); \ - goto label; \ - } else \ - label \ - : - -#define TAG(name) WITH_SCOPED(tmp, NMonitoring::name(__stream)) -#define TAG_CLASS(name, cls) WITH_SCOPED(tmp, NMonitoring::name(__stream, cls)) -#define TAG_CLASS_STYLE(name, cls, style) WITH_SCOPED(tmp, NMonitoring::name(__stream, {{"class", cls}, {"style", style}})) -#define TAG_CLASS_ID(name, cls, id) WITH_SCOPED(tmp, NMonitoring::name(__stream, cls, "", id)) -#define TAG_CLASS_FOR(name, cls, for0) WITH_SCOPED(tmp, NMonitoring::name(__stream, cls, for0)) -#define TAG_ATTRS(name, ...) WITH_SCOPED(tmp, NMonitoring::name(__stream, ##__VA_ARGS__)) - -#define HTML(str) WITH_SCOPED(__stream, NMonitoring::TOutputStreamRef(str)) - -#define HEAD() TAG(THead) -#define BODY() TAG(TBody) -#define HTML_TAG() TAG(THtml) -#define DIV() TAG(TDiv) -#define DIV_CLASS(cls) TAG_CLASS(TDiv, cls) + Y_UNUSED(var); \ + goto label; \ + } else \ + label \ + : + +#define TAG(name) WITH_SCOPED(tmp, NMonitoring::name(__stream)) +#define TAG_CLASS(name, cls) WITH_SCOPED(tmp, NMonitoring::name(__stream, cls)) +#define TAG_CLASS_STYLE(name, cls, style) WITH_SCOPED(tmp, NMonitoring::name(__stream, {{"class", cls}, {"style", style}})) +#define TAG_CLASS_ID(name, cls, id) WITH_SCOPED(tmp, NMonitoring::name(__stream, cls, "", id)) +#define TAG_CLASS_FOR(name, cls, for0) WITH_SCOPED(tmp, NMonitoring::name(__stream, cls, for0)) +#define TAG_ATTRS(name, ...) WITH_SCOPED(tmp, NMonitoring::name(__stream, ##__VA_ARGS__)) + +#define HTML(str) WITH_SCOPED(__stream, NMonitoring::TOutputStreamRef(str)) + +#define HEAD() TAG(THead) +#define BODY() TAG(TBody) +#define HTML_TAG() TAG(THtml) +#define DIV() TAG(TDiv) +#define DIV_CLASS(cls) TAG_CLASS(TDiv, cls) #define DIV_CLASS_ID(cls, id) TAG_CLASS_ID(TDiv, cls, id) -#define PRE() TAG(TPre) -#define TABLE() TAG(TTable) -#define TABLE_CLASS(cls) TAG_CLASS(TTable, cls) -#define TABLE_SORTABLE() TABLE_CLASS("table-sortable") +#define PRE() TAG(TPre) +#define TABLE() TAG(TTable) +#define TABLE_CLASS(cls) TAG_CLASS(TTable, cls) +#define TABLE_SORTABLE() TABLE_CLASS("table-sortable") #define TABLE_SORTABLE_CLASS(cls) TABLE_CLASS(cls " table-sortable") -#define TABLEHEAD() TAG(TTableHead) -#define TABLEHEAD_CLASS(cls) TAG_CLASS(TTableHead, cls) -#define TABLEBODY() TAG(TTableBody) -#define TABLEBODY_CLASS(cls) TAG_CLASS(TTableBody, cls) -#define TABLER() TAG(TTableR) -#define TABLER_CLASS(cls) TAG_CLASS(TTableR, cls) -#define TABLED() TAG(TTableD) -#define TABLED_CLASS(cls) TAG_CLASS(TTableD, cls) -#define TABLED_ATTRS(...) TAG_ATTRS(TTableD, ##__VA_ARGS__) -#define TABLEH() TAG(TTableH) -#define TABLEH_CLASS(cls) TAG_CLASS(TTableH, cls) -#define FORM() TAG(TFormC) -#define FORM_CLASS(cls) TAG_CLASS(TFormC, cls) -#define LABEL() TAG(TLabelC) -#define LABEL_CLASS(cls) TAG_CLASS(TLabelC, cls) +#define TABLEHEAD() TAG(TTableHead) +#define TABLEHEAD_CLASS(cls) TAG_CLASS(TTableHead, cls) +#define TABLEBODY() TAG(TTableBody) +#define TABLEBODY_CLASS(cls) TAG_CLASS(TTableBody, cls) +#define TABLER() TAG(TTableR) +#define TABLER_CLASS(cls) TAG_CLASS(TTableR, cls) +#define TABLED() TAG(TTableD) +#define TABLED_CLASS(cls) TAG_CLASS(TTableD, cls) +#define TABLED_ATTRS(...) TAG_ATTRS(TTableD, ##__VA_ARGS__) +#define TABLEH() TAG(TTableH) +#define TABLEH_CLASS(cls) TAG_CLASS(TTableH, cls) +#define FORM() TAG(TFormC) +#define FORM_CLASS(cls) TAG_CLASS(TFormC, cls) +#define LABEL() TAG(TLabelC) +#define LABEL_CLASS(cls) TAG_CLASS(TLabelC, cls) #define LABEL_CLASS_FOR(cls, for0) TAG_CLASS_FOR(TLabelC, cls, for0) -#define SPAN_CLASS(cls) TAG_CLASS(TSpanC, cls) +#define SPAN_CLASS(cls) TAG_CLASS(TSpanC, cls) #define SPAN_CLASS_STYLE(cls, style) TAG_CLASS_STYLE(TSpanC, cls, style) -#define PARA() TAG(TPara) -#define PARA_CLASS(cls) TAG_CLASS(TPara, cls) - -#define H1() TAG(TH1) -#define H1_CLASS(cls) TAG_CLASS(TH1, cls) -#define H2() TAG(TH2) -#define H2_CLASS(cls) TAG_CLASS(TH2, cls) -#define H3() TAG(TH3) -#define H3_CLASS(cls) TAG_CLASS(TH3, cls) -#define H4() TAG(TH4) -#define H4_CLASS(cls) TAG_CLASS(TH4, cls) -#define H5() TAG(TH5) -#define H5_CLASS(cls) TAG_CLASS(TH5, cls) -#define H6() TAG(TH6) -#define H6_CLASS(cls) TAG_CLASS(TH6, cls) - -#define SMALL() TAG(TSMALL) -#define STRONG() TAG(TSTRONG) - -#define LI() TAG(TLIST) -#define LI_CLASS(cls) TAG_CLASS(TLIST, cls) -#define UL() TAG(TULIST) -#define UL_CLASS(cls) TAG_CLASS(TULIST, cls) -#define OL() TAG(TOLIST) -#define OL_CLASS(cls) TAG_CLASS(TOLIST, cls) +#define PARA() TAG(TPara) +#define PARA_CLASS(cls) TAG_CLASS(TPara, cls) + +#define H1() TAG(TH1) +#define H1_CLASS(cls) TAG_CLASS(TH1, cls) +#define H2() TAG(TH2) +#define H2_CLASS(cls) TAG_CLASS(TH2, cls) +#define H3() TAG(TH3) +#define H3_CLASS(cls) TAG_CLASS(TH3, cls) +#define H4() TAG(TH4) +#define H4_CLASS(cls) TAG_CLASS(TH4, cls) +#define H5() TAG(TH5) +#define H5_CLASS(cls) TAG_CLASS(TH5, cls) +#define H6() TAG(TH6) +#define H6_CLASS(cls) TAG_CLASS(TH6, cls) + +#define SMALL() TAG(TSMALL) +#define STRONG() TAG(TSTRONG) + +#define LI() TAG(TLIST) +#define LI_CLASS(cls) TAG_CLASS(TLIST, cls) +#define UL() TAG(TULIST) +#define UL_CLASS(cls) TAG_CLASS(TULIST, cls) +#define OL() TAG(TOLIST) +#define OL_CLASS(cls) TAG_CLASS(TOLIST, cls) #define DL() TAG(DLIST) #define DL_CLASS(cls) TAG_CLASS(DLIST, cls) @@ -85,8 +85,8 @@ #define DD() TAG(DDESC) #define DD_CLASS(cls) TAG_CLASS(DDESC, cls) -#define CAPTION() TAG(TCaption) -#define CAPTION_CLASS(cls) CAPTION_CLASS(TCaption, cls) +#define CAPTION() TAG(TCaption) +#define CAPTION_CLASS(cls) CAPTION_CLASS(TCaption, cls) #define HTML_OUTPUT_PARAM(str, param) str << #param << ": " << param << "<br/>" #define HTML_OUTPUT_TIME_PARAM(str, param) str << #param << ": " << ToStringLocalTimeUpToSeconds(param) << "<br/>" @@ -116,9 +116,9 @@ namespace NMonitoring { IOutputStream& Str; }; - template <const char* tag> + template <const char* tag> struct TTag { - TTag(IOutputStream& str, TStringBuf cls = "", TStringBuf for0 = "", TStringBuf id = "") + TTag(IOutputStream& str, TStringBuf cls = "", TStringBuf for0 = "", TStringBuf id = "") : Str(str) { Str << "<" << tag; @@ -137,7 +137,7 @@ namespace NMonitoring { Str << ">"; } - TTag(IOutputStream& str, std::initializer_list<std::pair<TStringBuf, TStringBuf>> attributes) + TTag(IOutputStream& str, std::initializer_list<std::pair<TStringBuf, TStringBuf>> attributes) : Str(str) { Str << "<" << tag; @@ -152,20 +152,20 @@ namespace NMonitoring { ~TTag() { try { Str << "</" << tag << ">"; - } catch (...) { - } + } catch (...) { + } } explicit inline operator bool() const noexcept { return true; // just to work with WITH_SCOPED } - IOutputStream& Str; + IOutputStream& Str; }; // a nice class for creating collapsable regions of html output struct TCollapsedButton { - TCollapsedButton(IOutputStream& str, const TString& targetId, const TString& buttonText) + TCollapsedButton(IOutputStream& str, const TString& targetId, const TString& buttonText) : Str(str) { Str << "<button type='button' class='btn' data-toggle='collapse' data-target='#" << targetId << "'>" @@ -176,22 +176,22 @@ namespace NMonitoring { ~TCollapsedButton() { try { Str << "</div>"; - } catch (...) { - } + } catch (...) { + } } explicit inline operator bool() const noexcept { return true; // just to work with WITH_SCOPED } - IOutputStream& Str; + IOutputStream& Str; }; struct TOutputStreamRef { TOutputStreamRef(IOutputStream& str) : Str(str) - { - } + { + } inline operator IOutputStream&() noexcept { return Str; @@ -265,4 +265,4 @@ namespace NMonitoring { typedef TTag<DListTag> DLIST; typedef TTag<DTermTag> DTERM; typedef TTag<DDescTag> DDESC; -} +} |