Various utilities.
More...
|
auto | tolower (std::wstring_view sv) |
|
template<template< typename... > typename TOutContainer = std::vector, typename TInContainer , typename UnaryOp > |
auto | transform (TInContainer const &iterable, UnaryOp &&unary_op) |
| Maps each element in a container via a unary operation on each element.
|
|
template<template< typename... > typename TOutContainer = std::vector, typename TInContainer , typename UnaryOp > |
auto | transform_with_index (TInContainer const &iterable, UnaryOp &&unary_op) |
| Maps each element in a container via a unary operation on each element.
|
|
◆ tolower()
auto cppxaml::utils::tolower |
( |
std::wstring_view |
sv | ) |
|
|
inline |
◆ transform()
template<template< typename... > typename TOutContainer = std::vector, typename TInContainer , typename UnaryOp >
auto cppxaml::utils::transform |
( |
TInContainer const & |
iterable, |
|
|
UnaryOp && |
unary_op |
|
) |
| |
Maps each element in a container via a unary operation on each element.
- Template Parameters
-
TOutContainer | The output container type. Defaults to std::vector. |
TInContainer | The type of the container |
UnaryOp | Lambda type |
- Parameters
-
iterable | The container |
unary_op | The lambda for the unary operation; takes the element type of the input container. |
- Returns
- A container comprised of the mapped elements
Example:
◆ transform_with_index()
template<template< typename... > typename TOutContainer = std::vector, typename TInContainer , typename UnaryOp >
auto cppxaml::utils::transform_with_index |
( |
TInContainer const & |
iterable, |
|
|
UnaryOp && |
unary_op |
|
) |
| |
Maps each element in a container via a unary operation on each element.
- Template Parameters
-
TOutContainer | The output container type. Defaults to std::vector. |
TInContainer | The type of the container |
UnaryOp | Lambda type |
- Parameters
-
iterable | The container |
unary_op | The lambda for the unary operation; takes the element type of the input container, and the index within the container. |
- Returns
- A container comprised of the mapped elements
Example:
Here we can define a Grid with Buttons, each of whose content is sourced from a string vector:
auto strs = std::vector<std::wstring>{ L"first", L"second", L"third", L"fourth" };
return cppxaml::details::UIElementInGrid{
(int)index / 2,
(int)index % 2,
};
})
);
auto transform_with_index(TInContainer const &iterable, UnaryOp &&unary_op)
Maps each element in a container via a unary operation on each element.
Definition: utils.h:100
auto Button(C c)
Creates a Button.
Definition: Controls.h:604
Grid(details::GridRows gr, cppxaml::details::GridColumns gc, TElements &&elems)
Creates a Grid with the specified rows, columns, and children.
Definition: Controls.h:510
Example:
auto strs = std::vector<std::wstring>{ L"first", L"second", L"third", L"fourth" };
.Set(Grid::RowProperty(), (int)index / 2)
.Set(Grid::ColumnProperty(), (int)index % 2);
};
})
);