objective c - Expand parameter list in C -


i using c library in objective c project. c library offers following function

void processdata(...); 

which can used 1, 2 or 3 parameters, first parameter mandatory , can have different types int, double, long, float , other 2 arguments optional , have int , long values , can in whatever order.

examples of use of function are:

int myint = 2; double mydouble = 1.23; int dataquality = 1; long datatimestamp= get_now();  processdata(myint); processdata(myint, dataquality); processdata(mydouble, dataquality, datatimestamp); processdata(mydouble, datatimestamp); 

i need make objetive c wrapper uses datatype class call processdatawith correct parameters. data class has getters allows data type (first argument), value , whether second , third arguments have value , value.

the problem how make expansion? think must done @ compile time, , think mechanism available in c macros. have never used them. implementation should (the following pseudocode, arguments list evaluated @ runtime, guess should replaced macros in order evaluate arguments @ compile time):

-(void) objetivecprocessdata: (data) d {       argumentlist = {}       switch (d.getdatatype()) {          case int_type:               append(argumentlist, d.getvalueasint()); // <-- appends value type `int`               break;          case double_type:               append(argumentlist, d.getvalueasdouble()); // <-- appends value type `double`               break;          ...       }        if (d.hasquality()) {            append(argumentlist, d.getquality());       }        if (d.hastimestamp()) {            append(argumentlist, d.gettimestamp());       }        // call c function correct number , type of arguments       processdata(argumentlist);           } 


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -