Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boolean values for YAML v1.2 #52

Open
benmordaunt opened this issue Apr 2, 2022 · 4 comments
Open

Boolean values for YAML v1.2 #52

benmordaunt opened this issue Apr 2, 2022 · 4 comments

Comments

@benmordaunt
Copy link

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

@pantoniou
Copy link
Owner

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.

@benjaminmordaunt
Copy link

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

@yrashk
Copy link
Contributor

yrashk commented Apr 21, 2023

👍 Looking into this issue as well; wondering if you had any more thoughts on this?

I started writing some small scalar helps for handling types.

@pantoniou
Copy link
Owner

FWIW work is underway to support the builtin YAML spec schemas. That will support what you need among other things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants