Lets say we have a macro like this:
#define SOME_MACRO(a) ...do stuff
Now, calling the macro in this way:
SOME_MACRO(argName=1)
It should return only the first part of the given argument before = (just 'argName' in this case). Is it possible? Thank you in advance
Thank you all, this is my full problem: I'm using this macro to create an enum and a function to get the enum values as strings:
#define RA_MAKE_ENUMERATOR_S1(r, data, elem) case elem : return BOOST_PP_STRINGIZE(elem);
#define RA_MAKE_ENUMERATOR(name, enumerators) \
enum name \
{ \
BOOST_PP_SEQ_ENUM(enumerators) \
}; \
\
inline const std::string ValueToString(name v) \
{ \
switch (v) \
{ \
BOOST_PP_SEQ_FOR_EACH(RA_MAKE_ENUMERATOR_S1, name, enumerators) \
} \
}
RA_MAKE_ENUMERATOR(eTest, (ONE) (TWO))
This outputs the following code:
enum eTest
{
ONE,
TWO
};
inline const std::string ValueToString(eTest v)
{
switch (v)
{
case ONE : return "ONE";
case TWO : return "TWO";
}
}
Which is perfect. But what is I want to assign a specific value to ONE and TWO like:
enum eTest
{
ONE = 2,
TWO = 4
};
I tried calling the macro as
RA_MAKE_ENUMERATOR(eTest, (ONE=2) (TWO=2))
The enumerator is ok but of course the ValueToString function is messed up