majintao0131 / yaml-cpp

Automatically exported from code.google.com/p/yaml-cpp
MIT License
0 stars 0 forks source link

There's no way to remove an item from a sequence. #190

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Given

YAML::Node node = YAML::Load("[1, 2, 3]");

How can you turn it into [1, 3]?

Right now

node.remove(1);

does nothing; if anything, I think it should turn the node into a map, {0: 1, 
2: 3}, to mirror what happens if you write node[10] = 10.

So maybe node.remove_at(1)? I'm not sure...

Original issue reported on code.google.com by jbe...@gmail.com on 31 Jan 2013 at 6:48

GoogleCodeExporter commented 9 years ago
I don't know if this is the same problem or not, but it's a similar problem 
with remove so I'll add it:

    YAML::Node node;
    std::cout << node.size() << std::endl;

    //node[0] = YAML::Node();
    node[1] = YAML::Node();
    node[2] = YAML::Node();
    std::cout << node.size() << std::endl;

    node.remove(2);
    std::cout << node.size() << std::endl;

Output:
0
2
1

Un-comment the line and output:
0
3
3

Original comment by UGWil...@gmail.com on 11 Aug 2014 at 4:34

GoogleCodeExporter commented 9 years ago
Yeah, that's the same question - with the line uncommented, "node" is a 
sequence, so "remove" has no effect.

Original comment by jbe...@gmail.com on 11 Aug 2014 at 1:06

GoogleCodeExporter commented 9 years ago
This issue has moved to github: https://github.com/jbeder/yaml-cpp/issues/190

Original comment by jbe...@gmail.com on 1 Apr 2015 at 3:20