parcel 0.2.4
Wrappable, wire-transferable C++23 value system with JSON serialization
Loading...
Searching...
No Matches
version_constraint.h
Go to the documentation of this file.
1#pragma once
2
8#include <parcel/cell.h>
9#include <parcel/defaults.h>
10#include <parcel/descriptor.h>
11#include <parcel/json.h>
12
13#include <commons/json/version_constraint.hpp>
14#include <commons/version_constraint.hpp>
15
16#include <string>
17#include <string_view>
18#include <utility>
19
20namespace parcel {
21
29class VersionConstraintCell : public BaseCell<VersionConstraintCell, comms::VersionConstraint> {
31
32public:
33 using base_t::base_t;
34 using base_t::operator=;
35
36 static constexpr std::string_view kind_id = "version_constraint";
37
38 [[nodiscard]] std::string to_string() const override {
39 return this->value.to_string();
40 }
41
42 static cell_t from_json(json_t const& j, ParcelRegistry const&) {
43 auto v = base_t::cell_from_json<comms::VersionConstraint>(j, kind_id);
44 auto cell = std::make_shared<VersionConstraintCell>(std::move(v));
46 return cell;
47 }
48
49 static cell_type_descriptor_t descriptor() {
50 static const auto d = std::make_shared<SimpleCellTypeDescriptor<VersionConstraintCell>>(
51 DisplayInfo{.name = "VersionConstraint",
52 .description = "Semver range constraint (range string on the wire)"});
53 return d;
54 }
55};
56
57} // namespace parcel
58
Core ICell interface, cell_t handle, BaseCell CRTP base, and CellLike concept.
std::shared_ptr< ICell > cell_t
Shared handle to any ICell-derived value — the canonical cell pointer.
Definition cell.h:68
Runtime catalog of cell-type descriptors, keyed by wire kind id.
Definition registry.h:115
Cell wrapping comms::VersionConstraint.
Definition version_constraint.h:29
std::string to_string() const override
Render the cell's value as a compact human-readable string.
Definition version_constraint.h:38
The default_cell_for<T> trait that drives FieldsBuilder field-type inference.
#define PARCEL_DEFAULT_CELL(CellT)
Register a cell type as the default wrapper for its payload type.
Definition defaults.h:269
auto cell(T &&v)
Wrap a raw value into its default cell, returning a shared_ptr to the cell.
Definition defaults.h:192
Runtime cell-type descriptors and the schema-graph mix-ins (IHasFields, ISubTypes).
nlohmann::json typedef shared across cell types.
nlohmann::json json_t
Project-wide alias for nlohmann::json.
Definition json.h:19
CRTP base providing default to_json / clone / kind plumbing on top of a storage type.
Definition cell.h:343
static void absorb_display_info(json_t const &j, Out &out)
Read "d" (if present) from a JSON object and assign it onto a cell.
Definition cell.h:499
comms::VersionConstraint value
Held value of the cell.
Definition cell.h:348