Blame synfig-core/src/tool/optionsprocessor.h

Diego Barrios Romero ffa0f8
/* === S Y N F I G ========================================================= */
Diego Barrios Romero ffa0f8
/*!	\file tool/optionsprocessor.h
Diego Barrios Romero ffa0f8
**	\brief Synfig Tool Options Processor Class
Diego Barrios Romero ffa0f8
**
Diego Barrios Romero ffa0f8
**	$Id$
Diego Barrios Romero ffa0f8
**
Diego Barrios Romero ffa0f8
**	\legal
Diego Barrios Romero ffa0f8
**	Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
Diego Barrios Romero ffa0f8
**	Copyright (c) 2007, 2008 Chris Moore
Diego Barrios Romero 088628
**	Copyright (c) 2009-2014 Diego Barrios Romero
Diego Barrios Romero ffa0f8
**
Diego Barrios Romero ffa0f8
**	This package is free software; you can redistribute it and/or
Diego Barrios Romero ffa0f8
**	modify it under the terms of the GNU General Public License as
Diego Barrios Romero ffa0f8
**	published by the Free Software Foundation; either version 2 of
Diego Barrios Romero ffa0f8
**	the License, or (at your option) any later version.
Diego Barrios Romero ffa0f8
**
Diego Barrios Romero ffa0f8
**	This package is distributed in the hope that it will be useful,
Diego Barrios Romero ffa0f8
**	but WITHOUT ANY WARRANTY; without even the implied warranty of
Diego Barrios Romero ffa0f8
**	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Diego Barrios Romero ffa0f8
**	General Public License for more details.
Diego Barrios Romero ffa0f8
**	\endlegal
Diego Barrios Romero ffa0f8
*/
Diego Barrios Romero ffa0f8
/* ========================================================================= */
Diego Barrios Romero ffa0f8
Diego Barrios Romero ffa0f8
#ifndef __SYNFIG_OPTIONSPROCESSOR_H
Diego Barrios Romero ffa0f8
#define __SYNFIG_OPTIONSPROCESSOR_H
Diego Barrios Romero ffa0f8
Diego Barrios Romero 0b9c51
#include <string></string>
Diego Barrios Romero 0b9c51
#include <vector></vector>
Diego Barrios Romero 0b9c51
#include <synfig canvas.h=""></synfig>
cc8279
//#include <boost program_options.hpp=""></boost>
Diego Barrios Romero 0b9c51
Diego Barrios Romero 0b9c51
// TODO rename to CommandLineHandler and move the options creation inside.
Diego Barrios Romero be3429
/// Class to process all the command line options
cc8279
/*class OptionsProcessor
Diego Barrios Romero ffa0f8
{
Diego Barrios Romero ffa0f8
public:
Diego Barrios Romero ffa0f8
	OptionsProcessor(boost::program_options::variables_map& vm,
Diego Barrios Romero 0b9c51
					 const boost::program_options::options_description& po_visible);
Diego Barrios Romero ffa0f8
Diego Barrios Romero 06d6b9
#ifdef _DEBUG
[d.j.a.y] Jerome Blanchi 58172d
	void process_debug_options() throw (SynfigToolException&);
Diego Barrios Romero 06d6b9
#endif
Diego Barrios Romero 06d6b9
Diego Barrios Romero be3429
	/// Settings options
Diego Barrios Romero be3429
	/// verbose, quiet, threads, benchmarks
Diego Barrios Romero c5f825
	void process_settings_options();
Diego Barrios Romero ffa0f8
Diego Barrios Romero be3429
	/// Information options
Diego Barrios Romero be3429
	/// Options that will only display information
Diego Barrios Romero 0b9c51
	void process_info_options();
Diego Barrios Romero 71669d
Diego Barrios Romero be3429
	/// Extract the necessary options to create a job
Diego Barrios Romero be3429
	/// After this, it is necessary to overwrite the necessary RendDesc options
Diego Barrios Romero be3429
	/// and set the target parameters, if provided. Then can be processed
Diego Barrios Romero 0b9c51
	Job extract_job();
Diego Barrios Romero c8e79a
Diego Barrios Romero be3429
	/// Overwrite the input RendDesc object with the options given in the command line
Diego Barrios Romero be3429
	synfig::RendDesc extract_renddesc(const synfig::RendDesc& renddesc);
Diego Barrios Romero c8e79a
Diego Barrios Romero be3429
	/// Extract the target parameters from the options given in the command line
Diego Barrios Romero be3429
	/// video-codec, bitrate, sequence-separator
Diego Barrios Romero 0b9c51
	synfig::TargetParam extract_targetparam();
Diego Barrios Romero 0b9c51
Diego Barrios Romero 0b9c51
	void print_target_video_codecs_help() const;
Diego Barrios Romero 0b9c51
Diego Barrios Romero ffa0f8
private:
Diego Barrios Romero be3429
	/// Determine which parameters to show in the canvas info
Diego Barrios Romero be3429
	/// canvas-info
Diego Barrios Romero 71669d
	void extract_canvas_info(Job& job);
Diego Barrios Romero 71669d
Diego Barrios Romero ffa0f8
	boost::program_options::variables_map _vm;
Diego Barrios Romero ffa0f8
	boost::program_options::options_description _po_visible;
Diego Barrios Romero 0b9c51
Diego Barrios Romero 0b9c51
	struct VideoCodec
Diego Barrios Romero 0b9c51
	{
Diego Barrios Romero 0b9c51
		VideoCodec(const std::string& name_, const std::string& description_)
Diego Barrios Romero 0b9c51
			: name(name_), description(description_)
Diego Barrios Romero 0b9c51
		{ }
Diego Barrios Romero 0b9c51
Diego Barrios Romero 0b9c51
		std::string name, description;
Diego Barrios Romero 0b9c51
	};
Diego Barrios Romero 0b9c51
	/*! \warning These codecs are linked to the filename extensions for
Diego Barrios Romero 0b9c51
	 *  mod_ffmpeg. If you change this you must change the others accordingly.
cc8279
	 *//*
Diego Barrios Romero 0b9c51
	std::vector<videocodec> _allowed_video_codecs;</videocodec>
cc8279
};*/
Diego Barrios Romero ffa0f8
891c49
class SynfigCommandLineParser
891c49
{
891c49
public:
891c49
	SynfigCommandLineParser();
891c49
	bool parse(int argc, char* argv[]);
891c49
891c49
	/// Settings options
891c49
	/// verbose, quiet, threads, benchmarks
891c49
	void process_settings_options();
891c49
891c49
	/// Information options
891c49
	/// Options that will only display information
891c49
	void process_info_options();
891c49
891c49
	/// Extract the necessary options to create a job
891c49
	/// After this, it is necessary to overwrite the necessary RendDesc options
891c49
	/// and set the target parameters, if provided. Then can be processed
891c49
	Job extract_job();
891c49
891c49
	/// Overwrite the input RendDesc object with the options given in the command line
891c49
	synfig::RendDesc extract_renddesc(const synfig::RendDesc& renddesc);
891c49
891c49
	/// Extract the target parameters from the options given in the command line
891c49
	/// video-codec, bitrate, sequence-separator
891c49
	synfig::TargetParam extract_targetparam();
891c49
891c49
	/// Determine which parameters to show in the canvas info
891c49
	/// canvas-info
891c49
	void extract_canvas_info(Job& job);
891c49
891c49
	void print_target_video_codecs_help() const;
891c49
30c9aa
#ifdef _DEBUG
30c9aa
	void process_debug_options() throw (SynfigToolException&);
30c9aa
#endif
891c49
891c49
private:
891c49
891c49
	template<typename t=""></typename>
891c49
	void add_option(Glib::OptionGroup& og, const std::string& name, const gchar& short_name, T& entry, const std::string& description,
891c49
		const Glib::ustring& arg_description);
891c49
	// we need explicit method in case of different string/filename encodings
891c49
	void add_option_filename(Glib::OptionGroup& og, const std::string& name, const gchar& short_name, std::string& entry, const std::string& description, const Glib::ustring& arg_description);
891c49
	
891c49
	Glib::OptionContext context;
891c49
	Glib::OptionGroup og_set;
891c49
	Glib::OptionGroup og_switch;
891c49
	Glib::OptionGroup og_misc;
891c49
	Glib::OptionGroup og_ffmpeg;
891c49
	Glib::OptionGroup og_info;
891c49
#ifdef _DEBUG	
891c49
	Glib::OptionGroup og_debug;
891c49
#endif
891c49
891c49
891c49
	// Settings group
891c49
	Glib::ustring	set_target;
891c49
	int				set_width;
891c49
	int				set_height;
891c49
	int				set_span;
891c49
	int				set_antialias;
891c49
	int				set_quality;
891c49
//			(",Q", quality_arg_desc->default_value(DEFAULT_QUALITY), )
891c49
	double			set_gamma;
891c49
	int				set_num_threads;
891c49
	Glib::ustring	set_input_file;
891c49
	Glib::ustring	set_output_file;
891c49
	Glib::ustring	set_sequence_separator;
891c49
	Glib::ustring	set_canvas_id;
891c49
	double			set_fps;
891c49
	Glib::ustring	set_time;
891c49
	Glib::ustring	set_begin_time;
891c49
	Glib::ustring	set_start_time;
891c49
	Glib::ustring	set_end_time;
891c49
	double			set_dpi;
891c49
	double			set_dpi_x;
891c49
	double			set_dpi_y;
891c49
891c49
	// Switch group
891c49
	int				sw_verbosity;
891c49
	bool			sw_quiet;
891c49
	bool			sw_print_benchmarks;
891c49
	bool			sw_extract_alpha;
891c49
891c49
	// Misc group
891c49
	std::string		misc_append_filename;
891c49
	Glib::ustring	misc_canvas_info;
891c49
	bool			misc_canvases;
891c49
891c49
	//FFMPEG group
891c49
	Glib::ustring	video_codec;
891c49
	int				video_bitrate;
891c49
891c49
	// Synfig info group
891c49
	bool			show_help;
891c49
	bool			show_importers;
891c49
	bool			show_build_info;
891c49
	bool			show_layers_list;
891c49
	Glib::ustring	show_layer_info;
891c49
	bool			show_license;
891c49
	bool			show_modules;
891c49
	bool			show_targets;
891c49
	bool			show_codecs;
891c49
	bool			show_value_nodes;
891c49
	bool			show_version;
891c49
891c49
	// Debug group
891c49
#ifdef _DEBUG
891c49
	bool			debug_guid;
891c49
	bool			debug_signal;
891c49
#endif
891c49
	
891c49
	Glib::OptionGroup::vecustrings remaining_options_list;
891c49
891c49
	struct VideoCodec
891c49
	{
891c49
		VideoCodec(const std::string& name_, const std::string& description_)
891c49
			: name(name_), description(description_)
891c49
		{ }
891c49
891c49
		std::string name, description;
891c49
	};
891c49
	/*! \warning These codecs are linked to the filename extensions for
891c49
	 *  mod_ffmpeg. If you change this you must change the others accordingly.
891c49
	 */
891c49
	std::vector<videocodec> _allowed_video_codecs;</videocodec>
891c49
891c49
891c49
};
891c49
891c49
Diego Barrios Romero ffa0f8
#endif // __SYNFIG_OPTIONSPROCESSOR_H