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 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 element_ok (std::meta::info t)
 Can the driver's PHASE 1 (name pre-registration) register t's name before PHASE 2 binds the container that uses it — i.e.
consteval bool opaque_eligible (std::meta::info type)
 Is container type eligible for the generator — will PHASE 1 register every element/key/value type's name before PHASE 2 binds it (see element_ok)?
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).
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).

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

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

Definition at line 273 of file document.hpp.

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

Referenced by containers_in().

◆ 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 36 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 282 of file document.hpp.

References collect_into().

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

◆ 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 container element that is itself a class-template specialization (e.g. WMOGroup<ClientVersion{3,3,5,12340}>) 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 134 of file document.hpp.

References 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 the driver's PHASE 1 (name pre-registration) register t's name before PHASE 2 binds the container that uses it — i.e.

is t either a scalar leaf, or a top-level** welded class/enum (a weld_namespace sweep predeclares those names first)?

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. A nested container (vector<vector<int>>) is likewise unsafe (the inner container is a PHASE-2 binding, not a predeclared name). Both are excluded; hand-write their alias.

Definition at line 241 of file document.hpp.

References welder::is_reference_container(), 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 170 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 210 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 PHASE 1 register every element/key/value type's name before PHASE 2 binds it (see element_ok)?

The generator opens scalar-element AND welded-class/enum-element containers (the common std::vector<Entity> case); only nested-in-class element types and nested containers are left by value.

Precondition
type is a reference container.

Definition at line 260 of file document.hpp.

References element_ok(), and value_arg_count().

Referenced by collect_into().

◆ 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 200 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 86 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 50 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 223 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 42 of file document.hpp.

References welder::map.

Referenced by derive_name(), and opaque_eligible().