-
Notifications
You must be signed in to change notification settings - Fork 100
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
Remove a child/subtree #352
Comments
(I'm writing this on a phone, so the answer may be incomplete) In the As for using cJSON to build your data structures. Of course, you can do that. But if you're finding it hard to use rapidyaml to achieve the same, I would be curious to find out why. Mostly the |
Caro João Paulo, I will look into the delete nodes/children nodes methods. as you suggested. As for using cJSON: it is what I was used too, and I do think it could be done in (rapid)YAML. Abraço |
Yes, unfortunately docsforge went down recently and I need to remove those links. But if you browse through the QuickStart, you will be on your way. It shows the several ways you can deserialise. |
In particular, the functions |
Were you able to do the removal? |
No, whenever I try to remove something from the tree, my entire tree is removed. Here is the YAML I parsed into a tree
I want to remove the entire transactions-child, but never understood how to do it. BTW, did you see the issue I opened in c4conf? I have included a patch that resolves it for me, but don't know if it is the correct one. |
I must have been fighting myself...it is as easy as doing:
Thanks |
Actually, I know what I have been fighting. Not sure if it is a bug. I let you decide. When doing:
But there was no "transactions" child in the tree, it will clear the entire original tree!
It needs to be ConstNodeRef for valid to be false if it does not exist, but then for clear it cannot be ConstNodeRef. Edit: It sometimes still clears the entire tree .....still lost |
Sorry for the late reply. I've been abroad and with limited access. Let's go by parts, addressing first the unwanted clear. Let's discuss in another time the behavior of calling Can you clarify what you mean with "sometimes still clears the entire tree"? Can you get together a MVE (minimum verifiable example) which reproduces the problem? Also, I reckon you are using a Release build? If you build ryml in Debug, the assertions will be enabled and trigger an error at the appropriate point. This is generally very helpful. There is also a macro that ensures the assertions are enabled in release builds, (at a slight cost in codegen and speed). |
No problem. I will create a minimal example, but am a bit overloaded at the moment. |
The YAML tree resolve is great, as it allows me to use anchors. The result is then parsed as a JSON tree (using cJSON), which I am more familiar with.
Basically, I have a defaults-file, which has:
transactions:
name: Transaction One
name: Transaction Two
I then "merge" this with my requested input file, but that leaves me with this "transactions" node in the YAML-tree, that I am trying to get rid off. Except I can't figure out how to remove it...
As a minor comment: I am actually parsing it back to JSON, because I can't really figure out how to do everything with rapidyaml.
Other than that, rapidyaml combined with c4conf is extremely powerful.
Edit: The reason for this is that I want to save the merged YAML tree, so I can use that as an input and even if the defaults change, I can reproduce my output. It works even with that transactions node there, so it is merely cosmetic.
Kind regards,
Martijn
The text was updated successfully, but these errors were encountered: