Boost logo

Boost :

Subject: Re: [boost] [Filesystem V3] Filesystem Version 3 beta 1 availablefor download and comment
From: Beman Dawes (bdawes_at_[hidden])
Date: 2010-02-23 17:01:06


On Tue, Feb 23, 2010 at 12:28 AM, Jeffrey Bosboom <jbosboom_at_[hidden]> wrote:
> On 2/21/2010 8:00 AM, Beman Dawes wrote:
>>>
>>> One wrinkle that I never was able to decide how to handle was multiple
>>> extensions, like ".tar.gz".  Some use cases would want ".tar.gz", some would
>>> just want ".gz", and a few would even want just ".tar".  Does this library
>>> provide any direct support for managing chains of extensions like that?
>>
>> The design decision for stem() to return just the last extension
>> rather than the entire chain allows a user to visit each element in
>> the chain. For example,
>>
>> path p = "foo.bar.baz.tar.bz2";
>> for (; !p.extension().empty(); p = p.stem())
>>     cout<<  p.extension()<<  '\n';
>>
>> displays:
>>
>> .bz2
>> .tar
>> .baz
>> .bar
>
> I can't find this anywhere in the documentation, and it's pretty important
> to note -- I wouldn't have considered that for-loop structure, probably
> resorting instead to finding the first period and splitting up the string.

I've added the above example to the reference docs.

> I don't think an iterator is necessary here, although it would have made the
> loop construction more obvious.  I don't see a pressing need to pass
> extensions to functions that expect iterators.

Agreed.

Thanks!

--Beman


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk