January 14, 2012
On Fri, 13 Jan 2012 23:05:19 +0100, Matej Nanut wrote:

> While we're at it: what's the best way to parse in a formatted manner? For example, if I want to get 5 hexadecimal digits converted into an uint? And I want to simultaneously advance the string?
> 
> "sscanf" seems fiddly and unsafe.
> 

Check out readf: http://d-programming-language.org/phobos/ std_stream.html#readf

You'll need to wrap the string in a Stream interface (MemoryStream?), but since you're looking for advance-on-read, you want stream semantics anyhow.

Justin
January 14, 2012
I've never noticed std.conv.parse takes a radix argument, silly me.
And will take
a look at readf from std.stream, definitely.

Thanks!

On 14 January 2012 01:20, Justin Whear <justin@economicmodeling.com> wrote:
> On Fri, 13 Jan 2012 23:05:19 +0100, Matej Nanut wrote:
>
>> While we're at it: what's the best way to parse in a formatted manner? For example, if I want to get 5 hexadecimal digits converted into an uint? And I want to simultaneously advance the string?
>>
>> "sscanf" seems fiddly and unsafe.
>>
>
> Check out readf: http://d-programming-language.org/phobos/ std_stream.html#readf
>
> You'll need to wrap the string in a Stream interface (MemoryStream?), but since you're looking for advance-on-read, you want stream semantics anyhow.
>
> Justin
1 2
Next ›   Last »