The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
options.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012 - 2016 by Mark de Wever <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 /**
16  * @file
17  * Command line parameters for wesmage.
18  */
19 
20 #ifndef WESMAGE_OPTIONS_HPP_INCLUDED
21 #define WESMAGE_OPTIONS_HPP_INCLUDED
22 
23 #include <boost/noncopyable.hpp>
24 
25 #include <string>
26 #include <vector>
27 
28 /** A singleton class containing the parsed command line parameters. */
29 struct toptions
30  : private boost::noncopyable
31 {
32 private:
33 
34  toptions();
35 
36 public:
37 
38  /**
39  * Parses the command line.
40  *
41  * This function shall be called once at the beginning of the program.
42  *
43  * @param argc The @p argc to @ref main.
44  * @param argv The @p argv to @ref main.
45  *
46  * @returns The parsed options.
47  */
48  static const toptions&
49  parse(int argc, char* argv[]);
50 
51  /**
52  * Returns the cached parsed command line parameters.
53  *
54  * This function shall only be called after @ref toptions::parse has
55  * been called.
56  *
57  * @returns The parsed options.
58  */
59  static const toptions&
60  options();
61 
62  /** The filename of the input file. */
64 
65  /** The filename of the output file. */
67 
68  /** The filters to apply to the input file. */
69  std::vector<std::string> filters;
70 
71  /** Display the time that applying the filters took. */
72  bool time;
73 
74  /**
75  * The number of times the filter has to be applied.
76  *
77  * This feature is for performance testing only.
78  */
79  int count;
80 
81 private:
82 
83  /**
84  * Helper which contains the single instance of this class.
85  *
86  * @param is_initialized Helper variable to track whether
87  * @ref toptions::parse is only called once
88  * and whether @ref toptions::options isn't
89  * called before @ref toptions::parse.
90  *
91  * @returns The single instance of this class.
92  */
93  static toptions&
94  singleton(const bool is_initialized);
95 };
96 
97 #endif
A singleton class containing the parsed command line parameters.
Definition: options.hpp:29
bool time
Display the time that applying the filters took.
Definition: options.hpp:72
std::string output_filename
The filename of the output file.
Definition: options.hpp:66
static toptions & singleton(const bool is_initialized)
Helper which contains the single instance of this class.
Definition: options.cpp:261
std::string input_filename
The filename of the input file.
Definition: options.hpp:63
toptions()
Definition: options.cpp:25
static const toptions & parse(int argc, char *argv[])
Parses the command line.
Definition: options.cpp:157
int count
The number of times the filter has to be applied.
Definition: options.hpp:79
static const toptions & options()
Returns the cached parsed command line parameters.
Definition: options.cpp:255
GLsizei const GLcharARB ** string
Definition: glew.h:4503
std::vector< std::string > filters
The filters to apply to the input file.
Definition: options.hpp:69