commandline_options.hpp

Go to the documentation of this file.
00001 /* $Id: commandline_options.hpp 52910 2012-02-04 12:02:41Z gabba $ */
00002 /*
00003    Copyright (C) 2011 - 2012 by Lukasz Dobrogowski <lukasz.dobrogowski@gmail.com>
00004    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY.
00012 
00013    See the COPYING file for more details.
00014 */
00015 
00016 #ifndef COMMANDLINE_OPTIONS_HPP_INCLUDED
00017 #define COMMANDLINE_OPTIONS_HPP_INCLUDED
00018 
00019 #include <boost/optional.hpp>
00020 #include <boost/program_options.hpp>
00021 #include <boost/tuple/tuple.hpp>
00022 
00023 #include <string>
00024 #include <vector>
00025 
00026 class commandline_options
00027 {
00028 /// To be used for printing help to the commandline.
00029 friend std::ostream& operator<<(std::ostream &os, const commandline_options& cmdline_opts);
00030 
00031 public:
00032     commandline_options(int argc, char **argv);
00033 
00034     /// BitsPerPixel specified by --bpp option.
00035     boost::optional<int> bpp;
00036     /// Non-empty if --campaign was given on the command line. ID of the campaign we want to start.
00037     boost::optional<std::string> campaign;
00038     /// Non-empty if --campaign-difficulty was given on the command line. Numerical difficulty of the campaign to be played. Dependant on --campaign.
00039     boost::optional<int> campaign_difficulty;
00040     /// Non-empty if --campaign-scenario was given on the command line. Chooses starting scenario in the campaign to be played. Dependant on --campaign.
00041     boost::optional<std::string> campaign_scenario;
00042     /// True if --clock was given on the command line. Enables
00043     bool clock;
00044     /// True if --config-path was given on the command line. Prints path to user config directory and exits.
00045     bool config_path;
00046     /// Non-empty if --config-dir was given on the command line. Sets the config dir to the specified one.
00047     boost::optional<std::string> config_dir;
00048     /// Non-empty if --config-dir was given on the command line. Sets the config dir to the specified one.
00049     boost::optional<std::string> data_dir;
00050     /// True if --debug was given on the command line. Enables debug mode.
00051     bool debug;
00052 #ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
00053     /// Non-empty if --debug-dot-domain was given on the command line.
00054     boost::optional<std::string> debug_dot_domain;
00055     /// Non-empty if --debug-dot-level was given on the command line.
00056     boost::optional<std::string> debug_dot_level;
00057 #endif
00058     /// Non-empty if --editor was given on the command line. Goes directly into editor. If string is longer than 0, it contains path to the file to edit.
00059     boost::optional<std::string> editor;
00060     /// True if --fps was given on the command line. Shows number of fps.
00061     bool fps;
00062     /// True if --fullscreen was given on the command line. Starts Wesnoth in fullscreen mode.
00063     bool fullscreen;
00064     /// Non-empty if --gunzip was given on the command line. Uncompresses a .gz file and exits.
00065     boost::optional<std::string> gunzip;
00066     /// Non-empty if --gzip was given on the command line. Compresses a file to .gz and exits.
00067     boost::optional<std::string> gzip;
00068     /// True if --help was given on the command line. Prints help and exits.
00069     bool help;
00070     /// Non-empty if --language was given on the command line. Sets the language for this session.
00071     boost::optional<std::string> language;
00072     /// Contains parsed arguments of --log-* (e.g. --log-debug).
00073     /// Vector of pairs (severity, log domain).
00074     boost::optional<std::vector<boost::tuple<int, std::string> > > log;
00075     /// Non-empty if --load was given on the command line. Savegame specified to load after start.
00076     boost::optional<std::string> load;
00077     /// Non-empty if --logdomains was given on the command line. Prints possible logdomains filtered by given string and exits.
00078     boost::optional<std::string> logdomains;
00079     /// True if --multiplayer was given on the command line. Goes directly into multiplayer mode.
00080     bool multiplayer;
00081     /// Non-empty if --ai-config was given on the command line. Vector of pairs (side number, value). Dependant on --multiplayer.
00082     boost::optional<std::vector<boost::tuple<unsigned int, std::string> > > multiplayer_ai_config;
00083     /// Non-empty if --algorithm was given on the command line. Vector of pairs (side number, value). Dependant on --multiplayer.
00084     boost::optional<std::vector<boost::tuple<unsigned int, std::string> > > multiplayer_algorithm;
00085     /// Non-empty if --controller was given on the command line. Vector of pairs (side number, controller). Dependant on --multiplayer.
00086     boost::optional<std::vector<boost::tuple<unsigned int, std::string> > > multiplayer_controller;
00087     /// Non-empty if --era was given on the command line. Dependant on --multiplayer.
00088     boost::optional<std::string> multiplayer_era;
00089     /// True if --exit-at-and was given on the command line. Dependant on --multiplayer.
00090     bool multiplayer_exit_at_end;
00091     /// Non-empty if --label was given on the command line. Dependant on --multiplayer.
00092     boost::optional<std::string> multiplayer_label;
00093     /// Non-empty if --parm was given on the command line. Vector of pairs (side number, parm name, parm value). Dependant on --multiplayer.
00094     boost::optional<std::vector<boost::tuple<unsigned int, std::string, std::string> > > multiplayer_parm;
00095     /// Non-empty if --scenario was given on the command line. Dependant on --multiplayer.
00096     boost::optional<std::string> multiplayer_scenario;
00097     /// Non-empty if --side was given on the command line. Vector of pairs (side number, faction id). Dependant on --multiplayer.
00098     boost::optional<std::vector<boost::tuple<unsigned int, std::string> > > multiplayer_side;
00099     /// Non-empty if --turns was given on the command line. Dependant on --multiplayer.
00100     boost::optional<std::string> multiplayer_turns;
00101     /// Max FPS specified by --max-fps option.
00102     boost::optional<int> max_fps;
00103     /// True if --nocache was given on the command line. Disables cache usage.
00104     bool nocache;
00105     /// True if --nodelay was given on the command line.
00106     bool nodelay;
00107     /// True if --nogui was given on the command line. Disables GUI.
00108     bool nogui;
00109     /// True if --nomusic was given on the command line. Disables music.
00110     bool nomusic;
00111     /// True if --nosound was given on the command line. Disables sound.
00112     bool nosound;
00113     /// True if --new-storyscreens was given on the command line. Hidden option to help testing the work-in-progress new storyscreen code.
00114     bool new_storyscreens;
00115     /// True if --new-syntax was given on the command line. Does magic.
00116     bool new_syntax;
00117     /// True if --new-widgets was given on the command line. Hidden option to enable the new widget toolkit.
00118     bool new_widgets;
00119     /// True if --path was given on the command line. Prints the path to data directory and exits.
00120     bool path;
00121     /// True if --preprocess was given on the command line. Starts Wesnoth in preprocessor-only mode.
00122     bool preprocess;
00123     /// Defines that were given to the --preprocess option.
00124     boost::optional<std::vector<std::string> > preprocess_defines;
00125     /// Non-empty if --preprocess-input-macros was given on the command line. Specifies a file that contains [preproc_define]s to be included before preprocessing. Dependant on --preprocess.
00126     boost::optional<std::string> preprocess_input_macros;
00127     /// Non-empty if --preprocess-output-macros was given on the command line. Outputs all preprocessed macros to the specified file. Dependant on --preprocess.
00128     boost::optional<std::string> preprocess_output_macros;
00129     /// Path to parse that was given to the --preprocess option.
00130     boost::optional<std::string> preprocess_path;
00131     /// Target (output) path that was given to the --preprocess option.
00132     boost::optional<std::string> preprocess_target;
00133     /// True if --proxy was given on the command line. Enables proxy mode.
00134     bool proxy;
00135     /// Non-empty if --proxy-address was given on the command line.
00136     boost::optional<std::string> proxy_address;
00137     /// Non-empty if --proxy-password was given on the command line.
00138     boost::optional<std::string> proxy_password;
00139     /// Non-empty if --proxy-port was given on the command line.
00140     boost::optional<std::string> proxy_port;
00141     /// Non-empty if --proxy-user was given on the command line.
00142     boost::optional<std::string> proxy_user;
00143     /// Pair of AxB values specified after --resolution. Changes Wesnoth resolution.
00144     boost::optional<boost::tuple<int,int> > resolution;
00145     /// RNG seed specified by --rng-seed option. Initializes RNG with given seed.
00146     boost::optional<unsigned int> rng_seed;
00147     /// Non-empty if --server was given on the command line.  Connects Wesnoth to specified server. If no server was specified afterwards, contains an empty string.
00148     boost::optional<std::string> server;
00149     /// Non-empty if --username was given on the command line. Forces Wesnoth to use this network username.
00150     boost::optional<std::string> username;
00151     /// Non-empty if --password was given on the command line. Forces Wesnoth to use this network password.
00152     boost::optional<std::string> password;
00153     /// True if --screenshot was given on the command line. Starts Wesnoth in screenshot mode.
00154     bool screenshot;
00155     /// Map file to make a screenshot of. First parameter given after --screenshot.
00156     boost::optional<std::string> screenshot_map_file;
00157     /// Output file to put screenshot in. Second parameter given after --screenshot.
00158     boost::optional<std::string> screenshot_output_file;
00159     /// True if --smallgui was given on the command line. Makes Wesnoth use small gui layout.
00160     bool smallgui;
00161     /// True if --strict-validation was given on the command line. Makes Wesnoth trust validation errors as fatal WML errors and create WML exception, if so.
00162     bool strict_validation;
00163     /// Non-empty if --test was given on the command line. Goes directly into test mode, into a scenario, if specified.
00164     boost::optional<std::string> test;
00165     /// True if --validcache was given on the command line. Makes Wesnoth assume the cache is valid.
00166     bool validcache;
00167     /// True if --version was given on the command line. Prints version and exits.
00168     bool version;
00169     /// True if --windowed was given on the command line. Starts Wesnoth in windowed mode.
00170     bool windowed;
00171     /// True if --with-replay was given on the command line. Shows replay of the loaded file.
00172     bool with_replay;
00173 private:
00174     void parse_log_domains_(const std::string &domains_string, const int severity);
00175     void parse_resolution_ (const std::string &resolution_string);
00176     /// A helper function splitting vector of strings of format unsigned int:string to vector of tuples (unsigned int,string)
00177     std::vector<boost::tuple<unsigned int,std::string> > parse_to_uint_string_tuples_(const std::vector<std::string> &strings, char separator = ':');
00178     /// A helper function splitting vector of strings of format unsigned int:string:string to vector of tuples (unsigned int,string,string)
00179     std::vector<boost::tuple<unsigned int,std::string,std::string> > parse_to_uint_string_string_tuples_(const std::vector<std::string> &strings, char separator = ':');
00180     int argc_;
00181     char **argv_;
00182     boost::program_options::options_description all_;
00183     boost::program_options::options_description visible_;
00184     boost::program_options::options_description hidden_;
00185 };
00186 
00187 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Thu May 24 2012 01:02:32 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs