|
Porytiles
|
One named bit-field within a metatile attribute layout. More...
#include <metatile_attribute_schema.hpp>
Public Member Functions | |
| Field (std::string name, std::uint32_t mask, std::uint32_t default_value=0, std::optional< ProviderDefinition > provider=std::nullopt, std::optional< FieldRole > role=std::nullopt) | |
| Constructs a field from a name, mask, and optional default value, provider definition, and role. | |
| const std::string & | name () const |
| std::uint32_t | mask () const |
| std::uint32_t | default_value () const |
| std::uint32_t | offset () const |
| Returns the bit offset of the field's least-significant bit. | |
| std::uint32_t | width () const |
| Returns the number of bits the field occupies. | |
| std::uint32_t | max_value () const |
| Returns the largest value the field can hold. | |
| bool | has_provider () const |
| const std::optional< FieldRole > & | role () const |
| bool | packs_layer_type () const |
| Reports whether this field carries the layer_type role. | |
| const ProviderDefinition & | provider_definition () const |
| Returns the field's provider definition. | |
One named bit-field within a metatile attribute layout.
A field pairs a name with the mask of bits it occupies inside the packed attribute word. The mask is the single source of truth for the field's position and size: the offset, width, and maximum storable value are all derived from it. A field may also carry a provider definition describing how its values are named in a base-game header, and an optional role marking it as a field whose values Porytiles manages (see FieldRole).
A Field is a passive carrier and does not validate itself. Layout rules (contiguous non-zero mask, in-range, non-overlapping, default fits) are enforced when a Field is placed into a Schema via Schema::create. Deriving offset() or max_value() from a zero mask is meaningless, so those accessors document a non-zero-mask precondition that Schema::create guarantees for every field it accepts.
Definition at line 216 of file metatile_attribute_schema.hpp.
|
inline |
Constructs a field from a name, mask, and optional default value, provider definition, and role.
| name | The field name |
| mask | The bits this field occupies within the packed attribute word |
| default_value | The value used when the field is absent from a metatile's attribute |
| provider | An optional description of how this field's named values are declared |
| role | An optional semantic role marking a field whose values Porytiles manages |
Definition at line 225 of file metatile_attribute_schema.hpp.
|
inline |
Definition at line 246 of file metatile_attribute_schema.hpp.
|
inline |
Definition at line 281 of file metatile_attribute_schema.hpp.
|
inline |
Definition at line 241 of file metatile_attribute_schema.hpp.
|
inline |
Returns the largest value the field can hold.
This is the mask shifted down to bit zero, which is the single source of truth for the range checks that Schema::create and the provider-backed enum loading apply.
Definition at line 276 of file metatile_attribute_schema.hpp.
|
inline |
Definition at line 236 of file metatile_attribute_schema.hpp.
|
inline |
Returns the bit offset of the field's least-significant bit.
Definition at line 255 of file metatile_attribute_schema.hpp.
|
inline |
Reports whether this field carries the layer_type role.
The layer_type-role field receives each metatile's layer type when attributes are packed. Its per-metatile value comes from MetatileAttribute::layer_type() (inferred at compile time or pinned through the CSV's trailing "pin::layer_type" column), never from a normal CSV value column.
Definition at line 299 of file metatile_attribute_schema.hpp.
|
inline |
Returns the field's provider definition.
Definition at line 308 of file metatile_attribute_schema.hpp.
|
inline |
Definition at line 286 of file metatile_attribute_schema.hpp.
|
inline |
Returns the number of bits the field occupies.
Definition at line 263 of file metatile_attribute_schema.hpp.