Aria 2.0.0
C++23 MVVM framework (C++20 minimum) — reactive, coroutine-first, ABI-layered
Loading...
Searching...
No Matches
aria::binding::Converter< T, U > Struct Template Reference

Bidirectional converter between Model type T and View type U. More...

#include <converter.hpp>

Public Attributes

std::function< U(const T &)> to_view
std::function< T(const U &)> to_model
std::function< std::optional< T >(const U &)> try_to_model

Detailed Description

template<typename T, typename U>
struct aria::binding::Converter< T, U >

Bidirectional converter between Model type T and View type U.

Two parsing channels are supported on the View → Model direction:

  • try_to_model(view_value) — returns std::nullopt on failure. Preferred: lets the binding engine drop the update silently without touching the Model. Built-in converters always populate this field.
  • to_model(view_value) — historical channel. Built-in converters also populate it, but they now throw ConversionError on unparseable input instead of silently returning 0 / 0.0. Binding engines that fall back to this field route the exception through aria::report_callback_failure("binding.converter", …) and skip the Model write, so legacy callers gain the same safety as the new channel without any source change.

User-defined converters MAY leave try_to_model empty; the engine then uses to_model only.

Member Data Documentation

◆ to_view

template<typename T, typename U>
std::function<U(const T&)> aria::binding::Converter< T, U >::to_view

◆ to_model

template<typename T, typename U>
std::function<T(const U&)> aria::binding::Converter< T, U >::to_model

◆ try_to_model

template<typename T, typename U>
std::function<std::optional<T>(const U&)> aria::binding::Converter< T, U >::try_to_model

The documentation for this struct was generated from the following file: