samedi 30 mai 2015

Can I make macro like `MACRO(x, Type1 t1, Type2 t2)`

I want to make my code smaller. I think some macros could make my code smaller.
I want to make macro which contains objects declarations.
There are switch cases

    case SIGN_UP:
    {
        std::string userName;
        std::string password
        getArgs(args, userName, password);
        sv.signUp(userName, password);
    }
    break;

    case SIGN_IN:
    {
        std::string userName;
        std::string password
        getArgs(args, userName, password);
        sv.signIn(userName, password);
    }
    break;

    case SOMETHING:
    {
        std::string s;
        int i;
        getArgs(args, s, i);
        sv.something(s, i);
    }
    break;

I want to make macro to make this code like

    case SIGN_UP:
        GET_ARGS(args, std::string userName, std::string password);
        sv.signUp(userName, password);
        break;

    case SIGN_IN:
        GET_ARGS(args, std::string userName, std::string password);
        sv.signIn(userName, password);
        break;

    case SOMETHING:
        GET_ARGS(args, std::string s, int i);
        sv.something(s, i);
        break;

Is it possible?

Aucun commentaire:

Enregistrer un commentaire