C++ code generation from xml

Oleg Orlov11980884 orlov at diasoft.ru
Mon Apr 15 07:49:44 EDT 2002


"Max Ischenko" <max at malva.com.uaREMOVE.IT> wrote in message
news:of1e9a.4vg.ln at cvs...
>
> Hi there.
>
> I have a Python program that uses data stored in XML file to generate some
> C++ code. The problem (or, more precisely, code smell) I have is that the
> actual generation algorithm is hardwired into python and therefore is
> cryptic, difficult to understand and maintain.
>
> Small example:
> def genBody(self, c):
> name = c.cxxClassName
> new = 'new %s(%s);' % (name, c.factoryCtorArg or '')
> if c.factoryNargs == 0:
> return '\treturn %s' % new
> body = '\t%s * c = %s\n' % (name, new)
> body = body + '\tc->setCmdArgs(args);\n'
> return '%s\treturn c;' % body
>
> I'd like to have the algorithm moved out from Python source.
> I've heard about XSLT language that is used to describe transformation of
> XML data into HTML. I'm seeking for something similar. The difference is
> that target language is C++ and not HTML.
>
> Any suggestions?

Try www.reportlab.co.uk/rl-cgi/viewcvs.cgi/rlextra/preppy/preppy.py

Oleg






More information about the Python-list mailing list