KDBindings API Documentation  1.0.95
Classes | Namespaces | Macros
node_functions.h File Reference
#include <kdbindings/make_node.h>
#include <cmath>

Go to the source code of this file.

Classes

struct  KDBindings::node_abs
 An example struct that is used with a call to KDBINDINGS_DECLARE_FUNCTION to declare all overloads of std::abs as usable in data binding. More...
 

Namespaces

 KDBindings
 The main namespace of the KDBindings library.
 

Macros

#define KDBINDINGS_DECLARE_FUNCTION(NAME, FUNC)
 KDBINDINGS_DECLARE_FUNCTION is a helper macro to declare and define functions for use in data binding. More...
 
#define KDBINDINGS_DECLARE_FUNCTION_OBJECT(NAME, FUNCTION)
 This macro declares a callable struct that wraps a function with all its overloads. More...
 
#define KDBINDINGS_DECLARE_NAMESPACED_FUNCTION(NAMESPACE, NAME)
 This macro allows you to declare any function in a non-nested namespace as available in the context of data binding. More...
 
#define KDBINDINGS_DECLARE_STD_FUNCTION(NAME)    KDBINDINGS_DECLARE_NAMESPACED_FUNCTION(std, NAME)
 This macro is based on KDBINDINGS_DECLARE_NAMESPACED_FUNCTION(NAMESPACE, FUNC) to make it easier to declare any standard library function as available for data binding. More...
 

Macro Definition Documentation

◆ KDBINDINGS_DECLARE_FUNCTION

#define KDBINDINGS_DECLARE_FUNCTION (   NAME,
  FUNC 
)
Value:
template<typename... Ts> \
inline auto NAME(Ts &&...args)->std::enable_if_t<::KDBindings::Private::any_bindables<Ts...>::value, ::KDBindings::Private::Node<::KDBindings::Private::operator_node_result_t<decltype(FUNC), Ts...>>> \
{ \
return ::KDBindings::Private::makeNode(FUNC, std::forward<Ts>(args)...); \
}

KDBINDINGS_DECLARE_FUNCTION is a helper macro to declare and define functions for use in data binding.

This macro can take any callable object or function reference and create a new function that may be used in data binding expressions. The result function that can be called with a Property or the result of a data binding expression to create another data binding expression.

Note that if a function is overloaded, it is impossible to reference all of its overloads at once. Therefore we recommend declaring a struct with a templated operator() to use as the function object. See the KDBindings::node_abs struct for an example of how to do this.

Parameters
NAMEThe name of the function to generate.
FUNCThe function to wrap.

Definition at line 54 of file node_functions.h.

◆ KDBINDINGS_DECLARE_FUNCTION_OBJECT

#define KDBINDINGS_DECLARE_FUNCTION_OBJECT (   NAME,
  FUNCTION 
)
Value:
struct NAME { \
template<typename... Ts> \
auto operator()(Ts &&...x) const \
{ \
return FUNCTION(std::forward<Ts>(x)...); \
} \
};

This macro declares a callable struct that wraps a function with all its overloads.

The declared struct can be used as the FUNCTION argument to KDBINDINGS_DECLARE_FUNCTION(NAME, FUNCTION) to pass a function with all its overloads to the macro.

See the KDBindings::node_abs struct for an example of what this macro would generate.

Parameters
NAMEThe name of the resulting struct.
FUNCTIONThe function to wrap.

Definition at line 100 of file node_functions.h.

◆ KDBINDINGS_DECLARE_NAMESPACED_FUNCTION

#define KDBINDINGS_DECLARE_NAMESPACED_FUNCTION (   NAMESPACE,
  NAME 
)
Value:
KDBINDINGS_DECLARE_FUNCTION_OBJECT(node_##NAMESPACE_##NAME, NAMESPACE::NAME) \
KDBINDINGS_DECLARE_FUNCTION(NAME, node_##NAMESPACE_##NAME{})
#define KDBINDINGS_DECLARE_FUNCTION_OBJECT(NAME, FUNCTION)
This macro declares a callable struct that wraps a function with all its overloads.

This macro allows you to declare any function in a non-nested namespace as available in the context of data binding.

Parameters
NAMESPACEthe name of the namespace the function is in.
NAMEthe name of the function to wrap.

In comparison to KDBINDINGS_DECLARE_FUNCTION(NAME, FUNC), this macro will generate a helper struct using KDBINDINGS_DECLARE_FUNCTION_OBJECT, so all overloads of the function are made available at once.

KDBINDINGS_DECLARE_STD_FUNCTION is basically just a call to this macro with the NAMESPACE parameter set to std.

Definition at line 123 of file node_functions.h.

◆ KDBINDINGS_DECLARE_STD_FUNCTION

#define KDBINDINGS_DECLARE_STD_FUNCTION (   NAME)     KDBINDINGS_DECLARE_NAMESPACED_FUNCTION(std, NAME)

This macro is based on KDBINDINGS_DECLARE_NAMESPACED_FUNCTION(NAMESPACE, FUNC) to make it easier to declare any standard library function as available for data binding.

It uses KDBINDINGS_DECLARE_NAMESPACED_FUNCTION and can therefore make all overloads of the std:: function available at once.

Parameters
NAMEThe name of the function in the std:: namespace.

Definition at line 136 of file node_functions.h.


© Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
KDBindings
Reactive programming & data binding in C++
https://github.com/KDAB/KDBindings/
Generated by doxygen 1.9.1