summaryrefslogtreecommitdiffstats
path: root/options/m_option.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-11-28 16:52:46 +0100
committerwm4 <wm4@nowhere>2019-11-29 12:14:43 +0100
commit63270ff898785814dd40a648362d540be8108464 (patch)
tree59f9689897549bd8370c35faf9f0f859b9536565 /options/m_option.h
parent82735d1287a1ff6d057f42c475d25bc210d75cfe (diff)
downloadmpv-63270ff898785814dd40a648362d540be8108464.tar.bz2
mpv-63270ff898785814dd40a648362d540be8108464.tar.xz
m_option: add option comparison
Looks like this will be needed for fine-grained option change notifications. There are some other parts in the player which implement parts of this.
Diffstat (limited to 'options/m_option.h')
-rw-r--r--options/m_option.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/options/m_option.h b/options/m_option.h
index a5f9618462..c9538cf628 100644
--- a/options/m_option.h
+++ b/options/m_option.h
@@ -338,6 +338,17 @@ struct m_option_type {
int (*get)(const m_option_t *opt, void *ta_parent, struct mpv_node *dst,
void *src);
+ // Return whether the values are the same. (There are no "unordered"
+ // results; for example, two floats with the value NaN compare equal. Other
+ // ambiguous floats, such as +0 and -0 compare equal. Some option types may
+ // incorrectly report unequal for values that are equal, such as sets (if
+ // the element order is different, which incorrectly matters), but values
+ // duplicated with m_option_copy() always return as equal. Empty strings
+ // and NULL strings are equal. Ambiguous unicode representations compare
+ // unequal.)
+ // If not set, values are always considered equal (=> not really optional).
+ bool (*equal)(const m_option_t *opt, void *a, void *b);
+
// Optional: list of suffixes, terminated with a {0} entry. An empty list
// behaves like the list being NULL.
const struct m_option_action *actions;
@@ -543,6 +554,15 @@ static inline int m_option_get_node(const m_option_t *opt, void *ta_parent,
return M_OPT_UNKNOWN;
}
+static inline bool m_option_equal(const m_option_t *opt, void *a, void *b)
+{
+ // Handle trivial equivalence.
+ // If not implemented, assume this type has no actual values => always equal.
+ if (a == b || !opt->type->equal)
+ return true;
+ return opt->type->equal(opt, a, b);
+}
+
int m_option_required_params(const m_option_t *opt);
extern const char m_option_path_separator;