[util] Simplify output_options_t
This commit is contained in:
parent
e109f9a6f9
commit
09e4d7dd30
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
struct shape_closure_consumer_t : option_group_t
|
struct shape_closure_consumer_t : option_group_t
|
||||||
{
|
{
|
||||||
void add_options (struct option_parser_t *parser) override
|
void add_options (struct option_parser_t *parser)
|
||||||
{
|
{
|
||||||
shaper.add_options (parser);
|
shaper.add_options (parser);
|
||||||
|
|
||||||
|
|
|
@ -30,13 +30,9 @@
|
||||||
|
|
||||||
struct output_buffer_t
|
struct output_buffer_t
|
||||||
{
|
{
|
||||||
output_buffer_t ()
|
|
||||||
: options (hb_buffer_serialize_list_formats ())
|
|
||||||
{}
|
|
||||||
|
|
||||||
void add_options (option_parser_t *parser)
|
void add_options (option_parser_t *parser)
|
||||||
{
|
{
|
||||||
options.add_options (parser);
|
options.add_options (parser, hb_buffer_serialize_list_formats ());
|
||||||
format.add_options (parser);
|
format.add_options (parser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +55,7 @@ struct output_buffer_t
|
||||||
if (options.explicit_output_format)
|
if (options.explicit_output_format)
|
||||||
fail (false, "Unknown output format `%s'; supported formats are: %s",
|
fail (false, "Unknown output format `%s'; supported formats are: %s",
|
||||||
options.output_format,
|
options.output_format,
|
||||||
g_strjoinv ("/", const_cast<char**> (options.supported_formats)));
|
g_strjoinv ("/", const_cast<char**> (hb_buffer_serialize_list_formats ())));
|
||||||
else
|
else
|
||||||
/* Just default to TEXT if not explicitly requested and the
|
/* Just default to TEXT if not explicitly requested and the
|
||||||
* file extension is not recognized. */
|
* file extension is not recognized. */
|
||||||
|
@ -145,6 +141,7 @@ struct output_buffer_t
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
output_options_t options;
|
output_options_t options;
|
||||||
format_options_t format;
|
format_options_t format;
|
||||||
|
|
||||||
|
|
|
@ -653,7 +653,8 @@ text_options_t::add_options (option_parser_t *parser)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
output_options_t::add_options (option_parser_t *parser)
|
output_options_t::add_options (option_parser_t *parser,
|
||||||
|
const char **supported_formats)
|
||||||
{
|
{
|
||||||
const char *text;
|
const char *text;
|
||||||
|
|
||||||
|
|
|
@ -57,8 +57,6 @@ struct option_group_t
|
||||||
{
|
{
|
||||||
virtual ~option_group_t () {}
|
virtual ~option_group_t () {}
|
||||||
|
|
||||||
virtual void add_options (struct option_parser_t *parser) = 0;
|
|
||||||
|
|
||||||
virtual void pre_parse (GError **error G_GNUC_UNUSED) {}
|
virtual void pre_parse (GError **error G_GNUC_UNUSED) {}
|
||||||
virtual void post_parse (GError **error G_GNUC_UNUSED) {}
|
virtual void post_parse (GError **error G_GNUC_UNUSED) {}
|
||||||
};
|
};
|
||||||
|
@ -123,7 +121,7 @@ struct view_options_t : option_group_t
|
||||||
g_free (back);
|
g_free (back);
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_options (option_parser_t *parser) override;
|
void add_options (option_parser_t *parser);
|
||||||
|
|
||||||
hb_bool_t annotate = false;
|
hb_bool_t annotate = false;
|
||||||
char *fore = nullptr;
|
char *fore = nullptr;
|
||||||
|
@ -150,7 +148,7 @@ struct shape_options_t : option_group_t
|
||||||
g_strfreev (shapers);
|
g_strfreev (shapers);
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_options (option_parser_t *parser) override;
|
void add_options (option_parser_t *parser);
|
||||||
|
|
||||||
void setup_buffer (hb_buffer_t *buffer)
|
void setup_buffer (hb_buffer_t *buffer)
|
||||||
{
|
{
|
||||||
|
@ -440,7 +438,7 @@ struct font_options_t : option_group_t
|
||||||
hb_font_destroy (font);
|
hb_font_destroy (font);
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_options (option_parser_t *parser) override;
|
void add_options (option_parser_t *parser);
|
||||||
|
|
||||||
hb_font_t *get_font () const;
|
hb_font_t *get_font () const;
|
||||||
|
|
||||||
|
@ -493,7 +491,7 @@ struct text_options_t : option_group_t
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_options (option_parser_t *parser) override;
|
void add_options (option_parser_t *parser);
|
||||||
|
|
||||||
void post_parse (GError **error G_GNUC_UNUSED) override {
|
void post_parse (GError **error G_GNUC_UNUSED) override {
|
||||||
if (text && text_file)
|
if (text && text_file)
|
||||||
|
@ -520,9 +518,6 @@ struct text_options_t : option_group_t
|
||||||
|
|
||||||
struct output_options_t : option_group_t
|
struct output_options_t : option_group_t
|
||||||
{
|
{
|
||||||
output_options_t (const char **supported_formats_ = nullptr)
|
|
||||||
: supported_formats (supported_formats_)
|
|
||||||
{}
|
|
||||||
~output_options_t () override
|
~output_options_t () override
|
||||||
{
|
{
|
||||||
g_free (output_file);
|
g_free (output_file);
|
||||||
|
@ -531,7 +526,8 @@ struct output_options_t : option_group_t
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_options (option_parser_t *parser) override;
|
void add_options (option_parser_t *parser,
|
||||||
|
const char **supported_formats = nullptr);
|
||||||
|
|
||||||
void post_parse (GError **error G_GNUC_UNUSED) override
|
void post_parse (GError **error G_GNUC_UNUSED) override
|
||||||
{
|
{
|
||||||
|
@ -555,7 +551,6 @@ struct output_options_t : option_group_t
|
||||||
|
|
||||||
char *output_file = nullptr;
|
char *output_file = nullptr;
|
||||||
char *output_format = nullptr;
|
char *output_format = nullptr;
|
||||||
const char **supported_formats = nullptr;
|
|
||||||
bool explicit_output_format = false;
|
bool explicit_output_format = false;
|
||||||
|
|
||||||
mutable FILE *fp = nullptr;
|
mutable FILE *fp = nullptr;
|
||||||
|
@ -563,7 +558,7 @@ struct output_options_t : option_group_t
|
||||||
|
|
||||||
struct format_options_t : option_group_t
|
struct format_options_t : option_group_t
|
||||||
{
|
{
|
||||||
void add_options (option_parser_t *parser) override;
|
void add_options (option_parser_t *parser);
|
||||||
|
|
||||||
void serialize (hb_buffer_t *buffer,
|
void serialize (hb_buffer_t *buffer,
|
||||||
hb_font_t *font,
|
hb_font_t *font,
|
||||||
|
@ -614,7 +609,7 @@ struct subset_options_t : option_group_t
|
||||||
hb_subset_input_destroy (input);
|
hb_subset_input_destroy (input);
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_options (option_parser_t *parser) override;
|
void add_options (option_parser_t *parser);
|
||||||
|
|
||||||
hb_bool_t* bool_for(hb_subset_flags_t flag)
|
hb_bool_t* bool_for(hb_subset_flags_t flag)
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,9 +34,6 @@
|
||||||
|
|
||||||
struct view_cairo_t
|
struct view_cairo_t
|
||||||
{
|
{
|
||||||
view_cairo_t ()
|
|
||||||
: output_options (helper_cairo_supported_formats)
|
|
||||||
{}
|
|
||||||
~view_cairo_t ()
|
~view_cairo_t ()
|
||||||
{
|
{
|
||||||
cairo_debug_reset_static_data ();
|
cairo_debug_reset_static_data ();
|
||||||
|
@ -44,7 +41,7 @@ struct view_cairo_t
|
||||||
|
|
||||||
void add_options (option_parser_t *parser)
|
void add_options (option_parser_t *parser)
|
||||||
{
|
{
|
||||||
output_options.add_options (parser);
|
output_options.add_options (parser, helper_cairo_supported_formats);
|
||||||
view_options.add_options (parser);
|
view_options.add_options (parser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue