/
githubmirror
/
nbs
Обзор
Документация
Войти
/
githubmirror
/
nbs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
library/cpp/deprecated/enum_codegen/enum_codegen.h
33 строки
2 KB
qkrorlqr
Initial NBS OpenSource export
28 апр 2023, 21:54
28 апр 2023, 21:54
783a858
Код
Авторство
О чём код?
#pragma once /// see enum_codegen_ut.cpp for examples #define ENUM_VALUE_GEN(name, value, ...) name = value, #define ENUM_VALUE_GEN_NO_VALUE(name, ...) name, #define ENUM_TO_STRING_IMPL_ITEM(name, ...) \ case name: \ return #name; #define ENUM_LTLT_IMPL_ITEM(name, ...) \ case name: \ os << #name; \ break; #define ENUM_TO_STRING(type, MAP) \ static inline const char* ToCString(type value) { \ switch (value) { \ MAP(ENUM_TO_STRING_IMPL_ITEM) \ default: \ return "UNKNOWN"; \ } \ } \ \ static inline IOutputStream& operator<<(IOutputStream& os, type value) { \ switch (value) { \ MAP(ENUM_LTLT_IMPL_ITEM) \ default: \ os << int(value); \ break; \ } \ return os; \ }