Boost logo

Boost :

Subject: Re: [boost] [RFC] string inserter/extractor "q u o t i n g"
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2010-06-16 10:05:11

Beman Dawes wrote:
> The general solution presented here follows very common practice as to
> the format: strings are enclosed in delimiters on output and the
> delimiters (if present) are stripped on input. In the external format,
> an escape character precedes itself or the delimiter character should
> either be present in the string. The default delimiter character is
> the double-quote (") and the default escape character is the backslash
> (\). These defaults can be overridden.
> Example:
> const std::string expected("foo\\bar, \" *");
> std::cout << delimit(expected);
> std::string actual;
> std::stringstream ss;
> ss << delimit(expected);
> ss >> undelimit(actual);
> assert(expected == actual);
> The output to cout is "foo\\bar, \" *"

I like the concept. I think delimit() and undelimit() could be augmented with "delimited" manipulators:

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

In the first statement, it means that "expected" should be delimited. In the second statement, it means that "actual" should be extracted from delimited input.

> A prototype is available at
> <>.
> It is a header only implementation.
> Do you think this component, with suitable documentation, tests, etc.,
> should become a part of Boost?


> What library should it be part of? Seems too small to be a library all
> of its own.

I immediately thought of Utility and String Algos. The latter is already categorized under "String and text processing," so it seems the likely place.

> Where should the header live?


> What namespace should it be in?


> Are delimit() and undelimit() suitable names for the functions?

I don't care much for "undelimit" but I can't think of anything better as "delimit" seems exactly suited to the other operation.

> Any other comments?

Particularly if you accept my manipulator idea, then delimit() and undelimit() should be recast as algorithms in line with the others in Boost.StringAlgos. For example, it should be possible to get a delimited string from delimit(), it should be possible to do in-place manipulations, and it should be possible to use ranges of characters as inputs.

Rob Stewart robert.stewart_at_[hidden]
Software Engineer, Core Software using std::disclaimer;
Susquehanna International Group, LLP

IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.

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