Add more examles, including using range-based for loops for iterating over `YAML::Node`s (link to my examples)

Open
#1,127 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Documentation
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp, yaml
Domain
documentation

Research direction

Start with the README examples and the linked demo file, cpp/yaml-cpp_lib_demo.cpp. Review how the README links to examples and how the demo iterates over YAML sequences and maps; the issue proposes linking the demo and adding range-based loop examples. Done looks like the README points to the examples and readers can find sequence and map iteration guidance.

Written by the indexing model from the issue text.

Description

I really think you need some more examples, especially how to iterate over Sequences (lists) and Maps using range-based for loops.

I suggest you link to my examples here, in your readme: https://github.com/ElectricRCAircraftGuy/eRCaGuy_hello_world/blob/master/cpp/yaml-cpp_lib_demo.cpp

I'll add range-based for loop examples to my demo code above tonight, including like this, for example, to iterate over a Map:

    YAML::Node data_phi = root_node["data"][6];
    assert(data_phi.IsMap());

    for (const std::pair<YAML::Node, YAML::Node>& keyValue : data_phi)
    {
        std::string key = keyValue.first.as<std::string>();
        std::string value = keyValue.second.as<std::string>();
        printf("key = %-15s value = %-15s\n", key.c_str(), value.c_str());
    }
Dominant language
C++
Stars
6.1k
Forks
2.2k
Avg merge
22h 2m
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from jbeder/yaml-cpp

All issues in jbeder/yaml-cpp

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.