parse/enum: add is_registered test

This commit is contained in:
Danny Robson 2020-04-23 07:57:38 +10:00
parent d099a159fb
commit 62660f1146

View File

@ -218,6 +218,26 @@ namespace cruft::parse::enumeration {
} }
/// Returns true if a typeidx has been registered for enumeration
/// reflection.
inline
bool is_registered (int idx)
{
auto const &dat = detail::cache ();
auto const pos = dat.find (idx);
return pos != dat.cend ();
}
/// Returns true if a typename has been registered for enumation
/// reflection.
template <typename ValueT>
bool is_registered (void)
{
return is_registered (cruft::typeidx<ValueT> ());
}
/// Lookup an enumeration value given a string representation. /// Lookup an enumeration value given a string representation.
/// ///
/// The string view is taken by reference and will be modified so that it /// The string view is taken by reference and will be modified so that it