C++ code generation for repeted task

Posted by sateesh on Stack Overflow See other posts from Stack Overflow or by sateesh
Published on 2011-01-10T05:57:37Z Indexed on 2011/01/10 6:54 UTC
Read the original article Hit count: 178

Filed under:

Hi,

I have something like below which will get repeated many times based on the function that get called

for e.g

  acceptfunction()
  {
       inserter["quantity"] = sdd.getfloat(quantity);
       inserter["prodtype"]  = sdd.getstring(prodtype);
         :
         :
       so on 
   }

Like accept above there are 20 more functions(reject,cancel etc) which will do the similar thing.But the parameteres they insert can differ based on function called.

How can I automate this kind of code.So that I dont need to write new function from scratch.Basically what I need is if i provide parametres like ("quantity",prodtype) through some text file or xml, it should generate the required function with the input parametres.

Is this task can be handled through C++ tempalte Meta programming or someother code generation tool will help me to do this?

© Stack Overflow or respective owner

Related posts about c++