libfyaml icon indicating copy to clipboard operation
libfyaml copied to clipboard

Boolean values for YAML v1.2

Open benmordaunt opened this issue 2 years ago • 4 comments

The v1.2 spec states that "true", "false", "on", "off" etc. should be interpreted as their boolean value counterparts. As this library claims to support YAML 1.2, how is that handled, or do I just have to strcmp regardless?

Thanks

benmordaunt avatar Apr 02 '22 00:04 benmordaunt

Well, the problem is that C does not have a native object model that maps directly to a YAML core schema.

So, a boolean as defined by the core schema cannot right now automatically converted to a 'C' bool type.

There is some work being done to have user-defined schemas that would handle these cases (among lots of others) but nothing is ready yet.

For now you can extract the string and strcmp(), perhaps even using the scanf family of functions of the library.

pantoniou avatar Apr 12 '22 08:04 pantoniou

What's stopping {"true", "on", etc.} -> 1 (char), {"false", "off", etc.} -> 0 (char) ?

benjaminmordaunt avatar Apr 20 '22 13:04 benjaminmordaunt