mirror of
https://github.com/QuasarApp/QuasarAppLib.git
synced 2025-04-26 17:54:40 +00:00
178 lines
4.1 KiB
C++
178 lines
4.1 KiB
C++
/*
|
|
* Copyright (C) 2018-2021 QuasarApp.
|
|
* 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"
|
|
#include "helpdata.h"
|
|
|
|
namespace QuasarAppUtils {
|
|
|
|
/**
|
|
* @brief The Params class for parese app params
|
|
*/
|
|
|
|
enum VerboseLvl {
|
|
Info = 0x0,
|
|
Error = 0x1,
|
|
Warning = 0x2,
|
|
Debug = 0x3,
|
|
|
|
};
|
|
|
|
#ifdef RELEASE_BUILD
|
|
#define DEFAULT_VERBOSE_LVL "1"
|
|
|
|
#else
|
|
#define DEFAULT_VERBOSE_LVL "3"
|
|
|
|
#endif
|
|
class QUASARAPPSHARED_EXPORT Params
|
|
{
|
|
private:
|
|
static QString timeString();
|
|
static std::string lvlToString(VerboseLvl vLvl);
|
|
static bool writeLoginFile(const QString& log, VerboseLvl vLvl = VerboseLvl::Debug);
|
|
|
|
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
|
|
*/
|
|
static bool parseParams(const int argc, const char *argv[]);
|
|
static bool parseParams(int argc, char *argv[]);
|
|
|
|
/**
|
|
* @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);
|
|
|
|
/**
|
|
* @brief getStrArg - get string value of key
|
|
* @param key
|
|
* @param def - default value
|
|
* @return string value of argument
|
|
*/
|
|
static QString getStrArg(const QString& key, const QString& def = "");
|
|
|
|
/**
|
|
* @brief getArg - get string value of key
|
|
* @param key
|
|
* @param def - default value
|
|
* @return string value of argument
|
|
*/
|
|
static QVariant getArg(const QString& key, const QVariant &def = {});
|
|
|
|
/**
|
|
* @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);
|
|
|
|
/**
|
|
* @brief isEndable - check if enable argument of key
|
|
* @param key
|
|
* @return true if argument enabled
|
|
*/
|
|
static bool isEndable(const QString& key);
|
|
|
|
/**
|
|
* @brief log - print text on console if the flag "vergose" is enabled
|
|
* @param log - printed text
|
|
*/
|
|
static void log(const QString& log, VerboseLvl vLvl = VerboseLvl::Debug);
|
|
|
|
/**
|
|
* @brief getparamsHelp
|
|
* @return help string of default params
|
|
*/
|
|
static Help::Charters getparamsHelp();
|
|
|
|
/**
|
|
* @brief showHelp - show all strings of help
|
|
* @param help
|
|
*/
|
|
static void showHelp(const QStringList& help);
|
|
|
|
/**
|
|
* @brief showHelp - show structe of help value
|
|
* @param help
|
|
*/
|
|
static void showHelp(const Help::Charters& help);
|
|
|
|
/**
|
|
* @brief getVerboseLvl
|
|
* @return verbose lvl
|
|
*/
|
|
static VerboseLvl getVerboseLvl();
|
|
|
|
/**
|
|
* @brief isDebug
|
|
* @return true if verbose lvl >= 3
|
|
*/
|
|
static bool isDebug();
|
|
|
|
/**
|
|
* @brief size
|
|
* @return size of all params array
|
|
*/
|
|
static int size();
|
|
|
|
/**
|
|
* @brief customParamasSize
|
|
* @return size of params entered in conosole
|
|
*/
|
|
static int customParamasSize();
|
|
|
|
/**
|
|
* @brief showHelp - show base help section of QuasarAppLib
|
|
*/
|
|
static void showHelp();
|
|
|
|
/**
|
|
* @brief getUserParamsMap
|
|
* @return QVariantMap with user params
|
|
*/
|
|
static QVariantMap getUserParamsMap();
|
|
|
|
/**
|
|
* @brief clearParsedData - this method clear allparsed data.
|
|
*/
|
|
static void clearParsedData();
|
|
|
|
/**
|
|
* @brief getCurrentExecutable
|
|
* @return path to current executable.
|
|
*/
|
|
static QString getCurrentExecutable();
|
|
|
|
/**
|
|
* @brief getCurrentExecutableDir This method return a path to a folder with the current executable.
|
|
* @return path of executable.
|
|
*/
|
|
static QString getCurrentExecutableDir();
|
|
|
|
};
|
|
}
|
|
|
|
#endif // PARAMS_H
|