Subject: Re: [boost] [RFC] string inserter/extractor "q u o t i n g"
From: Rob Stewart (robertstewart_at_[hidden])
Date: 2010-06-22 22:49:30
On 6/18/2010 1:10 PM, Beman Dawes wrote:
> On Fri, Jun 18, 2010 at 6:38 AM, Stewart, Robert<Robert.Stewart_at_[hidden]> wrote:
>> Beman Dawes wrote:
>>> To speed the process, I'll just give a progress report rather than
>>> respond individually prior messages.
>> Apparently, by virtue of not mentioning my suggestion in this omnibus reply, you rejected my idea of a string algorithm for doing the quoting and unquoting which forms the foundation of the insertion and extraction manipulators. I still think that is the best approach as it doesn't force the use of std::stringstream to get a quoted or unquoted string from an existing string while still supporting the IOStream insertion and extraction needed by Filesystem.
> In principle, I agree with you. In practice, I don't really want to
> take the time to develop the algorithms, tests, documentation, etc.
> Perhaps someone else could take that on.
Well, then. I've done a fair bit of it. I've attached quote.hpp
and unquote.hpp, plus a simple test program.
I haven't written any documentation, and the test isn't up to
snuff, but it's enough to prove the algorithms. There may be
room to improve unquote()'s logic; I didn't spend a lot of time
My intention is that unquote() should handle a string with
multiple quoted substrings rather than just assuming that the
entire string is quoted. It is certainly reasonable to think
that it should only handle whole strings. In that case, it would
be easy to identify malformed strings on input: either it starts
and ends with the delimiter, and all other occurrences are
escaped, or it is malformed.
I quickly chose to throw std::logic_error from unquoted() when it
fails to find a closing delimiter. There may well be a better
approach; feel free to suggest alternatives.
Have a look at the code and let me know what you think.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk