New function as alternative to `operator[]` for read and write

Open
#1,448 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
cpp, yaml
Domain
backend

Research direction

Start by reading the public Node API and its tests to see how operator[] handles both reads and writes, including missing keys and exceptions. Identify an alternative function that supports both operations and determine its expected behavior from the existing API. Done means the proposed API is clear and tested for reading and writing YAML nodes.

Written by the indexing model from the issue text.

Description

Example:

YAML::Node node = YAML::LoadFile(constant::file::configuration);
const double commission_factor = node["factor"].as<double>();
node["factor"] = 4.532;

It would be beneficial to have an alternative function instead of the overloaded operator operator[] to please the clang-tidy recommendation to not use overloaded operator[], https://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/pro-bounds-avoid-unchecked-container-access.html. This is needed for read and write operations.

This makes sense as in the STL operator[] does not throw exceptions but rather aborts the programme and thus is not recommended.

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.