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

Add examples of iterating sequences in quickstart #438

Open
aleksigron opened this issue Jun 14, 2024 · 4 comments
Open

Add examples of iterating sequences in quickstart #438

aleksigron opened this issue Jun 14, 2024 · 4 comments

Comments

@aleksigron
Copy link

Would it be possible to add some examples of iterating sequences in quickstart.cpp? Currently I can only find checks that know ahead of time how many items are in the sequence. From what I've found looking at the code, it seems that the only way to iterate sequences is to use begin() and end() iterators. I'm using the node API btw.

@biojppm
Copy link
Owner

biojppm commented Jun 14, 2024

Do you mean these? That's really it; they are written as checks, but that's the way to iterate through a node's children; it doesn't matter whether they are seqs or maps.

@aleksigron
Copy link
Author

Ah, so children works for both seqs and maps. I didn't realize that. Didn't see that mentioned or used anywhere. Maybe it would be nice to mention somewhere in the documentation. I can make a small PR if you think it's a good idea. What do you think?

@biojppm
Copy link
Owner

biojppm commented Jun 15, 2024

What gave you the impression that this would be different? Being containers, both seqs and maps can have children.

As for the PR, sure, submit it and let's look at it.

@aleksigron
Copy link
Author

I didn't have much experience with YAML parsers before. The few others that I now took a look at, seem to also treat maps and sequences similarly to rapidyaml. I used rapidjson before, which does handle arrays and objects with separate interfaces, so that's probably where the confusion came from.

I think it would still be beneficial to add example usage of iterating sequences. I found it confusing that there are zero examples of sequences, while there are multiple examples of maps. I will open a PR soonish.

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

2 participants