welder 0.1.0
Bindings for annotated C++ types, from C++26 reflection
Loading...
Searching...
No Matches
welder::rods::opaque_containers Namespace Reference

Classes

struct  document
 The accumulator threaded through the rod's emission hooks: the deduped set of reference containers the welded namespace uses, and the renderer for the finished header. More...
struct  entry
 One container to open opaque: its C++ spelling, its derived target name, and whether a by_value mark excluded it (kept in the set so a later use site can be reconciled, but skipped at render). More...
struct  rod
 The opaque-container generator rod (satisfies welder::rod). More...

Functions

consteval std::string container_spelling (std::meta::info type)
 The C++ text of container type, infrastructure args (allocator/comparator/ hasher) dropped — the reflection display form, which already elides them (std::vector<int>, std::map<std::__cxx11::basic_string<char>, int>).
consteval std::size_t value_arg_count (std::meta::info type)
 How many leading (value) template arguments of type name its element/key/value types — a sequence exposes 1, a map 2.
consteval std::string sanitize_ident (std::string s)
 Reduce s to a valid C++ identifier: keep [A-Za-z0-9_], collapse every other run to a single _ (dropping leading/trailing ones), and prefix _ if it would start with a digit.
consteval std::string qualified_ident (std::meta::info entity)
 The collision-free qualified identifier of entity: its own identifier (or, for an unnameable entity, its display_string_of) prefixed by every enclosing named namespace and enclosing class, each PascalCased and concatenated — so a type is named uniquely across namespaces (geometry::PointGeometryPoint, physics::PointPhysicsPoint, never a colliding bare Point).
consteval std::string decimal_string (std::size_t n)
 Decimal render of n (constexpr std::to_string is unavailable on gcc-16) — the extent token an std::array derived name carries (see derive_name).
consteval std::string derive_name (std::meta::info arg)
 A readable, valid, collision-free PascalCase identifier for container/element arg — the template name plus each argument's name, recursing — vector<int>VectorInt, map<string,int>MapStringInt, nested map<string,vector<int>>MapStringVectorInt.
consteval bool has_opaque_hook (std::meta::info style_type)
 Does name style style_type (or any of its bases) declare the optional transform_opaque_container hook?
template<class Style, std::meta::info Enclosing, std::meta::info Container, std::meta::info Member>
consteval std::string opaque_name ()
 The opaque-wrapper name for container Container found on member/site Member within Enclosing — the customization point behind the generator's naming.
consteval std::string namespace_name (std::meta::info ns)
 The fully-qualified spelling of namespace ns for a namespace X { … } header block (no leading ::geometry::detail, not ::geometry::detail).
consteval bool scalar_leaf (std::meta::info t)
 Is t a scalar leaf — a fundamental type or a std::basic_string — i.e.
consteval bool opaque_eligible (std::meta::info type)
 Is container type eligible for the generator — will every element/key/value type's name exist when it binds (see element_ok)?
consteval bool element_ok (std::meta::info t)
 Can element/key/value type t appear inside an opaque container — i.e.
consteval std::size_t container_depth (std::meta::info type)
 How deeply container type nests further reference containers: 1 for vector<int>, 2 for vector<vector<int>>, … Non-containers are 0.
consteval void collect_into (std::vector< std::meta::info > &out, std::meta::info type)
 Append type's directly-named reference container when it is one and eligible (see opaque_eligible), then recurse into its element/key/value types — a nested container is opened opaque alongside the outer (the outer's binding hands out live references to it, so both must exist).
template<std::meta::info Type>
consteval std::vector< std::meta::info > containers_in ()
 The reference containers within surface type Type (a splice-ready static list for a template for).

Function Documentation

◆ collect_into()

void welder::rods::opaque_containers::collect_into ( std::vector< std::meta::info > & out,
std::meta::info type )
consteval

Append type's directly-named reference container when it is one and eligible (see opaque_eligible), then recurse into its element/key/value types — a nested container is opened opaque alongside the outer (the outer's binding hands out live references to it, so both must exist).

cv/ref-stripped like the bindability gate; non-eligible (nested-in-class-element) containers, and non-container wrappers (optional, pair), are left by value.

Parameters
outthe accumulator.
typea surface (member/param/return) type.

Definition at line 318 of file document.hpp.

References collect_into(), welder::is_reference_container(), opaque_eligible(), and value_arg_count().

Referenced by collect_into(), and containers_in().

◆ container_depth()

std::size_t welder::rods::opaque_containers::container_depth ( std::meta::info type)
consteval

How deeply container type nests further reference containers: 1 for vector<int>, 2 for vector<vector<int>>, … Non-containers are 0.

Drives the render order — an inner container's alias must weld before the outer that names it.

Definition at line 300 of file document.hpp.

References container_depth(), welder::is_reference_container(), and value_arg_count().

Referenced by welder::rods::opaque_containers::document::add_one(), and container_depth().

◆ container_spelling()

std::string welder::rods::opaque_containers::container_spelling ( std::meta::info type)
consteval

The C++ text of container type, infrastructure args (allocator/comparator/ hasher) dropped — the reflection display form, which already elides them (std::vector<int>, std::map<std::__cxx11::basic_string<char>, int>).

Valid, include-order-robust C++ for a WELDER_OPAQUE(...) / alias right-hand side.

Definition at line 37 of file document.hpp.

Referenced by welder::rods::opaque_containers::document::add_one().

◆ containers_in()

template<std::meta::info Type>
std::vector< std::meta::info > welder::rods::opaque_containers::containers_in ( )
consteval

The reference containers within surface type Type (a splice-ready static list for a template for).

Definition at line 331 of file document.hpp.

References collect_into().

Referenced by welder::rods::opaque_containers::document::collect().

◆ decimal_string()

std::string welder::rods::opaque_containers::decimal_string ( std::size_t n)
consteval

Decimal render of n (constexpr std::to_string is unavailable on gcc-16) — the extent token an std::array derived name carries (see derive_name).

Definition at line 123 of file document.hpp.

Referenced by derive_name().

◆ derive_name()

std::string welder::rods::opaque_containers::derive_name ( std::meta::info arg)
consteval

A readable, valid, collision-free PascalCase identifier for container/element arg — the template name plus each argument's name, recursing — vector<int>VectorInt, map<string,int>MapStringInt, nested map<string,vector<int>>MapStringVectorInt.

std::string folds to String; a scalar / welded class or enum uses its qualified_ident (namespace- and enclosing-class-qualified, so geometry::PointGeometryPoint) — which is what keeps distinct types from deriving the same name.

A fixed-size std::array<T, N> is named element-then-extent with an x separator — std::array<short, 289>ArrayShortx289, std::array<Vec3, 16>ArrayVec3x16 — so two arrays of the same element but different extents never collide (and the x keeps a digit-ending element name, e.g. Vec3, distinct from the extent). The N argument is a non-type value, not a type, so it is read and rendered directly rather than recursed as an element.

A container element that is itself a class-template specialization (e.g. Grid<Extent{2,3,4,5}>) recurses the SAME way — the template name plus each argument — so it never falls to display_string_of, which would keep :: < > { } ,. A non-type (NTTP) argument renders its value as a sanitized identifier token. The caller (document::add_one) sanitizes the final string as a safety net, so no input can yield a non-identifier.

Definition at line 153 of file document.hpp.

References decimal_string(), derive_name(), welder::is_reference_container(), qualified_ident(), and value_arg_count().

Referenced by derive_name(), and opaque_name().

◆ element_ok()

bool welder::rods::opaque_containers::element_ok ( std::meta::info t)
consteval

Can element/key/value type t appear inside an opaque container — i.e.

will its name exist when the container binds? True for a scalar leaf, a top-level welded class/enum (a weld_namespace sweep predeclares those names in PHASE 1), and a nested container** that is itself eligible — the generator opens the inner container too (see collect_into) and renders its alias FIRST (see document::render), so vector<vector<int>> binds as a VectorVectorInt whose elements are live VectorInt wrappers.

A NESTED (class-scoped) welded type is bound inside its enclosing class's interior in PHASE 3, after the containers, so it is NOT predeclared — a vector<Outer::Inner> would spell Inner's raw C++ name in the container's stub. It stays excluded; hand-write its alias.

Definition at line 269 of file document.hpp.

References welder::is_reference_container(), opaque_eligible(), welder::py, scalar_leaf(), and welder::welded_for().

Referenced by opaque_eligible().

◆ has_opaque_hook()

bool welder::rods::opaque_containers::has_opaque_hook ( std::meta::info style_type)
consteval

Does name style style_type (or any of its bases) declare the optional transform_opaque_container hook?

Detected by reflection rather than a requires-expression because the hook is a consteval static member — an immediate call cannot appear in the unevaluated operand of a requires, so a concept check would silently miss it.

Definition at line 194 of file document.hpp.

References has_opaque_hook().

Referenced by has_opaque_hook(), and opaque_name().

◆ namespace_name()

std::string welder::rods::opaque_containers::namespace_name ( std::meta::info ns)
consteval

The fully-qualified spelling of namespace ns for a namespace X { … } header block (no leading ::geometry::detail, not ::geometry::detail).

Definition at line 234 of file document.hpp.

Referenced by welder::rods::opaque_containers::rod::generate().

◆ opaque_eligible()

bool welder::rods::opaque_containers::opaque_eligible ( std::meta::info type)
consteval

Is container type eligible for the generator — will every element/key/value type's name exist when it binds (see element_ok)?

The generator opens scalar-element, welded-class/enum-element AND nested-container-element containers (recursively — the whole nesting chain must be eligible); only nested-in-class element types are left by value.

Precondition
type is a reference container.

Definition at line 288 of file document.hpp.

References element_ok(), and value_arg_count().

Referenced by collect_into(), and element_ok().

◆ opaque_name()

template<class Style, std::meta::info Enclosing, std::meta::info Container, std::meta::info Member>
std::string welder::rods::opaque_containers::opaque_name ( )
consteval

The opaque-wrapper name for container Container found on member/site Member within Enclosing — the customization point behind the generator's naming.

By default this is the collision-free derive_name of the container type. A name style Style may override it by providing an (optional) hook

static consteval std::string transform_opaque_container(
std::meta::info enclosing, // the enclosing class (namespace for a free fn)
std::meta::info container, // the container type being made opaque
std::meta::info member); // the data member / callable it was found on

— a style with no such hook (every stock welder::naming style) falls straight through to derive_name. The result is run through sanitize_ident either way, so a hook can never yield a non-identifier. Because opaque wrappers are deduped per container type** (module-wide), the hook is honoured at the container's first Style-aware use site; Enclosing / Member are that site's context.

Definition at line 224 of file document.hpp.

References derive_name(), has_opaque_hook(), and sanitize_ident().

Referenced by welder::rods::opaque_containers::document::add_one().

◆ qualified_ident()

std::string welder::rods::opaque_containers::qualified_ident ( std::meta::info entity)
consteval

The collision-free qualified identifier of entity: its own identifier (or, for an unnameable entity, its display_string_of) prefixed by every enclosing named namespace and enclosing class, each PascalCased and concatenated — so a type is named uniquely across namespaces (geometry::PointGeometryPoint, physics::PointPhysicsPoint, never a colliding bare Point).

The global namespace, an anonymous namespace, the std namespace, and an implementation-reserved (__-prefixed, e.g. std::__cxx11) inline namespace each contribute nothing — so a std:: container/element still reads clean (std::vectorVector, std::string folds to String before this is reached). This is what makes two same-named types in different namespaces derive distinct opaque-wrapper names without a weld_as (the render-time #error in document::render remains only as a last-resort backstop). Reuses welder::naming::restyle.

Definition at line 87 of file document.hpp.

References welder::naming::pascal, and welder::naming::restyle().

Referenced by derive_name().

◆ sanitize_ident()

std::string welder::rods::opaque_containers::sanitize_ident ( std::string s)
consteval

Reduce s to a valid C++ identifier: keep [A-Za-z0-9_], collapse every other run to a single _ (dropping leading/trailing ones), and prefix _ if it would start with a digit.

The generator's last-resort guarantee that no input — however exotic its display_string_of — can produce an uncompilable alias name.

Definition at line 51 of file document.hpp.

Referenced by opaque_name().

◆ scalar_leaf()

bool welder::rods::opaque_containers::scalar_leaf ( std::meta::info t)
consteval

Is t a scalar leaf — a fundamental type or a std::basic_string — i.e.

one that needs no class registration of its own?

Definition at line 247 of file document.hpp.

Referenced by element_ok().

◆ value_arg_count()

std::size_t welder::rods::opaque_containers::value_arg_count ( std::meta::info type)
consteval

How many leading (value) template arguments of type name its element/key/value types — a sequence exposes 1, a map 2.

Precondition
type is a reference container.

Definition at line 43 of file document.hpp.

References welder::map.

Referenced by collect_into(), container_depth(), derive_name(), and opaque_eligible().