Closed GoogleCodeExporter closed 9 years ago
I guess I expected the exception to raise for values outside the char range
[0-255].
Original comment by mdcb...@gmail.com
on 17 Jun 2014 at 9:43
This looks like it's the fault of std::stringstream. Since uint8_t == unsigned
char, it appears to try to read "10" by characters. So
std::stringstream ss("10");
uint8_t c;
ss >> c;
Leaves "0" left in the stream's buffer. At this point, yaml-cpp checks if it's
read the whole input (it hasn't) and so it reports a conversion error.
I'm not sure what to do with this. Any thoughts?
Original comment by jbe...@gmail.com
on 19 Jun 2014 at 1:22
[deleted comment]
newbie comment, sorry if I'm missing something, but why is yaml-cpp treating
char/uchar and family as characters rather than integral. a choice had to be
made but does it reflect the most common usage?
I can't think of 'character' in yaml file:
a_char: a # in fact, string "a"
a_char: "\x61" # unwieldly, a string anyway
my line of work, but it's quite common to have (u)int8_t for numerical values
so I would rather have:
Dump(Node((uint8_t) 0x10)) // 16 rather than "\x10"
and
Node((int) 10).as<uint8_t>() // == 10 rather than exception
Original comment by mdcb...@gmail.com
on 19 Jun 2014 at 7:22
possibly more illustrative:
Node((uint8_t) 48).as<int>() // 48 rather than 0
Node((uint8_t) 0).as<int>() // 0 rather than exception
Original comment by mdcb...@gmail.com
on 19 Jun 2014 at 7:56
You may be right, but it seems really weird for
foo: 5
to give
node["foo"].as<char>() == 0x05
and even weirder for
foo: t
node["foo"].as<char>()
to throw an exception.
You're right, a choice has to be made, and you'll get some weird behavior both
ways, but this seems... particularly weird.
Original comment by jbe...@gmail.com
on 21 Jun 2014 at 6:03
Original comment by jbe...@gmail.com
on 24 Jan 2015 at 9:21
Original issue reported on code.google.com by
mdcb...@gmail.com
on 17 Jun 2014 at 9:37