Boost logo

Boost :

Subject: Re: [boost] [Boost-commit] svn:boost r62919 - in trunk: boost/filesystem/v2 boost/filesystem/v3 libs/filesystem/v2/test libs/filesystem/v3/test
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2010-06-14 08:15:41


On 06/14/2010 03:12 PM, Beman Dawes wrote:
> On Sun, Jun 13, 2010 at 1:47 PM, Scott McMurray<me22.ca+boost_at_[hidden]> wrote:
>> On 13 June 2010 10:33,<bdawes_at_[hidden]> wrote:
>>> Author: bemandawes
>>> Date: 2010-06-13 13:33:39 EDT (Sun, 13 Jun 2010)
>>> New Revision: 62919
>>> URL: http://svn.boost.org/trac/boost/changeset/62919
>>>
>>> [...]
>>>
>>> @@ -620,7 +620,7 @@
>>> basic_path< String, Traits> & ph )
>>> {
>>> String str;
>>> - is>> str;
>>> + std::getline(is, str); // See ticket 3863
>>> ph = str;
>>> return is;
>>> }
>>>
>>
>> I'm not convinced this is the right approach here, since
>>
>> cout<< mypath<< ' '<< myint;
>>
>> doesn't roundtrip with
>>
>> cin>> mypath>> myint;
>>
>> the way I expect operator<< and operator>> to work.
>
> I agree with you that there is a problem here.
>
>> Perhaps the portable pathname grammar could be extended to allow
>> backslash-escaping of spaces and backslashes? That or remove the
>> stream operators entirely and force people to choose which way they
>> want to print the path and deal with the result as a fully-general
>> string.
>
> In thinking about your suggestion, and several similar approaches, I
> realized the problem isn't limited to filesystem::path. It pops up
> every time someone wants to stream string values.
>
> It should be pretty simple to write two function templates:
>
> For output:
>
> template<String>
> String delimit(const String& s);
>
> Returns: s wrapped in double-quote characters. Any double-quote
> characters in s are escaped.
>
> A similar function for input.
>
> I'll think this in more detail later today, but in the meantime
> perhaps someone else could flesh out this idea.

+1 for removing streaming operators for path. For diagnostic purposes it
should be enough to have the path::string< CharT > method. For
serialization purposes, I think, it's better to have a separate header
that enables support for Boost.Serialization.

The escape/unescape functions (why "delimit"?) you mentioned could be
useful, but only as helpers for other APIs (such as the OS API). I
think, convenience.hpp is the right place for them.

Just my 2 cents.


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