xca/lib/arguments.h
Christian Hohnstädt 68273d0a30 Switch from autotools/qmake to cmake
Why?
 - QT will switch from qmake to cmake sooner or later.
 - autotools are good for unix-ish systems, cmake also for
   macOS and Xcode as well as Windows and VS-code
 - Cross compiling the windows-binaries on linux
   is not very helpful to attract windows-centric
   developers.

Also drop qmake's xca.pro
Generate man-page and sphinx sources of commandline arguments
during build by executing xca (xcadoc.cpp).
Generating Version-patchlevel and git hash is now also
OS independent.
2021-06-01 17:48:37 +02:00

69 lines
1.3 KiB
C++

/* vi: set sw=4 ts=4:
*
* Copyright (C) 2020 Christian Hohnstaedt.
*
* All rights reserved.
*/
#ifndef __ARGUMENTS_H
#define __ARGUMENTS_H
#include <getopt.h>
#include <QString>
#include <QStringList>
#include <QMap>
struct option;
#define file_argument (required_argument+1)
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);
void fillOption(struct option *opt) const;
};
class arguments
{
private:
static const QList<arg_option> opts;
int result;
QMap<QString, QString> found_options;
QStringList files;
struct option *long_opts;
bool need_db;
QString result_string;
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);
~arguments();
QString operator [] (const QString &) const;
arguments &operator = (const arguments &);
bool has(const QString &opt) const;
int parse(int argc, char *argv[]);
QStringList getFiles() const;
int getResult() const;
QString resultString() const;
bool needDb() const;
};
#endif