
2009/6/2 Ryan McConnehey
Being able just add a type to a typelist and then have the appropriate helper functions generated would be nice but not a necessary. So far I'm having to put some logic functions into my helper functions.
void putUint16(std::string const& variableName, uint16 const variable) { m_CurrentStructure->remove(variableName); //This function call is duplicated in every helper function. m_CurrentStructure->m_Uint16Map[variableName] = variable; //This is needed in every helper function but the appropriate map is needs to be used. }
Since all these helper functions are exactly the same except the map being called I was hoping to refactor to allow adding new type more easily.
And as mentioned, the "which map" issue can be handled in templates by dispatching to an appropriate base class.
By the way, what is a PP sequence?
The boost preprocessor library would allow you do do something like this: UGLY_PREFIX_ALLOW_TYPES( (uint16)(uint32)(guid)(templated<something>) ); and auto-generate the macro invocations UGLY_PREFIX_ALLOW_TYPE(uint16); UGLY_PREFIX_ALLOW_TYPE(uint32); and so on.