I'm using the macros from this post looping through my arguments. Everything works great! However, is there a way to combine these two CCB_CREATE
and CCB_CREATE_MORE
?
I need to extract the first argument object_type
to write additional code. The additional object_type
s will be using the FOR_EACH
loop to insert into the map.
The compiler complaints when I only have one argument when using CCB_CREATE_MORE(Type1)
. To fix that I made another macro to handle that CCB_CREATE(Type1)
. Hoping to find a clever solution to combine these two into one elegant macro. Any ideas?
#define INSERT_LOADER_MAP(object_type) loader_map.insert(make_pair(#object_type, object_type##Loader::loader()))
#define CCB_CREATE_MORE(object_type,...) \
static CCNode * create##object_type##Node() { \
std::map<std::string, CCNodeLoader*> loader_map; \
std::string classname = #object_type; \
FOR_EACH(INSERT_LOADER_MAP,object_type,__VA_ARGS__); \
return loadCCBFile((classname + ".ccbi").c_str(), loader_map); \
}
#define CCB_CREATE(object_type) \
static CCNode * create##object_type##Node() { \
std::map<std::string, CCNodeLoader*> loader_map; \
std::string classname = #object_type; \
INSERT_LOADER_MAP(object_type); \
return loadCCBFile((classname + ".ccbi").c_str(), loader_map); \
}