3#include "di/container/interface/access.h"
4#include "di/container/string/string.h"
5#include "di/container/string/string_view.h"
6#include "di/container/vector/vector.h"
7#include "di/util/initializer_list.h"
18 constexpr auto value() const -> u32 {
23 constexpr auto has_value() const ->
bool {
return m_value != 0; }
25 constexpr auto value_or(u32 fallback)
const -> u32 {
45 constexpr auto get(usize index = 0, u32 fallback = 0) const -> u32 {
46 return m_subparams.at(index).value_or(
Param(fallback)).value_or(fallback);
49 constexpr auto empty()
const {
return m_subparams.empty(); }
50 constexpr auto size()
const {
return m_subparams.size(); }
54 auto operator==(
Subparams const& other) const ->
bool = default;
59 constexpr explicit
Subparams(di::Span<
Param const> subparams) : m_subparams(subparams) {}
61 di::Span<Param const> m_subparams;
73 constexpr Params(std::initializer_list<std::initializer_list<Param>>
params) {
81 constexpr auto get(usize index = 0, u32 fallback = 0) const -> u32 {
82 return m_parameters.at(index).and_then(di::at(0)).value_or(
Param(fallback)).value_or(fallback);
84 constexpr auto get_subparam(usize index = 0, usize subindex = 1, u32 fallback = 0) const -> u32 {
85 return m_parameters.at(index).and_then(di::at(subindex)).value_or(
Param(fallback)).value_or(fallback);
88 constexpr auto empty()
const {
return m_parameters.empty(); }
89 constexpr auto size()
const {
return m_parameters.size(); }
92 auto span = m_parameters.at(index)
96 .value_or(di::Span<Param const> {});
101 constexpr void add_param(u32 value) { m_parameters.push_back({ value }); }
107 m_parameters.back().value().push_back(value);
114 m_parameters.back().value().emplace_back();
120 auto operator==(
Params const& other) const ->
bool = default;
125 di::Vector<di::Vector<Param>> m_parameters;
constexpr Param(u32 value)
Definition params.h:16
constexpr auto has_value() const -> bool
Definition params.h:23
constexpr auto value_or(u32 fallback) const -> u32
Definition params.h:25
constexpr auto value() const -> u32
Definition params.h:18
auto operator==(Param const &) const -> bool=default
constexpr auto get(usize index=0, u32 fallback=0) const -> u32
Definition params.h:81
constexpr Params(std::initializer_list< std::initializer_list< Param > > params)
Definition params.h:73
constexpr void add_param(u32 value)
Definition params.h:101
auto to_string() const -> di::String
Definition params.cpp:33
constexpr auto empty() const
Definition params.h:88
constexpr void add_empty_subparam()
Definition params.h:110
constexpr auto clone() const -> Params
Definition params.h:79
constexpr void add_empty_param()
Definition params.h:100
constexpr void add_subparams(di::Vector< Param > subparams)
Definition params.h:116
constexpr auto subparams(usize index=0) const -> Subparams
Definition params.h:91
constexpr auto get_subparam(usize index=0, usize subindex=1, u32 fallback=0) const -> u32
Definition params.h:84
static auto from_string(di::StringView view) -> Params
Definition params.cpp:8
constexpr void add_subparam(u32 value)
Definition params.h:103
constexpr auto size() const
Definition params.h:89
constexpr auto size() const
Definition params.h:50
friend class Params
Definition params.h:57
constexpr auto get(usize index=0, u32 fallback=0) const -> u32
Definition params.h:45
auto to_string() const -> di::String
Definition params.cpp:23
constexpr auto empty() const
Definition params.h:49
Definition test_params.cpp:4
Definition cursor_style.h:5