1 /*
2 	Copyright 2006-2019 The QElectroTech Team
3 	This file is part of QElectroTech.
4 
5 	QElectroTech 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 
10 	QElectroTech is distributed in the hope that it will be useful,
11 	but WITHOUT ANY WARRANTY; without even the implied warranty of
12 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 	GNU General Public License for more details.
14 
15 	You should have received a copy of the GNU General Public License
16 	along with QElectroTech.  If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef QET_ARGUMENTS_H
19 #define QET_ARGUMENTS_H
20 #include <QtCore>
21 /**
22 	This class represents a set of arguments the application has received as
23 	parameters. Initialized from a list of strings, an instance of this class
24 	provides access to the differents options and files given on the command line.
25 */
26 class QETArguments : public QObject {
27 	Q_OBJECT
28 
29 	// constructors, destructor
30 	public:
31 	QETArguments(QObject * = nullptr);
32 	QETArguments(const QList<QString> &, QObject * = nullptr);
33 	QETArguments(const QETArguments &);
34 	QETArguments &operator=(const QETArguments &);
35 	~QETArguments() override;
36 
37 	// methods
38 	public:
39 	virtual void setArguments(const QList<QString> &);
40 	virtual QList<QString> arguments() const;
41 	virtual QList<QString> files() const;
42 	virtual QList<QString> projectFiles() const;
43 	virtual QList<QString> elementFiles() const;
44 	virtual QList<QString> titleBlockTemplateFiles() const;
45 #ifdef QET_ALLOW_OVERRIDE_CED_OPTION
46 	virtual bool commonElementsDirSpecified() const;
47 	virtual QString commonElementsDir() const;
48 #endif
49 #ifdef QET_ALLOW_OVERRIDE_CTBTD_OPTION
50 	virtual bool commonTitleBlockTemplatesDirSpecified() const;
51 	virtual QString commonTitleBlockTemplatesDir() const;
52 #endif
53 #ifdef QET_ALLOW_OVERRIDE_CD_OPTION
54 	virtual bool configDirSpecified() const;
55 	virtual QString configDir() const;
56 #endif
57 	virtual bool langDirSpecified() const;
58 	virtual QString langDir() const;
59 	virtual bool printHelpRequested() const;
60 	virtual bool printLicenseRequested() const;
61 	virtual bool printVersionRequested() const;
62 	virtual QList<QString> options() const;
63 	virtual QList<QString> unknownOptions() const;
64 
65 	private:
66 	void clear();
67 	void parseArguments(const QList<QString> &);
68 	void handleFileArgument(const QString &);
69 	void handleOptionArgument(const QString &);
70 
71 	// attributes
72 	private:
73 	QList<QString> project_files_;
74 	QList<QString> element_files_;
75 	QList<QString> tbt_files_;
76 	QList<QString> options_;
77 	QList<QString> unknown_options_;
78 #ifdef QET_ALLOW_OVERRIDE_CED_OPTION
79 	QString common_elements_dir_;
80 #endif
81 #ifdef QET_ALLOW_OVERRIDE_CTBTD_OPTION
82 	QString common_tbt_dir_;
83 #endif
84 #ifdef QET_ALLOW_OVERRIDE_CD_OPTION
85 	QString config_dir_;
86 #endif
87 	QString lang_dir_;
88 	bool print_help_;
89 	bool print_license_;
90 	bool print_version_;
91 };
92 #endif
93