parcel 0.2.2
Wrappable, wire-transferable C++23 value system with JSON serialization
Loading...
Searching...
No Matches
walk.h File Reference

std::generator-based walk over a cell tree. More...

#include <parcel/cell.h>
#include <parcel/list.h>
#include <parcel/map.h>
#include <parcel/struct.h>
#include <parcel/union.h>
#include <string>
#include <utility>
#include <vector>
Include dependency graph for walk.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  parcel::WalkEntry
 One node yielded by a tree walk: (json-pointer-path, cell). More...
 

Functions

std::vector< WalkEntryparcel::walk_to_vector (cell_t const &root)
 Eagerly collect every cell in root's tree, depth-first.
 

Detailed Description

std::generator-based walk over a cell tree.

Recurses into ListCell and MapCell depth-first, yielding each visited cell paired with a JSON-pointer-style path (RFC 6901, with ~ and / escaped to ~0 / ~1). Every other cell — including StructCell and UnionCell — is treated as a leaf.

Requires C++23 <generator>. When the standard header is unavailable (libc++ shipped with older Apple Clang, for example) this header exposes a fallback walk_to_vector that materializes the same nodes eagerly into a vector.

Function Documentation

◆ walk_to_vector()

std::vector< WalkEntry > parcel::walk_to_vector ( cell_t const &  root)
inline

Eagerly collect every cell in root's tree, depth-first.

Independent of the <generator> header so it always compiles. Prefer walk (below) when targeting a toolchain with C++23 generator support.

Parameters
rootRoot cell.
Returns
Vector of (path, cell) entries.