From 33220489729f9f26a0168762e409e1845780d588 Mon Sep 17 00:00:00 2001 From: Christian Heimlich Date: Mon, 30 May 2022 08:40:53 -0400 Subject: [PATCH 01/53] Initial CMake conversion --- CLIFp.pro | 77 -- CMakeLists.txt | 128 +++ cmake/module/FetchQx.cmake | 13 + cmake/module/ProjectVars.cmake | 43 + cmake/module/WinExecutableDetails.cmake | 72 ++ cmake/module/__project_vars.h.in | 5 + cmake/module/__resources.rc.in | 30 + include/qx-io.h | 274 ------ include/qx-net.h | 178 ---- include/qx-widgets.h | 103 --- include/qx-windows.h | 244 ------ include/qx-xml.h | 65 -- include/qx.h | 1031 ----------------------- lib/QxW_static32_0-0-7-9_Qt_5-15-2.lib | Bin 1165984 -> 0 bytes lib/QxW_static32_0-0-7-9_Qt_5-15-2d.lib | Bin 4387824 -> 0 bytes lib/QxW_static32_0-0-7-9_Qt_5-15-2d.pdb | Bin 4050944 -> 0 bytes lib/QxW_static64_0-0-7-9_Qt_5-15-2.lib | Bin 1611666 -> 0 bytes lib/QxW_static64_0-0-7-9_Qt_5-15-2d.lib | Bin 5634792 -> 0 bytes lib/QxW_static64_0-0-7-9_Qt_5-15-2d.pdb | Bin 4001792 -> 0 bytes resources.qrc => res/resources.qrc | 2 +- resources.rc | 32 - src/version.h | 21 - 22 files changed, 292 insertions(+), 2026 deletions(-) delete mode 100644 CLIFp.pro create mode 100644 CMakeLists.txt create mode 100644 cmake/module/FetchQx.cmake create mode 100644 cmake/module/ProjectVars.cmake create mode 100644 cmake/module/WinExecutableDetails.cmake create mode 100644 cmake/module/__project_vars.h.in create mode 100644 cmake/module/__resources.rc.in delete mode 100644 include/qx-io.h delete mode 100644 include/qx-net.h delete mode 100644 include/qx-widgets.h delete mode 100644 include/qx-windows.h delete mode 100644 include/qx-xml.h delete mode 100644 include/qx.h delete mode 100644 lib/QxW_static32_0-0-7-9_Qt_5-15-2.lib delete mode 100644 lib/QxW_static32_0-0-7-9_Qt_5-15-2d.lib delete mode 100644 lib/QxW_static32_0-0-7-9_Qt_5-15-2d.pdb delete mode 100644 lib/QxW_static64_0-0-7-9_Qt_5-15-2.lib delete mode 100644 lib/QxW_static64_0-0-7-9_Qt_5-15-2d.lib delete mode 100644 lib/QxW_static64_0-0-7-9_Qt_5-15-2d.pdb rename resources.qrc => res/resources.qrc (58%) delete mode 100644 resources.rc delete mode 100644 src/version.h diff --git a/CLIFp.pro b/CLIFp.pro deleted file mode 100644 index ad76c3e..0000000 --- a/CLIFp.pro +++ /dev/null @@ -1,77 +0,0 @@ -QT += core gui sql network - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -CONFIG += c++17 -TARGET = CLIFp - -# The following define makes your compiler emit warnings if you use -# any Qt feature that has been marked deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -SOURCES += \ - src/command/c-link.cpp \ - src/command/c-play.cpp \ - src/command/c-prepare.cpp \ - src/command/c-run.cpp \ - src/command/c-show.cpp \ - src/command.cpp \ - src/controller.cpp \ - src/core.cpp \ - src/driver.cpp \ - src/flashpoint/fp-db.cpp \ - src/flashpoint/fp-install.cpp \ - src/flashpoint/fp-json.cpp \ - src/flashpoint/fp-macro.cpp \ - src/logger.cpp \ - src/main.cpp \ - src/statusrelay.cpp - -HEADERS += \ - src/command/c-link.h \ - src/command/c-play.h \ - src/command/c-prepare.h \ - src/command/c-run.h \ - src/command/c-show.h \ - src/command.h \ - src/controller.h \ - src/core.h \ - src/driver.h \ - src/flashpoint/fp-db.h \ - src/flashpoint/fp-install.h \ - src/flashpoint/fp-json.h \ - src/flashpoint/fp-macro.h \ - src/logger.h \ - src/statusrelay.h \ - src/version.h - -RC_FILE = resources.rc - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target - -contains(QT_ARCH, i386) { - win32:CONFIG(release, debug|release): LIBS += -L$$PWD/lib/ -lQxW_static32_0-0-7-9_Qt_5-15-2 - else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/lib/ -lQxW_static32_0-0-7-9_Qt_5-15-2d -} else { - win32:CONFIG(release, debug|release): LIBS += -L$$PWD/lib/ -lQxW_static64_0-0-7-9_Qt_5-15-2 - else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/lib/ -lQxW_static64_0-0-7-9_Qt_5-15-2d -} - -INCLUDEPATH += $$PWD/include -DEPENDPATH += $$PWD/include - -contains(QT_ARCH, i386) { - win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/lib/QxW_static32_0-0-7-9_Qt_5-15-2.lib - else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/lib/QxW_static32_0-0-7-9_Qt_5-15-2d.lib -} else { - win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/lib/QxW_static64_0-0-7-9_Qt_5-15-2.lib - else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/lib/QxW_static64_0-0-7-9_Qt_5-15-2d.lib -} - -RESOURCES += \ - resources.qrc diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..63b04bd --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,128 @@ +cmake_minimum_required(VERSION 3.21.1) + +# Project +project(CLIFp VERSION 0.8 LANGUAGES CXX) +set(TARGET_FP_VERSION 10.1) +set(FORMAL_NAME "CLI for BlueMaxima's Flashpoint") + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +# Build augmentation +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +enable_language("RC") + +# Add local modules +set(PROJ_SCRIPTS_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +list(APPEND CMAKE_MODULE_PATH "${PROJ_SCRIPTS_PATH}/module") + +# Import Qt +find_package(Qt6 REQUIRED COMPONENTS + Core + Gui + Widgets + Sql + Network +) + +# Disable deprecated code +add_compile_definitions(QT_DISABLE_DEPRECATED_BEFORE=0x060000) + +# Fetch Qx (build and import from source) +include(FetchQx) +fetch_qx(ae48c53243bb1b2140196026bbc72aff3e56fbd9) # dev commit + +# Set app sources +set(CXX_SOURCES + src/command/c-link.h + src/command/c-link.cpp + src/command/c-play.h + src/command/c-play.cpp + src/command/c-prepare.h + src/command/c-prepare.cpp + src/command/c-run.h + src/command/c-run.cpp + src/command/c-show.cpp + src/command/c-show.h + src/command.h + src/command.cpp + src/controller.h + src/controller.cpp + src/core.h + src/core.cpp + src/driver.h + src/driver.cpp + src/flashpoint/fp-db.h + src/flashpoint/fp-db.cpp + src/flashpoint/fp-install.h + src/flashpoint/fp-install.cpp + src/flashpoint/fp-json.h + src/flashpoint/fp-json.cpp + src/flashpoint/fp-macro.h + src/flashpoint/fp-macro.cpp + src/logger.h + src/logger.cpp + src/statusrelay.h + src/statusrelay.cpp + src/main.cpp +) + +set(QT_RESOURCES + res/resources.qrc +) + +set(CXX_INCLUDE_PATHS + include +) + +# Add executable target +set(TARGET_NAME ${PROJECT_NAME}) +qt_add_executable(${TARGET_NAME} WIN32) + +# Add sources to target +target_sources(${TARGET_NAME} + PRIVATE + ${CXX_SOURCES} + ${QT_RESOURCES} +) + +# Add external includes to target +target_include_directories(${TARGET_NAME} + PRIVATE + ${CXX_INCLUDE_PATHS} +) + +## Forward select project variables to C++ code +#include(ProjectVars) +#set_cxx_project_vars(${TARGET_NAME} +# FULL_NAME "${FORMAL_NAME}" +# SHORT_NAME "${PROJECT_NAME}" +# TARGET_FP_VER ${TARGET_FP_VERSION} +#) + +# Set target exe details +include(WinExecutableDetails) +set_win_executable_details(${TARGET_NAME} + ICON "res/icon/CLIFp.ico" + FILE_VER ${PROJECT_VERSION} + PRODUCT_VER ${TARGET_FP_VERSION} + COMPANY_NAME "oblivioncth" + FILE_DESC "CLI for BlueMaxima's Flashpoint" + INTERNAL_NAME "CLIFp" + COPYRIGHT "Open Source @ 2022 oblivioncth" + TRADEMARKS_ONE "All Rights Reserved" + TRADEMARKS_TWO "GNU AGPL V3" + ORIG_FILENAME "CLIFp.exe" + PRODUCT_NAME "${FORMAL_NAME}" +) + +# Link target to libraries +target_link_libraries(${TARGET_NAME} + PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Widgets + Qt6::Sql + Qt6::Network +) diff --git a/cmake/module/FetchQx.cmake b/cmake/module/FetchQx.cmake new file mode 100644 index 0000000..e9187c2 --- /dev/null +++ b/cmake/module/FetchQx.cmake @@ -0,0 +1,13 @@ +# Sets up Qx to be built/installed as an external project for use in the main project + +# git_ref - Tag, branch name, or commit hash to retrieve. According to CMake docs, +# a commit hash is preferred for speed and reliability + +function(fetch_qx git_ref) + include(FetchContent) + FetchContent_Declare(Qx + GIT_REPOSITORY "https://github.com/oblivioncth/Qx" + GIT_TAG ${git_ref} + ) + FetchContent_MakeAvailable(Qx) +endfunction() diff --git a/cmake/module/ProjectVars.cmake b/cmake/module/ProjectVars.cmake new file mode 100644 index 0000000..e84627c --- /dev/null +++ b/cmake/module/ProjectVars.cmake @@ -0,0 +1,43 @@ +function(set_cxx_project_vars target) + # Const variables + set(GENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}") + set(GENERATED_NAME "project_vars.h") + set(GENERATED_PATH "${GENERATED_DIR}/${GENERATED_NAME}") + set(TEMPLATE_FILE "__project_vars.h.in") + + + # Additional Function inputs + set(oneValueArgs + FULL_NAME + SHORT_NAME + TARGET_FP_VER + ) + + # Parse arguments + cmake_parse_arguments(PV "" "${oneValueArgs}" "" ${ARGN}) + + # Validate input + foreach(unk_val ${WIN_ED_UNPARSED_ARGUMENTS}) + message(WARNING "Ignoring unrecognized parameter: ${unk_val}") + endforeach() + + if(${WIN_ED_KEYWORDS_MISSING_VALUES}) + foreach(missing_val ${WIN_ED_UNPARSED_ARGUMENTS}) + message(ERROR "A value for '${missing_val}' must be provided") + endforeach() + message(FATAL_ERROR "Not all required values were present!") + endif() + + # All values are string based and the cmake_parse_argument generated variable + # names are already correct for generation + + # Generate project_vars.h + configure_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${TEMPLATE_FILE}" + "${GENERATED_PATH}" + @ONLY + NEWLINE_STYLE UNIX + ) + + # Add file to target + target_sources(${target} PRIVATE "${GENERATED_PATH}") +endfunction() diff --git a/cmake/module/WinExecutableDetails.cmake b/cmake/module/WinExecutableDetails.cmake new file mode 100644 index 0000000..7b191ab --- /dev/null +++ b/cmake/module/WinExecutableDetails.cmake @@ -0,0 +1,72 @@ +function(set_win_executable_details target) + # Const variables + set(GENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/rc_gen") + set(GENERATED_NAME "resources.rc") + set(GENERATED_PATH "${GENERATED_DIR}/${GENERATED_NAME}") + set(TEMPLATE_FILE "__resources.rc.in") + + + # Additional Function inputs + set(oneValueArgs + ICON + FILE_VER + PRODUCT_VER + COMPANY_NAME + FILE_DESC + INTERNAL_NAME + COPYRIGHT + TRADEMARKS_ONE + TRADEMARKS_TWO + ORIG_FILENAME + PRODUCT_NAME + ) + + # Parse arguments + cmake_parse_arguments(WIN_ED "" "${oneValueArgs}" "" ${ARGN}) + + # Validate input + foreach(unk_val ${WIN_ED_UNPARSED_ARGUMENTS}) + message(WARNING "Ignoring unrecognized parameter: ${unk_val}") + endforeach() + + if(${WIN_ED_KEYWORDS_MISSING_VALUES}) + foreach(missing_val ${WIN_ED_UNPARSED_ARGUMENTS}) + message(ERROR "A value for '${missing_val}' must be provided") + endforeach() + message(FATAL_ERROR "Not all required values were present!") + endif() + + # Determine absolute icon path + set(EXE_ICON "${CMAKE_CURRENT_LIST_DIR}/${WIN_ED_ICON}") + + # Convert icon path to relative + cmake_path(RELATIVE_PATH EXE_ICON + BASE_DIRECTORY "${GENERATED_DIR}" + ) + + # Set binary file and product versions + string(REPLACE "." "," VER_FILEVERSION ${WIN_ED_FILE_VER}) + string(REPLACE "." "," VER_PRODUCTVERSION ${WIN_ED_PRODUCT_VER}) + + # Set string based values + set(VER_COMPANYNAME_STR "${WIN_ED_COMPANY_NAME}") + set(VER_FILEDESCRIPTION_STR "${WIN_ED_FILE_DESC}") + set(VER_FILEVERSION_STR "${WIN_ED_FILE_VER}") + set(VER_INTERNALNAME_STR "${WIN_ED_INTERNAL_NAME}") + set(VER_LEGALCOPYRIGHT_STR "${WIN_ED_COPYRIGHT}") + set(VER_LEGALTRADEMARKS1_STR "${WIN_ED_TRADEMARKS_ONE}") + set(VER_LEGALTRADEMARKS2_STR "${WIN_ED_TRADEMARKS_TWO}") + set(VER_ORIGINALFILENAME_STR "${WIN_ED_ORIG_FILENAME}") + set(VER_PRODUCTNAME_STR "${WIN_ED_PRODUCT_NAME}") + set(VER_PRODUCTVERSION_STR "${WIN_ED_PRODUCT_VER}") + + # Generate resources.rc + configure_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${TEMPLATE_FILE}" + "${GENERATED_PATH}" + @ONLY + NEWLINE_STYLE UNIX + ) + + # Add file to target + target_sources(${target} PRIVATE "${GENERATED_PATH}") +endfunction() diff --git a/cmake/module/__project_vars.h.in b/cmake/module/__project_vars.h.in new file mode 100644 index 0000000..ab103da --- /dev/null +++ b/cmake/module/__project_vars.h.in @@ -0,0 +1,5 @@ +// THIS FILE IS GENERATED BY CMAKE + +# define PROJECT_FULL_NAME "@PV_FULL_NAME@" +# define PROJECT_SHORT_NAME "@PV_SHORT_NAME@" +# define PROJECT_TARGET_FP_VER "@PV_TARGET_FP_VER@" \ No newline at end of file diff --git a/cmake/module/__resources.rc.in b/cmake/module/__resources.rc.in new file mode 100644 index 0000000..c21e647 --- /dev/null +++ b/cmake/module/__resources.rc.in @@ -0,0 +1,30 @@ +IDI_ICON1 ICON DISCARDABLE "@EXE_ICON@" + +#include "windows.h" + +VS_VERSION_INFO VERSIONINFO +FILEVERSION @VER_FILEVERSION@ +PRODUCTVERSION @VER_PRODUCTVERSION@ +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + BEGIN + VALUE "CompanyName", "@VER_COMPANYNAME_STR@" + VALUE "FileDescription", "@VER_FILEDESCRIPTION_STR@" + VALUE "FileVersion", "@VER_FILEVERSION_STR@" + VALUE "InternalName", "@VER_INTERNALNAME_STR@" + VALUE "LegalCopyright", "@VER_LEGALCOPYRIGHT_STR@" + VALUE "LegalTrademarks1", "@VER_LEGALTRADEMARKS1_STR@" + VALUE "LegalTrademarks2", "@VER_LEGALTRADEMARKS2_STR@" + VALUE "OriginalFilename", "@VER_ORIGINALFILENAME_STR@" + VALUE "ProductName", "@VER_PRODUCTNAME_STR@" + VALUE "ProductVersion", "@VER_PRODUCTVERSION_STR@" + END + END + + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 // 0x409: English Language, 1252: Western Code Page + END +END diff --git a/include/qx-io.h b/include/qx-io.h deleted file mode 100644 index 91e00ca..0000000 --- a/include/qx-io.h +++ /dev/null @@ -1,274 +0,0 @@ -#ifndef QXIO_H -#define QXIO_H - -#include "qx.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Qx -{ - -//-Types------------------------------------------------------------------------------------------------------ -enum IOOpType { IO_OP_READ, IO_OP_WRITE, IO_OP_ENUMERATE, IO_OP_INSPECT }; -enum IOOpResultType { IO_SUCCESS, IO_ERR_UNKNOWN, IO_ERR_ACCESS_DENIED, IO_ERR_NOT_A_FILE, IO_ERR_NOT_A_DIR, IO_ERR_OUT_OF_RES, - IO_ERR_READ, IO_ERR_WRITE, IO_ERR_FATAL, IO_ERR_OPEN, IO_ERR_ABORT, - IO_ERR_TIMEOUT, IO_ERR_REMOVE, IO_ERR_RENAME, IO_ERR_REPOSITION, - IO_ERR_RESIZE, IO_ERR_COPY, IO_ERR_FILE_DNE, IO_ERR_DIR_DNE, - IO_ERR_FILE_EXISTS, IO_ERR_CANT_MAKE_DIR, IO_ERR_FILE_SIZE_MISMATCH, IO_ERR_CURSOR_OOB, - IO_ERR_FILE_NOT_OPEN}; -enum IOOpTargetType { IO_FILE, IO_DIR }; -enum WriteMode { Append, Overwrite, NewOnly, ExistingOnly }; // TODO - Modify all classes in this unit to use this instead of overwrite bool - -//-Classes-------------------------------------------------------------------------------------------- -class IOOpReport -{ -//-Class Members---------------------------------------------------------------------------------------------------- -public: - static const inline QStringList TARGET_TYPES = {"file", "directory"}; - static const inline QString SUCCESS_TEMPLATE = R"(Succesfully %1 %2 "%3")"; - static const inline QString ERROR_TEMPLATE = R"(Error while %1 %2 "%3")"; - static const inline QHash SUCCESS_VERBS = { - {IO_OP_READ, "read"}, - {IO_OP_WRITE, "wrote"}, - {IO_OP_ENUMERATE, "enumerated"}, - {IO_OP_INSPECT, "inspected"} - }; - static const inline QHash ERROR_VERBS = { - {IO_OP_READ, "reading"}, - {IO_OP_WRITE, "writing"}, - {IO_OP_ENUMERATE, "enumerating"}, - {IO_OP_INSPECT, "inspecting"} - }; - static const inline QHash ERROR_INFO = { - {IO_ERR_UNKNOWN, "An unknown error has occured."}, - {IO_ERR_ACCESS_DENIED, "Access denied."}, - {IO_ERR_NOT_A_FILE, "Target is not a file."}, - {IO_ERR_NOT_A_DIR, "Target is not a directory."}, - {IO_ERR_OUT_OF_RES, "Out of resources."}, - {IO_ERR_READ, "General read error."}, - {IO_ERR_WRITE, "General write error."}, - {IO_ERR_FATAL, "A fatal error has occured."}, - {IO_ERR_OPEN, "Could not open file."}, - {IO_ERR_ABORT, "The opperation was aborted."}, - {IO_ERR_TIMEOUT, "Request timed out."}, - {IO_ERR_REMOVE, "The file could not be removed."}, - {IO_ERR_RENAME, "The file could not be renamed."}, - {IO_ERR_REPOSITION, "The file could not be moved."}, - {IO_ERR_RESIZE, "The file could not be resized."}, - {IO_ERR_COPY, "The file could not be copied."}, - {IO_ERR_FILE_DNE, "File does not exist."}, - {IO_ERR_DIR_DNE, "Directory does not exist."}, - {IO_ERR_FILE_EXISTS, "The file already exists."}, - {IO_ERR_CANT_MAKE_DIR, "The directory could not be created."}, - {IO_ERR_FILE_SIZE_MISMATCH, "File size mismatch."}, - {IO_ERR_CURSOR_OOB, "File data cursor has gone out of bounds."}, - {IO_ERR_FILE_NOT_OPEN, "The file is not open."} - }; - -//-Instance Members------------------------------------------------------------------------------------------------- -private: - bool mNull; - IOOpType mOperation; - IOOpResultType mResult; - IOOpTargetType mTargetType; - QString mTarget = QString(); - QString mOutcome = QString(); - QString mOutcomeInfo = QString(); - -//-Constructor------------------------------------------------------------------------------------------------------- -public: - IOOpReport(); - IOOpReport(IOOpType op, IOOpResultType res, const QFile& tar); - IOOpReport(IOOpType op, IOOpResultType res, const QDir& tar); - -//-Instance Functions---------------------------------------------------------------------------------------------- -private: - void parseOutcome(); - -public: - IOOpType getOperation() const; - IOOpResultType getResult() const; - IOOpTargetType getTargetType() const; - QString getTarget() const; - QString getOutcome() const; - QString getOutcomeInfo() const; - bool wasSuccessful() const; - bool isNull() const; -}; - -class TextPos -{ -//-Class Types------------------------------------------------------------------------------------------------------ -public: - static const TextPos START; - static const TextPos END; - -//-Instance Variables------------------------------------------------------------------------------------------------ -private: - int mLineNum; - int mCharNum; - -//-Constructor------------------------------------------------------------------------------------------------------- -public: - TextPos(); - TextPos(int lineNum, int charNum); - -//-Instance Functions------------------------------------------------------------------------------------------------ -public: - int getLineNum() const; - int getCharNum() const; - void setLineNum(int lineNum); - void setCharNum(int charNum); - void setNull(); - bool isNull() const; - - bool operator== (const TextPos &otherTextPos); - bool operator!= (const TextPos &otherTextPos); - bool operator> (const TextPos &otherTextPos); - bool operator>= (const TextPos &otherTextPos); - bool operator< (const TextPos &otherTextPos); - bool operator<= (const TextPos &otherTextPos); -}; - -class FileStreamWriter // Specialized wrapper for QDataStream -{ -//-Instance Variables------------------------------------------------------------------------------------------------ -private: - QDataStream mStreamWriter; - QFile& mTargetFile; - WriteMode mWriteMode; - bool mCreateDirs; - -//-Constructor------------------------------------------------------------------------------------------------------- -public: - FileStreamWriter(QFile& file, WriteMode writeMode = Append, bool createDirs = true); - -//-Instance Functions------------------------------------------------------------------------------------------------ -public: - // Stock functions - QDataStream::ByteOrder byteOrder() const; - QDataStream::FloatingPointPrecision floatingPointPrecision() const; - void resetStatus(); - void setByteOrder(QDataStream::ByteOrder bo); - void setFloatingPointPrecision(QDataStream::FloatingPointPrecision precision); - IOOpReport status(); - FileStreamWriter& writeRawData(const QByteArray& data); - - template)> - FileStreamWriter& operator<<(T d) { mStreamWriter << d; return *this; } - - // New functions - IOOpReport openFile(); - void closeFile(); -}; - -class FileStreamReader // Specialized wrapper for QDataStream -{ -//-Instance Variables------------------------------------------------------------------------------------------------ -private: - QDataStream mStreamReader; - QFile& mSourceFile; - -//-Constructor------------------------------------------------------------------------------------------------------- -public: - FileStreamReader(QFile& file); - -//-Instance Functions------------------------------------------------------------------------------------------------ -public: - // Stock functions - bool atEnd() const; - QDataStream::ByteOrder byteOrder() const; - QDataStream::FloatingPointPrecision floatingPointPrecision() const; - FileStreamReader& readRawData(QByteArray& data, int len); - void resetStatus(); - void setByteOrder(QDataStream::ByteOrder bo); - void setFloatingPointPrecision(QDataStream::FloatingPointPrecision precision); - void skipRawData(int len); - IOOpReport status(); - - template)> - FileStreamReader& operator>>(T& d) { mStreamReader >> d; return *this; } - - // New functions - IOOpReport openFile(); - void closeFile(); -}; - -class TextStreamWriter -{ -//-Instance Variables------------------------------------------------------------------------------------------------ -private: - QTextStream mStreamWriter; - QFile& mTargetFile; - WriteMode mWriteMode; - bool mCreateDirs; - bool mBuffered; - bool mAtLineStart; - -//-Constructor------------------------------------------------------------------------------------------------------- -public: - TextStreamWriter(QFile& file, WriteMode writeMode = Append, bool createDirs = true, bool buffered = true); - -//-Instance Functions------------------------------------------------------------------------------------------------ -public: - IOOpReport openFile(); - IOOpReport writeLine(QString line, bool ensureLineStart = true); - IOOpReport writeText(QString text); - void closeFile(); -}; - - -//-Variables------------------------------------------------------------------------------------------------------------ - const QString ENDL = "\n"; //Auto cross platform thanks to QIODevice::OpenMode Text - const QString LIST_ITM_PRFX = "- "; - - const QHash WRITE_OPEN_FLAGS_MAP = { - {Append, QIODevice::Append}, - {Overwrite, QIODevice::Truncate}, - {NewOnly, QIODevice::NewOnly}, - {ExistingOnly, QIODevice::ExistingOnly | QIODevice::Append} - }; - -//-Functions------------------------------------------------------------------------------------------------------------- -// General: - bool fileIsEmpty(const QFile& file); - bool fileIsEmpty(const QFile& file, IOOpReport& reportBuffer); - QString kosherizeFileName(QString fileName); - -// Text Based: - IOOpReport getLineCountOfFile(long long& returnBuffer, QFile& textFile); - IOOpReport findStringInFile(TextPos& returnBuffer, QFile& textFile, const QString& query, Qt::CaseSensitivity caseSensitivity = Qt::CaseSensitive, int hitsToSkip = 0 ); - IOOpReport findStringInFile(QList& returnBuffer, QFile& textFile, const QString& query, Qt::CaseSensitivity caseSensitivity = Qt::CaseSensitive, int hitLimit = -1); - IOOpReport fileContainsString(bool& returnBuffer, QFile& textFile, const QString& query, Qt::CaseSensitivity caseSensitivity = Qt::CaseSensitive); - IOOpReport readTextFromFile(QString& returnBuffer, QFile& textFile, TextPos textPos, int characters = -1); - IOOpReport readTextRangeFromFile(QString& returnBuffer, QFile& textFile, TextPos startPos, TextPos endPos = TextPos::END); - IOOpReport readTextFromFileByLine(QStringList& returnBuffer, QFile &textFile, int startLine = 0, int endLine = -1); - IOOpReport readAllTextFromFile(QString& returnBuffer, QFile& textFile); - IOOpReport writeStringAsFile(QFile &textFile, const QString& text, bool overwriteIfExist = false, bool createDirs = true); - IOOpReport writeStringToEndOfFile(QFile &textFile, const QString& text, bool ensureNewLine = false, bool createIfDNE = false, bool createDirs = true); // Consider making function just writeStringToFile and use TextPos with bool for overwrite vs insert - IOOpReport deleteTextRangeFromFile(QFile &textFile, TextPos startPos, TextPos endPos); - -// Directory Based: - IOOpReport getDirFileList(QStringList& returnBuffer, QDir directory, QStringList extFilter = QStringList(), QDirIterator::IteratorFlag traversalFlags = QDirIterator::NoIteratorFlags, - Qt::CaseSensitivity caseSensitivity = Qt::CaseInsensitive); - bool dirContainsFiles(QDir directory, bool includeSubdirectories = false); - bool dirContainsFiles(QDir directory, IOOpReport& reportBuffer, bool includeSubdirectories = false); - -// Integrity Based - IOOpReport calculateFileChecksum(QString& returnBuffer, QFile& file, QCryptographicHash::Algorithm hashAlgorithm); - IOOpReport fileMatchesChecksum(bool& returnBuffer, QFile& file, QString checksum, QCryptographicHash::Algorithm hashAlgorithm); - -// Raw Based - IOOpReport readAllBytesFromFile(QByteArray& returnBuffer, QFile &file); - IOOpReport readBytesFromFile(QByteArray& returnBuffer, QFile &file, long long start, long long end = -1); - IOOpReport writeBytesAsFile(QFile &file, const QByteArray &byteArray, bool overwriteIfExist = false, bool createDirs = true); -} - -#endif // IO_H diff --git a/include/qx-net.h b/include/qx-net.h deleted file mode 100644 index e72d612..0000000 --- a/include/qx-net.h +++ /dev/null @@ -1,178 +0,0 @@ -#ifndef QXNET_H -#define QXNET_H - -#include -#include -#include "qx.h" -#include "qx-io.h" - -namespace Qx -{ - -//-Structs------------------------------------------------------------------------------------------------------------ -struct DownloadTask -{ - QUrl target; - QFile* dest; - - friend bool operator== (const DownloadTask& lhs, const DownloadTask& rhs) noexcept; - friend size_t qHash(const DownloadTask& key, size_t seed) noexcept; -}; - -//-Classes------------------------------------------------------------------------------------------------------------ -class NetworkReplyError -{ -//-Instance Members---------------------------------------------------------------------------------------------- -private: - QNetworkReply::NetworkError mErrorType; - QUrl mUrl; - QString mErrorText; - -//-Constructor--------------------------------------------------------------------------------------------------- -public: - NetworkReplyError(); - NetworkReplyError(QNetworkReply* reply, QUrl url); - -//-Instance Functions-------------------------------------------------------------------------------------------- -public: - bool isValid(); - QNetworkReply::NetworkError getType(); - QUrl getUrl(); - QString getText(); -}; - -//TODO: Add AsyncDownloadManager using a finished signal instead and a dynamically managed progress output -//TODO: Potentially implement a full DownloadOpReport class similar to IOOpReport that is good for info on -// success and fail -class SyncDownloadManager: public QObject -{ -//-QObject Macro (Required for all QObject Derived Classes)----------------------------------------------------------- - Q_OBJECT - -//-Class Enums-------------------------------------------------------------------------------------------------------- -public: - enum class FinishStatus {Success, UserAbort, AutoAbort, Error}; - -//-Inner Classes------------------------------------------------------------------------------------------------------ -public: - class Report - { - //-Instance Variables--------------------------------------------------------------------------------------------- - private: - FinishStatus mFinishStatus; - GenericError mErrorInfo; - - //-Constructor------------------------------------------------------------------------------------------------------- - public: - Report(); - Report(FinishStatus finishStatus, GenericError errorInfo); - - //-Instance Functions---------------------------------------------------------------------------------------------- - public: - FinishStatus finishStatus() const; - GenericError errorInfo() const; - bool wasSuccessful() const; - }; - -//-Class Members------------------------------------------------------------------------------------------------------ -private: - // Errors - Primary - static inline const QString ERR_QUEUE_INCOMPL = "The download(s) failed to complete successfully"; - - // Errors - Secondary - static inline const QString ERR_OUTCOME_FAIL = "One or more downloads failed due to the following errors."; - static inline const QString ERR_OUTCOME_USER_ABORT = "The remaining downloads were aborted by the user."; - static inline const QString ERR_OUTCOME_AUTO_ABORT = "The remaining downloads were aborted due to previous errors."; - - // Errors - Detail - static inline const QString ERR_ENUM_TOTAL_SIZE = "[%1] Error enumerating download size"; - static inline const QString ERR_SINGLE_ABORT = "[%1] Aborted by user"; - static inline const QString ERR_GEN_FAIL = "[%1] %2"; - - // Errors - Messages - static inline const QString SSL_ERR = "The following SSL issues occured while attempting to download %1"; - static inline const QString CONTINUE_QUES = "Continue downloading?"; - static inline const QString AUTH_REQUIRED = "Authentication is required to connect to %1"; - static inline const QString PROXY_AUTH_REQUIRED = "Authentication is required to conenct to the proxy %1"; - - // Prompts - static inline const QString PROMPT_AUTH = "Authentication is required for %1"; - static inline const QString PROMPT_PROXY_AUTH = "Proxy authentication is required for %1"; - -//-Instance Members--------------------------------------------------------------------------------------------------- -private: - // Network Access - QNetworkAccessManager mDownloadAccessMan; - QNetworkAccessManager mQueryAccessMan; - - // Properties - int mMaxSimultaneous = 3; // < 1 is unlimited - QNetworkRequest::RedirectPolicy mRedirectPolicy = QNetworkRequest::NoLessSafeRedirectPolicy; // Applied to each request as well as manager because of priority levels - bool mOverwrite = false; - bool mAutoAbort = false; - - // Task tracking - QHash mReplyTaskMap; - - // Downloads - QList mPendingDownloads; - QHash> mActiveDownloads; - - // Progress - bool mDownloading = false; - Cumulation mTotalBytes; - Cumulation mCurrentBytes; - - // Synchronus elements - QEventLoop mDownloadWait; - QStringList mErrorList; - - // Status tracking - FinishStatus mFinishStatus = FinishStatus::Success; - -//-Constructor------------------------------------------------------------------------------------------------------- -public: - SyncDownloadManager(QObject* parent = nullptr); - -//-Instance Functions---------------------------------------------------------------------------------------------- -private: - NetworkReplyError enumerateTotalSize(); - NetworkReplyError getFileSize(quint64& returnBuffer, QUrl target); - IOOpReport startDownload(DownloadTask task); - void cancelAll(); - void reset(); - -public: - void appendTask(DownloadTask task); - void setMaxSimultaneous(int maxSimultaneous); - void setRedirectPolicy(QNetworkRequest::RedirectPolicy redirectPolicy); - void setOverwrite(bool overwrite); - void setAutoAbort(bool autoAbort); - Report processQueue(); - -//-Slots------------------------------------------------------------------------------------------------------------ -private slots: - void downloadProgressHandler(qint64 bytesCurrent, qint64 bytesTotal); - void downloadFinished(QNetworkReply* reply); - void readyRead(); - void sslErrorHandler(QNetworkReply* reply, const QList& errors); - void authHandler(QNetworkReply* reply, QAuthenticator* authenticator); - void proxyAuthHandler(const QNetworkProxy& proxy, QAuthenticator* authenticator); - -public slots: - void abort(); - - // TODO: Add preshared key auth support - -//-Signals------------------------------------------------------------------------------------------------------------ -signals: - void downloadProgress(qint64 bytesCurrent); - void downloadTotalChanged(quint64 bytesTotal); - - void sslErrors(Qx::GenericError errorMsg, bool* abort); - void authenticationRequired(QString prompt, QString* username, QString* password, bool* abort); -}; - -} - -#endif // QXNET_H diff --git a/include/qx-widgets.h b/include/qx-widgets.h deleted file mode 100644 index 690c386..0000000 --- a/include/qx-widgets.h +++ /dev/null @@ -1,103 +0,0 @@ -#ifndef QXWIDGETS_H -#define QXWIDGETS_H -#ifdef QT_WIDGETS_LIB // Only enabled for Widget applications - -#include -#include -#include -#include -#include - -namespace Qx -{ - -//-Classes------------------------------------------------------------------------------------------------------------ -class TreeInputDialog : public QDialog -{ -//-QObject Macro (Required for all QObject Derived Classes)----------------------------------------------------------- - Q_OBJECT - -//-Instance Members--------------------------------------------------------------------------------------------------- -private: - QTreeView* mTreeView; - QDialogButtonBox* mButtonBox; - -//-Constructor------------------------------------------------------------------------------------------------------- -public: - explicit TreeInputDialog(QWidget *parent = nullptr); - -//-Instance Functions---------------------------------------------------------------------------------------------- -public: - void setModel(QAbstractItemModel *model); - -//-Signals--------------------------------------------------------------------------------------------------------- -signals: - void selectAllClicked(); - void selectNoneClicked(); -}; - -class LoginDialog : public QDialog -{ -//-QObject Macro (Required for all QObject Derived Classes)----------------------------------------------------------- - Q_OBJECT - -//-Class Members------------------------------------------------------------------------------------------------------- -private: - static inline const QString LABEL_DEF_PRMT= "Login Required"; - static inline const QString LABEL_USRNAME = "&Username"; - static inline const QString LABEL_PSSWD = "&Password"; - -//-Instance Members--------------------------------------------------------------------------------------------------- -private: - QLabel* mPromptLabel; - QLabel* mUsernameLabel; - QLabel* mPasswordLabel; - QLineEdit* mUsernameLineEdit; - QLineEdit* mPasswordLineEdit; - QDialogButtonBox* mButtonBox; - -//-Constructor------------------------------------------------------------------------------------------------------- -public: - explicit LoginDialog(QWidget *parent = nullptr, QString prompt = LABEL_DEF_PRMT); - -//-Instance Functions---------------------------------------------------------------------------------------------- -public: - void setPrompt(QString prompt); - QString getUsername(); - QString getPassword(); - -//-Slots---------------------------------------------------------------------------------------------------------- -private slots: - void acceptHandler(); - void rejectHandler(); -}; - -class StandardItemModelX : public QStandardItemModel -{ -//-Instance Members--------------------------------------------------------------------------------------------------- -private: - bool mUpdatingParentTristate = false; - bool mAutoTristate = false; - -//-Constructor------------------------------------------------------------------------------------------------------- -public: - StandardItemModelX(); - -//-Instance Functions---------------------------------------------------------------------------------------------- -public: - void autoTristateChildren(QStandardItem* changingItem, const QVariant & value, int role); - void autoTristateParents(QStandardItem* changingItem, const QVariant & changingValue); - -public: - virtual bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole); - bool isAutoTristate(); - void setAutoTristate(bool autoTristate); - void forEachItem(std::function const& func, QModelIndex parent = QModelIndex()); - - void selectAll(); - void selectNone(); -}; - -} -#endif -#endif // S_H diff --git a/include/qx-windows.h b/include/qx-windows.h deleted file mode 100644 index 0572e3f..0000000 --- a/include/qx-windows.h +++ /dev/null @@ -1,244 +0,0 @@ -#ifndef QXWINDOWS_H -#define QXWINDOWS_H -#include "Windows.h" -#include "qx.h" -#include - -namespace Qx -{ - -//-Structs--------------------------------------------------------------------------------------------------------------- -struct ShortcutProperties -{ - enum ShowMode { - NORMAL = SW_SHOWNORMAL, - MAXIMIZED = SW_SHOWMAXIMIZED, - MINIMIZED = SW_SHOWMINIMIZED - }; - - QString target; - QString targetArgs; - QString startIn; - QString comment; - QString iconFilePath; - int iconIndex = 0; - ShowMode showMode = NORMAL; -}; - -//-Classes--------------------------------------------------------------------------------------------------------------- -class FileDetails -{ -//-Friends--------------------------------------------------------------------------------------------------------------- -friend FileDetails getFileDetails(QString filePath); - -//-Inner Enums----------------------------------------------------------------------------------------------------------- -public: - enum FileFlag { - FF_NONE = 0x00, - FF_DEBUG = 0x01, - FF_INFOINFERRED = 0x02, - FF_PATCHED = 0x04, - FF_PRERELEASE = 0x08, - FF_PRIVATEBUILD = 0x10, - FF_SPECIALBUILD = 0x20 - }; - Q_DECLARE_FLAGS(FileFlags, FileFlag) - - enum TargetSystem { - TS_NONE = 0x000, - TS_DOS = 0x001, - TS_NT = 0x002, - TS_WINDOWS16 = 0x004, - TS_WINDOWS32 = 0x008, - TS_OS216 = 0x010, - TS_OS232 = 0x020, - TS_PM16 = 0x040, - TS_PM32 = 0x080, - TS_UNK = 0x100, - TS_DOS_WINDOWS16 = TS_DOS | TS_WINDOWS16, - TS_DOS_WINDOWS32 = TS_DOS | TS_WINDOWS32, - TS_NT_WINDOWS32 = TS_NT | TS_WINDOWS32, - TS_OS216_PM16 = TS_OS216 | TS_PM16, - TS_OS232_PM32 = TS_OS232 | TS_PM32 - }; - Q_DECLARE_FLAGS(TargetSystems, TargetSystem) - - enum FileType { - FT_NONE = 0x00, - FT_APP = 0x01, - FT_DLL = 0x02, - FT_DRV = 0x04, - FT_FONT = 0x08, - FT_STATIC_LIB = 0x10, - FT_VXD = 0x20, - FT_UNK = 0x40 - }; - Q_DECLARE_FLAGS(FileTypes, FileType) - - enum FileSubType { - FST_NONE = 0x00, - FST_DRV_COMM = 0x01, - FST_DRV_DISPLAY = 0x02, - FST_DRV_INSTALLABLE = 0x04, - FST_DRV_KEYBOARD = 0x08, - FST_DRV_LANGUAGE = 0x10, - FST_DRV_MOUSE = 0x20, - FST_DRV_NETWORK = 0x40, - FST_DRV_PRINTER = 0x80, - FST_DRV_SOUND = 0x100, - FST_DRV_SYSTEM = 0x200, - FST_DRV_VER_PRINTER = 0x400, - FST_FONT_RASTER = 0x800, - FST_FONT_TRUETYPE = 0x1000, - FST_FONT_VECTOR = 0x2000, - FST_VXD_ID = 0x4000, - FST_UNK = 0x8000 - }; - Q_DECLARE_FLAGS(FileSubTypes, FileSubType) - -//-Inner Structs--------------------------------------------------------------------------------------------------------- -public: - struct StringTable - { - QString metaLanguageID; - QString metaCodePageID; - QString comments; - QString companyName; - QString fileDescription; - QString fileVersion; - QString internalName; - QString legalCopyright; - QString legalTrademarks; - QString originalFilename; - QString productName; - QString productVersion; - QString privateBuild; - QString specialBuild; - }; - -//-Class Members---------------------------------------------------------------------------------------------------- -private: - static inline const QString LANG_CODE_PAGE_QUERY = "\\VarFileInfo\\Translation"; - static inline const QString SUB_BLOCK_BASE_TEMPLATE = "\\StringFileInfo\\%1%2\\"; - static inline const QString ST_COMMENTS_QUERY = "Comments"; - static inline const QString ST_COMPANY_NAME_QUERY = "CompanyName"; - static inline const QString ST_FILE_DESCRIPTION_QUERY = "FileDescription"; - static inline const QString ST_FILE_VERSION_QUERY = "FileVersion"; - static inline const QString ST_INTERNAL_NAME_QUERY = "InternalName"; - static inline const QString ST_LEGAL_COPYRIGHT_QUERY = "LegalCopyright"; - static inline const QString ST_LEGAL_TRADEMARKS_QUERY = "LegalTrademarks"; - static inline const QString ST_ORIGINAL_FILENAME_QUERY = "OriginalFilename"; - static inline const QString ST_PRODUCT_NAME_QUERY = "ProductName"; - static inline const QString ST_PRODUCT_VERSION_QUERY = "ProductVersion"; - static inline const QString ST_PRIVATE_BUILD_QUERY = "PrivateBuild"; - static inline const QString ST_SPECIAL_BUILD_QUERY = "SpecialBuild"; - - static inline const QHash FILE_FLAG_MAP{{VS_FF_DEBUG, FF_DEBUG}, - {VS_FF_INFOINFERRED, FF_INFOINFERRED}, - {VS_FF_PATCHED, FF_PATCHED}, - {VS_FF_PRERELEASE, FF_PRERELEASE}, - {VS_FF_PRIVATEBUILD, FF_PRIVATEBUILD}, - {VS_FF_SPECIALBUILD, FF_SPECIALBUILD}}; - - static inline const QHash TARGET_SYSTEM_MAP{{VOS_DOS, TS_DOS}, - {VOS_NT, TS_NT}, - {VOS__WINDOWS16, TS_WINDOWS16}, - {VOS__WINDOWS32, TS_WINDOWS32}, - {VOS_OS216, TS_OS216}, - {VOS_OS232, TS_OS232}, - {VOS__PM16, TS_PM16}, - {VOS__PM32, TS_PM32}, - {VOS_UNKNOWN, TS_UNK}}; - - static inline const QHash FILE_TYPE_MAP{{VFT_APP, FT_APP}, - {VFT_DLL, FT_DLL}, - {VFT_DRV, FT_DRV}, - {VFT_FONT, FT_FONT}, - {VFT_STATIC_LIB, FT_STATIC_LIB}, - {VFT_UNKNOWN, FT_VXD}, - {VFT_VXD, FT_UNK}}; - - static inline const QHash, FileSubType> FILE_SUB_TYPE_MAP{{qMakePair(VFT_DRV, VFT2_DRV_COMM), FST_DRV_COMM}, - {qMakePair(VFT_DRV, VFT2_DRV_DISPLAY), FST_DRV_DISPLAY}, - {qMakePair(VFT_DRV, VFT2_DRV_INSTALLABLE), FST_DRV_INSTALLABLE}, - {qMakePair(VFT_DRV, VFT2_DRV_KEYBOARD), FST_DRV_KEYBOARD}, - {qMakePair(VFT_DRV, VFT2_DRV_LANGUAGE), FST_DRV_LANGUAGE}, - {qMakePair(VFT_DRV, VFT2_DRV_MOUSE), FST_DRV_MOUSE}, - {qMakePair(VFT_DRV, VFT2_DRV_NETWORK), FST_DRV_NETWORK}, - {qMakePair(VFT_DRV, VFT2_DRV_PRINTER), FST_DRV_PRINTER}, - {qMakePair(VFT_DRV, VFT2_DRV_SOUND), FST_DRV_SOUND}, - {qMakePair(VFT_DRV, VFT2_DRV_SYSTEM), FST_DRV_SYSTEM}, - {qMakePair(VFT_DRV, VFT2_DRV_VERSIONED_PRINTER), FST_DRV_VER_PRINTER}, - {qMakePair(VFT_DRV, VFT2_UNKNOWN), FST_UNK}, - {qMakePair(VFT_FONT, VFT2_FONT_RASTER), FST_FONT_RASTER}, - {qMakePair(VFT_FONT, VFT2_FONT_TRUETYPE), FST_FONT_TRUETYPE}, - {qMakePair(VFT_FONT, VFT2_FONT_VECTOR), FST_FONT_VECTOR}, - {qMakePair(VFT_FONT, VFT2_UNKNOWN), FST_UNK}}; - -//-Instance Members------------------------------------------------------------------------------------------------- -private: - MMRB mMetaStructVersion; - MMRB mFileVersion; - MMRB mProductVersion; - FileFlags mFileFlags = FF_NONE; - TargetSystems mTargetSystems = TS_NONE; - FileType mFileType = FT_NONE; - FileSubType mFileSubType = FST_NONE; - int mVirtualDeviceID = -1; - QList mStringTables; - QHash, int> mLangCodePageMap; - -//-Constructor------------------------------------------------------------------------------------------------------- -public: - FileDetails(); - -//-Instance Functions---------------------------------------------------------------------------------------------- -private: - void addStringTable(StringTable stringTable); - -public: - bool isNull(); - int stringTableCount(); - QList> availableLangCodePages(); - bool hasLangCodePage(QString lanuage, QString codePage); - MMRB metaStructVersion(); - - MMRB getFileVersion(); - MMRB getProductVersion(); - FileFlags getFileFlags(); - TargetSystems getTargetSystems(); - FileType getFileType(); - FileSubType getFileSubType(); - int getVirtualDeviceID(); - const StringTable getStringTable(int index = 0); - const StringTable getStringTable(QString language, QString codePage); -}; - -//-Functions------------------------------------------------------------------------------------------------------------- - -// Files -FileDetails getFileDetails(QString filePath); - -// Processes -DWORD getProcessIDByName(QString processName); -QString getProcessNameByID(DWORD processID); -bool processIsRunning(QString processName); -bool processIsRunning(DWORD processID); -bool enforceSingleInstance(); - -// Error codes -Qx::GenericError translateHresult(HRESULT res); -Qx::GenericError translateNtstatus(NTSTATUS stat); - -// Filesystem -Qx::GenericError createShortcut(QString shortcutPath, ShortcutProperties sp); - -} - -//-Qt Flag Operators----------------------------------------------------------------------------------------------------- -Q_DECLARE_OPERATORS_FOR_FLAGS(Qx::FileDetails::FileFlags) -Q_DECLARE_OPERATORS_FOR_FLAGS(Qx::FileDetails::TargetSystems) -Q_DECLARE_OPERATORS_FOR_FLAGS(Qx::FileDetails::FileTypes) -Q_DECLARE_OPERATORS_FOR_FLAGS(Qx::FileDetails::FileSubTypes) - -#endif // QXWINDOWS_H diff --git a/include/qx-xml.h b/include/qx-xml.h deleted file mode 100644 index 948c084..0000000 --- a/include/qx-xml.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef QXXML_H -#define QXXML_H - -#include -#include - -namespace Qx -{ - -class XmlStreamWriterError -{ -//-Instance Members---------------------------------------------------------------------------------------------- -private: - QString mErrorText; - -//-Constructor--------------------------------------------------------------------------------------------------- -public: - XmlStreamWriterError(); - XmlStreamWriterError(QString errorText); - -//-Instance Functions-------------------------------------------------------------------------------------------- -public: - bool isValid(); - QString getText(); -}; - -class XmlStreamReaderError -{ -//-Class Members-------------------------------------------------------------------------------------------------- -private: - static inline const QHash STD_ERR_TXT = { - {QXmlStreamReader::NoError, "No error has occured."}, - {QXmlStreamReader::CustomError, "A custom error has been raised with raiseError()."}, - {QXmlStreamReader::NotWellFormedError, "The parser internally raised an error due to the read XML not being well-formed."}, - {QXmlStreamReader::PrematureEndOfDocumentError, "The input stream ended before a well-formed XML document was parsed."}, - {QXmlStreamReader::UnexpectedElementError, "The parser encountered an element that was different to those it expected."} - }; - - //TODO: Because of the missed errorString() method that is part of QIODevice, this hash isn't needed (is this true?) - -//-Instance Members---------------------------------------------------------------------------------------------- -private: - QXmlStreamReader::Error mErrorType; - QString mErrorText; - -//-Constructor--------------------------------------------------------------------------------------------------- -public: - XmlStreamReaderError(); - XmlStreamReaderError(QXmlStreamReader::Error standardError); - XmlStreamReaderError(QString customError); - -//-Instance Functions-------------------------------------------------------------------------------------------- -public: - bool isValid(); - QXmlStreamReader::Error getType(); - QString getText(); -}; - -//-Functions------------------------------------------------------------------------------------------------------------- -//Public: -QString xmlSanitized(QString string); - -} - -#endif // QXXML_H diff --git a/include/qx.h b/include/qx.h deleted file mode 100644 index b7727e0..0000000 --- a/include/qx.h +++ /dev/null @@ -1,1031 +0,0 @@ -#ifndef QX_H -#define QX_H - -#define ENABLE_IF(...) std::enable_if_t<__VA_ARGS__::value, int> = 0 // enable_if Macro; allows ENABLE_IF(std::is_arithmetic) for example -#define ENABLE_IF2(...) std::enable_if_t<__VA_ARGS__::value, int> // enable_if Macro with no default argument, use if template was already forward declared - -#ifdef QT_WIDGETS_LIB // Only enabled for Widget applications -#include -#include -#endif - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include "assert.h" - -//-Non-namspace Functions------------------------------------------------------------------------------------------------- -template -const T qAsConstR(T &&t) { return std::move(t); } - -namespace Qx -{ -//-std::functional Extensions----------------------------------------------------------------------------------- -struct left_shift { - - template - constexpr auto operator()(L&& l, R&& r) const - noexcept(noexcept(std::forward(l) << std::forward(r))) - -> decltype(std::forward(l) << std::forward(r)) - { - return std::forward(l) << std::forward(r); - } -}; - -struct right_shift { - - template - constexpr auto operator()(L&& l, R&& r) const - noexcept(noexcept(std::forward(l) >> std::forward(r))) - -> decltype(std::forward(l) >> std::forward(r)) - { - return std::forward(l) >> std::forward(r); - } -}; - -//-Traits------------------------------------------------------------------------------------------------------- -// TODO: Get these working where they make sense -//template class Template> -//struct is_specialization : std::false_type {}; - -//template