|
Crunch
A Message Definition Language for Getting Things Right
|
A validated, typed message field. More...
#include <crunch_scalar.hpp>
Public Types | |
| using | ValueType = ScalarType |
Public Member Functions | |
| constexpr | Scalar (ScalarType v) |
| constexpr std::optional< Error > | set (ScalarType v) noexcept |
| constexpr void | set_without_validation (ScalarType v) noexcept |
| constexpr ScalarType | get () const noexcept |
| constexpr void | clear () noexcept |
| constexpr bool | operator== (const Scalar &other) const noexcept |
| Checks if two fields are equal. | |
| constexpr auto | Validate () const noexcept -> std::optional< Error > |
| Validates the current value of the field against all validators. | |
Static Public Member Functions | |
| static constexpr auto | Validate (ScalarType v, FieldId id=0) noexcept -> std::optional< Error > |
| Validates a value against all validators without setting it. | |
A validated, typed message field.
Wraps a primitive, fixed-size type with validation and presence logic.
| ScalarType | The underlying primitive type (e.g., int32_t). Must satisfy std::regular. |
| Validators | One or more validators to enforce value constraints. Each must satisfy Validator<V, ScalarType>. At least one validator is required (use None for no validation). |
|
inlineconstexprnoexcept |
Validates the current value of the field against all validators.
|
inlinestaticconstexprnoexcept |
Validates a value against all validators without setting it.
| v | The value to validate. |
| id | The FieldId for this field within its message. Unused for aggregate fields. |