I am reading the type of an object from a file:
enum class type_index { ... };
type_index typeidx = read(file_handle, type_index{});
Depending
Build an unordered_map
from type_index
to processing code.
Read the type_index
, lookup in map, execute. Error check for missing entries.
Simple, extendible, versionable -- simply add a length header on entries (make sure it handles 64 bit lengths -- have max lower bit count length mean real length is next, which allows single bit lengths to start), and if you do not understand an entry you can skip it.