On Monday, 19 August 2013 at 13:31:27 UTC, Jacob Carlborg wrote:
On 2013-08-19 15:03, Dicebot wrote:

Great! Are there any difficulties with the input?

It just that I don't clearly know how the code will need to look like, and I'm not particular familiar with implementing range based code.

Maybe we need some kind of doc explaining the idiomatic usage of ranges?

Personally, I'd like to do something like this:

    auto archive = new XmlArchive!(char); // create an XML archive
auto serializer = new Serializer(archive); // create the serializer
    serializer.serialize(foo);

    pipe(archive.out, someFile);

Where pipe would read from the left and write to the right. My idea for an implementation is through using take():

    void pipe(R) (R input, File output) // isInputRange(R)...
    {
        while (!input.empty) {
// if Serializer has no data cached, goes through one step
            // and returns what it has
            auto arr = input.take(BUF_SIZE);
            input.popFrontN(arr.length);
            output.write(arr);
        }
    }

For now, I'd be happy for serializer to process all data in serialize(), but change the behavior later to do step through computation when calling take().

I don't know if this helps, and others are very likely to have better ideas.

Reply via email to