File: arguments.h

package info (click to toggle)
xca 2.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,328 kB
  • sloc: cpp: 30,584; sh: 341; xml: 74; makefile: 56; python: 34
file content (66 lines) | stat: -rw-r--r-- 1,290 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* vi: set sw=4 ts=4:
 *
 * Copyright (C) 2020 Christian Hohnstaedt.
 *
 * All rights reserved.
 */

#ifndef __ARGUMENTS_H
#define __ARGUMENTS_H

#include "base.h"
#include <QString>
#include <QStringList>
#include <QMap>
#include <QCommandLineOption>

enum {
	file_argument,
	required_argument,
	no_argument,
};

class arg_option
{
  public:
	const char *long_opt{};
	const char *arg{};
	int arg_type{};
	bool no_gui{};
	bool need_db{};
	QString help{};

	arg_option(const char *l, const char *a, int has_arg,
		bool n, bool nd, const char *h);
	QCommandLineOption getCmdOption() const;
};

class arguments
{
  private:
	static const QList<arg_option> opts;
	int result{};
	QMap<QString, QString> found_options{};
	QStringList files{};
	bool need_db{ false };

  public:
	static bool is_console(int argc, char *argv[]);
	static QString help();
	static QString man();
	static QString rst();
	static QString completion();
	static size_t maxOptWidth();
	static QString doc(const QString &which);

	arguments(int argc, char *argv[]);
	arguments(const arguments &a);

	QString operator [] (const QString &) const;
	arguments &operator = (const arguments &);
	bool has(const QString &opt) const;
	int parse(int argc, char *argv[]);
	QStringList getFiles() const;
	bool needDb() const;
};
#endif