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 18:10:14

On Mon, Jun 14, 2010 at 8:15 AM, Andrey Semashev
<andrey.semashev_at_[hidden]> wrote:
> On 06/14/2010 03:12 PM, Beman Dawes wrote:
> +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.

Actually, what I'd like to propose is that path continue to have
streaming operations, but that the output format be double quote
delimited, with an escape character such as backslash or ampersand to
escape double quotes or itself. The input format accepted would be (1)
the same as the output format, thus ensuring roundtrips, or (2) if the
first character is not a double quote then the first whitespace will
terminate as in the past. An alternate for (2) would be to throw an
exception, but that seems a bit draconian to me.

Furthermore, I see the need to output and then roundtrip strings back
as input, regardless of embedded whitespace, to be a common need, so
would provide a general facility so a user could write:

  std::stringstream ss;

  const std::string expected("foo bar");
  std::string actual;

  ss << delimit_string(expected);
  ss >> delimit_string(actual);

  assert(expected == actual);

  std::cout << delimit_string(expected); // will output "foo bar",
including the double quotes

I see this need as so commonplace that I wouldn't be surprised if it
already exists somewhere in boost. If not, I'll put it in namespace
detail for now, but it might go in the string library at some point.
The actual prototype code I've written for delimit_string() takes
optional arguments for the escape character and the delimiter. It
needs to be templated to work with various string types.


Boost list run by bdawes at, gregod at, cpdaniel at, john at