tarantool / tarantool/doc

tntcxx: update response decoding documentation

Open
#3,968 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

tntcxx
Dominant language
CSS
Stars
15
Forks
49
Avg merge
1d 13h
Merged PRs (30d)
3

Description

Decoding and reading the data section is almost completely irrelevant since the decoder was reworked, we need to update it.

Class Data has decode method now. One can call it and pass a reference to container in which the tuples are to be placed. For example, your tuples has format [int, int]. That's how decoding of such tuples looks like:

using MyTuple = std::tuple<int, int>;
std::vector<MyTuple> tuples;
data.decode(tuples);

Generally, here are supported objects:

  • std::nullptr_t will be always decoded as MP_NIL.
  • fundamental types (int, float, bool, ...)
  • char[N], std::string for MP_STR.
  • Any putable, contiguous (if underlying type is not char) or tuple-like object is considered as MP_ARR.
  • Any putable, contiguous (if underlying type is not char) or tuple-like object, containing pairs (including std::map), is considered as MP_MAP.
  • Any optional-like object can be decoded as MP_NIL or as its underlying value.
  • Any variant-like object can be decoded as any of its alternatives.

Also, one can populate its own class with encoding rule using static constexpr mpp_dec or mpp member, containing pointers to the class member. Used members must be public. And, one can use mpp::as_* tag to specify what type to encode into. Semantics is the same as the one in #3967 (these features are described in the end of the issue).

Contributor guide

Open the contributing guide

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.

Research direction

Open the linked “Decoding and reading the data” section in the getting-started C++ documentation and compare it with the current Data::decode API. Update the section to cover the tuple example, supported decoded object categories, and custom class rules using mpp_dec or mpp and mpp::as_* tags. The section should accurately describe the reworked decoder and provide an example that matches the current API.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.