#pragma once #include #include #include #include "data.h" namespace NAnalytics { inline TString ToHtml(const TTable& in) { TSet cols; bool hasName = false; for (const TRow& row : in) { hasName = hasName || !row.Name.empty(); for (const auto& kv : row) { cols.insert(kv.first); } } TStringStream ss; ss << ""; ss << ""; if (hasName) { ss << ""; } for (const TString& c : cols) { ss << ""; } ss << ""; for (const TRow& row : in) { ss << ""; if (hasName) { ss << ""; } for (const TString& c : cols) { TString value; ss << ""; } ss << ""; } ss << "
Name" << c << "
" << row.Name << "" << (row.GetAsString(c, value) ? value : TString("-")) << "
"; return ss.Str(); } inline TString ToTransposedHtml(const TTable& in) { TSet cols; bool hasName = false; for (const TRow& row : in) { hasName = hasName || !row.Name.empty(); for (const auto& kv : row) { cols.insert(kv.first); } } TStringStream ss; ss << ""; if (hasName) { ss << ""; ss << ""; for (const TRow& row : in) { ss << ""; } ss << ""; } ss << ""; for (const TString& c : cols) { ss << ""; ss << ""; for (const TRow& row : in) { TString value; ss << ""; } ss << ""; } ss << "
Name" << row.Name << "
" << c << "" << (row.GetAsString(c, value) ? value : TString("-")) << "
"; return ss.Str(); } }