Author: zaroth
Date: Sun May 29 19:31:07 2011
New Revision: 49701

URL: http://svn.gna.org/viewcvs/wesnoth?rev=49701&view=rev
Log:
Created new command_options object, which will be responsible for
commandline parsing. Introduces Boost.Program_options dependency.

Added:
    trunk/src/commandline_options.cpp
    trunk/src/commandline_options.hpp
Modified:
    trunk/CMakeLists.txt
    trunk/SConstruct
    trunk/src/CMakeLists.txt
    trunk/src/SConscript

Modified: trunk/CMakeLists.txt
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/CMakeLists.txt?rev=49701&r1=49700&r2=49701&view=diff
==============================================================================
--- trunk/CMakeLists.txt (original)
+++ trunk/CMakeLists.txt Sun May 29 19:31:07 2011
@@ -19,7 +19,7 @@
 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
 
 find_package(SDL 1.2.7 REQUIRED)
-find_package(Boost 1.35 REQUIRED COMPONENTS iostreams regex)
+find_package(Boost 1.35 REQUIRED COMPONENTS iostreams program_options regex)
 
 # no, gettext executables are not required when NLS is deactivated
 find_package(Gettext)

Modified: trunk/SConstruct
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/SConstruct?rev=49701&r1=49700&r2=49701&view=diff
==============================================================================
--- trunk/SConstruct (original)
+++ trunk/SConstruct Sun May 29 19:31:07 2011
@@ -304,6 +304,7 @@
     have_client_prereqs = have_server_prereqs and \
         conf.CheckPango("cairo") and \
         conf.CheckPKG("fontconfig") and \
+        conf.CheckBoost("program_options", require_version="1.35.0") and \
         conf.CheckBoost("regex", require_version = "1.35.0") and \
         conf.CheckSDL("SDL_ttf", require_version = "2.0.8") and \
         conf.CheckSDL("SDL_mixer", require_version = '1.2.0') and \

Modified: trunk/src/CMakeLists.txt
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/CMakeLists.txt?rev=49701&r1=49700&r2=49701&view=diff
==============================================================================
--- trunk/src/CMakeLists.txt (original)
+++ trunk/src/CMakeLists.txt Sun May 29 19:31:07 2011
@@ -336,6 +336,7 @@
        attack_prediction.cpp
        attack_prediction_display.cpp
        callable_objects.cpp
+       commandline_options.cpp
        config_cache.cpp
        controller_base.cpp
        dialogs.cpp

Modified: trunk/src/SConscript
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/SConscript?rev=49701&r1=49700&r2=49701&view=diff
==============================================================================
--- trunk/src/SConscript (original)
+++ trunk/src/SConscript Sun May 29 19:31:07 2011
@@ -198,6 +198,7 @@
     attack_prediction.cpp
     attack_prediction_display.cpp
     callable_objects.cpp
+    commandline_options.cpp
     config_cache.cpp
     controller_base.cpp
     dialogs.cpp

Added: trunk/src/commandline_options.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/commandline_options.cpp?rev=49701&view=auto
==============================================================================
--- trunk/src/commandline_options.cpp (added)
+++ trunk/src/commandline_options.cpp Sun May 29 19:31:07 2011
@@ -1,0 +1,76 @@
+/* $Id$ */
+/*
+   Copyright (C) 2011 by Lukasz Dobrogowski <[email protected]>
+   Part of the Battle for Wesnoth Project http://www.wesnoth.org/
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY.
+
+   See the COPYING file for more details.
+*/
+
+#include "commandline_options.hpp"
+
+commandline_options::commandline_options ( int /* argc*/, char** /*argv*/ ) :
+       bpp(),
+       campaign(),
+       campaign_difficulty(),
+       campaign_scenario(),
+       clock(false),
+       config_path(false),
+       config_dir(),
+       data_dir(),
+       debug(false),
+#ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
+       debug_dot_level(),
+       debug_dot_domain(),
+#endif
+       editor(),
+       fps(false),
+       fullscreen(false),
+       gunzip(),
+       gzip(),
+       log(),
+       load(),
+       logdomains(),
+       multiplayer(false),
+       max_fps(),
+       nocache(false),
+       nodelay(false),
+       nogui(false),
+       nomusic(false),
+       nosound(false),
+       new_storyscreens(false),
+       new_syntax(false),
+       new_widgets(false),
+       path(false),
+       preprocess(false),
+       preprocess_defines(),
+       preprocess_input_macros(),
+       preprocess_output_macros(),
+       preprocess_path(),
+       preprocess_target(),
+       proxy(false),
+       proxy_address(),
+       proxy_password(),
+       proxy_port(),
+       proxy_user(),
+       resolution(),
+       rng_seed(),
+       server(),
+       screenshot(false),
+       screenshot_map_file(),
+       screenshot_output_file(),
+       smallgui(false),
+       test(false),
+       validcache(false),
+       version(false),
+       windowed(false),
+       with_replay(false)
+{
+
+}

Added: trunk/src/commandline_options.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/commandline_options.hpp?rev=49701&view=auto
==============================================================================
--- trunk/src/commandline_options.hpp (added)
+++ trunk/src/commandline_options.hpp Sun May 29 19:31:07 2011
@@ -1,0 +1,143 @@
+/* $Id$ */
+/*
+   Copyright (C) 2011 by Lukasz Dobrogowski <[email protected]>
+   Part of the Battle for Wesnoth Project http://www.wesnoth.org/
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY.
+
+   See the COPYING file for more details.
+*/
+
+#ifndef COMMANDLINE_OPTIONS_HPP_INCLUDED
+#define COMMANDLINE_OPTIONS_HPP_INCLUDED
+
+#include <boost/optional.hpp>
+#include <boost/program_options.hpp>
+
+#include <string>
+#include <utility>
+#include <vector>
+
+class commandline_options
+{
+public:
+       commandline_options(int argc, char **argv);
+
+       /// BitsPerPixel specified by --bpp option.
+       boost::optional<int> bpp;
+       /// Non-empty if --campaign was given on the command line. ID of the 
campaign we want to start.
+       boost::optional<std::string> campaign;
+       /// Non-empty if --campaign-difficulty was given on the command line. 
Numerical difficulty of the campaign to be played. Dependant on --campaign.
+       boost::optional<int> campaign_difficulty;
+       /// Non-empty if --campaign-scenario was given on the command line. 
Chooses starting scenario in the campaign to be played. Dependant on --campaign.
+       boost::optional<std::string> campaign_scenario;
+       /// True if --clock was given on the command line. Enables
+       bool clock;
+       /// True if --config-path was given on the command line. Prints path to 
user config directory and exits.
+       bool config_path;
+       /// Non-empty if --config-dir was given on the command line. Sets the 
config dir to the specified one.
+       boost::optional<std::string> config_dir;
+       /// Non-empty if --config-dir was given on the command line. Sets the 
config dir to the specified one.
+       boost::optional<std::string> data_dir;
+       /// True if --debug was given on the command line. Enables debug mode.
+       bool debug;
+#ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
+       /// Non-empty if --debug-dot-level was given on the command line.
+       boost::optional<std::string> debug_dot_level;
+       /// Non-empty if --debug-dot-domain was given on the command line.
+       boost::optional<std::string> debug_dot_domain;
+#endif
+       /// 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.
+       boost::optional<std::string> editor;
+       /// True if --fps was given on the command line. Shows number of fps.
+       bool fps;
+       /// True if --fullscreen was given on the command line. Starts Wesnoth 
in fullscreen mode.
+       bool fullscreen;
+       /// Non-empty if --gunzip was given on the command line. Uncompresses a 
.gz file and exits.
+       boost::optional<std::string> gunzip;
+       /// Non-empty if --gzip was given on the command line. Compresses a 
file to .gz and exits.
+       boost::optional<std::string> gzip;
+       /// Contains parsed arguments of --log-* (e.g. --log-debug).
+       /// Vector of pairs (severity, log domain).
+       boost::optional<std::vector<std::pair<int, std::string> > > log;
+       /// Non-empty if --load was given on the command line. Savegame 
specified to load after start.
+       boost::optional<std::string> load;
+       /// Non-empty if --logdomains was given on the command line. Prints 
possible logdomains filtered by given string and exits.
+       boost::optional<std::string> logdomains;
+       /// True if --multiplayer was given on the command line. Goes directly 
into multiplayer mode.
+       bool multiplayer;
+       /// Max FPS specified by --max-fps option.
+       boost::optional<int> max_fps;
+       /// True if --nocache was given on the command line. Disables cache 
usage.
+       bool nocache;
+       /// True if --nodelay was given on the command line.
+       bool nodelay;
+       /// True if --nogui was given on the command line. Disables GUI.
+       bool nogui;
+       /// True if --nomusic was given on the command line. Disables music.
+       bool nomusic;
+       /// True if --nosound was given on the command line. Disables sound.
+       bool nosound;
+       /// True if --new-storyscreens was given on the command line. Hidden 
option to help testing the work-in-progress new storyscreen code.
+       bool new_storyscreens;
+       /// True if --new-syntax was given on the command line. Does magic.
+       bool new_syntax;
+       /// True if --new-widgets was given on the command line. Hidden option 
to enable the new widget toolkit.
+       bool new_widgets;
+       /// True if --path was given on the command line. Prints the path to 
data directory and exits.
+       bool path;
+       /// True if --preprocess was given on the command line. Starts Wesnoth 
in preprocessor-only mode.
+       bool preprocess;
+       /// Defines that were given to the --preprocess option.
+       boost::optional<std::vector<std::string> > preprocess_defines;
+       /// 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.
+       boost::optional<std::string> preprocess_input_macros;
+       /// Non-empty if --preprocess-output-macros was given on the command 
line. Outputs all preprocessed macros to the specified file. Dependant on 
--preprocess.
+       boost::optional<std::string> preprocess_output_macros;
+       /// Path to parse that was given to the --preprocess option.
+       boost::optional<std::string> preprocess_path;
+       /// Target (output) path tha was given to the --preprocess option.
+       boost::optional<std::string> preprocess_target;
+       /// True if --proxy was given on the command line. Enables proxy mode.
+       bool proxy;
+       /// Non-empty if --proxy-address was given on the command line.
+       boost::optional<std::string> proxy_address;
+       /// Non-empty if --proxy-password was given on the command line.
+       boost::optional<std::string> proxy_password;
+       /// Non-empty if --proxy-port was given on the command line.
+       boost::optional<std::string> proxy_port;
+       /// Non-empty if --proxy-user was given on the command line.
+       boost::optional<std::string> proxy_user;
+       /// Pair of AxB values specified after --resolution. Changes Wesnoth 
resolution.
+       boost::optional<std::pair<int,int> > resolution;
+       /// RNG seed specified by --rng-seed option. Initializes RNG with given 
seed.
+       boost::optional<int> rng_seed;
+       /// 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.
+       boost::optional<std::string> server;
+       /// True if --screenshot was given on the command line. Starts Wesnoth 
in screenshot mode.
+       bool screenshot;
+       /// Map file to make a screenshot of. First parameter given after 
--screenshot.
+       boost::optional<std::string> screenshot_map_file;
+       /// Output file to put screenshot in. Second parameter given after 
--screenshot.
+       boost::optional<std::string> screenshot_output_file;
+       /// True if --smallgui was given on the command line. Makes Wesnoth use 
small gui layout.
+       bool smallgui;
+       /// True if --test was given on the command line. Goes directly into 
test mode.
+       bool test;
+       /// True if --validcache was given on the command line. Makes Wesnoth 
assume the cache is valid.
+       bool validcache;
+       /// True if --version was given on the command line. Prints version and 
exits.
+       bool version;
+       /// True if --windowed was given on the command line. Starts Wesnoth in 
windowed mode.
+       bool windowed;
+       /// True if --with-replay was given on the command line. Shows replay 
of the loaded file.
+       bool with_replay;
+private:
+};
+
+#endif


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to