c++ - A function return different object based on its parameter? -
i have bunch of functions this:
void business::convertdatatolistentityoftypex() // x = a,b,c..... { qbytearray tmp = getdata(); bool ok; qvariantlist result = parse (tmp,&ok); if (ok) { (int = 0; < result.size(); ++i) { typexentity e; convertvarianttotypexentity(result[i],e); typexentitylist.push_back(e);//typexentitylist private variables in business } } }
i want group them 1 function this
enum type{typea, typeb}; void business::convertdatatolistentity(type tp) { qbytearray tmp = getdata(); bool ok; qvariantlist result = parse (tmp,&ok); if (ok) { (int = 0; < result.size(); ++i) { typexentity e;// need magic function map enum typexentity convertvarianttotypexentity(result[i],e); typexentitylist.push_back(e);//need magic function map enum typexentitylist } } }
so there possible way qt
or boost
(qt prefered ) ?
any ideas appreciated :)
Comments
Post a Comment