| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | //====================================================================================================================== | ||
| 2 | /* | ||
| 3 | RABERU - Fancy Parameters Library | ||
| 4 | Copyright : RABERU Project Contributors | ||
| 5 | SPDX-License-Identifier: BSL-1.0 | ||
| 6 | */ | ||
| 7 | //====================================================================================================================== | ||
| 8 | #pragma once | ||
| 9 | |||
| 10 | namespace rbr | ||
| 11 | { | ||
| 12 | namespace result | ||
| 13 | { | ||
| 14 | template<typename Settings, template<typename...> class List = types> struct keywords; | ||
| 15 | template<typename Settings, template<typename...> class List = types> struct values; | ||
| 16 | |||
| 17 | template<typename... Opts, template<typename...> class List> struct keywords<settings<Opts...>, List> | ||
| 18 | { | ||
| 19 | using type = List<typename Opts::keyword_type...>; | ||
| 20 | }; | ||
| 21 | |||
| 22 | template<typename... Opts, template<typename...> class List> struct values<settings<Opts...>, List> | ||
| 23 | { | ||
| 24 | using type = List<typename Opts::stored_value_type...>; | ||
| 25 | }; | ||
| 26 | |||
| 27 | template<typename Settings, template<typename...> class List = types> | ||
| 28 | using keywords_t = typename keywords<Settings, List>::type; | ||
| 29 | |||
| 30 | template<typename Settings, template<typename...> class List = types> | ||
| 31 | using values_t = typename values<Settings, List>::type; | ||
| 32 | } | ||
| 33 | |||
| 34 | //==================================================================================================================== | ||
| 35 | //! @ingroup stng | ||
| 36 | //! @brief Retrieved the list of all keywords in a settings | ||
| 37 | //! | ||
| 38 | //! @tparam List A n-ary template type to hold the result values | ||
| 39 | //! @param s Settings to inspect | ||
| 40 | //! @return An instance of rbr::type containing all the keyword from a rbr::settings. | ||
| 41 | //! | ||
| 42 | //! ## Helper Types | ||
| 43 | //! @code | ||
| 44 | //! namespace rbr::result | ||
| 45 | //! { | ||
| 46 | //! template<template<typename...> class List, typename Settings> struct keywords; | ||
| 47 | //! | ||
| 48 | //! template<template<typename...> class List, typename Settings> | ||
| 49 | //! using keywords_t = typename keywords<List,Settings>::type; | ||
| 50 | //! } | ||
| 51 | //! @endcode | ||
| 52 | //! | ||
| 53 | //! Return the type of a call to rbr::keywords. | ||
| 54 | //! | ||
| 55 | //! ## Example: | ||
| 56 | //! @include doc/keywords.cpp | ||
| 57 | //==================================================================================================================== | ||
| 58 | template<template<typename...> class List, typename... Opts> | ||
| 59 | 1 | constexpr auto keywords([[maybe_unused]] rbr::settings<Opts...> const& s) | |
| 60 | { | ||
| 61 | 1 | return result::keywords_t<rbr::settings<Opts...>, List>{typename Opts::keyword_type{}...}; | |
| 62 | } | ||
| 63 | |||
| 64 | //==================================================================================================================== | ||
| 65 | //! @ingroup stng | ||
| 66 | //! @brief Retrieved the list of all value stored in a settings | ||
| 67 | //! | ||
| 68 | //! @tparam List A n-ary template type to hold the result | ||
| 69 | //! @param s Settings to inspect | ||
| 70 | //! @return an instance of rbr::type containing all the values from a rbr::settings. | ||
| 71 | //! | ||
| 72 | //! ## Helper Types | ||
| 73 | //! @code | ||
| 74 | //! namespace rbr::result | ||
| 75 | //! { | ||
| 76 | //! template<template<typename...> class List, typename Settings> struct values; | ||
| 77 | //! | ||
| 78 | //! template<template<typename...> class List, typename Settings> | ||
| 79 | //! using values_t = typename values<List,Settings>::type; | ||
| 80 | //! } | ||
| 81 | //! @endcode | ||
| 82 | //! | ||
| 83 | //! Return the type of a call to rbr::values. | ||
| 84 | //! | ||
| 85 | //! ## Example: | ||
| 86 | //! @include doc/values.cpp | ||
| 87 | //==================================================================================================================== | ||
| 88 | 2 | template<template<typename...> class List, typename... Opts> constexpr auto values(rbr::settings<Opts...> const& s) | |
| 89 | { | ||
| 90 | 2 | return result::values_t<rbr::settings<Opts...>, List>{s[typename Opts::keyword_type{}]...}; | |
| 91 | } | ||
| 92 | } | ||
| 93 |