QuasarAppLib
params.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018-2025 QuasarApp.
3 * Distributed under the lgplv3 software license, see the accompanying
4 * Everyone is permitted to copy and distribute verbatim copies
5 * of this license document, but changing it is not allowed.
6*/
7
8#ifndef PARAMS_H
9#define PARAMS_H
10
11#include <QMap>
12#include <QVariant>
13#include "quasarapp_global.h"
14#include "helpdata.h"
15#include "optiondata.h"
16
17namespace QuasarAppUtils {
18
19
25 Error = 0x0,
27 Warning = 0x1,
29 Info = 0x2,
31 Debug = 0x3,
32
33};
34#ifdef QA_DISABLE_LOG
35#define DEFAULT_VERBOSE_LVL "0"
36#else
37#ifdef QT_DEBUG
38#define DEFAULT_VERBOSE_LVL "3"
39#else
40#define DEFAULT_VERBOSE_LVL "2"
41#endif
42#endif
43
62class QUASARAPPSHARED_EXPORT Params
63{
64public:
65 Params() = delete;
66
75 static bool parseParams(const int argc, const char *argv[], const OptionsDataList& options = {});
76
85 static bool parseParams(int argc, char *argv[], const OptionsDataList& options = {});
86
94 static bool parseParams(const QStringList& paramsArray, const OptionsDataList& options = {});
95
103 static QString getArg(const QString& key, const QString &def = {});
104
110 static void setArg(const QString& key, const QString& val);
111
118 static void setEnable(const QString& key, bool enable);
119
125 static bool isEndable(const QString& key);
126
134 [[deprecated("Use QALogger and qt debug functions(qDebug, qInfo, qError...)")]]
135 static void log(const QString& log, VerboseLvl vLvl = VerboseLvl::Debug);
136
141 static VerboseLvl getVerboseLvl();
142
147 static bool isDebug();
148
153 [[deprecated("Use Qt MACROSSSES")]]
154 static bool isDebugBuild();
155
160 static int size();
161
165 static void showHelp();
166
177 static void showHelpForInputOptions();
178
183 static Help::Section getHelpOfInputOptions();
184
190 static const Help::Section& getHelp();
191
196 static const QMap<QString, QString> &getUserParamsMap();
197
201 static void clearParsedData();
202
207 static QString getCurrentExecutable();
208
213 static QString getCurrentExecutableDir();
214
219 static OptionsDataList availableArguments();
220
221private:
222
223 static bool optionsForEach(const QStringList& paramsArray,
224 const OptionsDataList &availableOptions);
225
231 static void printWorkingOptions();
232
238 static bool checkOption(const OptionData &option, const QString &rawOptionName);
239
246 static void parseAvailableOptions(const OptionsDataList& availableOptionsListIn,
247 OptionsDataList* availableOptionsListOut,
248 Help::Section* helpOut);
249
250
251 static QMap<QString, QString> params;
252 static OptionsDataList inputOptions;
253
254 static Help::Section userHelp;
255 static QString appPath;
256 static QString appName;
257
258};
259}
260
261#endif // PARAMS_H
The QuasaraAppUtils class This lib include base functions for the all applications of QuasarApp group...
Definition helpdata.cpp:18
VerboseLvl
The VerboseLvl enum uses for sets log level.
Definition params.h:23
@ Error
Error message. This logs will marked as a Error and printing if the verbose lvl >= 0.
Definition params.h:25
@ Warning
Warning message. This logs will marked as a Warning and printing if the verbose lvl >= 1.
Definition params.h:27
@ Info
General information. This logs will marked as a Info and and printing if the verbose lvl >= 2.
Definition params.h:29
@ Debug
Debug message. This logs will marked as a Debug and printing if the verbose lvl >= 3.
Definition params.h:31
#define QUASARAPPSHARED_EXPORT