Skip to content

Commit e5f4adc

Browse files
committed
[ntuple] add RFieldDescriptor::IsCustomEnum()
1 parent af3ac17 commit e5f4adc

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

tree/ntuple/inc/ROOT/RNTupleDescriptor.hxx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ public:
149149
/// natively supported stdlib classes.
150150
/// The dictionary does not need to be available for this method.
151151
bool IsCustomClass() const;
152+
/// Tells if the field describes a user-defined enum type.
153+
/// The dictionary does not need to be available for this method.
154+
/// Needs the full descriptor to look up sub fields.
155+
bool IsCustomEnum(const RNTupleDescriptor &desc) const;
152156
};
153157

154158
// clang-format off

tree/ntuple/src/RNTupleDescriptor.cxx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,24 @@ bool ROOT::RFieldDescriptor::IsCustomClass() const
169169
return true;
170170
}
171171

172+
bool ROOT::RFieldDescriptor::IsCustomEnum(const RNTupleDescriptor &desc) const
173+
{
174+
if (fStructure != ROOT::ENTupleStructure::kPlain)
175+
return false;
176+
if (fTypeName.rfind("std::", 0) == 0)
177+
return false;
178+
179+
auto subFieldId = desc.FindFieldId("_0", fFieldId);
180+
if (subFieldId == kInvalidDescriptorId)
181+
return false;
182+
183+
static const std::string gIntTypeNames[] = {"bool", "char", "std::int8_t", "std::uint8_t",
184+
"std::int16_t", "std::uint16_t", "std::int32_t", "std::uint32_t",
185+
"std::int64_t", "std::uint64_t"};
186+
return std::find(std::begin(gIntTypeNames), std::end(gIntTypeNames),
187+
desc.GetFieldDescriptor(subFieldId).GetTypeName()) != std::end(gIntTypeNames);
188+
}
189+
172190
////////////////////////////////////////////////////////////////////////////////
173191

174192
bool ROOT::RColumnDescriptor::operator==(const RColumnDescriptor &other) const

0 commit comments

Comments
 (0)