M
Markus Dehmann
I'd like to process text or document templates that use "embedded
C++". Here is a constructed example (the texts I have in mind are much
longer and contain relatively few code blocks):
--------TEXT TEMPLATE--------
<CI>#include <iostream>
#include "LetterDataContainer.hpp"
using namespace std;
LetterDataContainer d;</CI>
Dear <C>if(d.isMale()) cout << "Sir";
else cout << "Madam";</C>
as you may have noticed, you still owe me some<C>if(d.getAmount() >
1000){cout << " considerable";}</C> amount of money. Please pay
<C>cout << d.getUrgency();</C>.
--------TEXT TEMPLATE--------
So, it's a text template containing several C++ code blocks that refer
to some data in an object. Every block of code is within <C></C> tags.
The <CI></CI> tags contain header code that is needed as a header for
every code block file.
Now, a program could extract each code block and compile it into an .o
file. Each .o file would contain the header code and one method, for
example sth like
void block_001(){if(d.getAmount() > 1000){cout << " considerable";}}
Then, it would alternately print a piece of text and execute a code
block, print the next piece of text, execute the next code block and
so on.
Is there a better way to process document templates? Or is there a
library that does sth like this? Of course, it's easier to do such a
processing and eval thing in Perl (see
http://perl.plover.com/Template), but the data I have is gathered by a
C++ object.
Thanks!
Markus
C++". Here is a constructed example (the texts I have in mind are much
longer and contain relatively few code blocks):
--------TEXT TEMPLATE--------
<CI>#include <iostream>
#include "LetterDataContainer.hpp"
using namespace std;
LetterDataContainer d;</CI>
Dear <C>if(d.isMale()) cout << "Sir";
else cout << "Madam";</C>
as you may have noticed, you still owe me some<C>if(d.getAmount() >
1000){cout << " considerable";}</C> amount of money. Please pay
<C>cout << d.getUrgency();</C>.
--------TEXT TEMPLATE--------
So, it's a text template containing several C++ code blocks that refer
to some data in an object. Every block of code is within <C></C> tags.
The <CI></CI> tags contain header code that is needed as a header for
every code block file.
Now, a program could extract each code block and compile it into an .o
file. Each .o file would contain the header code and one method, for
example sth like
void block_001(){if(d.getAmount() > 1000){cout << " considerable";}}
Then, it would alternately print a piece of text and execute a code
block, print the next piece of text, execute the next code block and
so on.
Is there a better way to process document templates? Or is there a
library that does sth like this? Of course, it's easier to do such a
processing and eval thing in Perl (see
http://perl.plover.com/Template), but the data I have is gathered by a
C++ object.
Thanks!
Markus