1
Programming / Re: ruleset dumping for testing (modding & coding)
« on: December 29, 2013, 02:14:36 am »
How acceptable are macros?
This code can be cleaner, more readable by using macros.
bool Example::map(Node& node, const typename MemberMappingNodeKey<Node, Example>::type *key, const Example *oldValue) using macros:
where MAP_MEMBER is defined by:
This code can be cleaner, more readable by using macros.
bool Example::map(Node& node, const typename MemberMappingNodeKey<Node, Example>::type *key, const Example *oldValue) using macros:
Code: [Select]
bool result = true;
MAP_MEMBER(op, required, result, Example, x, node, "x", oldValue)
MAP_MEMBER(op, required, result, Example, y, node, "y", oldValue)
return result;
where MAP_MEMBER is defined by:
Code: [Select]
#define MAP_MEMBER(op, required, result, Type, member, ...) \
if (!MemberMapping<op, required>::map(*this, &Type::member, __VA_ARGS__)) \
{ \
if(op == MemberMappingOps::equals) return false; \
result = !required; \
}