From 44791d19c2b2e0feb88ab43ccea4dd451fe2b17c Mon Sep 17 00:00:00 2001 From: EndrII Date: Sun, 17 May 2020 23:21:12 +0300 Subject: [PATCH] update library --- CMakeLists.txt | 2 +- global.h | 16 ++++++++++++++++ params.cpp | 11 ++++++++++- params.h | 11 +++++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c1f951..72e6573 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,4 +44,4 @@ add_library(${PROJECT_NAME} SHARED ${SOURCE_CPP}) target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Core) target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -setVersion(1 3 1) +setVersion(1 4 0) diff --git a/global.h b/global.h index 4733c1b..6af37f9 100644 --- a/global.h +++ b/global.h @@ -3,6 +3,7 @@ #include #include +#include template constexpr inline T operator | (T lhs, T rhs) @@ -64,4 +65,19 @@ constexpr inline T operator ^ (T lhs, T rhs) return static_cast(static_cast(lhs) ^ static_cast(rhs)); } + +constexpr uint32_t static_hash(const char* str) { + uint32_t hash = 0; + unsigned char index = 0; + uint32_t tmp = 1; + while (str[index] && index < 0xff) { + tmp *= str[index]; + if (index % 4 == 0) { + hash = hash % str[index]; + tmp = 1; + } + } + return hash; +} + #endif // GLOBAL_H diff --git a/params.cpp b/params.cpp index 7ddb948..169a130 100644 --- a/params.cpp +++ b/params.cpp @@ -99,6 +99,15 @@ QVariantMap Params::getUserParamsMap() { return result; } +void Params::clearParsedData() { + params.clear(); + _argc = 0; +} + +QString Params::getCurrentExecutable() { + return getStrArg(APP_PATH) + "/" + getStrArg(APP_NAME); +} + int Params::size() { return params.size(); } @@ -141,7 +150,7 @@ std::string Params::lvlToString(VerboseLvl vLvl) { bool Params::writeLoginFile(const QString &log, VerboseLvl vLvl) { if (isEndable("fileLog")) { - QString path = getStrArg(APP_PATH) + "/" + getStrArg(APP_NAME) + ".log"; + QString path = getCurrentExecutable() + ".log"; auto file = getStrArg("fileLog"); if (file.size()) { QString path = file; diff --git a/params.h b/params.h index 8d7427c..264917d 100644 --- a/params.h +++ b/params.h @@ -148,6 +148,17 @@ public: * @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(); }; }