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: Beman Dawes (bdawes_at_[hidden])
Date: 2010-06-14 07:12:22


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.

Thanks,

--Beman


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