.. index:: pair: struct; EE::UI::UIValueConverter .. _doxid-struct_e_e_1_1_u_i_1_1_u_i_value_converter: template struct EE::UI::UIValueConverter ======================================== .. toctree:: :hidden: Overview ~~~~~~~~ Binding-independent conversion between a typed value and a widget property string. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include template struct UIValueConverter { // typedefs typedef std::function<:ref:`UIValueResult`(const :ref:`CSS::PropertyDefinition`*, const std::string&)> :target:`ToValue`; typedef std::function<:ref:`UIValueResult`(const :ref:`CSS::PropertyDefinition`*, const T&)> :target:`FromValue`; // fields :ref:`ToValue` :target:`toValue`; :ref:`FromValue` :target:`fromValue`; // construction :target:`UIValueConverter`(); :target:`UIValueConverter`(:ref:`ToValue` toValue, :ref:`FromValue` fromValue); // methods static UIValueConverter :target:`converterDefault`(); static UIValueConverter :target:`converterString`(); static UIValueConverter :target:`converterBool`(); }; .. _details-struct_e_e_1_1_u_i_1_1_u_i_value_converter: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Binding-independent conversion between a typed value and a widget property string. :ref:`UIDataBind ` and :ref:`UIValueBinding ` share this policy type, so custom conversions do not depend on either ownership model. The PropertyDefinition describes the widget property being synchronized and can be used for CSS-aware parsing. .. ref-code-block:: cpp auto converter = UIValueConverter( []( const CSS::PropertyDefinition*, const std::string& text ) { MyEnum value; return enumFromString( value, text ) ? UIValueResult::success( value ) : UIValueResult::error( 1 ); }, []( const CSS::PropertyDefinition*, const MyEnum& value ) { return UIValueResult::success( enumToString( value ) ); } );