aboutsummaryrefslogtreecommitdiffstats
path: root/tools/enum_parser/enum_serialization_runtime/enum_runtime.h
diff options
context:
space:
mode:
authorswarmer <swarmer@yandex-team.ru>2022-06-13 01:37:00 +0300
committerswarmer <swarmer@yandex-team.ru>2022-06-13 01:37:00 +0300
commite5e7d3b69b61a7855104d9eddb0b6ff02e7a2979 (patch)
tree355a99d6e7e7cdb5c269b105f15580e2de445bca /tools/enum_parser/enum_serialization_runtime/enum_runtime.h
parent669e8d5ef59e6f49667af117dfee9a43efbf2441 (diff)
downloadydb-e5e7d3b69b61a7855104d9eddb0b6ff02e7a2979.tar.gz
[enum_parser] generate ToStringBuf specialization
IGNIETFERRO-1350 ref:bb9bb1755b6abfc5a27639daf049b8a7cd748fe4
Diffstat (limited to 'tools/enum_parser/enum_serialization_runtime/enum_runtime.h')
-rw-r--r--tools/enum_parser/enum_serialization_runtime/enum_runtime.h35
1 files changed, 25 insertions, 10 deletions
diff --git a/tools/enum_parser/enum_serialization_runtime/enum_runtime.h b/tools/enum_parser/enum_serialization_runtime/enum_runtime.h
index cac142608d..7c85ed3934 100644
--- a/tools/enum_parser/enum_serialization_runtime/enum_runtime.h
+++ b/tools/enum_parser/enum_serialization_runtime/enum_runtime.h
@@ -102,34 +102,51 @@ namespace NEnumSerializationRuntime {
public:
using TBase::TBase;
+ // ToString
+ // Return reference to singleton preallocated string
const TString& ToString(const EEnum key) const {
return TBase::ToString(TCast::CastToRepresentationType(key));
}
- bool FromString(const TStringBuf name, EEnum& ret) const {
- return MapFindResult(TBase::TryFromString(name), ret);
+ // ToStringBuf
+ TStringBuf ToStringBuf(EEnum key) const {
+ return TBase::ToStringBuf(TCast::CastToRepresentationType(key));
}
-
- EEnum FromString(const TStringBuf name) const {
- return TCast::CastFromRepresentationType(TBase::FromString(name));
+ static TStringBuf ToStringBufFullScan(const EEnum key, const TInitializationData& enumInitData) {
+ return TBase::ToStringBufFullScan(TCast::CastToRepresentationType(key), enumInitData);
+ }
+ static TStringBuf ToStringBufSorted(const EEnum key, const TInitializationData& enumInitData) {
+ return TBase::ToStringBufSorted(TCast::CastToRepresentationType(key), enumInitData);
+ }
+ static TStringBuf ToStringBufDirect(const EEnum key, const TInitializationData& enumInitData) {
+ return TBase::ToStringBufDirect(TCast::CastToRepresentationType(key), enumInitData);
}
+ // TryFromString-like functons
+ // Return false for unknown enumeration names
+ bool FromString(const TStringBuf name, EEnum& ret) const {
+ return MapFindResult(TBase::TryFromString(name), ret);
+ }
static bool TryFromStringFullScan(const TStringBuf name, EEnum& ret, const TInitializationData& enumInitData) {
return MapFindResult(TBase::TryFromStringFullScan(name, enumInitData), ret);
}
-
static bool TryFromStringSorted(const TStringBuf name, EEnum& ret, const TInitializationData& enumInitData) {
return MapFindResult(TBase::TryFromStringSorted(name, enumInitData), ret);
}
+ // FromString
+ // Throw exception for unknown enumeration names
+ EEnum FromString(const TStringBuf name) const {
+ return TCast::CastFromRepresentationType(TBase::FromString(name));
+ }
static EEnum FromStringFullScan(const TStringBuf name, const TInitializationData& enumInitData) {
return TCast::CastFromRepresentationType(TBase::FromStringFullScan(name, enumInitData));
}
-
static EEnum FromStringSorted(const TStringBuf name, const TInitializationData& enumInitData) {
return TCast::CastFromRepresentationType(TBase::FromStringSorted(name, enumInitData));
}
+ // Inspection
TMappedDictView<EEnum, TString> EnumNames() const noexcept {
return {TBase::TypelessEnumNames()};
}
@@ -138,18 +155,16 @@ namespace NEnumSerializationRuntime {
return {TBase::TypelessEnumValues()};
}
+ // Out
void Out(IOutputStream* os, const EEnum key) const {
TBase::Out(os, TCast::CastToRepresentationType(key));
}
-
static void OutFullScan(IOutputStream* os, const EEnum key, const TInitializationData& enumInitData) {
TBase::OutFullScan(os, TCast::CastToRepresentationType(key), enumInitData);
}
-
static void OutSorted(IOutputStream* os, const EEnum key, const TInitializationData& enumInitData) {
TBase::OutSorted(os, TCast::CastToRepresentationType(key), enumInitData);
}
-
static void OutDirect(IOutputStream* os, const EEnum key, const TInitializationData& enumInitData) {
TBase::OutDirect(os, TCast::CastToRepresentationType(key), enumInitData);
}