24#include <fmt/format.h>
33 : data_(
std::move(data)) {}
38 return data_.count(param_name) == 1;
43 const auto iter = data_.find(param_name);
44 if (iter == data_.end()) {
46 fmt::format(
"Parameter {} not found.", param_name));
48 return iter->second.to_double();
53 const auto iter = data_.find(param_name);
54 if (iter == data_.end()) {
56 fmt::format(
"Parameter {} not found.", param_name));
58 return iter->second.to_variant();
62 -> fmt::format_context::iterator {
64 for (
const auto& [key, value] : data_) {
73 out = fmt::format_to(out,
"{}={}", key, value.to_string());
80 ->
std::unordered_map<
util::Utf8String,
util::Utf8String> {
81 std::unordered_map<util::Utf8String, util::Utf8String> data;
82 data.reserve(data_.size());
83 for (
const auto& pair : data_) {
84 data.try_emplace(pair.first.str(), pair.second.to_string());
91 if (!
has(param_name)) {
93 fmt::format(
"Parameter {} not found.", param_name));
97 for (
const auto& pair : data_) {
98 if (pair.first != param_name) {
106 std::size_t hash = 0;
107 std::hash<ParameterName> name_hash{};
108 for (
const auto& pair : data_) {
109 hash ^= name_hash(pair.first);
110 hash ^= pair.second.calculate_hash();
116 return data_ == rhs.data_;
120 return !(*
this == rhs);
128auto formatter<stat_bench::param::ParameterDict>::format(
130 ->
typename format_context::iterator {
131 return val.format_to(context.out());
Class of exceptions in this library.
Class of dictionaries of parameters.
auto format_to(fmt::format_context::iterator out) const -> fmt::format_context::iterator
Format to string.
auto get_as_double(const ParameterName ¶m_name) const -> double
Get a parameter value as double.
auto has(const ParameterName ¶m_name) const -> bool
Check whether this has a parameter with a name.
auto get_as_variant(const ParameterName ¶m_name) const -> ParameterValueVariant
Get a parameter value as a variant object.
auto empty() const noexcept -> bool
Check whether this is empty.
auto clone_without(const ParameterName ¶m_name) const -> ParameterDict
Create a new dictionary without a parameter.
auto operator!=(const ParameterDict &rhs) const -> bool
Check whether this is not equal to another dictionary.
auto as_string_dict() const -> std::unordered_map< util::Utf8String, util::Utf8String >
Get as a dictionary of string values.
ParameterDict(util::OrderedMap< ParameterName, ParameterValue > data)
Constructor.
auto calculate_hash() const -> std::size_t
Calculate hash value.
auto operator==(const ParameterDict &rhs) const -> bool
Check whether this is equal to another dictionary.
Class of names of parameters.
Class of mapping which preserves order of insertion.
auto try_emplace(const Key &key, Args &&... args) -> std::pair< iterator, bool >
Insert a pair if the key does not exist.
void reserve(std::size_t size)
Reserve memory space.
Namespace of fmt library.
Namespace of parameters of benchmarks.
std::variant< bool, std::intmax_t, std::uintmax_t, long double, std::string > ParameterValueVariant
Type of variant of parameter values.
Namespace of utility functions and classes.
Namespace of stat_bench source codes.
Definition of ParameterDict class.
Definition of ParameterName class.