Boost logo

Boost Users :

Subject: Re: [Boost-users] compile time (template or preprocessor) text processing
From: Ian Bruntlett (ian.bruntlett_at_[hidden])
Date: 2010-12-06 10:46:00


Hi Lsazio,

On 5 December 2010 21:04, Laszlo Marak <ujoimro_at_[hidden]> 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

-- 
-- ACCU - Professionalism in programming - http://www.accu.org/


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net