Boost logo

Boost Users :

Subject: Re: [Boost-users] boost fusion and/or boost parameter: open ended question about constructing object from a string
From: e r (erwann.rogard_at_[hidden])
Date: 2008-09-10 18:03:12


David Abrahams wrote:
> on Wed Sep 10 2008, e r <erwann.rogard-AT-gmail.com> wrote:
>
>>>> So I'd like to put all these arguments in a file, each line
>>>> corresponding to an object, rather than have a messy cpp file.
>>> Well, if you're willing to compile that file as C++, you could go back
>>> to using Boost.Parameter... ;-)
>> since the arguments to be passed into object constructors are known at
>> compile time, i guess i could still do this?
>
> I guess. Why, exactly, did you want to use strings, then?

I guess in my first post wanted something like this:
            std::string line;
            while(std::getline(is,line) ){ }

But your remarks have made it irrelevant and I wasn't even thinking of
this in my second post.

>
>> a) have some sort of cpp template i.e. some, not all the code
>> intentionally left out (say marked by "NA"), to be filled from a text
>> file, via a text processor b) compile the modified cpp file.
>>
>> i'm not all that experienced with parsers and such. is this where
>> Boost.Xpressive etc fit in or should i just go ahead and use perl?
>
> If you're going to go back to using Boost.Parameter, you probably won't
> have any use for parsers and such. If you're going to use parsers and
> such, there probably is no role for Boost.Parameter.
>
> I guess you could set up a toolchain where you parse some text file,
> generate C++ code, and compile that... is that where you are heading?
> And if so, why bother with the text file?
>

generate C++ code from a text file: yes, that's what I meant in my
second post.

Why bother? Because I'd like to have the text file to have a simpler
syntax and a cleaner aspect, particularly if I'm going to change it
often. for example:

args.txt:

{Type=type0,tag::key00=arg00,tag::key01=arg01,...}
.
.
.
{Type=typeN,tag::keyN0=argN0,tag::keyN1=argN1,...}

*.cpp

//Some code here

typedef fusion::vector<type0,...,typeN> vec_type;

vec_type vec = factory<vec_type>.create(
 (
   tag::key00 = arg00, tag::key01=arg01,...
   .
   .
   .
   tag::keyN0 = argN0, tag::keyN1=argN1,...
 )
);

//Rest of the code

Thanks again.


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