dimval 0.2.0
Modern C++23 header-only library of dimensional values (units, measures, ranges)
Loading...
Searching...
No Matches
parcel.hpp File Reference

Optional cpp-parcel integration. More...

#include <dimval/format.hpp>
#include <dimval/json_nlohmann.hpp>
#include <dimval/measure.hpp>
#include <dimval/range.hpp>
#include <dimval/traits.hpp>
#include <dimval/unit.hpp>
#include <memory>
#include <string>
#include <string_view>
#include <parcel/parcel.h>
Include dependency graph for parcel.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Detailed Description

Optional cpp-parcel integration.

Activates when parcel is on the include path (or when DIMVAL_WITH_PARCEL=1 is defined by CMake).

Wire envelope (parcel framing of dimval's JSON adapter shape):

UnitValue<U,T>          {"k":"uv",  "v":{"u":"m","v":42.5}}
MeasureValue<M,T>       {"k":"mv",  "v":{"m":"distance","u":"m","v":42.5}}
UnitRangeValue<U,T>     {"k":"urv", "v":{"u":"m","min":0,"max":10,
                                         "mi":true,"xi":true}}
MeasureRangeValue<M,T>  {"k":"mrv", "v":{"m":"distance","u":"m",
                                         "min":0,"max":10,
                                         "mi":true,"xi":true}}

Inner field-name legend (from dimval's JSON adapter): u = unit id, m = measure id, v = value, mi = min_inclusive, xi = max_inclusive.

Limitation: every UnitValueCell<U,T> instantiation shares kind_id="uv" (and likewise for the other three cells), so a single ParcelRegistry cannot hold dispatchers for multiple unit-tag variants simultaneously — the last register_kind() wins. dimval users typically decode at sites that already know the C++ type, and the inner JSON-adapter from_json validates the unit/measure field, so cross-tag mismatches still surface as exceptions.