Boost logo

Boost :

Subject: Re: [boost] hex/unhex()?
From: Marshall Clow (mclow.lists_at_[hidden])
Date: 2011-11-01 18:32:54


On Nov 1, 2011, at 3:26 PM, Olaf van der Spek wrote:
> On Tue, Nov 1, 2011 at 9:29 PM, Marshall Clow <mclow.lists_at_[hidden]> wrote:
>> You want something like this?
>> template <typename InputIterator, typename OutputIterator>
>> OutputIterator hex ( InputIterator first, InputIterator last, OutputIterator out );
>>
>> template <typename InputIterator, typename OutputIterator>
>> OutputIterator unhex ( InputIterator first, InputIterator last, OutputIterator out );
>>
>> [ + range based versions ]
>> [ + versions that work on char/wchar_t/short/int/long/long long, etc]
>
> No, I'm looking for one that returns std::string.
> Although the generic versions might be useful too.

        std::string input ( "61626f6465" );
        std::string result;
        unhex ( input.begin(), input.end (), std::back_inserter(result));

        ---> result should contain "abode"

> How would your unhex() flag an error?

Throw an exception.

-- Marshall

Marshall Clow Idio Software <mailto:mclow.lists_at_[hidden]>

A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly moderated down to (-1, Flamebait).
        -- Yu Suzuki


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