base: Make it possible to convert strings to enums

The __to_number helper function defined in base/str.hh is used by
unserializing code. Its purpose is to convert a string into an
integral/floating point number.  Since enums underlying type can only be
an integer type, it makes sense to extend the helper function for enums
as well. In this way it will be possible to unserialize Enums and
containers of Enums without the need of casting.

Change-Id: I74069cc4c04ec8b5eb80939acea7ab18fb366dd4
Signed-off-by: Giacomo Travaglini <>
Reviewed-by: Ciro Santilli <>
Reviewed-by: Andreas Sandberg <>
Reviewed-by: Nikos Nikoleris <>
Reviewed-by: Gabe Black <>
Maintainer: Andreas Sandberg <>
1 file changed