E
edd
Hello all,
I'm trying to put together some code that reads 3 adjacent pairs of hex
digits from an istream. Each hex digit pair represents a non-negative
integer.
For example I would like to extract 1, 255 and 18 from 01ff12 (as the
components of a simple RGB colour, in my application).
I was hoping to find something like std::setw for istreams and use it
in combination with std::hex so that I could read 2 hex digits at a
time, but as far as I can tell no such entity exists in the C++
standard library.
Is there a neat and tidy way of doing what I want, or am I going to
have to do something nasty like put each digit pair in to its own
buffer and stream-extract/strtoul the numbers from there?
Why is it that no equivalent to setw exists for istreams?
Kind Regards,
Edd
I'm trying to put together some code that reads 3 adjacent pairs of hex
digits from an istream. Each hex digit pair represents a non-negative
integer.
For example I would like to extract 1, 255 and 18 from 01ff12 (as the
components of a simple RGB colour, in my application).
I was hoping to find something like std::setw for istreams and use it
in combination with std::hex so that I could read 2 hex digits at a
time, but as far as I can tell no such entity exists in the C++
standard library.
Is there a neat and tidy way of doing what I want, or am I going to
have to do something nasty like put each digit pair in to its own
buffer and stream-extract/strtoul the numbers from there?
Why is it that no equivalent to setw exists for istreams?
Kind Regards,
Edd