parcel 0.2.2
Wrappable, wire-transferable C++23 value system with JSON serialization
Loading...
Searching...
No Matches
builtins.h
Go to the documentation of this file.
1#pragma once
2
27#include <parcel/commons.h>
28#include <parcel/ext/chrono.h>
30#include <parcel/ext/ulid.h>
31#include <parcel/list.h>
32#include <parcel/map.h>
33#include <parcel/primitive.h>
34#include <parcel/registry.h>
36
37namespace parcel {
38
65#ifdef COMMONS_HAS_INT128
70#endif
71
98#ifdef COMMONS_HAS_INT128
103#endif
104
131#ifdef COMMONS_HAS_INT128
136#endif
137
138// Complex typed collections (wire kinds e.g. "l:cf64", "m:cs8", "hm:cu32").
139
160
181
202
236
244 reg.register_kind(HashMapCell::descriptor());
245}
246
271#ifdef COMMONS_HAS_INT128
274#endif
285
299#ifdef COMMONS_HAS_INT128
302#endif
313
314 reg.register_kind(CharHashMapCell::descriptor());
315 reg.register_kind(BoolHashMapCell::descriptor());
316 reg.register_kind(U8HashMapCell::descriptor());
317 reg.register_kind(U16HashMapCell::descriptor());
318 reg.register_kind(U32HashMapCell::descriptor());
319 reg.register_kind(U64HashMapCell::descriptor());
320 reg.register_kind(I8HashMapCell::descriptor());
321 reg.register_kind(I16HashMapCell::descriptor());
322 reg.register_kind(I32HashMapCell::descriptor());
323 reg.register_kind(I64HashMapCell::descriptor());
324 reg.register_kind(FloatHashMapCell::descriptor());
325 reg.register_kind(DoubleHashMapCell::descriptor());
326 reg.register_kind(StringHashMapCell::descriptor());
327#ifdef COMMONS_HAS_INT128
328 reg.register_kind(U128HashMapCell::descriptor());
329 reg.register_kind(I128HashMapCell::descriptor());
330#endif
331 reg.register_kind(Cs8HashMapCell::descriptor());
332 reg.register_kind(Cs16HashMapCell::descriptor());
333 reg.register_kind(Cs32HashMapCell::descriptor());
334 reg.register_kind(Cs64HashMapCell::descriptor());
335 reg.register_kind(Cu8HashMapCell::descriptor());
336 reg.register_kind(Cu16HashMapCell::descriptor());
337 reg.register_kind(Cu32HashMapCell::descriptor());
338 reg.register_kind(Cu64HashMapCell::descriptor());
339 reg.register_kind(Cf32HashMapCell::descriptor());
340 reg.register_kind(Cf64HashMapCell::descriptor());
341}
342
353inline void register_std(ParcelRegistry& reg) {
354 reg.register_kind(SystemTimePointCell::descriptor());
355 reg.register_kind(UnixMillisCell::descriptor());
356 reg.register_kind(DurationMsCell::descriptor());
357 reg.register_kind(YmdCell::descriptor());
358 reg.register_kind(PathCell::descriptor());
359}
360
372 reg.register_kind(ColorCell::descriptor());
373 reg.register_kind(IconCell::descriptor());
374 reg.register_kind(DisplayInfoCell::descriptor());
375 reg.register_kind(FlagCell::descriptor());
376 reg.register_kind(FlagSetCell::descriptor());
377 reg.register_kind(SemVerCell::descriptor());
378 reg.register_kind(VersionConstraintCell::descriptor());
379 reg.register_kind(OriginCell::descriptor());
380}
381
382#if PARCEL_HAS_ULID
391inline void register_ulid(ParcelRegistry& reg) {
392 reg.register_kind(UlidCell::descriptor());
393}
394#endif
395
401inline void register_builtins(ParcelRegistry& reg, const BuiltinsOptions opts = {}) {
402 if (opts.primitives) {
403 register_primitives(reg);
404 }
405 if (opts.collections) {
407 }
408 if (opts.typed_collections) {
410 }
411 if (opts.std) {
412 register_std(reg);
413 }
414 if (opts.commons) {
415 register_commons(reg);
416 }
417#if PARCEL_HAS_ULID
418 if (opts.ulid) {
419 register_ulid(reg);
420 }
421#endif
422}
423
424// Defined here (rather than in registry.h) so the registry header doesn't
425// pull in every primitive / collection cell. The declaration lives on
426// ParcelRegistry; this is just the inline body.
428 register_builtins(*this, opts);
429}
430
431} // namespace parcel
void register_commons(ParcelRegistry &reg)
Register the commons-adapter cells into reg.
Definition builtins.h:371
void register_collections(ParcelRegistry &reg)
Register the heterogeneous ListCell, MapCell, and HashMapCell into reg.
Definition builtins.h:241
void register_builtins(ParcelRegistry &reg, const BuiltinsOptions opts={})
Apply the opts toggles to populate reg with built-in cells.
Definition builtins.h:401
void register_std(ParcelRegistry &reg)
Register the std-adapter cells into reg.
Definition builtins.h:353
void register_primitives(ParcelRegistry &reg)
Register every PrimitiveCell<T> into reg.
Definition builtins.h:207
void register_typed_collections(ParcelRegistry &reg)
Register TypedListCell<P>, TypedMapCell<P>, and TypedHashMapCell<P> for every primitive P.
Definition builtins.h:257
Cell adapters for std::chrono types.
static cell_type_descriptor_t descriptor()
Cached descriptor for ListCell.
Definition list.h:672
static cell_type_descriptor_t descriptor()
Cached descriptor for MapCell.
Definition map.h:658
Runtime catalog of cell-type descriptors, keyed by wire kind id.
Definition registry.h:115
void register_kind(cell_type_descriptor_t d)
Register or replace a descriptor by its kind id.
Definition registry.h:252
ParcelRegistry(BuiltinsOptions opts={})
Construct, optionally tuning which builtins are pre-registered.
Definition builtins.h:427
static cell_type_descriptor_t descriptor()
Cached descriptor for this primitive type.
Definition primitive.h:399
Homogeneous string-keyed unordered_map of values of type T.
Definition unordered_map.h:75
Homogeneous list of element cells of type T.
Definition list.h:106
static cell_type_descriptor_t descriptor()
Cached descriptor for this typed list.
Definition list.h:385
Homogeneous string-keyed map of values of type T.
Definition map.h:106
static cell_type_descriptor_t descriptor()
Cached descriptor for this typed map.
Definition map.h:368
Parcel cell adapters for the aurimasniekis/cpp-commons vocabulary types.
Cell adapter for std::filesystem::path.
TypedListCell<T> and heterogeneous ListCell with their descriptors.
TypedMapCell<T> and heterogeneous MapCell with their descriptors.
PrimitiveCell<T> plus the per-storage PrimitiveTraits<T> specializations.
ParcelRegistry, Definition, and BuiltinsOptions for polymorphic dispatch.
Toggles for the built-in cell registrations performed by register_builtins.
Definition registry.h:50
Optional cell adapter for ulid::Ulid (from aurimasniekis/cpp-ulid).
Hash-backed map cells — TypedHashMapCell<T> and HashMapCell.