json icon indicating copy to clipboard operation
json copied to clipboard

basic implementation of context-based path traction

Open grisumbras opened this issue 10 months ago • 3 comments

Very rough draft of the idea.

For a context type Ctx the user is supposed to implement these functions:

void tag_invoke(context_key_push_tag, string_view,  Ctx const&);
void tag_invoke(context_key_pop_tag, Ctx const&);
void tag_invoke(context_index_push_tag, std::size_t, Ctx const&);
void tag_invoke(context_index_pop_tag, Ctx const&);

The library would invoke them when traversing through the converted/parsed/serialized value.

Things to think about:

  • The user may actually want to set error_code in those callbacks.
  • The user may want to clear error_code in those functions. But then where would we get the results the calling function was supposed to create?

grisumbras avatar Feb 25 '25 02:02 grisumbras

An automated preview of the documentation is available at https://1075.json.prtest2.cppalliance.org/libs/json/doc/html/index.html

cppalliance-bot avatar Feb 25 '25 02:02 cppalliance-bot

Is very interesting and clean. I would suggest in this section

https://github.com/grisumbras/json/blob/e4e192a84f7482aaad923575e34e6f37669252d0/include/boost/json/detail/value_to.hpp#L376

To move the json::context_key_push(ctx, D::name);

Before the check, so we can capture the "last processed" json pointer

RoyBellingan avatar Jun 23 '25 02:06 RoyBellingan