2018-09-29 15:56:04 +03:00
|
|
|
/*
|
2021-01-05 13:04:05 +03:00
|
|
|
* Copyright (C) 2018-2021 QuasarApp.
|
2018-09-29 15:56:04 +03:00
|
|
|
* Distributed under the lgplv3 software license, see the accompanying
|
|
|
|
* Everyone is permitted to copy and distribute verbatim copies
|
|
|
|
* of this license document, but changing it is not allowed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PARAMS_H
|
|
|
|
#define PARAMS_H
|
|
|
|
|
|
|
|
#include <QVariant>
|
|
|
|
#include "quasarapp_global.h"
|
2020-02-18 22:28:17 +03:00
|
|
|
#include "helpdata.h"
|
2018-09-29 15:56:04 +03:00
|
|
|
|
|
|
|
namespace QuasarAppUtils {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief The Params class for parese app params
|
|
|
|
*/
|
|
|
|
|
2019-03-28 18:58:36 +03:00
|
|
|
enum VerboseLvl {
|
2020-04-14 17:57:54 +03:00
|
|
|
Info = 0x0,
|
|
|
|
Error = 0x1,
|
2019-03-28 18:58:36 +03:00
|
|
|
Warning = 0x2,
|
2020-04-14 17:57:54 +03:00
|
|
|
Debug = 0x3,
|
2020-04-04 15:42:56 +03:00
|
|
|
|
2019-03-28 18:58:36 +03:00
|
|
|
};
|
|
|
|
|
2020-08-25 15:33:38 +03:00
|
|
|
#ifdef RELEASE_BUILD
|
2020-04-04 15:42:56 +03:00
|
|
|
#define DEFAULT_VERBOSE_LVL "1"
|
|
|
|
|
2020-08-25 15:33:38 +03:00
|
|
|
#else
|
|
|
|
#define DEFAULT_VERBOSE_LVL "3"
|
|
|
|
|
|
|
|
#endif
|
2018-09-29 15:56:04 +03:00
|
|
|
class QUASARAPPSHARED_EXPORT Params
|
|
|
|
{
|
2019-08-22 14:21:43 +03:00
|
|
|
private:
|
2019-08-23 20:41:13 +03:00
|
|
|
static QString timeString();
|
2020-04-04 15:42:56 +03:00
|
|
|
static std::string lvlToString(VerboseLvl vLvl);
|
2019-08-22 14:21:43 +03:00
|
|
|
static bool writeLoginFile(const QString& log, VerboseLvl vLvl = VerboseLvl::Debug);
|
2020-03-09 14:35:08 +03:00
|
|
|
|
2018-09-29 15:56:04 +03:00
|
|
|
public:
|
|
|
|
Params() = delete;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief parseParams - parase input data of started application
|
|
|
|
* @param argc - count of arguments
|
|
|
|
* @param argv - arrat of arguments
|
|
|
|
* @return true if all arguments read else false
|
|
|
|
*/
|
2020-03-09 15:32:39 +03:00
|
|
|
static bool parseParams(const int argc, const char *argv[]);
|
2019-11-21 18:03:13 +03:00
|
|
|
static bool parseParams(int argc, char *argv[]);
|
|
|
|
|
2019-09-10 18:22:13 +03:00
|
|
|
/**
|
|
|
|
* @brief parseParams - parase input data of started application
|
|
|
|
* @param params - arguments
|
|
|
|
* @return true if all arguments read else false
|
|
|
|
*/
|
|
|
|
static bool parseParams(const QStringList& paramsArray);
|
2018-09-29 15:56:04 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief getStrArg - get string value of key
|
|
|
|
* @param key
|
2019-08-26 20:32:33 +03:00
|
|
|
* @param def - default value
|
2018-09-29 15:56:04 +03:00
|
|
|
* @return string value of argument
|
|
|
|
*/
|
2019-08-26 20:32:33 +03:00
|
|
|
static QString getStrArg(const QString& key, const QString& def = "");
|
2018-09-29 15:56:04 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief getArg - get string value of key
|
|
|
|
* @param key
|
2019-08-26 20:32:33 +03:00
|
|
|
* @param def - default value
|
2018-09-29 15:56:04 +03:00
|
|
|
* @return string value of argument
|
|
|
|
*/
|
2019-08-26 20:32:33 +03:00
|
|
|
static QVariant getArg(const QString& key, const QVariant &def = {});
|
2018-09-29 15:56:04 +03:00
|
|
|
|
2019-02-02 16:01:28 +03:00
|
|
|
/**
|
|
|
|
* @brief setArg - set value of key
|
|
|
|
* @param key
|
|
|
|
*/
|
|
|
|
static void setArg(const QString& key, const QVariant& val);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief setArg - set boolean value of key
|
|
|
|
* @param key
|
|
|
|
* @param enable - new value of key
|
|
|
|
*/
|
|
|
|
static void setEnable(const QString& key, bool enable);
|
|
|
|
|
2018-09-29 15:56:04 +03:00
|
|
|
/**
|
|
|
|
* @brief isEndable - check if enable argument of key
|
|
|
|
* @param key
|
|
|
|
* @return true if argument enabled
|
|
|
|
*/
|
|
|
|
static bool isEndable(const QString& key);
|
2019-01-02 13:42:51 +03:00
|
|
|
|
|
|
|
/**
|
2020-04-04 18:17:26 +03:00
|
|
|
* @brief log - print text on console if the flag "vergose" is enabled
|
2019-01-02 13:42:51 +03:00
|
|
|
* @param log - printed text
|
|
|
|
*/
|
2020-04-04 15:42:56 +03:00
|
|
|
static void log(const QString& log, VerboseLvl vLvl = VerboseLvl::Debug);
|
2019-08-22 14:21:43 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief getparamsHelp
|
|
|
|
* @return help string of default params
|
|
|
|
*/
|
2020-02-18 22:28:17 +03:00
|
|
|
static Help::Charters getparamsHelp();
|
2019-08-22 14:21:43 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief showHelp - show all strings of help
|
|
|
|
* @param help
|
|
|
|
*/
|
|
|
|
static void showHelp(const QStringList& help);
|
2019-09-16 12:38:10 +03:00
|
|
|
|
2020-02-18 22:28:17 +03:00
|
|
|
/**
|
|
|
|
* @brief showHelp - show structe of help value
|
|
|
|
* @param help
|
|
|
|
*/
|
|
|
|
static void showHelp(const Help::Charters& help);
|
|
|
|
|
2020-04-14 17:57:54 +03:00
|
|
|
/**
|
|
|
|
* @brief getVerboseLvl
|
|
|
|
* @return verbose lvl
|
|
|
|
*/
|
|
|
|
static VerboseLvl getVerboseLvl();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief isDebug
|
|
|
|
* @return true if verbose lvl >= 3
|
|
|
|
*/
|
|
|
|
static bool isDebug();
|
|
|
|
|
2021-01-24 14:04:31 +03:00
|
|
|
/**
|
|
|
|
* @brief isDebugBuild This method return true if the library buildet in debug mode.
|
|
|
|
* @return true if this library buildet in debug mode.
|
|
|
|
*/
|
|
|
|
static bool isDebugBuild();
|
|
|
|
|
|
|
|
|
2019-09-16 12:38:10 +03:00
|
|
|
/**
|
|
|
|
* @brief size
|
|
|
|
* @return size of all params array
|
|
|
|
*/
|
|
|
|
static int size();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief customParamasSize
|
|
|
|
* @return size of params entered in conosole
|
|
|
|
*/
|
|
|
|
static int customParamasSize();
|
2020-02-18 22:28:17 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief showHelp - show base help section of QuasarAppLib
|
|
|
|
*/
|
|
|
|
static void showHelp();
|
2020-04-18 21:28:35 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief getUserParamsMap
|
|
|
|
* @return QVariantMap with user params
|
|
|
|
*/
|
|
|
|
static QVariantMap getUserParamsMap();
|
2020-05-17 23:21:12 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief clearParsedData - this method clear allparsed data.
|
|
|
|
*/
|
|
|
|
static void clearParsedData();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief getCurrentExecutable
|
|
|
|
* @return path to current executable.
|
|
|
|
*/
|
|
|
|
static QString getCurrentExecutable();
|
2020-09-28 23:42:54 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief getCurrentExecutableDir This method return a path to a folder with the current executable.
|
|
|
|
* @return path of executable.
|
|
|
|
*/
|
|
|
|
static QString getCurrentExecutableDir();
|
|
|
|
|
2018-09-29 15:56:04 +03:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // PARAMS_H
|