diff options
Diffstat (limited to 'core/m_option.h')
-rw-r--r-- | core/m_option.h | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/core/m_option.h b/core/m_option.h index ef2df4e12c..0026406569 100644 --- a/core/m_option.h +++ b/core/m_option.h @@ -133,25 +133,15 @@ typedef struct { char separator; } m_obj_params_t; -// Parse a set of parameters. -/** Parameters are separated by the given separator and each one - * successively sets a field from the struct. The option priv field - * (\ref m_option::priv) must point to a \ref m_obj_params_t. - */ -extern const m_option_type_t m_option_type_obj_params; - -typedef struct { - int start; - int end; -} m_span_t; -// Ready made settings to parse a \ref m_span_t with a start-end syntax. -extern const m_obj_params_t m_span_params_def; - struct m_opt_choice_alternatives { char *name; int value; }; +// For OPT_STRING_VALIDATE(). Behaves like m_option_type.parse(). +typedef int (*m_opt_string_validate_fn)(const m_option_t *opt, struct bstr name, + struct bstr param); + // m_option.priv points to this if M_OPT_TYPE_USE_SUBSTRUCT is used struct m_sub_options { const struct m_option *opts; @@ -174,12 +164,12 @@ struct m_sub_options { #define CONF_TYPE_IMGFMT (&m_option_type_imgfmt) #define CONF_TYPE_FOURCC (&m_option_type_fourcc) #define CONF_TYPE_AFMT (&m_option_type_afmt) -#define CONF_TYPE_SPAN (&m_option_type_span) #define CONF_TYPE_OBJ_SETTINGS_LIST (&m_option_type_obj_settings_list) #define CONF_TYPE_CUSTOM_URL (&m_option_type_custom_url) #define CONF_TYPE_OBJ_PARAMS (&m_option_type_obj_params) #define CONF_TYPE_TIME (&m_option_type_time) #define CONF_TYPE_CHOICE (&m_option_type_choice) +#define CONF_TYPE_INT_PAIR (&m_option_type_intpair) // Possible option values. Code is allowed to access option data without going // through this union. It serves for self-documentation and to get minimal @@ -198,7 +188,6 @@ union m_option_value { int imgfmt; unsigned int fourcc; int afmt; - m_span_t span; m_obj_settings_t *obj_settings_list; double time; struct m_rel_time rel_time; @@ -475,6 +464,8 @@ static inline void m_option_free(const m_option_t *opt, void *dst) opt->type->free(dst); } +int m_option_required_params(const m_option_t *opt); + // Cause a compilation warning if typeof(expr) != type. // Should be used with pointer types only. #define MP_EXPECT_TYPE(type, expr) (0 ? (type)0 : (expr)) @@ -563,6 +554,9 @@ static inline void m_option_free(const m_option_t *opt, void *dst) #define OPT_FLOAT(...) \ OPT_GENERAL(float, __VA_ARGS__, .type = &m_option_type_float) +#define OPT_DOUBLE(...) \ + OPT_GENERAL(double, __VA_ARGS__, .type = &m_option_type_double) + #define OPT_STRING(...) \ OPT_GENERAL(char*, __VA_ARGS__, .type = &m_option_type_string) @@ -611,6 +605,12 @@ static inline void m_option_free(const m_option_t *opt, void *dst) #define OPT_TRACKCHOICE(name, var) \ OPT_CHOICE_OR_INT(name, var, 0, 0, 8190, ({"no", -2}, {"auto", -1})) +#define OPT_STRING_VALIDATE_(optname, varname, flags, validate_fn, ...) \ + OPT_GENERAL(char*, optname, varname, flags, __VA_ARGS__, \ + .priv = MP_EXPECT_TYPE(m_opt_string_validate_fn, validate_fn)) +#define OPT_STRING_VALIDATE(...) \ + OPT_STRING_VALIDATE_(__VA_ARGS__, .type = &m_option_type_string) + // subconf must have the type struct m_sub_options. // All sub-options are prefixed with "name-" and are added to the current // (containing) option list. |