summaryrefslogtreecommitdiffstats
path: root/options/m_property.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-02-15 16:41:48 +0100
committerwm4 <wm4@nowhere>2014-02-16 03:51:02 +0100
commit309ae76e0b159d4000e24f04aabef8e29f41e86a (patch)
treeb1c6ee2311c0366e7238abe4c7823eeea97ef735 /options/m_property.h
parentccfbe434558075c5d5dd9353a8c9dcc1b9954547 (diff)
downloadmpv-309ae76e0b159d4000e24f04aabef8e29f41e86a.tar.bz2
mpv-309ae76e0b159d4000e24f04aabef8e29f41e86a.tar.xz
m_property: add a sub-property mechanism
This adds a mechanism for easier export of sub-properties. The following commits will make use of it to export fine grained information about certain things. The sub-property mechanism reduces the amount of code needed to export a data value to 1 line.
Diffstat (limited to 'options/m_property.h')
-rw-r--r--options/m_property.h28
1 files changed, 27 insertions, 1 deletions
diff --git a/options/m_property.h b/options/m_property.h
index ae4b7716b6..cb9f8b5a25 100644
--- a/options/m_property.h
+++ b/options/m_property.h
@@ -22,7 +22,8 @@
#include <stdbool.h>
#include <stdint.h>
-struct m_option;
+#include "m_option.h"
+
struct mp_log;
extern const struct m_option_type m_option_type_dummy;
@@ -141,4 +142,29 @@ int m_property_double_ro(const struct m_option* prop, int action, void* arg,
int m_property_strdup_ro(const struct m_option* prop, int action, void* arg,
const char *var);
+struct m_sub_property {
+ // Name of the sub-property - this will be prefixed with the parent
+ // property's name.
+ const char *name;
+ // Type of the data stored in the value member. See m_option.
+ const struct m_option_type *type;
+ // Data returned by the sub-property. m_property_read_sub() will make a
+ // copy of this if needed. It will never write or free the data.
+ union m_option_value value;
+ // This can be set to true if the property should be hidden.
+ bool unavailable;
+};
+
+// Convenience macros which can be used as part of a sub_property entry.
+#define SUB_PROP_INT(i) \
+ .type = CONF_TYPE_INT, .value = {.int_ = (i)}
+#define SUB_PROP_STR(s) \
+ .type = CONF_TYPE_STRING, .value = {.string = (char *)(s)}
+#define SUB_PROP_FLOAT(f) \
+ .type = CONF_TYPE_FLOAT, .value = {.float_ = (f)}
+#define SUB_PROP_FLAG(f) \
+ .type = CONF_TYPE_FLAG, .value = {.flag = (f)}
+
+int m_property_read_sub(const struct m_sub_property *props, int action, void *arg);
+
#endif /* MPLAYER_M_PROPERTY_H */