Closed GoogleCodeExporter closed 8 years ago
Hi, I have encountered the same problem today. I am using your yaml-cpp 0.5 new
API, and want to iterate down in a map node to get existing nodes or insert new
nodes, but the referencing will cause it to change the root node itself.
Are there any workarounds of this? Or where I can modify a bit in your source
code(even some kind of 'dirty fix') to add this feature?
Thanks in advance!
Original comment by chk0...@gmail.com
on 26 Mar 2013 at 5:01
It shouldn't be hard - just reset the shared memory and node delegate in
YAML::Node.
Original comment by jbe...@gmail.com
on 28 Mar 2013 at 3:41
Thanks for your reply, but how can I do that? Currently I am using something
like:
template<typename T>
void setVal(const vector<string>& path, YAML::Node& root_node, T val)
{
YAML::Node node = root_node;
// suppose all child nodes exists
for(itr = path.begin(); itr != path.end() ++itr)
node = root_node[path];
node = val;
}
But this will destroy root_node, after this function call it will be changed to
the leaf node and I cannot recover the reference to the original root node.
Original comment by chk0...@gmail.com
on 28 Mar 2013 at 9:25
Sorry, I meant, you would add a reset() method to YAML::Node.
Original comment by jbe...@gmail.com
on 28 Mar 2013 at 2:10
Fixed,
https://code.google.com/p/yaml-cpp/source/detail?r=476cbbebe57bb1808b947c03337bd
643dcbe2db2&repo=new-api
(Implemented Node::reset)
Original comment by jbe...@gmail.com
on 3 Apr 2013 at 1:50
Great news for me! I am trying it out! Thanks very much!
Original comment by chk0...@gmail.com
on 3 Apr 2013 at 2:08
Original issue reported on code.google.com by
jbe...@gmail.com
on 31 Jan 2013 at 6:44