2018-09-29 15:56:04 +03:00
|
|
|
/*
|
2019-12-08 13:51:32 +03:00
|
|
|
* Copyright (C) 2018-2020 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"
|
|
|
|
|
|
|
|
|
|
|
|
namespace QuasarAppUtils {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief The Params class for parese app params
|
|
|
|
*/
|
|
|
|
|
2019-03-28 18:58:36 +03:00
|
|
|
enum VerboseLvl {
|
|
|
|
Debug = 0x0,
|
|
|
|
Error = 0x1,
|
|
|
|
Warning = 0x2,
|
|
|
|
Info = 0x3,
|
|
|
|
};
|
|
|
|
|
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();
|
2019-08-22 14:21:43 +03:00
|
|
|
static QString lvlToString(VerboseLvl vLvl);
|
|
|
|
static bool writeLoginFile(const QString& log, VerboseLvl vLvl = VerboseLvl::Debug);
|
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
|
|
|
|
*/
|
2019-03-28 18:58:36 +03:00
|
|
|
static bool parseParams(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
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief verboseLog - print text on console if the flag "vergose" is enabled
|
|
|
|
* @param log - printed text
|
|
|
|
*/
|
2019-03-28 18:58:36 +03:00
|
|
|
static void verboseLog(const QString& log, VerboseLvl vLvl = VerboseLvl::Debug);
|
2019-08-22 14:21:43 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief getparamsHelp
|
|
|
|
* @return help string of default params
|
|
|
|
*/
|
|
|
|
static QStringList getparamsHelp();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief showHelp - show all strings of help
|
|
|
|
* @param help
|
|
|
|
*/
|
|
|
|
static void showHelp(const QStringList& help);
|
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();
|
2018-09-29 15:56:04 +03:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // PARAMS_H
|