/
githubmirror
/
nbs
Обзор
Документация
Войти
/
githubmirror
/
nbs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
library/cpp/eventlog/event_field_printer.h
38 строк
1 KB
qkrorlqr
Initial NBS OpenSource export
28 апр 2023, 21:54
28 апр 2023, 21:54
783a858
Код
Авторство
О чём код?
#pragma once #include "event_field_output.h" #include <google/protobuf/message.h> // NB: For historical reasons print code for all primitive types/repeated fields/etc generated by https://a.yandex-team.ru/arc/trunk/arcadia/tools/event2cpp enum class EProtobufMessageFieldPrintMode { // Use <TEventProtobufMessageFieldType>::Print method for fields that has it // Print json for other fields DEFAULT = 0, JSON = 1, }; class TEventProtobufMessageFieldPrinter { public: explicit TEventProtobufMessageFieldPrinter(EProtobufMessageFieldPrintMode mode); template <typename TEventProtobufMessageFieldType, bool HasPrintFunction> void PrintProtobufMessageFieldToOutput(const TEventProtobufMessageFieldType& field, TEventFieldOutput& output) { if constexpr (HasPrintFunction) { if (Mode == EProtobufMessageFieldPrintMode::DEFAULT) { field.Print(output.GetOutputStream(), output.GetFlags()); return; } } PrintProtobufMessageFieldToOutput<google::protobuf::Message, false>(field, output); } template <> void PrintProtobufMessageFieldToOutput<google::protobuf::Message, false>(const google::protobuf::Message& field, TEventFieldOutput& output); private: EProtobufMessageFieldPrintMode Mode; };