On 5 December 2010 21:04, Laszlo Marak
<ujoimro@gmail.com> wrote:
Is there a possibility to generate a std::string from a FILE following some
rules using template meta-programming (or possibly the preprocessor)?
Are you familiar with makefiles? the preprocessor?
This might be a suitable recipe for you.
1. Write a program to turn the contents of a text file into, say, a C or C++ file that contains the text of the file in question.
Something like a program that takes this (sample.txt) :-
This is the first line of sample.txt
This is the second line of sample.txt
And outputs something like this as something like sample.c:-
char *MessageArray[] =
{
"This is the first line of sample.txt",
"This is the second line of sample.txt"
};
Which can then be #included into your source code, ready to be compiled along with the rest of your code,
The role of the makefile would be to generate the C source code before it gets compiled, invoking a utility program (written by you) to turn sample.txt into sample.c.
HTH,
Ian
--