drop Qt4 support, move Source files and few other changes
This commit is contained in:
parent
d7b28c2468
commit
e463d2d22c
165 changed files with 114 additions and 6133 deletions
33
.ci/app.rc
33
.ci/app.rc
|
@ -1,33 +0,0 @@
|
||||||
IDI_ICON1 ICON DISCARDABLE "5sync.ico"
|
|
||||||
#define RT_MANIFEST 24
|
|
||||||
#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1
|
|
||||||
CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "gta5view.exe.manifest"
|
|
||||||
#include <windows.h>
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
|
||||||
FILEVERSION MAJOR_VER, MINOR_VER, PATCH_VER, INT_BUILD_VER
|
|
||||||
PRODUCTVERSION MAJOR_VER, MINOR_VER, PATCH_VER, INT_BUILD_VER
|
|
||||||
FILEFLAGSMASK 0x3fL
|
|
||||||
FILEFLAGS 0
|
|
||||||
FILEOS VOS_NT_WINDOWS32
|
|
||||||
FILETYPE VFT_APP
|
|
||||||
FILESUBTYPE VFT2_UNKNOWN
|
|
||||||
BEGIN
|
|
||||||
BLOCK "VarFileInfo"
|
|
||||||
BEGIN
|
|
||||||
VALUE "Translation", 0x0809, 1200
|
|
||||||
END
|
|
||||||
BLOCK "StringFileInfo"
|
|
||||||
BEGIN
|
|
||||||
BLOCK "040904b0"
|
|
||||||
BEGIN
|
|
||||||
VALUE "CompanyName", "Syping"
|
|
||||||
VALUE "FileDescription", "gta5view"
|
|
||||||
VALUE "FileVersion", "MAJOR_VER.MINOR_VER.PATCH_VERSTR_BUILD_VER"
|
|
||||||
VALUE "InternalName", "gta5view"
|
|
||||||
VALUE "LegalCopyright", "Copyright © 2016-2022 Syping"
|
|
||||||
VALUE "OriginalFilename", "gta5view.exe"
|
|
||||||
VALUE "ProductName", "gta5view"
|
|
||||||
VALUE "ProductVersion", "MAJOR_VER.MINOR_VER.PATCH_VERSTR_BUILD_VER"
|
|
||||||
END
|
|
||||||
END
|
|
||||||
END
|
|
72
.ci/ci.sh
72
.ci/ci.sh
|
@ -1,72 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
if [ $(git name-rev --tags --name-only $(git rev-parse HEAD)) == "undefined" ]; then
|
|
||||||
export APPLICATION_VERSION=$(lua -e 'for line in io.lines("config.h") do local m = string.match(line, "#define GTA5SYNC_APPVER \"(.+)\"$"); if m then print(m); os.exit(0) end end')
|
|
||||||
else
|
|
||||||
export APPLICATION_VERSION=$(git name-rev --tags --name-only $(git rev-parse HEAD))
|
|
||||||
fi
|
|
||||||
export PACKAGE_VERSION=$(grep -oE '^[^\-]*' <<< $APPLICATION_VERSION)
|
|
||||||
export PACKAGE_BUILD=$(grep -oP '\-\K.+' <<< $APPLICATION_VERSION)
|
|
||||||
export EXECUTABLE_VERSION=${PACKAGE_VERSION}${PACKAGE_BUILD}${EXECUTABLE_TAG}
|
|
||||||
|
|
||||||
export APPLICATION_MAJOR_VERSION=$(cut -d. -f1 <<< $APPLICATION_VERSION)
|
|
||||||
export APPLICATION_MINOR_VERSION=$(cut -d. -f2 <<< $APPLICATION_VERSION)
|
|
||||||
export APPLICATION_PATCH_VERSION=$(cut -d. -f3 <<< $APPLICATION_VERSION)
|
|
||||||
|
|
||||||
if [ "${PACKAGE_BUILD}" == "" ]; then
|
|
||||||
export PACKAGE_BUILD=1
|
|
||||||
else
|
|
||||||
export APPLICATION_BUILD_INT_VERSION=$(grep -oE '[1-9]*$' <<< $PACKAGE_BUILD)
|
|
||||||
export APPLICATION_BUILD_STR_VERSION=-${PACKAGE_BUILD}
|
|
||||||
fi
|
|
||||||
|
|
||||||
cat ".ci/app.rc" | sed \
|
|
||||||
-e "s/MAJOR_VER/$APPLICATION_MAJOR_VERSION/g" \
|
|
||||||
-e "s/MINOR_VER/$APPLICATION_MINOR_VERSION/g" \
|
|
||||||
-e "s/PATCH_VER/$APPLICATION_PATCH_VERSION/g" \
|
|
||||||
-e "s/INT_BUILD_VER/0/g" \
|
|
||||||
-e "s/STR_BUILD_VER/$APPLICATION_BUILD_STR_VERSION/g" \
|
|
||||||
-e "s/STR_BUILD_VER/$APPLICATION_BUILD_STR_VERSION/g" \
|
|
||||||
> "res/app.rc"
|
|
||||||
|
|
||||||
if [ "${BUILD_TYPE}" == "ALPHA" ]; then
|
|
||||||
export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE=Alpha"
|
|
||||||
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE=\\\\\\\"Alpha\\\\\\\""
|
|
||||||
elif [ "${BUILD_TYPE}" == "Alpha" ]; then
|
|
||||||
export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE=Alpha"
|
|
||||||
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE=\\\\\\\"Alpha\\\\\\\""
|
|
||||||
elif [ "${BUILD_TYPE}" == "BETA" ]; then
|
|
||||||
export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE=Beta"
|
|
||||||
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE=\\\\\\\"Beta\\\\\\\""
|
|
||||||
elif [ "${BUILD_TYPE}" == "Beta" ]; then
|
|
||||||
export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE=Beta"
|
|
||||||
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE=\\\\\\\"Beta\\\\\\\""
|
|
||||||
elif [ "${BUILD_TYPE}" == "DEV" ]; then
|
|
||||||
export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE=Developer"
|
|
||||||
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE=\\\\\\\"Developer\\\\\\\""
|
|
||||||
elif [ "${BUILD_TYPE}" == "Development" ]; then
|
|
||||||
export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE=Developer"
|
|
||||||
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE=\\\\\\\"Developer\\\\\\\""
|
|
||||||
elif [ "${BUILD_TYPE}" == "DAILY" ]; then
|
|
||||||
export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE=Daily Build"
|
|
||||||
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE=\\\\\\\"Daily Build\\\\\\\""
|
|
||||||
elif [ "${BUILD_TYPE}" == "Daily" ]; then
|
|
||||||
export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE=Daily Build"
|
|
||||||
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE=\\\\\\\"Daily Build\\\\\\\""
|
|
||||||
elif [ "${BUILD_TYPE}" == "RC" ]; then
|
|
||||||
export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE=Release Candidate"
|
|
||||||
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE=\\\\\\\"Release Candidate\\\\\\\""
|
|
||||||
elif [ "${BUILD_TYPE}" == "Release Candidate" ]; then
|
|
||||||
export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE=Release Candidate"
|
|
||||||
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE=\\\\\\\"Release Candidate\\\\\\\""
|
|
||||||
elif [ "${BUILD_TYPE}" == "REL" ]; then
|
|
||||||
export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE=Release"
|
|
||||||
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE=\\\\\\\"Release\\\\\\\""
|
|
||||||
elif [ "${BUILD_TYPE}" == "Release" ]; then
|
|
||||||
export CMAKE_BUILD_TYPE="-DGTA5VIEW_BUILDTYPE=Release"
|
|
||||||
export QMAKE_BUILD_TYPE="DEFINES+=GTA5SYNC_BUILDTYPE=\\\\\\\"Release\\\\\\\""
|
|
||||||
fi
|
|
||||||
|
|
||||||
export PROJECT_DIR=$(pwd)
|
|
||||||
|
|
||||||
.ci/${BUILD_SCRIPT}
|
|
|
@ -1,38 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# Creating folders
|
|
||||||
cd ${PROJECT_DIR} && \
|
|
||||||
echo "gta5view build version is ${APPLICATION_VERSION}" && \
|
|
||||||
mkdir -p build && \
|
|
||||||
mkdir -p assets && \
|
|
||||||
chmod -x res/gta5sync_*.qm res/*.desktop res/*gta5view*.png && \
|
|
||||||
cd build && \
|
|
||||||
mkdir -p qt5 && \
|
|
||||||
cd qt5 && \
|
|
||||||
echo "Grand Theft Auto V Snapmatic and Savegame viewer/editor" > ./description-pak && \
|
|
||||||
cd .. && \
|
|
||||||
|
|
||||||
# Set compiler
|
|
||||||
export CC=clang && \
|
|
||||||
export CXX=clang++ && \
|
|
||||||
|
|
||||||
# Prepare checkinstall step
|
|
||||||
mkdir -p /usr/share/gta5view && \
|
|
||||||
|
|
||||||
# Starting build
|
|
||||||
cd qt5 && \
|
|
||||||
cmake \
|
|
||||||
"-DCMAKE_INSTALL_PREFIX=/usr" \
|
|
||||||
"${CMAKE_BUILD_TYPE}" \
|
|
||||||
"-DFORCE_QT_VERSION=5" \
|
|
||||||
"-DGTA5VIEW_BUILDCODE=${PACKAGE_CODE}" \
|
|
||||||
"-DGTA5VIEW_APPVER=${APPLICATION_VERSION}" \
|
|
||||||
"-DGTA5VIEW_COMMIT=${APPLICATION_COMMIT}" \
|
|
||||||
"-DWITH_DONATE=ON" \
|
|
||||||
"-DWITH_TELEMETRY=ON" \
|
|
||||||
"-DDONATE_ADDRESSES=$(cat ${PROJECT_DIR}/.ci/donate.txt)" \
|
|
||||||
"-DTELEMETRY_WEBURL=https://dev.syping.de/gta5view-userstats/" \
|
|
||||||
"-DQCONF_BUILD=ON" \
|
|
||||||
../../ && \
|
|
||||||
make -j 4 && \
|
|
||||||
checkinstall -D --default --nodoc --install=no --pkgname=gta5view --pkgversion=${PACKAGE_VERSION} --pkgrelease=${PACKAGE_BUILD} --pkggroup=utility --maintainer="Syping \<dpkg@syping.de\>" --requires=libqt5core5a,libqt5gui5,libqt5network5,libqt5svg5,libqt5widgets5,qttranslations5-l10n --conflicts=gta5view-qt4,gta5view-qt5 --replaces=gta5view-qt4,gta5view-qt5 --pakdir=${PROJECT_DIR}/assets
|
|
|
@ -1,8 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# Install packages
|
|
||||||
.ci/debian_install.sh && \
|
|
||||||
|
|
||||||
# Build gta5view
|
|
||||||
.ci/debian_build.sh && \
|
|
||||||
cd ${PROJECT_DIR}
|
|
|
@ -1,15 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
if [ "${DOCKER_USER}" != "" ]; then
|
|
||||||
DOCKER_IMAGE=${DOCKER_USER}/debian:${DEBIAN_VERSION}
|
|
||||||
else
|
|
||||||
DOCKER_IMAGE=debian:${DEBIAN_VERSION}
|
|
||||||
fi
|
|
||||||
PROJECT_DIR_DOCKER=/gta5view
|
|
||||||
|
|
||||||
cd ${PROJECT_DIR} && \
|
|
||||||
docker pull ${DOCKER_IMAGE} && \
|
|
||||||
docker run --rm \
|
|
||||||
-v "${PROJECT_DIR}:${PROJECT_DIR_DOCKER}" \
|
|
||||||
${DOCKER_IMAGE} \
|
|
||||||
/bin/bash -c "export PROJECT_DIR=${PROJECT_DIR_DOCKER} && export QT_SELECT=${QT_SELECT} && export APPLICATION_VERSION=${APPLICATION_VERSION} && export APPLICATION_COMMIT=${APPLICATION_COMMIT} && export BUILD_TYPE=${BUILD_TYPE} && export APT_INSTALL=${APT_INSTALL} && export QMAKE_FLAGS_QT4=${QMAKE_FLAGS_QT4} && export QMAKE_FLAGS_QT5=${QMAKE_FLAGS_QT5} && export CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} && export QMAKE_BUILD_TYPE=${QMAKE_BUILD_TYPE} && export PACKAGE_VERSION=${PACKAGE_VERSION} && export PACKAGE_BUILD=${PACKAGE_BUILD} && export PACKAGE_CODE=${PACKAGE_CODE} && export EXECUTABLE_VERSION=${EXECUTABLE_VERSION} && export EXECUTABLE_ARCH=${EXECUTABLE_ARCH} && cd ${PROJECT_DIR_DOCKER} && .ci/debian_install.sh && .ci/debian_build.sh"
|
|
|
@ -1,13 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# Source OS Release
|
|
||||||
source /etc/os-release
|
|
||||||
|
|
||||||
# When Debian add backports
|
|
||||||
if [ "${ID}" == "debian" ]; then
|
|
||||||
echo "deb http://deb.debian.org/debian ${VERSION_CODENAME}-backports main" >> /etc/apt/sources.list
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Install packages
|
|
||||||
apt-get update -qq && \
|
|
||||||
apt-get install -qq ${APT_INSTALL} checkinstall cmake dpkg-dev fakeroot g++ gcc qtbase5-dev qt5-qmake qttranslations5-l10n libqt5svg5-dev
|
|
File diff suppressed because it is too large
Load diff
364
.ci/gta5view.nsi
364
.ci/gta5view.nsi
|
@ -1,364 +0,0 @@
|
||||||
######################################################################
|
|
||||||
|
|
||||||
!define APP_NAME "gta5view"
|
|
||||||
!define APP_EXT ".g5e"
|
|
||||||
!define COMP_NAME "Syping"
|
|
||||||
!define WEB_SITE "https://gta5view.syping.de/"
|
|
||||||
!define VERSION "1.10.1.1"
|
|
||||||
!define COPYRIGHT "Copyright © 2016-2022 Syping"
|
|
||||||
!define DESCRIPTION "Open Source Snapmatic and Savegame viewer/editor for GTA V"
|
|
||||||
!define INSTALLER_NAME "gta5view_setup.exe"
|
|
||||||
!define MAIN_APP_EXE "gta5view.exe"
|
|
||||||
!define INSTALL_TYPE "SetShellVarContext all"
|
|
||||||
!define REG_ROOT "HKLM"
|
|
||||||
!define REG_APP_PATH "Software\Microsoft\Windows\CurrentVersion\App Paths\${MAIN_APP_EXE}"
|
|
||||||
!define UNINSTALL_PATH "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}"
|
|
||||||
!define LICENSE_TXT "../LICENSE"
|
|
||||||
|
|
||||||
######################################################################
|
|
||||||
|
|
||||||
VIProductVersion "${VERSION}"
|
|
||||||
VIAddVersionKey "ProductName" "${APP_NAME}"
|
|
||||||
VIAddVersionKey "ProductVersion" "${VERSION}"
|
|
||||||
VIAddVersionKey "CompanyName" "${COMP_NAME}"
|
|
||||||
VIAddVersionKey "LegalCopyright" "${COPYRIGHT}"
|
|
||||||
VIAddVersionKey "FileDescription" "${DESCRIPTION}"
|
|
||||||
VIAddVersionKey "FileVersion" "${VERSION}"
|
|
||||||
|
|
||||||
######################################################################
|
|
||||||
|
|
||||||
!include "x64.nsh"
|
|
||||||
SetCompressor LZMA
|
|
||||||
Name "${APP_NAME}"
|
|
||||||
Caption "${APP_NAME}"
|
|
||||||
OutFile "${INSTALLER_NAME}"
|
|
||||||
#BrandingText "${APP_NAME}"
|
|
||||||
XPStyle on
|
|
||||||
Unicode true
|
|
||||||
InstallDirRegKey "${REG_ROOT}" "${REG_APP_PATH}" ""
|
|
||||||
InstallDir "$PROGRAMFILES64\Syping\gta5view"
|
|
||||||
|
|
||||||
######################################################################
|
|
||||||
|
|
||||||
!include "MUI2.nsh"
|
|
||||||
|
|
||||||
!define MUI_ABORTWARNING
|
|
||||||
!define MUI_UNABORTWARNING
|
|
||||||
|
|
||||||
!define MUI_LANGDLL_REGISTRY_ROOT "${REG_ROOT}"
|
|
||||||
!define MUI_LANGDLL_REGISTRY_KEY "${UNINSTALL_PATH}"
|
|
||||||
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
|
|
||||||
|
|
||||||
!insertmacro MUI_PAGE_WELCOME
|
|
||||||
|
|
||||||
!ifdef LICENSE_TXT
|
|
||||||
!insertmacro MUI_PAGE_LICENSE "${LICENSE_TXT}"
|
|
||||||
!endif
|
|
||||||
|
|
||||||
!insertmacro MUI_PAGE_DIRECTORY
|
|
||||||
|
|
||||||
!ifdef REG_START_MENU
|
|
||||||
!define MUI_STARTMENUPAGE_NODISABLE
|
|
||||||
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "gta5view"
|
|
||||||
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "${REG_ROOT}"
|
|
||||||
!define MUI_STARTMENUPAGE_REGISTRY_KEY "${UNINSTALL_PATH}"
|
|
||||||
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${REG_START_MENU}"
|
|
||||||
!insertmacro MUI_PAGE_STARTMENU Application $SM_Folder
|
|
||||||
!endif
|
|
||||||
|
|
||||||
!insertmacro MUI_PAGE_INSTFILES
|
|
||||||
|
|
||||||
!define MUI_FINISHPAGE_RUN "$INSTDIR\${MAIN_APP_EXE}"
|
|
||||||
!insertmacro MUI_PAGE_FINISH
|
|
||||||
|
|
||||||
!insertmacro MUI_UNPAGE_CONFIRM
|
|
||||||
|
|
||||||
!insertmacro MUI_UNPAGE_INSTFILES
|
|
||||||
|
|
||||||
!insertmacro MUI_UNPAGE_FINISH
|
|
||||||
|
|
||||||
!insertmacro MUI_LANGUAGE "English"
|
|
||||||
!insertmacro MUI_LANGUAGE "French"
|
|
||||||
!insertmacro MUI_LANGUAGE "German"
|
|
||||||
!insertmacro MUI_LANGUAGE "Korean"
|
|
||||||
!insertmacro MUI_LANGUAGE "Russian"
|
|
||||||
!insertmacro MUI_LANGUAGE "Ukrainian"
|
|
||||||
!insertmacro MUI_LANGUAGE "TradChinese"
|
|
||||||
|
|
||||||
!insertmacro MUI_RESERVEFILE_LANGDLL
|
|
||||||
|
|
||||||
######################################################################
|
|
||||||
|
|
||||||
Function .onInit
|
|
||||||
!insertmacro MUI_LANGDLL_DISPLAY
|
|
||||||
!ifdef WIN32
|
|
||||||
MessageBox MB_OK|MB_ICONSTOP "Windows 32-Bit is not supported anymore!"
|
|
||||||
Quit
|
|
||||||
!endif
|
|
||||||
SetRegView 64
|
|
||||||
FunctionEnd
|
|
||||||
|
|
||||||
######################################################################
|
|
||||||
|
|
||||||
Section -MainProgram
|
|
||||||
${INSTALL_TYPE}
|
|
||||||
SetOverwrite ifnewer
|
|
||||||
SetOutPath "$INSTDIR"
|
|
||||||
File "../build/gta5view.exe"
|
|
||||||
File "/opt/llvm-mingw/x86_64-w64-mingw32/bin/libc++.dll"
|
|
||||||
File "/opt/llvm-mingw/x86_64-w64-mingw32/bin/libunwind.dll"
|
|
||||||
File "/usr/local/lib/x86_64-w64-mingw32/openssl/bin/libcrypto-1_1-x64.dll"
|
|
||||||
File "/usr/local/lib/x86_64-w64-mingw32/openssl/bin/libssl-1_1-x64.dll"
|
|
||||||
File "/usr/local/lib/x86_64-w64-mingw32/qt5/bin/Qt5Core.dll"
|
|
||||||
File "/usr/local/lib/x86_64-w64-mingw32/qt5/bin/Qt5Gui.dll"
|
|
||||||
File "/usr/local/lib/x86_64-w64-mingw32/qt5/bin/Qt5Network.dll"
|
|
||||||
File "/usr/local/lib/x86_64-w64-mingw32/qt5/bin/Qt5Svg.dll"
|
|
||||||
File "/usr/local/lib/x86_64-w64-mingw32/qt5/bin/Qt5Widgets.dll"
|
|
||||||
SetOutPath "$INSTDIR\lang"
|
|
||||||
File "../build/gta5sync_en_US.qm"
|
|
||||||
File "../build/gta5sync_de.qm"
|
|
||||||
File "../build/gta5sync_fr.qm"
|
|
||||||
File "../build/gta5sync_ko.qm"
|
|
||||||
File "../build/gta5sync_ru.qm"
|
|
||||||
File "../build/gta5sync_uk.qm"
|
|
||||||
File "../build/gta5sync_zh_TW.qm"
|
|
||||||
File "../build/qtbase_en_GB.qm"
|
|
||||||
File "../res/qt5/qtbase_de.qm"
|
|
||||||
File "../res/qt5/qtbase_fr.qm"
|
|
||||||
File "../res/qt5/qtbase_ko.qm"
|
|
||||||
File "../res/qt5/qtbase_ru.qm"
|
|
||||||
File "../res/qt5/qtbase_uk.qm"
|
|
||||||
File "../res/qt5/qtbase_zh_TW.qm"
|
|
||||||
SetOutPath "$INSTDIR\resources"
|
|
||||||
File "../res/add.svgz"
|
|
||||||
File "../res/avatararea.png"
|
|
||||||
File "../res/avatarareaimport.png"
|
|
||||||
File "../res/back.svgz"
|
|
||||||
File "../res/flag-de.png"
|
|
||||||
File "../res/flag-fr.png"
|
|
||||||
File "../res/flag-gb.png"
|
|
||||||
File "../res/flag-kr.png"
|
|
||||||
File "../res/flag-ru.png"
|
|
||||||
File "../res/flag-tw.png"
|
|
||||||
File "../res/flag-ua.png"
|
|
||||||
File "../res/flag-us.png"
|
|
||||||
File "../res/gta5view-16.png"
|
|
||||||
File "../res/gta5view-24.png"
|
|
||||||
File "../res/gta5view-32.png"
|
|
||||||
File "../res/gta5view-40.png"
|
|
||||||
File "../res/gta5view-48.png"
|
|
||||||
File "../res/gta5view-64.png"
|
|
||||||
File "../res/gta5view-96.png"
|
|
||||||
File "../res/gta5view-128.png"
|
|
||||||
File "../res/gta5view-256.png"
|
|
||||||
File "../res/mapcayoperico.jpg"
|
|
||||||
File "../res/mappreview.jpg"
|
|
||||||
File "../res/next.svgz"
|
|
||||||
File "../res/pointmaker-8.png"
|
|
||||||
File "../res/pointmaker-16.png"
|
|
||||||
File "../res/pointmaker-24.png"
|
|
||||||
File "../res/pointmaker-32.png"
|
|
||||||
File "../res/savegame.svgz"
|
|
||||||
File "../res/watermark_1b.png"
|
|
||||||
File "../res/watermark_2b.png"
|
|
||||||
File "../res/watermark_2r.png"
|
|
||||||
SetOutPath "$INSTDIR\imageformats"
|
|
||||||
File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/imageformats/qgif.dll"
|
|
||||||
File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/imageformats/qicns.dll"
|
|
||||||
File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/imageformats/qico.dll"
|
|
||||||
File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/imageformats/qjpeg.dll"
|
|
||||||
File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/imageformats/qsvg.dll"
|
|
||||||
File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/imageformats/qtga.dll"
|
|
||||||
File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/imageformats/qtiff.dll"
|
|
||||||
File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/imageformats/qwbmp.dll"
|
|
||||||
File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/imageformats/qwebp.dll"
|
|
||||||
SetOutPath "$INSTDIR\platforms"
|
|
||||||
File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/platforms/qwindows.dll"
|
|
||||||
SetOutPath "$INSTDIR\styles"
|
|
||||||
File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/styles/qcleanlooksstyle.dll"
|
|
||||||
File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/styles/qplastiquestyle.dll"
|
|
||||||
File "/usr/local/lib/x86_64-w64-mingw32/qt5/plugins/styles/qwindowsvistastyle.dll"
|
|
||||||
SectionEnd
|
|
||||||
|
|
||||||
######################################################################
|
|
||||||
|
|
||||||
Section -Icons_Reg
|
|
||||||
SetOutPath "$INSTDIR"
|
|
||||||
WriteUninstaller "$INSTDIR\uninstall.exe"
|
|
||||||
|
|
||||||
!ifdef REG_START_MENU
|
|
||||||
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
|
|
||||||
CreateDirectory "$SMPROGRAMS\$SM_Folder"
|
|
||||||
CreateShortCut "$SMPROGRAMS\$SM_Folder\${APP_NAME}.lnk" "$INSTDIR\${MAIN_APP_EXE}"
|
|
||||||
CreateShortCut "$SMPROGRAMS\$SM_Folder\Uninstall ${APP_NAME}.lnk" "$INSTDIR\uninstall.exe"
|
|
||||||
|
|
||||||
!ifdef WEB_SITE
|
|
||||||
WriteIniStr "$INSTDIR\${APP_NAME} website.url" "InternetShortcut" "URL" "${WEB_SITE}"
|
|
||||||
CreateShortCut "$SMPROGRAMS\$SM_Folder\gta5view Website.lnk" "$INSTDIR\${APP_NAME} website.url"
|
|
||||||
!endif
|
|
||||||
!insertmacro MUI_STARTMENU_WRITE_END
|
|
||||||
!endif
|
|
||||||
|
|
||||||
!ifndef REG_START_MENU
|
|
||||||
CreateDirectory "$SMPROGRAMS\gta5view"
|
|
||||||
CreateShortCut "$SMPROGRAMS\gta5view\${APP_NAME}.lnk" "$INSTDIR\${MAIN_APP_EXE}"
|
|
||||||
CreateShortCut "$SMPROGRAMS\gta5view\Uninstall ${APP_NAME}.lnk" "$INSTDIR\uninstall.exe"
|
|
||||||
|
|
||||||
!ifdef WEB_SITE
|
|
||||||
WriteIniStr "$INSTDIR\${APP_NAME} website.url" "InternetShortcut" "URL" "${WEB_SITE}"
|
|
||||||
CreateShortCut "$SMPROGRAMS\gta5view\gta5view Website.lnk" "$INSTDIR\${APP_NAME} website.url"
|
|
||||||
!endif
|
|
||||||
!endif
|
|
||||||
|
|
||||||
WriteRegStr ${REG_ROOT} "${REG_APP_PATH}" "" "$INSTDIR\${MAIN_APP_EXE}"
|
|
||||||
WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}" "DisplayName" "${APP_NAME}"
|
|
||||||
WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}" "UninstallString" "$INSTDIR\uninstall.exe"
|
|
||||||
WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}" "DisplayIcon" "$INSTDIR\${MAIN_APP_EXE}"
|
|
||||||
WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}" "DisplayVersion" "${VERSION}"
|
|
||||||
WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}" "Publisher" "${COMP_NAME}"
|
|
||||||
|
|
||||||
!ifdef WEB_SITE
|
|
||||||
WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}" "URLInfoAbout" "${WEB_SITE}"
|
|
||||||
!endif
|
|
||||||
SectionEnd
|
|
||||||
|
|
||||||
######################################################################
|
|
||||||
|
|
||||||
Section -ShellAssoc
|
|
||||||
WriteRegStr ${REG_ROOT} "Software\Classes\${APP_NAME}\DefaultIcon" "" "$INSTDIR\${MAIN_APP_EXE},0"
|
|
||||||
WriteRegStr ${REG_ROOT} "Software\Classes\${APP_NAME}\shell\open\command" "" '"$INSTDIR\${MAIN_APP_EXE}" "%1"'
|
|
||||||
WriteRegStr ${REG_ROOT} "Software\Classes\${APP_EXT}" "" "${APP_NAME}"
|
|
||||||
WriteRegStr ${REG_ROOT} "Software\Classes\${APP_EXT}" "Content Type" "application/x-gta5view-export"
|
|
||||||
System::Call 'SHELL32::SHChangeNotify(i0x8000000,i0,p0,p0)'
|
|
||||||
SectionEnd
|
|
||||||
|
|
||||||
######################################################################
|
|
||||||
|
|
||||||
Section -un.ShellAssoc
|
|
||||||
ClearErrors
|
|
||||||
ReadRegStr $0 ${REG_ROOT} "Software\Classes\${APP_EXT}" ""
|
|
||||||
DeleteRegKey ${REG_ROOT} "Software\Classes\${APP_NAME}"
|
|
||||||
${IfNot} ${Errors}
|
|
||||||
${AndIf} $0 == "${APP_NAME}"
|
|
||||||
DeleteRegValue ${REG_ROOT} "Software\Classes\${APP_EXT}" ""
|
|
||||||
DeleteRegKey /IfEmpty ${REG_ROOT} "Software\Classes\${APP_EXT}"
|
|
||||||
${EndIf}
|
|
||||||
System::Call 'SHELL32::SHChangeNotify(i0x8000000,i0,p0,p0)'
|
|
||||||
SectionEnd
|
|
||||||
|
|
||||||
######################################################################
|
|
||||||
|
|
||||||
Section Uninstall
|
|
||||||
${INSTALL_TYPE}
|
|
||||||
Delete "$INSTDIR\gta5view.exe"
|
|
||||||
Delete "$INSTDIR\libc++.dll"
|
|
||||||
Delete "$INSTDIR\libunwind.dll"
|
|
||||||
Delete "$INSTDIR\libcrypto-1_1-x64.dll"
|
|
||||||
Delete "$INSTDIR\libssl-1_1-x64.dll"
|
|
||||||
Delete "$INSTDIR\Qt5Core.dll"
|
|
||||||
Delete "$INSTDIR\Qt5Gui.dll"
|
|
||||||
Delete "$INSTDIR\Qt5Network.dll"
|
|
||||||
Delete "$INSTDIR\Qt5Svg.dll"
|
|
||||||
Delete "$INSTDIR\Qt5Widgets.dll"
|
|
||||||
Delete "$INSTDIR\lang\gta5sync_en_US.qm"
|
|
||||||
Delete "$INSTDIR\lang\gta5sync_de.qm"
|
|
||||||
Delete "$INSTDIR\lang\gta5sync_fr.qm"
|
|
||||||
Delete "$INSTDIR\lang\gta5sync_ko.qm"
|
|
||||||
Delete "$INSTDIR\lang\gta5sync_ru.qm"
|
|
||||||
Delete "$INSTDIR\lang\gta5sync_uk.qm"
|
|
||||||
Delete "$INSTDIR\lang\gta5sync_zh_TW.qm"
|
|
||||||
Delete "$INSTDIR\lang\qtbase_en_GB.qm"
|
|
||||||
Delete "$INSTDIR\lang\qtbase_de.qm"
|
|
||||||
Delete "$INSTDIR\lang\qtbase_fr.qm"
|
|
||||||
Delete "$INSTDIR\lang\qtbase_ko.qm"
|
|
||||||
Delete "$INSTDIR\lang\qtbase_ru.qm"
|
|
||||||
Delete "$INSTDIR\lang\qtbase_uk.qm"
|
|
||||||
Delete "$INSTDIR\lang\qtbase_zh_TW.qm"
|
|
||||||
Delete "$INSTDIR\resources\add.svgz"
|
|
||||||
Delete "$INSTDIR\resources\avatararea.png"
|
|
||||||
Delete "$INSTDIR\resources\avatarareaimport.png"
|
|
||||||
Delete "$INSTDIR\resources\back.svgz"
|
|
||||||
Delete "$INSTDIR\resources\flag-de.png"
|
|
||||||
Delete "$INSTDIR\resources\flag-fr.png"
|
|
||||||
Delete "$INSTDIR\resources\flag-gb.png"
|
|
||||||
Delete "$INSTDIR\resources\flag-kr.png"
|
|
||||||
Delete "$INSTDIR\resources\flag-ru.png"
|
|
||||||
Delete "$INSTDIR\resources\flag-tw.png"
|
|
||||||
Delete "$INSTDIR\resources\flag-ua.png"
|
|
||||||
Delete "$INSTDIR\resources\flag-us.png"
|
|
||||||
Delete "$INSTDIR\resources\gta5view-16.png"
|
|
||||||
Delete "$INSTDIR\resources\gta5view-24.png"
|
|
||||||
Delete "$INSTDIR\resources\gta5view-32.png"
|
|
||||||
Delete "$INSTDIR\resources\gta5view-40.png"
|
|
||||||
Delete "$INSTDIR\resources\gta5view-48.png"
|
|
||||||
Delete "$INSTDIR\resources\gta5view-64.png"
|
|
||||||
Delete "$INSTDIR\resources\gta5view-96.png"
|
|
||||||
Delete "$INSTDIR\resources\gta5view-128.png"
|
|
||||||
Delete "$INSTDIR\resources\gta5view-256.png"
|
|
||||||
Delete "$INSTDIR\resources\mapcayoperico.jpg"
|
|
||||||
Delete "$INSTDIR\resources\mappreview.jpg"
|
|
||||||
Delete "$INSTDIR\resources\next.svgz"
|
|
||||||
Delete "$INSTDIR\resources\pointmaker-8.png"
|
|
||||||
Delete "$INSTDIR\resources\pointmaker-16.png"
|
|
||||||
Delete "$INSTDIR\resources\pointmaker-24.png"
|
|
||||||
Delete "$INSTDIR\resources\pointmaker-32.png"
|
|
||||||
Delete "$INSTDIR\resources\savegame.svgz"
|
|
||||||
Delete "$INSTDIR\resources\watermark_1b.png"
|
|
||||||
Delete "$INSTDIR\resources\watermark_2b.png"
|
|
||||||
Delete "$INSTDIR\resources\watermark_2r.png"
|
|
||||||
Delete "$INSTDIR\imageformats\qgif.dll"
|
|
||||||
Delete "$INSTDIR\imageformats\qicns.dll"
|
|
||||||
Delete "$INSTDIR\imageformats\qico.dll"
|
|
||||||
Delete "$INSTDIR\imageformats\qjpeg.dll"
|
|
||||||
Delete "$INSTDIR\imageformats\qsvg.dll"
|
|
||||||
Delete "$INSTDIR\imageformats\qtga.dll"
|
|
||||||
Delete "$INSTDIR\imageformats\qtiff.dll"
|
|
||||||
Delete "$INSTDIR\imageformats\qwbmp.dll"
|
|
||||||
Delete "$INSTDIR\imageformats\qwebp.dll"
|
|
||||||
Delete "$INSTDIR\platforms\qwindows.dll"
|
|
||||||
Delete "$INSTDIR\styles\qcleanlooksstyle.dll"
|
|
||||||
Delete "$INSTDIR\styles\qplastiquestyle.dll"
|
|
||||||
Delete "$INSTDIR\styles\qwindowsvistastyle.dll"
|
|
||||||
RmDir "$INSTDIR\lang"
|
|
||||||
RmDir "$INSTDIR\imageformats"
|
|
||||||
RmDir "$INSTDIR\platforms"
|
|
||||||
RmDir "$INSTDIR\styles"
|
|
||||||
|
|
||||||
Delete "$INSTDIR\uninstall.exe"
|
|
||||||
!ifdef WEB_SITE
|
|
||||||
Delete "$INSTDIR\${APP_NAME} website.url"
|
|
||||||
!endif
|
|
||||||
|
|
||||||
RmDir "$INSTDIR"
|
|
||||||
|
|
||||||
!ifdef REG_START_MENU
|
|
||||||
!insertmacro MUI_STARTMENU_GETFOLDER "Application" $SM_Folder
|
|
||||||
Delete "$SMPROGRAMS\$SM_Folder\${APP_NAME}.lnk"
|
|
||||||
Delete "$SMPROGRAMS\$SM_Folder\Uninstall ${APP_NAME}.lnk"
|
|
||||||
!ifdef WEB_SITE
|
|
||||||
Delete "$SMPROGRAMS\$SM_Folder\gta5view Website.lnk"
|
|
||||||
!endif
|
|
||||||
RmDir "$SMPROGRAMS\$SM_Folder"
|
|
||||||
!endif
|
|
||||||
|
|
||||||
!ifndef REG_START_MENU
|
|
||||||
Delete "$SMPROGRAMS\gta5view\${APP_NAME}.lnk"
|
|
||||||
Delete "$SMPROGRAMS\gta5view\Uninstall ${APP_NAME}.lnk"
|
|
||||||
!ifdef WEB_SITE
|
|
||||||
Delete "$SMPROGRAMS\gta5view\gta5view Website.lnk"
|
|
||||||
!endif
|
|
||||||
RmDir "$SMPROGRAMS\gta5view"
|
|
||||||
!endif
|
|
||||||
|
|
||||||
DeleteRegKey ${REG_ROOT} "${REG_APP_PATH}"
|
|
||||||
DeleteRegKey ${REG_ROOT} "${UNINSTALL_PATH}"
|
|
||||||
SectionEnd
|
|
||||||
|
|
||||||
######################################################################
|
|
||||||
|
|
||||||
Function un.onInit
|
|
||||||
!insertmacro MUI_UNGETLANGUAGE
|
|
||||||
SetRegView 64
|
|
||||||
FunctionEnd
|
|
||||||
|
|
||||||
######################################################################
|
|
|
@ -1,24 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# Creating folders
|
|
||||||
cd ${PROJECT_DIR} && \
|
|
||||||
echo "gta5view build version is ${APPLICATION_VERSION}" && \
|
|
||||||
echo "gta5view image name is gta5view-osx_${APPLICATION_VERSION}.dmg" && \
|
|
||||||
mkdir -p build && \
|
|
||||||
mkdir -p assets && \
|
|
||||||
cd build && \
|
|
||||||
|
|
||||||
/usr/local/bin/cmake \
|
|
||||||
"-DCMAKE_PREFIX_PATH=/usr/local/opt/qt" \
|
|
||||||
"${CMAKE_BUILD_TYPE}" \
|
|
||||||
"-DGTA5VIEW_BUILDCODE=${PACKAGE_CODE}" \
|
|
||||||
"-DGTA5VIEW_APPVER=${APPLICATION_VERSION}" \
|
|
||||||
"-DGTA5VIEW_COMMIT=${APPLICATION_COMMIT}" \
|
|
||||||
"-DWITH_DONATE=ON" \
|
|
||||||
"-DWITH_TELEMETRY=ON" \
|
|
||||||
"-DDONATE_ADDRESSES=$(cat ${PROJECT_DIR}/.ci/donate.txt)" \
|
|
||||||
"-DTELEMETRY_WEBURL=https://dev.syping.de/gta5view-userstats/" \
|
|
||||||
../ && \
|
|
||||||
make -j 4 && \
|
|
||||||
/usr/local/opt/qt/bin/macdeployqt gta5view.app -dmg && \
|
|
||||||
cp -Rf gta5view.dmg ../assets/gta5view-osx_${APPLICATION_VERSION}.dmg
|
|
|
@ -1,8 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# Install packages
|
|
||||||
.ci/osx_install.sh && \
|
|
||||||
|
|
||||||
# Build gta5view
|
|
||||||
.ci/osx_build.sh && \
|
|
||||||
cd ${PROJECT_DIR}
|
|
|
@ -1,4 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# Install packages
|
|
||||||
brew upgrade cmake qt
|
|
|
@ -1,28 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# Prepare environment variable
|
|
||||||
export GTA5VIEW_EXECUTABLE=gta5view-${EXECUTABLE_VERSION}${EXECUTABLE_ARCH}.exe && \
|
|
||||||
|
|
||||||
# Creating folders
|
|
||||||
cd ${PROJECT_DIR} && \
|
|
||||||
echo "gta5view build version is ${APPLICATION_VERSION}" && \
|
|
||||||
echo "gta5view executable is ${GTA5VIEW_EXECUTABLE}" && \
|
|
||||||
mkdir -p build && \
|
|
||||||
mkdir -p assets && \
|
|
||||||
|
|
||||||
# Starting build
|
|
||||||
cd build && \
|
|
||||||
mingw64-qt-cmake \
|
|
||||||
"${CMAKE_BUILD_TYPE}" \
|
|
||||||
"-DGTA5VIEW_BUILDCODE=${PACKAGE_CODE}" \
|
|
||||||
"-DGTA5VIEW_APPVER=${APPLICATION_VERSION}" \
|
|
||||||
"-DGTA5VIEW_COMMIT=${APPLICATION_COMMIT}" \
|
|
||||||
"-DWITH_DONATE=ON" \
|
|
||||||
"-DWITH_TELEMETRY=ON" \
|
|
||||||
"-DDONATE_ADDRESSES=$(cat ${PROJECT_DIR}/.ci/donate.txt)" \
|
|
||||||
"-DTELEMETRY_WEBURL=https://dev.syping.de/gta5view-userstats/" \
|
|
||||||
.. && \
|
|
||||||
make -j 4 && \
|
|
||||||
x86_64-w64-mingw32-strip -s gta5view.exe && \
|
|
||||||
cp -Rf *.exe ${PROJECT_DIR}/assets/${GTA5VIEW_EXECUTABLE} && \
|
|
||||||
cd ${PROJECT_DIR}/assets
|
|
|
@ -1,25 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
DOCKER_IMAGE=sypingauto/gta5view-build:1.10-static
|
|
||||||
PROJECT_DIR_DOCKER=/gta5view
|
|
||||||
|
|
||||||
cd ${PROJECT_DIR} && \
|
|
||||||
docker pull ${DOCKER_IMAGE} && \
|
|
||||||
docker run --rm \
|
|
||||||
-v "${PROJECT_DIR}:${PROJECT_DIR_DOCKER}" \
|
|
||||||
${DOCKER_IMAGE} \
|
|
||||||
/bin/bash -c "export PROJECT_DIR=${PROJECT_DIR_DOCKER} && export QT_SELECT=${QT_SELECT} && export APPLICATION_VERSION=${APPLICATION_VERSION} && export APPLICATION_COMMIT=${APPLICATION_COMMIT} && export BUILD_TYPE=${BUILD_TYPE} && export QMAKE_FLAGS_QT4=${QMAKE_FLAGS_QT4} && export QMAKE_FLAGS_QT5=${QMAKE_FLAGS_QT5} && export CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} && export QMAKE_BUILD_TYPE=${QMAKE_BUILD_TYPE} && export PACKAGE_VERSION=${PACKAGE_VERSION} && export PACKAGE_BUILD=${PACKAGE_BUILD} && export PACKAGE_CODE=${PACKAGE_CODE} && export EXECUTABLE_VERSION=${EXECUTABLE_VERSION} && export EXECUTABLE_ARCH=${EXECUTABLE_ARCH} && cd ${PROJECT_DIR_DOCKER} && .ci/windows_build.sh" && \
|
|
||||||
|
|
||||||
# Prepare environment variable
|
|
||||||
export GTA5VIEW_EXECUTABLE=gta5view-${EXECUTABLE_VERSION}${EXECUTABLE_ARCH}.exe && \
|
|
||||||
|
|
||||||
# Upload Assets to Dropbox
|
|
||||||
if [ "${PACKAGE_CODE}" == "gta5-mods" ]; then
|
|
||||||
${PROJECT_DIR}/.ci/dropbox_uploader.sh mkdir gta5-mods/${PACKAGE_VERSION}
|
|
||||||
${PROJECT_DIR}/.ci/dropbox_uploader.sh upload ${PROJECT_DIR}/assets/${GTA5VIEW_EXECUTABLE} gta5-mods/${PACKAGE_VERSION}/${GTA5VIEW_EXECUTABLE} && \
|
|
||||||
rm -rf ${GTA5VIEW_EXECUTABLE}
|
|
||||||
elif [ "${PACKAGE_CODE}" == "gtainside" ]; then
|
|
||||||
${PROJECT_DIR}/.ci/dropbox_uploader.sh mkdir gtainside/${PACKAGE_VERSION}
|
|
||||||
${PROJECT_DIR}/.ci/dropbox_uploader.sh upload ${PROJECT_DIR}/assets/${GTA5VIEW_EXECUTABLE} gtainside/${PACKAGE_VERSION}/${GTA5VIEW_EXECUTABLE} && \
|
|
||||||
rm -rf ${GTA5VIEW_EXECUTABLE}
|
|
||||||
fi
|
|
|
@ -1,29 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# Creating folders
|
|
||||||
cd ${PROJECT_DIR} && \
|
|
||||||
echo "gta5view build version is ${APPLICATION_VERSION}" && \
|
|
||||||
mkdir -p build && \
|
|
||||||
mkdir -p assets && \
|
|
||||||
|
|
||||||
# Starting build
|
|
||||||
cd build && \
|
|
||||||
mingw64-qt-cmake \
|
|
||||||
"${CMAKE_BUILD_TYPE}" \
|
|
||||||
"-DGTA5VIEW_BUILDCODE=${PACKAGE_CODE}" \
|
|
||||||
"-DGTA5VIEW_APPVER=${APPLICATION_VERSION}" \
|
|
||||||
"-DGTA5VIEW_COMMIT=${APPLICATION_COMMIT}" \
|
|
||||||
"-DWITH_DONATE=ON" \
|
|
||||||
"-DWITH_TELEMETRY=ON" \
|
|
||||||
"-DDONATE_ADDRESSES=$(cat ${PROJECT_DIR}/.ci/donate.txt)" \
|
|
||||||
"-DTELEMETRY_WEBURL=https://dev.syping.de/gta5view-userstats/" \
|
|
||||||
"-DQCONF_BUILD=ON" \
|
|
||||||
"-DGTA5VIEW_INLANG=RUNDIR:SEPARATOR:lang" \
|
|
||||||
"-DGTA5VIEW_LANG=RUNDIR:SEPARATOR:lang" \
|
|
||||||
"-DGTA5VIEW_PLUG=RUNDIR:SEPARATOR:plugins" \
|
|
||||||
.. && \
|
|
||||||
make -j 4 && \
|
|
||||||
x86_64-w64-mingw32-strip -s gta5view.exe && \
|
|
||||||
cd ${PROJECT_DIR}/assets && \
|
|
||||||
makensis "-XTarget amd64-unicode" -NOCD ${PROJECT_DIR}/.ci/gta5view.nsi && \
|
|
||||||
mv -f gta5view_setup.exe gta5view-${EXECUTABLE_VERSION}_setup.exe
|
|
|
@ -1,11 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
DOCKER_IMAGE=sypingauto/gta5view-build:1.10-shared
|
|
||||||
PROJECT_DIR_DOCKER=/gta5view
|
|
||||||
|
|
||||||
cd ${PROJECT_DIR} && \
|
|
||||||
docker pull ${DOCKER_IMAGE} && \
|
|
||||||
docker run --rm \
|
|
||||||
-v "${PROJECT_DIR}:${PROJECT_DIR_DOCKER}" \
|
|
||||||
${DOCKER_IMAGE} \
|
|
||||||
/bin/bash -c "export PROJECT_DIR=${PROJECT_DIR_DOCKER} && export QT_SELECT=${QT_SELECT} && export APPLICATION_VERSION=${APPLICATION_VERSION} && export APPLICATION_COMMIT=${APPLICATION_COMMIT} && export BUILD_TYPE=${BUILD_TYPE} && export QMAKE_FLAGS_QT4=${QMAKE_FLAGS_QT4} && export QMAKE_FLAGS_QT5=${QMAKE_FLAGS_QT5} && export CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} && export QMAKE_BUILD_TYPE=${QMAKE_BUILD_TYPE} && export PACKAGE_VERSION=${PACKAGE_VERSION} && export PACKAGE_BUILD=${PACKAGE_BUILD} && export PACKAGE_CODE=${PACKAGE_CODE} && export EXECUTABLE_VERSION=${EXECUTABLE_VERSION} && export EXECUTABLE_ARCH=${EXECUTABLE_ARCH} && cd ${PROJECT_DIR_DOCKER} && .ci/wininstall_build.sh"
|
|
36
.drone.yml
36
.drone.yml
|
@ -1,36 +0,0 @@
|
||||||
kind: pipeline
|
|
||||||
type: docker
|
|
||||||
|
|
||||||
environment:
|
|
||||||
BUILD_TYPE: "REL"
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Windows Installer
|
|
||||||
image: sypingauto/gta5view-build:1.10-shared
|
|
||||||
environment:
|
|
||||||
BUILD_SCRIPT: "wininstall_build.sh"
|
|
||||||
QT_SELECT: "qt5-x86_64-w64-mingw32"
|
|
||||||
TCA_PASS:
|
|
||||||
from_secret: tca_pass
|
|
||||||
commands:
|
|
||||||
- .drone/drone.sh
|
|
||||||
volumes:
|
|
||||||
- name: gta5view
|
|
||||||
path: /srv/gta5view
|
|
||||||
- name: Windows Portable
|
|
||||||
image: sypingauto/gta5view-build:1.10-static
|
|
||||||
environment:
|
|
||||||
BUILD_SCRIPT: "windows_build.sh"
|
|
||||||
QT_SELECT: "qt5-x86_64-w64-mingw32"
|
|
||||||
TCA_PASS:
|
|
||||||
from_secret: tca_pass
|
|
||||||
commands:
|
|
||||||
- .drone/drone.sh
|
|
||||||
volumes:
|
|
||||||
- name: gta5view
|
|
||||||
path: /srv/gta5view
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
- name: gta5view
|
|
||||||
host:
|
|
||||||
path: /srv/gta5view
|
|
Binary file not shown.
|
@ -1,33 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Cleanup previous Drone build
|
|
||||||
if [ -d "assets" ]; then
|
|
||||||
rm -rf assets
|
|
||||||
fi
|
|
||||||
if [ -d "build" ]; then
|
|
||||||
rm -rf build
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Decrypt Telemetry Authenticator
|
|
||||||
rm -rf tmext/TelemetryClassAuthenticator.cpp && \
|
|
||||||
openssl aes-256-cbc -k ${TCA_PASS} -in .drone/TelemetryClassAuthenticator.cpp.enc -out tmext/TelemetryClassAuthenticator.cpp -d -pbkdf2
|
|
||||||
|
|
||||||
# Check if build is not tagged
|
|
||||||
if [ "${DRONE_TAG}" == "" ]; then
|
|
||||||
export EXECUTABLE_TAG=-$(git rev-parse --short HEAD)
|
|
||||||
else
|
|
||||||
export EXECUTABLE_TAG=
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if package code is not set
|
|
||||||
if [ "${PACKAGE_CODE}" == "" ]; then
|
|
||||||
export PACKAGE_CODE=Drone
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Init Application Commit Hash
|
|
||||||
export APPLICATION_COMMIT=$(git rev-parse --short HEAD)
|
|
||||||
|
|
||||||
# Start CI script and copying assets into gta5view directory
|
|
||||||
.ci/ci.sh && \
|
|
||||||
mkdir -p /srv/gta5view/${APPLICATION_COMMIT} && \
|
|
||||||
cp -Rf assets/* /srv/gta5view/${APPLICATION_COMMIT}/
|
|
|
@ -1,22 +0,0 @@
|
||||||
app-id: de.syping.gta5view
|
|
||||||
runtime: org.kde.Platform
|
|
||||||
runtime-version: '5.15-21.08'
|
|
||||||
sdk: org.kde.Sdk
|
|
||||||
command: gta5view
|
|
||||||
finish-args:
|
|
||||||
- --share=network
|
|
||||||
- --share=ipc
|
|
||||||
- --socket=fallback-x11
|
|
||||||
- --socket=wayland
|
|
||||||
- --device=dri
|
|
||||||
modules:
|
|
||||||
- name: gta5view
|
|
||||||
buildsystem: cmake-ninja
|
|
||||||
config-opts:
|
|
||||||
- -DFLATPAK_BUILD=ON
|
|
||||||
- -DQCONF_BUILD=ON
|
|
||||||
- -DGTA5VIEW_BUILDCODE=Flatpak
|
|
||||||
- -DGTA5VIEW_BUILDTYPE=Release
|
|
||||||
sources:
|
|
||||||
- type: dir
|
|
||||||
path: ../
|
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -27,7 +27,8 @@
|
||||||
*.out
|
*.out
|
||||||
*.app
|
*.app
|
||||||
|
|
||||||
# Qt project user file
|
# Qt project user files
|
||||||
|
CMakeLists.txt.user
|
||||||
*.pro.user
|
*.pro.user
|
||||||
|
|
||||||
# Gettext translation files
|
# Gettext translation files
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
stages:
|
|
||||||
- build
|
|
||||||
|
|
||||||
variables:
|
|
||||||
BUILD_TYPE: "REL"
|
|
||||||
|
|
||||||
Windows Installer:
|
|
||||||
stage: build
|
|
||||||
image: sypingauto/gta5view-build:1.10-shared
|
|
||||||
variables:
|
|
||||||
BUILD_SCRIPT: "wininstall_build.sh"
|
|
||||||
QT_SELECT: "qt5-x86_64-w64-mingw32"
|
|
||||||
script:
|
|
||||||
- .gitlab/gitlab.sh
|
|
||||||
artifacts:
|
|
||||||
name: "gta5view-$CI_COMMIT_REF_NAME-${CI_COMMIT_SHA:0:8}_setup"
|
|
||||||
paths:
|
|
||||||
- "gta5view-*.exe"
|
|
||||||
|
|
||||||
Windows Portable:
|
|
||||||
stage: build
|
|
||||||
image: sypingauto/gta5view-build:1.10-static
|
|
||||||
variables:
|
|
||||||
BUILD_SCRIPT: "windows_build.sh"
|
|
||||||
QT_SELECT: "qt5-x86_64-w64-mingw32"
|
|
||||||
script:
|
|
||||||
- .gitlab/gitlab.sh
|
|
||||||
artifacts:
|
|
||||||
name: "gta5view-$CI_COMMIT_REF_NAME-${CI_COMMIT_SHA:0:8}_portable"
|
|
||||||
paths:
|
|
||||||
- "gta5view-*.exe"
|
|
Binary file not shown.
|
@ -1,24 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Decrypt Telemetry Authenticator
|
|
||||||
rm -rf tmext/TelemetryClassAuthenticator.cpp && \
|
|
||||||
openssl aes-256-cbc -k ${tca_pass} -in .gitlab/TelemetryClassAuthenticator.cpp.enc -out tmext/TelemetryClassAuthenticator.cpp -d
|
|
||||||
|
|
||||||
# Check if build is not tagged
|
|
||||||
if [ "${CI_COMMIT_TAG}" == "" ]; then
|
|
||||||
export EXECUTABLE_TAG=-$(git rev-parse --short HEAD)
|
|
||||||
else
|
|
||||||
export EXECUTABLE_TAG=
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if package code is not set
|
|
||||||
if [ "${PACKAGE_CODE}" == "" ]; then
|
|
||||||
export PACKAGE_CODE=GitLab
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Init Application Commit Hash
|
|
||||||
export APPLICATION_COMMIT=$(git rev-parse --short HEAD)
|
|
||||||
|
|
||||||
# Start CI script and copying assets into base directory
|
|
||||||
.ci/ci.sh && \
|
|
||||||
cp -Rf assets/* ./
|
|
50
.travis.yml
50
.travis.yml
|
@ -1,50 +0,0 @@
|
||||||
dist: bionic
|
|
||||||
sudo: required
|
|
||||||
|
|
||||||
language: cpp
|
|
||||||
|
|
||||||
services:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
env:
|
|
||||||
global:
|
|
||||||
- BUILD_TYPE=REL
|
|
||||||
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- env:
|
|
||||||
- BUILD_SCRIPT=debian_docker.sh
|
|
||||||
- RELEASE_LABEL="Debian 64-Bit Package"
|
|
||||||
- DEBIAN_VERSION=buster
|
|
||||||
- DOCKER_USER=amd64
|
|
||||||
- APT_INSTALL=clang
|
|
||||||
- env:
|
|
||||||
- BUILD_SCRIPT=windows_docker.sh
|
|
||||||
- QT_SELECT=qt5-x86_64-w64-mingw32
|
|
||||||
- RELEASE_LABEL="Windows 64-Bit Portable"
|
|
||||||
- env:
|
|
||||||
- BUILD_SCRIPT=wininstall_docker.sh
|
|
||||||
- QT_SELECT=qt5-x86_64-w64-mingw32
|
|
||||||
- RELEASE_LABEL="Windows 64-Bit Installer"
|
|
||||||
- os: osx
|
|
||||||
osx_image: xcode12.2
|
|
||||||
env:
|
|
||||||
- BUILD_SCRIPT=osx_ci.sh
|
|
||||||
- RELEASE_LABEL="Mac OS X 64-Bit Disk Image"
|
|
||||||
|
|
||||||
before_install:
|
|
||||||
- ".travis/source.sh"
|
|
||||||
|
|
||||||
script:
|
|
||||||
- ".travis/travis.sh"
|
|
||||||
|
|
||||||
deploy:
|
|
||||||
provider: releases
|
|
||||||
api_key:
|
|
||||||
secure: o7VneEz1aHfdVwZvOZLfopf6uJWNrFsZaBvunTmXFzpmNFhlNS1qwqgMUkIA2yBRbZ3wIzVs4vfwIHv7W9yE/PqK+AYL+R8+AwKGrwlgT4HqJNuk6VM/LNJ6GwT/qkQuaoOVw29bUjmzzgIRdHmw53SlJv6Hh1VE8HphlTT//aex6nCfcFhUZ0BETdZDWz5FSHwL3NalUoqfKfQrJeky5RXzCyCANQC2tKt0bV46GaWIgWrDo2KCTNqPtRWWf5GDmnkXE5IYRMQ3mXvO9iYh0v5Y2jo4PiXGUiFUU6Z3aAWFAiPdGclrBO697cf3lCTzDMhuCETR153qFYsLShUlFf61ITAmCeHAWETjZDri0lmPONo3GoNB6alGfYEA51qw14kXakrTpICtTJj7gw/gtUYOabW6hrzmieNzMBIy62RikDPjyakFnuwW2qNHRlD65e0jYv+6nCpb6E+OV16Ysh1zhV2vTfpfzVmSuyu2J+ELqXD3OZCXRSPpDIih9UQ8335p8FBji6jHORcgym/TRgdgRmENibh8tLzWp+UjpWHuWfcpvZgOskjfwU0iDMCayMJ7tDpOhXHcAhDRnd6XRIiOJ5YZCzflj2nEwmt3YUd7DwXS/AU+WHOmcNQBjXBxF/FJa35XXcy3HKJM5TTKqtph3medo30us5yXHeG6NNg=
|
|
||||||
label: ${RELEASE_LABEL}
|
|
||||||
file_glob: true
|
|
||||||
file: assets/*
|
|
||||||
skip_cleanup: true
|
|
||||||
on:
|
|
||||||
tags: true
|
|
Binary file not shown.
|
@ -1 +0,0 @@
|
||||||
Poァ鏖<EFBFBD>劾ラ<作1x」%几<>ャネw|RtZv<>kホ銓顴Z肄2チ廁湮ォ`<1A>ム,4vヨマ・@<>ヲeハ・~U$+<2B><><EFBFBD><1A><牾&蓬熙
|
|
|
@ -1,5 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
rm -rf tmext/TelemetryClassAuthenticator.cpp && \
|
|
||||||
openssl aes-256-cbc -K $encrypted_db000a5d87d6_key -iv $encrypted_db000a5d87d6_iv -in .travis/TelemetryClassAuthenticator.cpp.enc -out tmext/TelemetryClassAuthenticator.cpp -d && \
|
|
||||||
openssl aes-256-cbc -K $encrypted_d57e7d2f8877_key -iv $encrypted_d57e7d2f8877_iv -in .travis/dropbox_uploader.enc -out ~/.dropbox_uploader -d
|
|
|
@ -1,27 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Install lua
|
|
||||||
if [ "${TRAVIS_OS_NAME}" == "osx" ]; then
|
|
||||||
brew install lua
|
|
||||||
else
|
|
||||||
sudo apt-get update -qq && \
|
|
||||||
sudo apt-get install -qq lua5.2
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if build is not tagged
|
|
||||||
if [ "${TRAVIS_TAG}" == "" ]; then
|
|
||||||
export EXECUTABLE_TAG=-$(git rev-parse --short HEAD)
|
|
||||||
else
|
|
||||||
export EXECUTABLE_TAG=
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if package code is not set
|
|
||||||
if [ "${PACKAGE_CODE}" == "" ]; then
|
|
||||||
export PACKAGE_CODE=GitHub
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Init Application Commit Hash
|
|
||||||
export APPLICATION_COMMIT=$(git rev-parse --short HEAD)
|
|
||||||
|
|
||||||
# Start CI script
|
|
||||||
.ci/ci.sh
|
|
|
@ -1,8 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Install packages
|
|
||||||
sudo .ci/debian_install.sh && \
|
|
||||||
|
|
||||||
# Build gta5view
|
|
||||||
sudo .ci/debian_build.sh && \
|
|
||||||
cd ${PROJECT_DIR}
|
|
217
CMakeLists.txt
217
CMakeLists.txt
|
@ -1,6 +1,6 @@
|
||||||
cmake_minimum_required(VERSION 3.7)
|
cmake_minimum_required(VERSION 3.7)
|
||||||
|
|
||||||
project(gta5view LANGUAGES C CXX)
|
project(gta5view VERSION 1.11.0 LANGUAGES C CXX)
|
||||||
|
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ if(APPLE)
|
||||||
res/gta5view.icns
|
res/gta5view.icns
|
||||||
)
|
)
|
||||||
set(MACOSX_BUNDLE_BUNDLE_NAME gta5view)
|
set(MACOSX_BUNDLE_BUNDLE_NAME gta5view)
|
||||||
set(MACOSX_BUNDLE_BUNDLE_VERSION 1.10.1)
|
set(MACOSX_BUNDLE_BUNDLE_VERSION ${gta5view_VERSION})
|
||||||
set(MACOSX_BUNDLE_ICON_FILE gta5view.icns)
|
set(MACOSX_BUNDLE_ICON_FILE gta5view.icns)
|
||||||
set(MACOSX_BUNDLE_GUI_IDENTIFIER de.syping.gta5view)
|
set(MACOSX_BUNDLE_GUI_IDENTIFIER de.syping.gta5view)
|
||||||
set_source_files_properties(res/gta5view.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
|
set_source_files_properties(res/gta5view.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
|
||||||
|
@ -50,111 +50,112 @@ list(APPEND GTA5VIEW_DEFINES
|
||||||
)
|
)
|
||||||
|
|
||||||
set(GTA5VIEW_SOURCES
|
set(GTA5VIEW_SOURCES
|
||||||
main.cpp
|
src/main.cpp
|
||||||
AboutDialog.cpp
|
src/AboutDialog.cpp
|
||||||
AppEnv.cpp
|
src/AppEnv.cpp
|
||||||
CrewDatabase.cpp
|
src/CrewDatabase.cpp
|
||||||
DatabaseThread.cpp
|
src/DatabaseThread.cpp
|
||||||
ExportDialog.cpp
|
src/ExportDialog.cpp
|
||||||
ExportThread.cpp
|
src/ExportThread.cpp
|
||||||
GlobalString.cpp
|
src/GlobalString.cpp
|
||||||
IconLoader.cpp
|
src/IconLoader.cpp
|
||||||
ImportDialog.cpp
|
src/ImportDialog.cpp
|
||||||
JsonEditorDialog.cpp
|
src/JsonEditorDialog.cpp
|
||||||
MapLocationDialog.cpp
|
src/MapLocationDialog.cpp
|
||||||
OptionsDialog.cpp
|
src/OptionsDialog.cpp
|
||||||
PictureDialog.cpp
|
src/PictureDialog.cpp
|
||||||
PictureExport.cpp
|
src/PictureExport.cpp
|
||||||
PictureWidget.cpp
|
src/PictureWidget.cpp
|
||||||
PlayerListDialog.cpp
|
src/PlayerListDialog.cpp
|
||||||
ProfileDatabase.cpp
|
src/ProfileDatabase.cpp
|
||||||
ProfileInterface.cpp
|
src/ProfileInterface.cpp
|
||||||
ProfileLoader.cpp
|
src/ProfileLoader.cpp
|
||||||
ProfileWidget.cpp
|
src/ProfileWidget.cpp
|
||||||
RagePhoto.cpp
|
src/RagePhoto.cpp
|
||||||
SavegameCopy.cpp
|
src/SavegameCopy.cpp
|
||||||
SavegameData.cpp
|
src/SavegameData.cpp
|
||||||
SavegameDialog.cpp
|
src/SavegameDialog.cpp
|
||||||
SavegameWidget.cpp
|
src/SavegameWidget.cpp
|
||||||
SidebarGenerator.cpp
|
src/SidebarGenerator.cpp
|
||||||
SnapmaticEditor.cpp
|
src/SnapmaticEditor.cpp
|
||||||
SnapmaticPicture.cpp
|
src/SnapmaticPicture.cpp
|
||||||
SnapmaticWidget.cpp
|
src/SnapmaticWidget.cpp
|
||||||
StandardPaths.cpp
|
src/StandardPaths.cpp
|
||||||
StringParser.cpp
|
src/StringParser.cpp
|
||||||
TranslationClass.cpp
|
src/TranslationClass.cpp
|
||||||
UserInterface.cpp
|
src/UserInterface.cpp
|
||||||
anpro/imagecropper.cpp
|
src/anpro/imagecropper.cpp
|
||||||
pcg/pcg_basic.c
|
src/pcg/pcg_basic.c
|
||||||
uimod/JSHighlighter.cpp
|
src/uimod/JSHighlighter.cpp
|
||||||
uimod/UiModLabel.cpp
|
src/uimod/UiModLabel.cpp
|
||||||
uimod/UiModWidget.cpp
|
src/uimod/UiModWidget.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(GTA5VIEW_HEADERS
|
set(GTA5VIEW_HEADERS
|
||||||
config.h
|
src/config.h
|
||||||
wrapper.h
|
src/wrapper.h
|
||||||
AboutDialog.h
|
src/AboutDialog.h
|
||||||
AppEnv.h
|
src/AppEnv.h
|
||||||
CrewDatabase.h
|
src/CrewDatabase.h
|
||||||
DatabaseThread.h
|
src/DatabaseThread.h
|
||||||
ExportDialog.h
|
src/ExportDialog.h
|
||||||
ExportThread.h
|
src/ExportThread.h
|
||||||
GlobalString.h
|
src/GlobalString.h
|
||||||
IconLoader.h
|
src/IconLoader.h
|
||||||
ImportDialog.h
|
src/ImportDialog.h
|
||||||
JsonEditorDialog.h
|
src/JsonEditorDialog.h
|
||||||
MapLocationDialog.h
|
src/MapLocationDialog.h
|
||||||
OptionsDialog.h
|
src/OptionsDialog.h
|
||||||
PictureDialog.h
|
src/PictureDialog.h
|
||||||
PictureExport.h
|
src/PictureExport.h
|
||||||
PictureWidget.h
|
src/PictureWidget.h
|
||||||
PlayerListDialog.h
|
src/PlayerListDialog.h
|
||||||
ProfileDatabase.h
|
src/ProfileDatabase.h
|
||||||
ProfileInterface.h
|
src/ProfileInterface.h
|
||||||
ProfileLoader.h
|
src/ProfileLoader.h
|
||||||
ProfileWidget.h
|
src/ProfileWidget.h
|
||||||
RagePhoto.h
|
src/RagePhoto.h
|
||||||
SavegameCopy.h
|
src/SavegameCopy.h
|
||||||
SavegameData.h
|
src/SavegameData.h
|
||||||
SavegameDialog.h
|
src/SavegameDialog.h
|
||||||
SavegameWidget.h
|
src/SavegameWidget.h
|
||||||
SidebarGenerator.h
|
src/SidebarGenerator.h
|
||||||
SnapmaticEditor.h
|
src/SnapmaticEditor.h
|
||||||
SnapmaticPicture.h
|
src/SnapmaticPicture.h
|
||||||
SnapmaticWidget.h
|
src/SnapmaticWidget.h
|
||||||
StandardPaths.h
|
src/StandardPaths.h
|
||||||
StringParser.h
|
src/StringParser.h
|
||||||
TranslationClass.h
|
src/TranslationClass.h
|
||||||
UserInterface.h
|
src/UserInterface.h
|
||||||
anpro/imagecropper.h
|
src/anpro/imagecropper.h
|
||||||
pcg/pcg_basic.h
|
src/pcg/pcg_basic.h
|
||||||
uimod/JSHighlighter.h
|
src/uimod/JSHighlighter.h
|
||||||
uimod/UiModLabel.h
|
src/uimod/UiModLabel.h
|
||||||
uimod/UiModWidget.h
|
src/uimod/UiModWidget.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(GTA5VIEW_INCLUDEDIR
|
set(GTA5VIEW_INCLUDEDIR
|
||||||
anpro
|
src
|
||||||
pcg
|
src/anpro
|
||||||
uimod
|
src/pcg
|
||||||
|
src/uimod
|
||||||
)
|
)
|
||||||
|
|
||||||
set(GTA5VIEW_FORMS
|
set(GTA5VIEW_FORMS
|
||||||
AboutDialog.ui
|
src/AboutDialog.ui
|
||||||
ExportDialog.ui
|
src/ExportDialog.ui
|
||||||
ImportDialog.ui
|
src/ImportDialog.ui
|
||||||
JsonEditorDialog.ui
|
src/JsonEditorDialog.ui
|
||||||
MapLocationDialog.ui
|
src/MapLocationDialog.ui
|
||||||
OptionsDialog.ui
|
src/OptionsDialog.ui
|
||||||
PictureDialog.ui
|
src/PictureDialog.ui
|
||||||
PlayerListDialog.ui
|
src/PlayerListDialog.ui
|
||||||
ProfileInterface.ui
|
src/ProfileInterface.ui
|
||||||
SavegameDialog.ui
|
src/SavegameDialog.ui
|
||||||
SavegameWidget.ui
|
src/SavegameWidget.ui
|
||||||
SnapmaticEditor.ui
|
src/SnapmaticEditor.ui
|
||||||
SnapmaticWidget.ui
|
src/SnapmaticWidget.ui
|
||||||
UserInterface.ui
|
src/UserInterface.ui
|
||||||
)
|
)
|
||||||
|
|
||||||
set(GTA5VIEW_TRANSLATIONS
|
set(GTA5VIEW_TRANSLATIONS
|
||||||
|
@ -222,10 +223,10 @@ option(WITH_DONATE "Donate menu option and donation dialog" OFF)
|
||||||
if(WITH_DONATE)
|
if(WITH_DONATE)
|
||||||
set(DONATE_ADDRESSES "" CACHE STRING "Donation addresses")
|
set(DONATE_ADDRESSES "" CACHE STRING "Donation addresses")
|
||||||
list(APPEND GTA5VIEW_HEADERS
|
list(APPEND GTA5VIEW_HEADERS
|
||||||
anpro/QrCode.h
|
src/anpro/QrCode.h
|
||||||
)
|
)
|
||||||
list(APPEND GTA5VIEW_SOURCES
|
list(APPEND GTA5VIEW_SOURCES
|
||||||
anpro/QrCode.cpp
|
src/anpro/QrCode.cpp
|
||||||
)
|
)
|
||||||
list(APPEND GTA5VIEW_DEFINES
|
list(APPEND GTA5VIEW_DEFINES
|
||||||
-DGTA5SYNC_DONATE
|
-DGTA5SYNC_DONATE
|
||||||
|
@ -244,10 +245,10 @@ option(WITH_MOTD "Developer message system directed to users" OFF)
|
||||||
if(WITH_MOTD)
|
if(WITH_MOTD)
|
||||||
set(MOTD_WEBURL "" CACHE STRING "Messages WebURL")
|
set(MOTD_WEBURL "" CACHE STRING "Messages WebURL")
|
||||||
list(APPEND GTA5VIEW_HEADERS
|
list(APPEND GTA5VIEW_HEADERS
|
||||||
MessageThread.h
|
src/MessageThread.h
|
||||||
)
|
)
|
||||||
list(APPEND GTA5VIEW_SOURCES
|
list(APPEND GTA5VIEW_SOURCES
|
||||||
MessageThread.cpp
|
src/MessageThread.cpp
|
||||||
)
|
)
|
||||||
list(APPEND GTA5VIEW_DEFINES
|
list(APPEND GTA5VIEW_DEFINES
|
||||||
-DGTA5SYNC_MOTD
|
-DGTA5SYNC_MOTD
|
||||||
|
@ -267,15 +268,15 @@ if(WITH_TELEMETRY)
|
||||||
set(TELEMETRY_REGURL "" CACHE STRING "Telemetry RegURL")
|
set(TELEMETRY_REGURL "" CACHE STRING "Telemetry RegURL")
|
||||||
set(TELEMETRY_WEBURL "" CACHE STRING "Telemetry WebURL")
|
set(TELEMETRY_WEBURL "" CACHE STRING "Telemetry WebURL")
|
||||||
list(APPEND GTA5VIEW_HEADERS
|
list(APPEND GTA5VIEW_HEADERS
|
||||||
TelemetryClass.h
|
src/TelemetryClass.h
|
||||||
tmext/TelemetryClassAuthenticator.h
|
src/tmext/TelemetryClassAuthenticator.h
|
||||||
)
|
)
|
||||||
list(APPEND GTA5VIEW_SOURCES
|
list(APPEND GTA5VIEW_SOURCES
|
||||||
TelemetryClass.cpp
|
src/TelemetryClass.cpp
|
||||||
tmext/TelemetryClassAuthenticator.cpp
|
src/tmext/TelemetryClassAuthenticator.cpp
|
||||||
)
|
)
|
||||||
list(APPEND GTA5VIEW_INCLUDEDIR
|
list(APPEND GTA5VIEW_INCLUDEDIR
|
||||||
tmext
|
src/tmext
|
||||||
)
|
)
|
||||||
list(APPEND GTA5VIEW_DEFINES
|
list(APPEND GTA5VIEW_DEFINES
|
||||||
-DGTA5SYNC_TELEMETRY
|
-DGTA5SYNC_TELEMETRY
|
||||||
|
@ -351,7 +352,7 @@ if(LINGUIST_FOUND AND QCONF_BUILD)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.16.0")
|
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.16.0")
|
||||||
target_precompile_headers(gta5view PRIVATE config.h)
|
target_precompile_headers(gta5view PRIVATE src/config.h)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(Qt5Core_VERSION VERSION_GREATER_EQUAL "5.14.0")
|
if(Qt5Core_VERSION VERSION_GREATER_EQUAL "5.14.0")
|
||||||
|
|
285
gta5view.pro
285
gta5view.pro
|
@ -1,285 +0,0 @@
|
||||||
#/*****************************************************************************
|
|
||||||
#* gta5view Grand Theft Auto V Profile Viewer
|
|
||||||
#* Copyright (C) 2015-2021 Syping
|
|
||||||
#*
|
|
||||||
#* This program is free software: you can redistribute it and/or modify
|
|
||||||
#* it under the terms of the GNU General Public License as published by
|
|
||||||
#* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
#* (at your option) any later version.
|
|
||||||
#*
|
|
||||||
#* This program is distributed in the hope that it will be useful,
|
|
||||||
#* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
#* GNU General Public License for more details.
|
|
||||||
#*
|
|
||||||
#* You should have received a copy of the GNU General Public License
|
|
||||||
#* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#*****************************************************************************/
|
|
||||||
|
|
||||||
QT += core gui network svg
|
|
||||||
|
|
||||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
|
||||||
greaterThan(QT_MAJOR_VERSION, 4): win32: LIBS += -ldwmapi
|
|
||||||
|
|
||||||
DEPLOYMENT.display_name = gta5view
|
|
||||||
TARGET = gta5view
|
|
||||||
TEMPLATE = app
|
|
||||||
|
|
||||||
HEADERS += config.h \
|
|
||||||
wrapper.h
|
|
||||||
PRECOMPILED_HEADER += config.h
|
|
||||||
|
|
||||||
SOURCES += main.cpp \
|
|
||||||
AboutDialog.cpp \
|
|
||||||
AppEnv.cpp \
|
|
||||||
CrewDatabase.cpp \
|
|
||||||
DatabaseThread.cpp \
|
|
||||||
ExportDialog.cpp \
|
|
||||||
ExportThread.cpp \
|
|
||||||
GlobalString.cpp \
|
|
||||||
IconLoader.cpp \
|
|
||||||
ImportDialog.cpp \
|
|
||||||
JsonEditorDialog.cpp \
|
|
||||||
MapLocationDialog.cpp \
|
|
||||||
MessageThread.cpp \
|
|
||||||
OptionsDialog.cpp \
|
|
||||||
PictureDialog.cpp \
|
|
||||||
PictureExport.cpp \
|
|
||||||
PictureWidget.cpp \
|
|
||||||
PlayerListDialog.cpp \
|
|
||||||
ProfileDatabase.cpp \
|
|
||||||
ProfileInterface.cpp \
|
|
||||||
ProfileLoader.cpp \
|
|
||||||
ProfileWidget.cpp \
|
|
||||||
RagePhoto.cpp \
|
|
||||||
SavegameCopy.cpp \
|
|
||||||
SavegameData.cpp \
|
|
||||||
SavegameDialog.cpp \
|
|
||||||
SavegameWidget.cpp \
|
|
||||||
SidebarGenerator.cpp \
|
|
||||||
SnapmaticEditor.cpp \
|
|
||||||
SnapmaticPicture.cpp \
|
|
||||||
SnapmaticWidget.cpp \
|
|
||||||
StandardPaths.cpp \
|
|
||||||
StringParser.cpp \
|
|
||||||
TelemetryClass.cpp \
|
|
||||||
TranslationClass.cpp \
|
|
||||||
UserInterface.cpp \
|
|
||||||
anpro/imagecropper.cpp \
|
|
||||||
pcg/pcg_basic.c \
|
|
||||||
tmext/TelemetryClassAuthenticator.cpp \
|
|
||||||
uimod/JSHighlighter.cpp \
|
|
||||||
uimod/UiModLabel.cpp \
|
|
||||||
uimod/UiModWidget.cpp
|
|
||||||
|
|
||||||
HEADERS += \
|
|
||||||
AboutDialog.h \
|
|
||||||
AppEnv.h \
|
|
||||||
CrewDatabase.h \
|
|
||||||
DatabaseThread.h \
|
|
||||||
ExportDialog.h \
|
|
||||||
ExportThread.h \
|
|
||||||
GlobalString.h \
|
|
||||||
IconLoader.h \
|
|
||||||
ImportDialog.h \
|
|
||||||
JsonEditorDialog.h \
|
|
||||||
MapLocationDialog.h \
|
|
||||||
MessageThread.h \
|
|
||||||
OptionsDialog.h \
|
|
||||||
PictureDialog.h \
|
|
||||||
PictureExport.h \
|
|
||||||
PictureWidget.h \
|
|
||||||
PlayerListDialog.h \
|
|
||||||
ProfileDatabase.h \
|
|
||||||
ProfileInterface.h \
|
|
||||||
ProfileLoader.h \
|
|
||||||
ProfileWidget.h \
|
|
||||||
RagePhoto.h \
|
|
||||||
SavegameCopy.h \
|
|
||||||
SavegameData.h \
|
|
||||||
SavegameDialog.h \
|
|
||||||
SavegameWidget.h \
|
|
||||||
SidebarGenerator.h \
|
|
||||||
SnapmaticEditor.h \
|
|
||||||
SnapmaticPicture.h \
|
|
||||||
SnapmaticWidget.h \
|
|
||||||
StandardPaths.h \
|
|
||||||
StringParser.h \
|
|
||||||
TelemetryClass.h \
|
|
||||||
TranslationClass.h \
|
|
||||||
UserInterface.h \
|
|
||||||
anpro/imagecropper.h \
|
|
||||||
anpro/imagecropper_e.h \
|
|
||||||
anpro/imagecropper_p.h \
|
|
||||||
pcg/pcg_basic.h \
|
|
||||||
tmext/TelemetryClassAuthenticator.h \
|
|
||||||
uimod/JSHighlighter.h \
|
|
||||||
uimod/UiModLabel.h \
|
|
||||||
uimod/UiModWidget.h
|
|
||||||
|
|
||||||
FORMS += \
|
|
||||||
AboutDialog.ui \
|
|
||||||
ExportDialog.ui \
|
|
||||||
ImportDialog.ui \
|
|
||||||
JsonEditorDialog.ui \
|
|
||||||
MapLocationDialog.ui \
|
|
||||||
OptionsDialog.ui \
|
|
||||||
PictureDialog.ui \
|
|
||||||
PlayerListDialog.ui \
|
|
||||||
ProfileInterface.ui \
|
|
||||||
SavegameDialog.ui \
|
|
||||||
SavegameWidget.ui \
|
|
||||||
SnapmaticEditor.ui \
|
|
||||||
SnapmaticWidget.ui \
|
|
||||||
UserInterface.ui
|
|
||||||
|
|
||||||
TRANSLATIONS += \
|
|
||||||
res/gta5sync.ts \
|
|
||||||
res/gta5sync_de.ts \
|
|
||||||
res/gta5sync_en_US.ts \
|
|
||||||
res/gta5sync_fr.ts \
|
|
||||||
res/gta5sync_ko.ts \
|
|
||||||
res/gta5sync_ru.ts \
|
|
||||||
res/gta5sync_uk.ts \
|
|
||||||
res/gta5sync_zh_TW.ts
|
|
||||||
|
|
||||||
RESOURCES += \
|
|
||||||
res/img.qrc \
|
|
||||||
res/template.qrc \
|
|
||||||
res/tr_g5p.qrc
|
|
||||||
|
|
||||||
DISTFILES += \
|
|
||||||
res/gta5view-16.png \
|
|
||||||
res/gta5view-24.png \
|
|
||||||
res/gta5view-32.png \
|
|
||||||
res/gta5view-40.png \
|
|
||||||
res/gta5view-48.png \
|
|
||||||
res/gta5view-64.png \
|
|
||||||
res/gta5view-96.png \
|
|
||||||
res/gta5view-128.png \
|
|
||||||
res/gta5view-256.png \
|
|
||||||
res/gta5view-512.png \
|
|
||||||
res/app.rc \
|
|
||||||
res/de.syping.gta5view.desktop \
|
|
||||||
res/de.syping.gta5view.png \
|
|
||||||
res/gta5sync_de.ts \
|
|
||||||
res/gta5sync_en_US.ts \
|
|
||||||
res/gta5sync_fr.ts \
|
|
||||||
res/gta5sync_ko.ts \
|
|
||||||
res/gta5sync_ru.ts \
|
|
||||||
res/gta5sync_uk.ts \
|
|
||||||
res/gta5sync_zh_TW.ts \
|
|
||||||
res/gta5view.exe.manifest \
|
|
||||||
res/gta5view.png \
|
|
||||||
lang/README.txt
|
|
||||||
|
|
||||||
INCLUDEPATH += ./anpro ./pcg ./tmext ./uimod
|
|
||||||
|
|
||||||
# GTA5SYNC/GTA5VIEW ONLY
|
|
||||||
|
|
||||||
DEFINES += GTA5SYNC_QMAKE # We using qmake do we?
|
|
||||||
DEFINES += GTA5SYNC_PROJECT # Enable exclusive gta5sync/gta5view functions
|
|
||||||
|
|
||||||
# WINDOWS ONLY
|
|
||||||
|
|
||||||
win32: RC_FILE += res/app.rc
|
|
||||||
win32: CONFIG -= embed_manifest_exe
|
|
||||||
contains(DEFINES, GTA5SYNC_TELEMETRY): win32: LIBS += -ld3d9 # Required for getting information about GPU
|
|
||||||
|
|
||||||
# MAC OS X ONLY
|
|
||||||
macx: ICON = res/gta5view.icns
|
|
||||||
|
|
||||||
# QT4 ONLY STUFF
|
|
||||||
|
|
||||||
isEqual(QT_MAJOR_VERSION, 4): INCLUDEPATH += ./qjson4
|
|
||||||
isEqual(QT_MAJOR_VERSION, 4): HEADERS += qjson4/QJsonArray.h \
|
|
||||||
qjson4/QJsonDocument.h \
|
|
||||||
qjson4/QJsonObject.h \
|
|
||||||
qjson4/QJsonParseError.h \
|
|
||||||
qjson4/QJsonValue.h \
|
|
||||||
qjson4/QJsonValueRef.h \
|
|
||||||
qjson4/QJsonParser.h \
|
|
||||||
qjson4/QJsonRoot.h
|
|
||||||
|
|
||||||
isEqual(QT_MAJOR_VERSION, 4): SOURCES += qjson4/QJsonArray.cpp \
|
|
||||||
qjson4/QJsonDocument.cpp \
|
|
||||||
qjson4/QJsonObject.cpp \
|
|
||||||
qjson4/QJsonParseError.cpp \
|
|
||||||
qjson4/QJsonValue.cpp \
|
|
||||||
qjson4/QJsonValueRef.cpp \
|
|
||||||
qjson4/QJsonParser.cpp
|
|
||||||
|
|
||||||
isEqual(QT_MAJOR_VERSION, 4): RESOURCES += res/qt4/tr_qt.qrc
|
|
||||||
isEqual(QT_MAJOR_VERSION, 4): GTA5SYNC_RCC = $$[QT_INSTALL_BINS]/rcc
|
|
||||||
|
|
||||||
# QT5 ONLY STUFF
|
|
||||||
|
|
||||||
isEqual(QT_MAJOR_VERSION, 5): RESOURCES += res/qt5/tr_qt.qrc
|
|
||||||
|
|
||||||
# QT5+ ONLY STUFF
|
|
||||||
|
|
||||||
greaterThan(QT_MAJOR_VERSION, 4): GTA5SYNC_RCC = $$[QT_HOST_BINS]/rcc
|
|
||||||
|
|
||||||
# QT6 ONLY STUFF
|
|
||||||
|
|
||||||
isEqual(QT_MAJOR_VERSION, 6): RESOURCES += res/qt6/tr_qt.qrc
|
|
||||||
|
|
||||||
# RESOURCE COMPILATION
|
|
||||||
|
|
||||||
system($$GTA5SYNC_RCC -threshold 0 -compress 9 $$PWD/res/global.qrc -o $$OUT_PWD/qrc_global.cpp) {
|
|
||||||
SOURCES += $$OUT_PWD/qrc_global.cpp
|
|
||||||
} else {
|
|
||||||
message("Failed to generate qrc_global.cpp")
|
|
||||||
}
|
|
||||||
|
|
||||||
# PROJECT INSTALLATION
|
|
||||||
|
|
||||||
isEmpty(GTA5SYNC_PREFIX): GTA5SYNC_PREFIX = /usr/local
|
|
||||||
|
|
||||||
appfiles.path = $$GTA5SYNC_PREFIX/share/applications
|
|
||||||
appfiles.files = $$PWD/res/de.syping.gta5view.desktop
|
|
||||||
pixmaps.path = $$GTA5SYNC_PREFIX/share/pixmaps
|
|
||||||
pixmaps.files = $$PWD/res/de.syping.gta5view.png
|
|
||||||
target.path = $$GTA5SYNC_PREFIX/bin
|
|
||||||
INSTALLS += target pixmaps appfiles
|
|
||||||
|
|
||||||
# QCONF BASED BUILD STUFF
|
|
||||||
|
|
||||||
contains(DEFINES, GTA5SYNC_QCONF) {
|
|
||||||
isEqual(QT_MAJOR_VERSION, 4): RESOURCES -= res/qt4/tr_qt.qrc
|
|
||||||
isEqual(QT_MAJOR_VERSION, 5): RESOURCES -= res/qt5/tr_qt.qrc
|
|
||||||
isEqual(QT_MAJOR_VERSION, 6): RESOURCES -= res/qt6/tr_qt.qrc
|
|
||||||
!contains(DEFINES, GTA5SYNC_QCONF_IN) {
|
|
||||||
RESOURCES -= res/tr_g5p.qrc
|
|
||||||
langfiles.path = $$GTA5SYNC_PREFIX/share/gta5view/translations
|
|
||||||
langfiles.files = $$PWD/res/gta5sync_en_US.qm $$PWD/res/gta5sync_de.qm $$PWD/res/gta5sync_fr.qm $$PWD/res/gta5sync_ko.qm $$PWD/res/gta5sync_ru.qm $$PWD/res/gta5sync_uk.qm $$PWD/res/gta5sync_zh_TW.qm $$PWD/res/qtbase_en_GB.qm
|
|
||||||
INSTALLS += langfiles
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# TELEMETRY BASED STUFF
|
|
||||||
|
|
||||||
!contains(DEFINES, GTA5SYNC_TELEMETRY) {
|
|
||||||
SOURCES -= TelemetryClass.cpp \
|
|
||||||
tmext/TelemetryClassAuthenticator.cpp
|
|
||||||
HEADERS -= TelemetryClass.h \
|
|
||||||
tmext/TelemetryClassAuthenticator.h
|
|
||||||
}
|
|
||||||
|
|
||||||
!contains(DEFINES, GTA5SYNC_MOTD) {
|
|
||||||
SOURCES -= MessageThread.cpp
|
|
||||||
HEADERS -= MessageThread.h
|
|
||||||
} else {
|
|
||||||
lessThan(QT_MAJOR_VERSION, 5) {
|
|
||||||
SOURCES -= MessageThread.cpp
|
|
||||||
HEADERS -= MessageThread.h
|
|
||||||
DEFINES -= GTA5SYNC_MOTD
|
|
||||||
message("Messages require Qt5 or newer!")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# CMAKE BASED STUFF
|
|
||||||
|
|
||||||
greaterThan(QT_MAJOR_VERSION, 4) {
|
|
||||||
message("Building gta5view with QMake is deprecated, please use CMake instead!")
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
Community translation files
|
|
||||||
|
|
||||||
They get loaded in ApplicationPathExecFileFolder/lang
|
|
||||||
|
|
||||||
You can help translate with using Qt Linguist, after you've translated you'll need to send me a pull request on https://github.com/SyDevTeam/gta5view
|
|
|
@ -1 +0,0 @@
|
||||||
#include "QJsonArray.h"
|
|
|
@ -1,410 +0,0 @@
|
||||||
/*****************************************************************************
|
|
||||||
* gta5view Grand Theft Auto V Profile Viewer
|
|
||||||
* Copyright (C) 2016 Syping
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
#include "QJsonArray.h"
|
|
||||||
#include "QJsonValueRef.h"
|
|
||||||
#include "QJsonValue.h"
|
|
||||||
#include <QtCore/QStringList>
|
|
||||||
|
|
||||||
#if QT_VERSION < 0x050000
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: QJsonArray
|
|
||||||
// Desc: default constructor
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonArray::QJsonArray() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: QJsonArray
|
|
||||||
// Desc: copy constructor
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonArray::QJsonArray(const QJsonArray &other) : values_(other.values_) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: QJsonArray
|
|
||||||
// Desc: Creates an array initialized from args initialization list.
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonArray::QJsonArray(std::initializer_list<QJsonValue> args) {
|
|
||||||
for(const QJsonValue &arg : args) {
|
|
||||||
values_.append(arg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: ~QJsonArray
|
|
||||||
// Desc: destructor
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonArray::~QJsonArray() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: operator=
|
|
||||||
// Desc: assignment operator
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonArray &QJsonArray::operator=(const QJsonArray &other) {
|
|
||||||
QJsonArray(other).swap(*this);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: operator+=
|
|
||||||
// Desc:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonArray &QJsonArray::operator+=(const QJsonValue &value) {
|
|
||||||
values_.append(value);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: operator<<
|
|
||||||
// Desc:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonArray &QJsonArray::operator<<(const QJsonValue &value) {
|
|
||||||
values_.append(value);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: operator+
|
|
||||||
// Desc:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonArray QJsonArray::operator+(const QJsonValue &value) const {
|
|
||||||
QJsonArray arr(*this);
|
|
||||||
arr.append(value);
|
|
||||||
return arr;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: operator!=
|
|
||||||
// Desc: returns true if the compared array IS NOT equal to this
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonArray::operator!=(const QJsonArray &other) const {
|
|
||||||
return values_ != other.values_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: operator==
|
|
||||||
// Desc: returns true if the compared array IS equal to this
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonArray::operator==(const QJsonArray &other) const {
|
|
||||||
return values_ == other.values_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: begin
|
|
||||||
// Desc: returns an iterator to the first contained element
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonArray::const_iterator QJsonArray::begin() const {
|
|
||||||
return values_.begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: end
|
|
||||||
// Desc: returns an iterator to one past the last contained element
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonArray::const_iterator QJsonArray::end() const {
|
|
||||||
return values_.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: begin
|
|
||||||
// Desc: returns an iterator to the first contained element
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonArray::iterator QJsonArray::begin() {
|
|
||||||
return values_.begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: end
|
|
||||||
// Desc: returns an iterator to one past the last contained element
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonArray::iterator QJsonArray::end() {
|
|
||||||
return values_.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: constBegin
|
|
||||||
// Desc: returns an iterator to the first contained element
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonArray::const_iterator QJsonArray::constBegin() const {
|
|
||||||
return begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: constEnd
|
|
||||||
// Desc: returns an iterator to one past the last contained element
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonArray::const_iterator QJsonArray::constEnd() const {
|
|
||||||
return end();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: first
|
|
||||||
// Desc: returns the first element by value
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValue QJsonArray::first() const {
|
|
||||||
Q_ASSERT(!empty());
|
|
||||||
return values_.first();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: last
|
|
||||||
// Desc: returns the last element by value
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValue QJsonArray::last() const {
|
|
||||||
Q_ASSERT(!empty());
|
|
||||||
return values_.last();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: operator[]
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValueRef QJsonArray::operator[](int i) {
|
|
||||||
return QJsonValueRef(this, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: operator[]
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValue QJsonArray::operator[](int i) const {
|
|
||||||
return values_[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: at
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValue QJsonArray::at(int i) const {
|
|
||||||
return values_.at(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: size
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
int QJsonArray::size() const {
|
|
||||||
return values_.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: count
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
int QJsonArray::count() const {
|
|
||||||
return size();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: empty
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonArray::empty() const {
|
|
||||||
return values_.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: isEmpty
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonArray::isEmpty() const {
|
|
||||||
return empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: pop_back
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void QJsonArray::pop_back() {
|
|
||||||
values_.pop_back();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: pop_front
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void QJsonArray::pop_front() {
|
|
||||||
values_.pop_front();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: push_back
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void QJsonArray::push_back(const QJsonValue &value) {
|
|
||||||
values_.push_back(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: push_front
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void QJsonArray::push_front(const QJsonValue &value) {
|
|
||||||
values_.push_front(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void QJsonArray::append(const QJsonValue &value) {
|
|
||||||
values_.append(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonArray::contains(const QJsonValue &value) const {
|
|
||||||
return values_.contains(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonArray::iterator QJsonArray::erase(iterator it) {
|
|
||||||
return values_.erase(it);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void QJsonArray::insert(int i, const QJsonValue &value) {
|
|
||||||
values_.insert(i, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonArray::iterator QJsonArray::insert(iterator before, const QJsonValue &value) {
|
|
||||||
return values_.insert(before, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void QJsonArray::prepend(const QJsonValue &value) {
|
|
||||||
values_.prepend(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void QJsonArray::removeAt(int i) {
|
|
||||||
values_.removeAt(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void QJsonArray::removeFirst() {
|
|
||||||
values_.removeFirst();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void QJsonArray::removeLast() {
|
|
||||||
values_.removeLast();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void QJsonArray::replace(int i, const QJsonValue &value) {
|
|
||||||
values_.replace(i, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValue QJsonArray::takeAt(int i) {
|
|
||||||
return values_.takeAt(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: toVariantList
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QVariantList QJsonArray::toVariantList() const {
|
|
||||||
QVariantList a;
|
|
||||||
Q_FOREACH(const QJsonValue &v, *this) {
|
|
||||||
a.push_back(v.toVariant());
|
|
||||||
}
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonArray QJsonArray::fromStringList(const QStringList &list) {
|
|
||||||
QJsonArray a;
|
|
||||||
Q_FOREACH(const QString &s, list) {
|
|
||||||
a.push_back(QJsonValue(s));
|
|
||||||
}
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonArray QJsonArray::fromVariantList(const QVariantList &list) {
|
|
||||||
QJsonArray a;
|
|
||||||
Q_FOREACH(const QVariant &v, list) {
|
|
||||||
a.push_back(QJsonValue::fromVariant(v));
|
|
||||||
}
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonRoot *QJsonArray::clone() const {
|
|
||||||
return new QJsonArray(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
const QJsonObject *QJsonArray::toObject() const {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonObject *QJsonArray::toObject() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonArray *QJsonArray::toArray() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
const QJsonArray *QJsonArray::toArray() const {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void QJsonArray::swap(QJsonArray &other) {
|
|
||||||
qSwap(values_, other.values_);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,139 +0,0 @@
|
||||||
/*****************************************************************************
|
|
||||||
* gta5view Grand Theft Auto V Profile Viewer
|
|
||||||
* Copyright (C) 2016 Syping
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef QJSON_ARRAY_H_
|
|
||||||
#define QJSON_ARRAY_H_
|
|
||||||
|
|
||||||
#include <QtCore/QtGlobal>
|
|
||||||
|
|
||||||
#if QT_VERSION >= 0x050000
|
|
||||||
#include <QtCore/QJsonArray>
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include "QJsonRoot.h"
|
|
||||||
#include <QtCore/QList>
|
|
||||||
#include <QtCore/QVariantList>
|
|
||||||
|
|
||||||
class QJsonValue;
|
|
||||||
class QJsonValueRef;
|
|
||||||
|
|
||||||
class QJsonArray : public QJsonRoot {
|
|
||||||
friend class QJsonDocument;
|
|
||||||
friend class QJsonValue;
|
|
||||||
friend class QJsonValueRef;
|
|
||||||
friend class QJsonParser;
|
|
||||||
public:
|
|
||||||
// TODO(eteran): manually implement the array, for now we use QList
|
|
||||||
// but the real thing has a custom implementation
|
|
||||||
// I guess for the purposes of less interdependancies?
|
|
||||||
// maybe so it's easier to forward declare the iterators?
|
|
||||||
|
|
||||||
typedef QList<QJsonValue>::const_iterator const_iterator;
|
|
||||||
typedef QList<QJsonValue>::iterator iterator;
|
|
||||||
typedef const_iterator ConstIterator;
|
|
||||||
typedef iterator Iterator;
|
|
||||||
typedef QList<QJsonValue>::const_pointer const_pointer;
|
|
||||||
typedef QList<QJsonValue>::const_reference const_reference;
|
|
||||||
typedef QList<QJsonValue>::difference_type difference_type;
|
|
||||||
typedef QList<QJsonValue>::pointer pointer;
|
|
||||||
typedef QList<QJsonValue>::reference reference;
|
|
||||||
typedef QList<QJsonValue>::size_type size_type;
|
|
||||||
typedef QList<QJsonValue>::value_type value_type;
|
|
||||||
|
|
||||||
public:
|
|
||||||
QJsonArray();
|
|
||||||
QJsonArray(const QJsonArray &other);
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
QJsonArray(std::initializer_list<QJsonValue> args);
|
|
||||||
#endif
|
|
||||||
~QJsonArray();
|
|
||||||
|
|
||||||
public:
|
|
||||||
QJsonArray &operator=(const QJsonArray &other);
|
|
||||||
|
|
||||||
public:
|
|
||||||
bool operator!=(const QJsonArray &other) const;
|
|
||||||
bool operator==(const QJsonArray &other) const;
|
|
||||||
QJsonArray operator+(const QJsonValue &value) const;
|
|
||||||
QJsonArray &operator+=(const QJsonValue &value);
|
|
||||||
QJsonArray &operator<<(const QJsonValue &value);
|
|
||||||
|
|
||||||
public:
|
|
||||||
const_iterator begin() const;
|
|
||||||
const_iterator end() const;
|
|
||||||
iterator begin();
|
|
||||||
iterator end();
|
|
||||||
const_iterator constBegin() const;
|
|
||||||
const_iterator constEnd() const;
|
|
||||||
|
|
||||||
public:
|
|
||||||
QJsonValueRef operator[](int i);
|
|
||||||
QJsonValue operator[](int i) const;
|
|
||||||
QJsonValue at(int i) const;
|
|
||||||
QJsonValue first() const;
|
|
||||||
QJsonValue last() const;
|
|
||||||
|
|
||||||
public:
|
|
||||||
int size() const;
|
|
||||||
int count() const;
|
|
||||||
bool empty() const;
|
|
||||||
bool isEmpty() const;
|
|
||||||
|
|
||||||
public:
|
|
||||||
void pop_back();
|
|
||||||
void pop_front();
|
|
||||||
void push_back(const QJsonValue &value);
|
|
||||||
void push_front(const QJsonValue &value);
|
|
||||||
|
|
||||||
public:
|
|
||||||
void append(const QJsonValue &value);
|
|
||||||
bool contains(const QJsonValue &value) const;
|
|
||||||
iterator erase(iterator it);
|
|
||||||
void insert(int i, const QJsonValue &value);
|
|
||||||
iterator insert(iterator before, const QJsonValue &value);
|
|
||||||
void prepend(const QJsonValue &value);
|
|
||||||
void removeAt(int i);
|
|
||||||
void removeFirst();
|
|
||||||
void removeLast();
|
|
||||||
void replace(int i, const QJsonValue &value);
|
|
||||||
QJsonValue takeAt(int i);
|
|
||||||
|
|
||||||
public:
|
|
||||||
QVariantList toVariantList() const;
|
|
||||||
|
|
||||||
public:
|
|
||||||
static QJsonArray fromStringList(const QStringList &list);
|
|
||||||
static QJsonArray fromVariantList(const QVariantList &list);
|
|
||||||
|
|
||||||
private:
|
|
||||||
virtual QJsonRoot *clone() const;
|
|
||||||
virtual QJsonArray *toArray();
|
|
||||||
virtual QJsonObject *toObject();
|
|
||||||
virtual const QJsonArray *toArray() const;
|
|
||||||
virtual const QJsonObject *toObject() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void swap(QJsonArray &other);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QList<QJsonValue> values_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1 +0,0 @@
|
||||||
#include "QJsonDocument.h"
|
|
|
@ -1,424 +0,0 @@
|
||||||
/*****************************************************************************
|
|
||||||
* gta5view Grand Theft Auto V Profile Viewer
|
|
||||||
* Copyright (C) 2016 Syping
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
#include "QJsonDocument.h"
|
|
||||||
#include "QJsonObject.h"
|
|
||||||
#include "QJsonArray.h"
|
|
||||||
#include "QJsonParser.h"
|
|
||||||
|
|
||||||
#include <QtCore/QStringList>
|
|
||||||
#include <QtCore/QByteArray>
|
|
||||||
#include <QtCore/QTextStream>
|
|
||||||
#include <QtCore/QTextCodec>
|
|
||||||
#include <QtCore/QtCore>
|
|
||||||
|
|
||||||
#if QT_VERSION < 0x050000
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: QJsonDocument
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonDocument::QJsonDocument() : root_(0) {
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: QJsonDocument
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonDocument::QJsonDocument(const QJsonObject &object) : root_(0) {
|
|
||||||
setObject(object);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: QJsonDocument
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonDocument::QJsonDocument(const QJsonArray &array) : root_(0) {
|
|
||||||
setArray(array);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: QJsonDocument
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonDocument::QJsonDocument(const QJsonDocument &other) : root_(0) {
|
|
||||||
if(other.root_) {
|
|
||||||
root_ = other.root_->clone();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: ~QJsonDocument
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonDocument::~QJsonDocument() {
|
|
||||||
delete root_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: operator=
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonDocument &QJsonDocument::operator=(const QJsonDocument &other) {
|
|
||||||
QJsonDocument(other).swap(*this);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: operator!=
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonDocument::operator!=(const QJsonDocument &other) const {
|
|
||||||
return !(*this == other);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: operator==
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonDocument::operator==(const QJsonDocument &other) const {
|
|
||||||
|
|
||||||
if(isArray() && other.isArray()) {
|
|
||||||
return array() == other.array();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isObject() && other.isObject()) {
|
|
||||||
return object() == other.object();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isEmpty() && other.isEmpty()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isNull() && other.isNull()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: isArray
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonDocument::isArray() const {
|
|
||||||
return root_ && root_->toArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: isEmpty
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonDocument::isEmpty() const {
|
|
||||||
|
|
||||||
// TODO(eteran): figure out the rules here that Qt5 uses
|
|
||||||
// it *looks* like they define empty as being NULL
|
|
||||||
// which is obviously different than this
|
|
||||||
|
|
||||||
return !root_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: isNull
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonDocument::isNull() const {
|
|
||||||
return !root_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: isObject
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonDocument::isObject() const {
|
|
||||||
return root_ && root_->toObject();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: setArray
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void QJsonDocument::setArray(const QJsonArray &array) {
|
|
||||||
setRoot(array);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: setObject
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void QJsonDocument::setObject(const QJsonObject &object) {
|
|
||||||
setRoot(object);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: setRoot
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void QJsonDocument::setRoot(const QJsonRoot &root) {
|
|
||||||
delete root_;
|
|
||||||
root_ = root.clone();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: toBinaryData
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QByteArray QJsonDocument::toBinaryData() const {
|
|
||||||
QByteArray r;
|
|
||||||
// TODO(eteran): implement this
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: escapeString
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QString QJsonDocument::escapeString(const QString &s) const {
|
|
||||||
|
|
||||||
QString r;
|
|
||||||
|
|
||||||
Q_FOREACH(QChar ch, s) {
|
|
||||||
switch(ch.toLatin1()) {
|
|
||||||
case '\"': r.append("\\\""); break;
|
|
||||||
case '\\': r.append("\\\\"); break;
|
|
||||||
#if 0
|
|
||||||
case '/': r.append("\\/"); break;
|
|
||||||
#endif
|
|
||||||
case '\b': r.append("\\b"); break;
|
|
||||||
case '\f': r.append("\\f"); break;
|
|
||||||
case '\n': r.append("\\n"); break;
|
|
||||||
case '\r': r.append("\\r"); break;
|
|
||||||
case '\t': r.append("\\t"); break;
|
|
||||||
default:
|
|
||||||
r += ch;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: toJson
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QString QJsonDocument::toJson(const QJsonValue &v, JsonFormat format, int indent) const {
|
|
||||||
|
|
||||||
QString b;
|
|
||||||
QTextStream ss(&b, QIODevice::WriteOnly | QIODevice::Text);
|
|
||||||
bool compact = (format == JsonFormat::Compact);
|
|
||||||
|
|
||||||
switch(v.type()) {
|
|
||||||
case QJsonValue::Null:
|
|
||||||
ss << "null";
|
|
||||||
break;
|
|
||||||
case QJsonValue::Bool:
|
|
||||||
ss << (v.toBool() ? "true" : "false");
|
|
||||||
break;
|
|
||||||
case QJsonValue::Double:
|
|
||||||
{
|
|
||||||
double d = v.toDouble ();
|
|
||||||
if (qIsFinite(d)) {
|
|
||||||
// +2 to format to ensure the expected precision
|
|
||||||
ss << QByteArray::number(d, 'g', 15 + 2); // ::digits10 is 15
|
|
||||||
} else {
|
|
||||||
ss << "null"; // +INF || -INF || NaN (see RFC4627#section2.4)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case QJsonValue::String:
|
|
||||||
ss << '"' << escapeString(v.toString()) << '"';
|
|
||||||
break;
|
|
||||||
case QJsonValue::Array:
|
|
||||||
{
|
|
||||||
const QJsonArray a = v.toArray();
|
|
||||||
ss << (compact ? "[" : "[\n");
|
|
||||||
if(!a.empty()) {
|
|
||||||
QJsonArray::const_iterator it = a.begin();
|
|
||||||
QJsonArray::const_iterator e = a.end();
|
|
||||||
|
|
||||||
if (!compact) ss << QByteArray(4*indent, ' ');
|
|
||||||
ss << toJson(*it++, format, indent+1);
|
|
||||||
|
|
||||||
for(;it != e; ++it) {
|
|
||||||
ss << (compact ? "," : ",\n");
|
|
||||||
if (!compact) ss << QByteArray(4*indent, ' ');
|
|
||||||
ss << toJson(*it, format, indent+1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
indent--;
|
|
||||||
ss << (compact ? "]" : QString("\n%1]").arg(QString(4*indent, ' ')));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case QJsonValue::Object:
|
|
||||||
{
|
|
||||||
const QJsonObject o = v.toObject();
|
|
||||||
ss << (compact ? "{" : "{\n");
|
|
||||||
if(!o.empty()) {
|
|
||||||
QJsonObject::const_iterator it = o.begin();
|
|
||||||
QJsonObject::const_iterator e = o.end();
|
|
||||||
|
|
||||||
if (!compact) ss << QByteArray(4*indent, ' ');
|
|
||||||
ss << '"' << escapeString(it.key()) << (compact ? "\":" : "\": ") << toJson(it.value(), format, indent+1);
|
|
||||||
++it;
|
|
||||||
for(;it != e; ++it) {
|
|
||||||
ss << (compact ? "," : ",\n");
|
|
||||||
if (!compact) ss << QByteArray(4*indent, ' ');
|
|
||||||
ss << '"' << escapeString(it.key()) << (compact ? "\":" : "\": ") << toJson(it.value(), format, indent+1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
indent--;
|
|
||||||
ss << (compact ? "}" : QString("\n%1}").arg(QString(4*indent, ' ')));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case QJsonValue::Undefined:
|
|
||||||
Q_ASSERT(0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: toJson
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QByteArray QJsonDocument::toJson(JsonFormat format) const {
|
|
||||||
|
|
||||||
Q_UNUSED(format);
|
|
||||||
|
|
||||||
if(isArray()) {
|
|
||||||
QString s = toJson(array(), format);
|
|
||||||
return s.toUtf8();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isObject()) {
|
|
||||||
QString s = toJson(object(), format);
|
|
||||||
return s.toUtf8();
|
|
||||||
}
|
|
||||||
|
|
||||||
return QByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: toVariant
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QVariant QJsonDocument::toVariant() const {
|
|
||||||
|
|
||||||
if(!isEmpty()) {
|
|
||||||
if(QJsonObject *const object = root_->toObject()) {
|
|
||||||
return object->toVariantMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(QJsonArray *const array = root_->toArray()) {
|
|
||||||
return array->toVariantList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return QVariant();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: array
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonArray QJsonDocument::array() const {
|
|
||||||
|
|
||||||
if(!isEmpty()) {
|
|
||||||
if(QJsonArray *const array = root_->toArray()) {
|
|
||||||
return *array;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return QJsonArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: object
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonObject QJsonDocument::object() const {
|
|
||||||
|
|
||||||
if(!isEmpty()) {
|
|
||||||
if(QJsonObject *const object = root_->toObject()) {
|
|
||||||
return *object;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return QJsonObject();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: rawData
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
const char *QJsonDocument::rawData(int *size) const {
|
|
||||||
Q_UNUSED(size);
|
|
||||||
// TODO(eteran): implement this
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: fromBinaryData
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonDocument QJsonDocument::fromBinaryData(const QByteArray &data, DataValidation validation) {
|
|
||||||
Q_UNUSED(data);
|
|
||||||
Q_UNUSED(validation);
|
|
||||||
|
|
||||||
QJsonDocument doc;
|
|
||||||
// TODO(eteran): implement this
|
|
||||||
return doc;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: fromJson
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonDocument QJsonDocument::fromJson(const QByteArray &json, QJsonParseError *error) {
|
|
||||||
QJsonDocument doc;
|
|
||||||
|
|
||||||
const char *const begin = json.constData();
|
|
||||||
const char *const end = begin + json.size();
|
|
||||||
|
|
||||||
QJsonParser parser(begin, end);
|
|
||||||
|
|
||||||
doc.root_ = parser.parse();
|
|
||||||
|
|
||||||
if(error) {
|
|
||||||
*error = parser.state();
|
|
||||||
}
|
|
||||||
|
|
||||||
return doc;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: fromRawData
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonDocument QJsonDocument::fromRawData(const char *data, int size, DataValidation validation) {
|
|
||||||
|
|
||||||
// data has to be aligned to a 4 byte boundary.
|
|
||||||
Q_ASSERT(!(reinterpret_cast<quintptr>(data) % 3));
|
|
||||||
|
|
||||||
return fromBinaryData(QByteArray::fromRawData(data, size), validation);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: fromVariant
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonDocument QJsonDocument::fromVariant(const QVariant &variant) {
|
|
||||||
|
|
||||||
QJsonDocument doc;
|
|
||||||
|
|
||||||
if (variant.type() == QVariant::Map) {
|
|
||||||
doc.setObject(QJsonObject::fromVariantMap(variant.toMap()));
|
|
||||||
} else if (variant.type() == QVariant::Hash) {
|
|
||||||
doc.setObject(QJsonObject::fromVariantHash(variant.toHash()));
|
|
||||||
} else if (variant.type() == QVariant::List) {
|
|
||||||
doc.setArray(QJsonArray::fromVariantList(variant.toList()));
|
|
||||||
} else if (variant.type() == QVariant::StringList) {
|
|
||||||
doc.setArray(QJsonArray::fromStringList(variant.toStringList()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return doc;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: swap
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void QJsonDocument::swap(QJsonDocument &other) {
|
|
||||||
qSwap(root_, other.root_);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,103 +0,0 @@
|
||||||
/*****************************************************************************
|
|
||||||
* gta5view Grand Theft Auto V Profile Viewer
|
|
||||||
* Copyright (C) 2016 Syping
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef QJSON_DOCUMENT_H_
|
|
||||||
#define QJSON_DOCUMENT_H_
|
|
||||||
|
|
||||||
#include <QtCore/QtGlobal>
|
|
||||||
|
|
||||||
#if QT_VERSION >= 0x050000
|
|
||||||
#include <QtCore/QJsonDocument>
|
|
||||||
#else
|
|
||||||
|
|
||||||
class QVariant;
|
|
||||||
class QByteArray;
|
|
||||||
class QTextStream;
|
|
||||||
class QJsonObject;
|
|
||||||
class QJsonValue;
|
|
||||||
class QJsonArray;
|
|
||||||
class QJsonParseError;
|
|
||||||
class QJsonRoot;
|
|
||||||
|
|
||||||
class QJsonDocument {
|
|
||||||
public:
|
|
||||||
enum DataValidation {
|
|
||||||
Validate = 0,
|
|
||||||
BypassValidation = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
enum JsonFormat {
|
|
||||||
Indented,
|
|
||||||
Compact
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
|
||||||
QJsonDocument();
|
|
||||||
QJsonDocument(const QJsonObject &object);
|
|
||||||
QJsonDocument(const QJsonArray &array);
|
|
||||||
QJsonDocument(const QJsonDocument &other);
|
|
||||||
~QJsonDocument();
|
|
||||||
|
|
||||||
public:
|
|
||||||
QJsonDocument &operator=(const QJsonDocument &other);
|
|
||||||
|
|
||||||
public:
|
|
||||||
bool operator!=(const QJsonDocument &other) const;
|
|
||||||
bool operator==(const QJsonDocument &other) const;
|
|
||||||
|
|
||||||
public:
|
|
||||||
bool isArray() const;
|
|
||||||
bool isEmpty() const;
|
|
||||||
bool isNull() const;
|
|
||||||
bool isObject() const;
|
|
||||||
|
|
||||||
public:
|
|
||||||
QByteArray toBinaryData() const;
|
|
||||||
QByteArray toJson(JsonFormat format = Indented) const;
|
|
||||||
QVariant toVariant() const;
|
|
||||||
|
|
||||||
public:
|
|
||||||
QJsonArray array() const;
|
|
||||||
QJsonObject object() const;
|
|
||||||
const char *rawData(int *size) const;
|
|
||||||
|
|
||||||
public:
|
|
||||||
void setArray(const QJsonArray &array);
|
|
||||||
void setObject(const QJsonObject &object);
|
|
||||||
|
|
||||||
public:
|
|
||||||
static QJsonDocument fromBinaryData(const QByteArray &data, DataValidation validation = Validate);
|
|
||||||
static QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error = 0);
|
|
||||||
static QJsonDocument fromRawData(const char *data, int size, DataValidation validation = Validate);
|
|
||||||
static QJsonDocument fromVariant(const QVariant &variant);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void setRoot(const QJsonRoot &root);
|
|
||||||
QString toJson(const QJsonValue &v, JsonFormat format, int indent = 1) const;
|
|
||||||
QString escapeString(const QString &s) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void swap(QJsonDocument &other);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QJsonRoot *root_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1 +0,0 @@
|
||||||
#include "QJsonObject.h"
|
|
|
@ -1,322 +0,0 @@
|
||||||
/*****************************************************************************
|
|
||||||
* gta5view Grand Theft Auto V Profile Viewer
|
|
||||||
* Copyright (C) 2016 Syping
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
#include "QJsonObject.h"
|
|
||||||
|
|
||||||
#if QT_VERSION < 0x050000
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: QJsonObject
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonObject::QJsonObject() {
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: QJsonObject
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonObject::QJsonObject(const QJsonObject &other) : values_(other.values_) {
|
|
||||||
}
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: QJsonObject
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonObject::QJsonObject(std::initializer_list<QPair<QString, QJsonValue> > args) {
|
|
||||||
for(const QPair<QString, QJsonValue> &arg : args) {
|
|
||||||
values_.insert(arg.first, arg.second);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: ~QJsonObject
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonObject::~QJsonObject() {
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonObject &QJsonObject::operator=(const QJsonObject &other) {
|
|
||||||
QJsonObject(other).swap(*this);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonObject::iterator QJsonObject::begin() {
|
|
||||||
return values_.begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonObject::const_iterator QJsonObject::begin() const {
|
|
||||||
return values_.begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonObject::iterator QJsonObject::end() {
|
|
||||||
return values_.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonObject::const_iterator QJsonObject::end() const {
|
|
||||||
return values_.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonObject::const_iterator QJsonObject::constBegin() const {
|
|
||||||
return begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonObject::const_iterator QJsonObject::constEnd() const {
|
|
||||||
return end();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
int QJsonObject::count() const {
|
|
||||||
return size();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
int QJsonObject::length() const {
|
|
||||||
return size();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
int QJsonObject::size() const {
|
|
||||||
return values_.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonObject::empty() const {
|
|
||||||
return values_.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonObject::isEmpty() const {
|
|
||||||
return empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonObject::const_iterator QJsonObject::constFind(const QString &key) const {
|
|
||||||
return values_.find(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonObject::contains(const QString &key) const {
|
|
||||||
return values_.contains(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonObject::iterator QJsonObject::find(const QString &key) {
|
|
||||||
return values_.find(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonObject::const_iterator QJsonObject::find(const QString &key) const {
|
|
||||||
return values_.find(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonObject::iterator QJsonObject::erase(iterator it) {
|
|
||||||
return values_.erase(it);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonObject::iterator QJsonObject::insert(const QString &key, const QJsonValue &value) {
|
|
||||||
return values_.insert(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QStringList QJsonObject::keys() const {
|
|
||||||
return values_.keys();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void QJsonObject::remove(const QString &key) {
|
|
||||||
values_.remove(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValue QJsonObject::take(const QString &key) {
|
|
||||||
return values_.take(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValue QJsonObject::value(const QString &key) const {
|
|
||||||
return values_.value(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonObject::operator!=(const QJsonObject &other) const {
|
|
||||||
return values_ != other.values_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonObject::operator==(const QJsonObject &other) const {
|
|
||||||
return values_ != other.values_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValue QJsonObject::operator[](const QString &key) const {
|
|
||||||
return values_[key];
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValueRef QJsonObject::operator[](const QString &key) {
|
|
||||||
return QJsonValueRef(this, key);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QVariantMap QJsonObject::toVariantMap() const {
|
|
||||||
QVariantMap a;
|
|
||||||
for(const_iterator it = begin(); it != end(); ++it) {
|
|
||||||
a.insert(it.key(), it.value().toVariant());
|
|
||||||
}
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QVariantHash QJsonObject::toVariantHash() const {
|
|
||||||
QVariantHash a;
|
|
||||||
for(const_iterator it = begin(); it != end(); ++it) {
|
|
||||||
a.insert(it.key(), it.value().toVariant());
|
|
||||||
}
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonObject QJsonObject::fromVariantMap(const QVariantMap &map) {
|
|
||||||
QJsonObject o;
|
|
||||||
for(QVariantMap::const_iterator it = map.begin(); it != map.end(); ++it) {
|
|
||||||
o.insert(it.key(), QJsonValue::fromVariant(it.value()));
|
|
||||||
}
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonObject QJsonObject::fromVariantHash(const QVariantHash &hash) {
|
|
||||||
QJsonObject o;
|
|
||||||
for(QVariantHash::const_iterator it = hash.begin(); it != hash.end(); ++it) {
|
|
||||||
o.insert(it.key(), QJsonValue::fromVariant(it.value()));
|
|
||||||
}
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonRoot *QJsonObject::clone() const {
|
|
||||||
return new QJsonObject(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
const QJsonObject *QJsonObject::toObject() const {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonObject *QJsonObject::toObject() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonArray *QJsonObject::toArray() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
const QJsonArray *QJsonObject::toArray() const {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: swap
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void QJsonObject::swap(QJsonObject &other) {
|
|
||||||
qSwap(values_, other.values_);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,121 +0,0 @@
|
||||||
/*****************************************************************************
|
|
||||||
* gta5view Grand Theft Auto V Profile Viewer
|
|
||||||
* Copyright (C) 2016 Syping
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef QJSON_OBJECT_H_
|
|
||||||
#define QJSON_OBJECT_H_
|
|
||||||
|
|
||||||
#include <QtCore/QtGlobal>
|
|
||||||
|
|
||||||
#if QT_VERSION >= 0x050000
|
|
||||||
#include <QtCore/QJsonObject>
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include "QJsonRoot.h"
|
|
||||||
#include "QJsonValueRef.h"
|
|
||||||
#include "QJsonValue.h"
|
|
||||||
#include <QtCore/QString>
|
|
||||||
#include <QtCore/QStringList>
|
|
||||||
#include <QtCore/QVariantMap>
|
|
||||||
#include <QtCore/QMap>
|
|
||||||
|
|
||||||
class QJsonObject : public QJsonRoot {
|
|
||||||
friend class QJsonDocument;
|
|
||||||
friend class QJsonValue;
|
|
||||||
friend class QJsonValueRef;
|
|
||||||
friend class QJsonParser;
|
|
||||||
public:
|
|
||||||
// TODO(eteran): manually implement the map, for now we use QMap
|
|
||||||
// but the real thing has a custom implementation
|
|
||||||
// I guess for the purposes of less interdependancies?
|
|
||||||
// maybe so it's easier to forward declare the iterators?
|
|
||||||
|
|
||||||
typedef QMap<QString, QJsonValue>::const_iterator const_iterator;
|
|
||||||
typedef QMap<QString, QJsonValue>::iterator iterator;
|
|
||||||
typedef const_iterator ConstIterator;
|
|
||||||
typedef iterator Iterator;
|
|
||||||
typedef QMap<QString, QJsonValue>::key_type key_type;
|
|
||||||
typedef QMap<QString, QJsonValue>::mapped_type mapped_type;
|
|
||||||
typedef QMap<QString, QJsonValue>::size_type size_type;
|
|
||||||
|
|
||||||
public:
|
|
||||||
QJsonObject();
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
QJsonObject(std::initializer_list<QPair<QString, QJsonValue> > args);
|
|
||||||
#endif
|
|
||||||
QJsonObject(const QJsonObject &other);
|
|
||||||
~QJsonObject();
|
|
||||||
QJsonObject &operator=(const QJsonObject &other);
|
|
||||||
|
|
||||||
public:
|
|
||||||
iterator begin();
|
|
||||||
const_iterator begin() const;
|
|
||||||
iterator end();
|
|
||||||
const_iterator end() const;
|
|
||||||
const_iterator constBegin() const;
|
|
||||||
const_iterator constEnd() const;
|
|
||||||
|
|
||||||
public:
|
|
||||||
int count() const;
|
|
||||||
int length() const;
|
|
||||||
int size() const;
|
|
||||||
bool empty() const;
|
|
||||||
bool isEmpty() const;
|
|
||||||
|
|
||||||
public:
|
|
||||||
const_iterator constFind(const QString &key) const;
|
|
||||||
bool contains(const QString &key) const;
|
|
||||||
iterator find(const QString &key);
|
|
||||||
const_iterator find(const QString &key) const;
|
|
||||||
|
|
||||||
public:
|
|
||||||
iterator erase(iterator it);
|
|
||||||
iterator insert(const QString &key, const QJsonValue &value);
|
|
||||||
QStringList keys() const;
|
|
||||||
void remove(const QString &key);
|
|
||||||
QJsonValue take(const QString &key);
|
|
||||||
QJsonValue value(const QString &key) const;
|
|
||||||
bool operator!=(const QJsonObject &other) const;
|
|
||||||
bool operator==(const QJsonObject &other) const;
|
|
||||||
QJsonValue operator[](const QString &key) const;
|
|
||||||
QJsonValueRef operator[](const QString &key);
|
|
||||||
|
|
||||||
public:
|
|
||||||
QVariantMap toVariantMap() const;
|
|
||||||
QVariantHash toVariantHash() const;
|
|
||||||
|
|
||||||
public:
|
|
||||||
static QJsonObject fromVariantMap(const QVariantMap &map);
|
|
||||||
static QJsonObject fromVariantHash(const QVariantHash &hash);
|
|
||||||
|
|
||||||
private:
|
|
||||||
virtual QJsonRoot *clone() const;
|
|
||||||
virtual QJsonArray *toArray();
|
|
||||||
virtual QJsonObject *toObject();
|
|
||||||
virtual const QJsonArray *toArray() const;
|
|
||||||
virtual const QJsonObject *toObject() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void swap(QJsonObject &other);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QMap<QString, QJsonValue> values_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1 +0,0 @@
|
||||||
#include "QJsonParseError.h"
|
|
|
@ -1,64 +0,0 @@
|
||||||
/*****************************************************************************
|
|
||||||
* gta5view Grand Theft Auto V Profile Viewer
|
|
||||||
* Copyright (C) 2016 Syping
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
#include "QJsonParseError.h"
|
|
||||||
|
|
||||||
#if QT_VERSION < 0x050000
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: errorString
|
|
||||||
// Desc: The QJsonParseError class is used to report errors during JSON parsing.
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QString QJsonParseError::errorString() const {
|
|
||||||
switch(error) {
|
|
||||||
case NoError:
|
|
||||||
return "No error occurred";
|
|
||||||
case UnterminatedObject:
|
|
||||||
return "unterminated object";
|
|
||||||
case MissingNameSeparator:
|
|
||||||
return "missing name separator";
|
|
||||||
case UnterminatedArray:
|
|
||||||
return "unterminated array";
|
|
||||||
case MissingValueSeparator:
|
|
||||||
return "missing value separator";
|
|
||||||
case IllegalValue:
|
|
||||||
return "illegal value";
|
|
||||||
case TerminationByNumber:
|
|
||||||
return "invalid termination by number";
|
|
||||||
case IllegalNumber:
|
|
||||||
return "illegal number";
|
|
||||||
case IllegalEscapeSequence:
|
|
||||||
return "illegal escape sequence";
|
|
||||||
case IllegalUTF8String:
|
|
||||||
return "invalid UTF8 string";
|
|
||||||
case UnterminatedString:
|
|
||||||
return "unterminated string";
|
|
||||||
case MissingObject:
|
|
||||||
return "object is missing after a comma";
|
|
||||||
case DeepNesting:
|
|
||||||
return "too deeply nested document";
|
|
||||||
case DocumentTooLarge:
|
|
||||||
return "too large document";
|
|
||||||
case GarbageAtEnd:
|
|
||||||
return "garbage at the end of the document";
|
|
||||||
}
|
|
||||||
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,60 +0,0 @@
|
||||||
/*****************************************************************************
|
|
||||||
* gta5view Grand Theft Auto V Profile Viewer
|
|
||||||
* Copyright (C) 2016 Syping
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef QJSON_PARSE_ERROR_H_
|
|
||||||
#define QJSON_PARSE_ERROR_H_
|
|
||||||
|
|
||||||
#include <QtCore/QtGlobal>
|
|
||||||
|
|
||||||
#if QT_VERSION >= 0x050000
|
|
||||||
#include <QtCore/QJsonParseError>
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include <QtCore/QString>
|
|
||||||
|
|
||||||
class QJsonParseError {
|
|
||||||
public:
|
|
||||||
enum ParseError {
|
|
||||||
NoError = 0,
|
|
||||||
UnterminatedObject = 1,
|
|
||||||
MissingNameSeparator = 2,
|
|
||||||
UnterminatedArray = 3,
|
|
||||||
MissingValueSeparator = 4,
|
|
||||||
IllegalValue = 5,
|
|
||||||
TerminationByNumber = 6,
|
|
||||||
IllegalNumber = 7,
|
|
||||||
IllegalEscapeSequence = 8,
|
|
||||||
IllegalUTF8String = 9,
|
|
||||||
UnterminatedString = 10,
|
|
||||||
MissingObject = 11,
|
|
||||||
DeepNesting = 12,
|
|
||||||
DocumentTooLarge = 13,
|
|
||||||
GarbageAtEnd = 14
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
|
||||||
QString errorString() const;
|
|
||||||
|
|
||||||
public:
|
|
||||||
ParseError error;
|
|
||||||
int offset;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,455 +0,0 @@
|
||||||
/*****************************************************************************
|
|
||||||
* gta5view Grand Theft Auto V Profile Viewer
|
|
||||||
* Copyright (C) 2016 Syping
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
#include "QJsonParser.h"
|
|
||||||
#include "QJsonArray.h"
|
|
||||||
#include "QJsonObject.h"
|
|
||||||
#include "QJsonValue.h"
|
|
||||||
|
|
||||||
|
|
||||||
#if QT_VERSION < 0x050000
|
|
||||||
|
|
||||||
#include <cctype>
|
|
||||||
#include <QScopedPointer>
|
|
||||||
#include <QVector>
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
unsigned int to_hex(int ch) {
|
|
||||||
|
|
||||||
static const int hexval[256] = {
|
|
||||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
|
||||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
|
||||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
|
||||||
0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
|
||||||
0x0, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
|
||||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
|
||||||
0x0, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
|
|
||||||
};
|
|
||||||
|
|
||||||
if(static_cast<unsigned int>(ch) < 256) {
|
|
||||||
return hexval[static_cast<unsigned int>(ch)];
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: QJsonParser
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonParser::QJsonParser(const char *begin, const char *end) : begin_(begin), end_(end), p_(begin) {
|
|
||||||
state_.error = QJsonParseError::NoError;
|
|
||||||
state_.offset = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: parse
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonRoot *QJsonParser::parse() {
|
|
||||||
if(begin_ == end_) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
QJsonRoot *ret = 0;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const char ch = peek();
|
|
||||||
switch(ch) {
|
|
||||||
case ArrayBegin:
|
|
||||||
ret = getArray();
|
|
||||||
break;
|
|
||||||
case ObjectBegin:
|
|
||||||
ret = getObject();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
state_.error = QJsonParseError::IllegalValue;
|
|
||||||
state_.offset = p_ - begin_;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} catch(const QJsonParseError &e) {
|
|
||||||
state_ = e;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ret) {
|
|
||||||
// eat up trailing white space...
|
|
||||||
while(p_ != end_ && std::isspace(*p_)) {
|
|
||||||
++p_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//detect trailing garbage
|
|
||||||
if(p_ != end_) {
|
|
||||||
state_.error = QJsonParseError::GarbageAtEnd;
|
|
||||||
state_.offset = p_ - begin_;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: peek
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
char QJsonParser::peek() {
|
|
||||||
// first eat up some whitespace
|
|
||||||
while(p_ != end_ && std::isspace(*p_)) {
|
|
||||||
++p_;
|
|
||||||
}
|
|
||||||
|
|
||||||
return *p_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: getValue
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValue QJsonParser::getValue() {
|
|
||||||
|
|
||||||
switch(peek()) {
|
|
||||||
case ObjectBegin:
|
|
||||||
{
|
|
||||||
QScopedPointer<QJsonObject> obj(getObject());
|
|
||||||
return QJsonValue(*obj);
|
|
||||||
}
|
|
||||||
case ArrayBegin:
|
|
||||||
{
|
|
||||||
QScopedPointer<QJsonArray> arr(getArray());
|
|
||||||
return QJsonValue(*arr);
|
|
||||||
}
|
|
||||||
case Quote:
|
|
||||||
return QJsonValue(getString());
|
|
||||||
case 't':
|
|
||||||
return getTrue();
|
|
||||||
case 'f':
|
|
||||||
return getFalse();
|
|
||||||
case 'n':
|
|
||||||
return getNull();
|
|
||||||
default:
|
|
||||||
return getNumber();
|
|
||||||
}
|
|
||||||
|
|
||||||
throwError(QJsonParseError::MissingObject);
|
|
||||||
return QJsonValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: getObject
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonObject *QJsonParser::getObject() {
|
|
||||||
|
|
||||||
QScopedPointer<QJsonObject> obj(new QJsonObject);
|
|
||||||
|
|
||||||
char tok = peek();
|
|
||||||
if(tok != ObjectBegin) {
|
|
||||||
throwError(QJsonParseError::IllegalValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
++p_;
|
|
||||||
|
|
||||||
// handle empty object
|
|
||||||
tok = peek();
|
|
||||||
if(peek() == ObjectEnd) {
|
|
||||||
++p_;
|
|
||||||
} else {
|
|
||||||
|
|
||||||
do {
|
|
||||||
QPair<QString, QJsonValue> p = getPair();
|
|
||||||
obj->values_.insert(p.first, p.second);
|
|
||||||
|
|
||||||
tok = peek();
|
|
||||||
++p_;
|
|
||||||
|
|
||||||
} while(tok == ValueSeparator);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(tok != ObjectEnd) {
|
|
||||||
throwError(QJsonParseError::UnterminatedObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
return obj.take();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: getArray
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonArray *QJsonParser::getArray() {
|
|
||||||
|
|
||||||
QScopedPointer<QJsonArray> arr(new QJsonArray);
|
|
||||||
|
|
||||||
char tok = peek();
|
|
||||||
|
|
||||||
if(tok != ArrayBegin) {
|
|
||||||
throwError(QJsonParseError::IllegalValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
++p_;
|
|
||||||
|
|
||||||
// handle empty object
|
|
||||||
tok = peek();
|
|
||||||
if(tok == ArrayEnd) {
|
|
||||||
++p_;
|
|
||||||
} else {
|
|
||||||
do {
|
|
||||||
arr->values_.push_back(getValue());
|
|
||||||
|
|
||||||
tok = peek();
|
|
||||||
++p_;
|
|
||||||
|
|
||||||
} while(tok == ValueSeparator);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(tok != ArrayEnd) {
|
|
||||||
throwError(QJsonParseError::MissingValueSeparator);
|
|
||||||
}
|
|
||||||
|
|
||||||
return arr.take();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: getPair
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QPair<QString, QJsonValue> QJsonParser::getPair() {
|
|
||||||
|
|
||||||
QString key = getString();
|
|
||||||
|
|
||||||
if(peek() != NameSeparator) {
|
|
||||||
throwError(QJsonParseError::MissingNameSeparator);
|
|
||||||
}
|
|
||||||
++p_;
|
|
||||||
|
|
||||||
return qMakePair(key, getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: getString
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QString QJsonParser::getString() {
|
|
||||||
|
|
||||||
if(peek() != Quote) {
|
|
||||||
throwError(QJsonParseError::IllegalUTF8String);
|
|
||||||
}
|
|
||||||
++p_;
|
|
||||||
|
|
||||||
QByteArray s;
|
|
||||||
|
|
||||||
while(p_ != end_ && *p_ != Quote && *p_ != '\n') {
|
|
||||||
if(*p_ == '\\') {
|
|
||||||
++p_;
|
|
||||||
if(p_ != end_) {
|
|
||||||
switch(*p_) {
|
|
||||||
case '"': s.append('"'); break;
|
|
||||||
case '\\': s.append('\\'); break;
|
|
||||||
case '/': s.append('/'); break;
|
|
||||||
case 'b': s.append('\b'); break;
|
|
||||||
case 'f': s.append('\f'); break;
|
|
||||||
case 'n': s.append('\n'); break;
|
|
||||||
case 'r': s.append('\r'); break;
|
|
||||||
case 't': s.append('\t'); break;
|
|
||||||
case 'u':
|
|
||||||
{
|
|
||||||
|
|
||||||
QString hexChar;
|
|
||||||
|
|
||||||
// convert \uXXXX escape sequences to UTF-8
|
|
||||||
char hex[4];
|
|
||||||
if(p_ == end_) { throwError(QJsonParseError::IllegalEscapeSequence); } hex[0] = *++p_;
|
|
||||||
if(p_ == end_) { throwError(QJsonParseError::IllegalEscapeSequence); } hex[1] = *++p_;
|
|
||||||
if(p_ == end_) { throwError(QJsonParseError::IllegalEscapeSequence); } hex[2] = *++p_;
|
|
||||||
if(p_ == end_) { throwError(QJsonParseError::IllegalEscapeSequence); } hex[3] = *++p_;
|
|
||||||
|
|
||||||
if(!std::isxdigit(hex[0])) throwError(QJsonParseError::IllegalUTF8String);
|
|
||||||
if(!std::isxdigit(hex[1])) throwError(QJsonParseError::IllegalUTF8String);
|
|
||||||
if(!std::isxdigit(hex[2])) throwError(QJsonParseError::IllegalUTF8String);
|
|
||||||
if(!std::isxdigit(hex[3])) throwError(QJsonParseError::IllegalUTF8String);
|
|
||||||
|
|
||||||
quint16 w1 = 0;
|
|
||||||
quint16 w2 = 0;
|
|
||||||
|
|
||||||
w1 |= (to_hex(hex[0]) << 12);
|
|
||||||
w1 |= (to_hex(hex[1]) << 8);
|
|
||||||
w1 |= (to_hex(hex[2]) << 4);
|
|
||||||
w1 |= (to_hex(hex[3]));
|
|
||||||
|
|
||||||
hexChar.append(QChar(w1));
|
|
||||||
|
|
||||||
if((w1 & 0xfc00) == 0xdc00) {
|
|
||||||
throwError(QJsonParseError::IllegalUTF8String);
|
|
||||||
}
|
|
||||||
|
|
||||||
if((w1 & 0xfc00) == 0xd800) {
|
|
||||||
// part of a surrogate pair
|
|
||||||
if(p_ == end_ || *++p_ != '\\') { throwError(QJsonParseError::IllegalEscapeSequence); }
|
|
||||||
if(p_ == end_ || *++p_ != 'u') { throwError(QJsonParseError::IllegalEscapeSequence); }
|
|
||||||
|
|
||||||
// convert \uXXXX escape sequences to UTF-8
|
|
||||||
if(p_ == end_) { throwError(QJsonParseError::IllegalEscapeSequence); } hex[0] = *++p_;
|
|
||||||
if(p_ == end_) { throwError(QJsonParseError::IllegalEscapeSequence); } hex[1] = *++p_;
|
|
||||||
if(p_ == end_) { throwError(QJsonParseError::IllegalEscapeSequence); } hex[2] = *++p_;
|
|
||||||
if(p_ == end_) { throwError(QJsonParseError::IllegalEscapeSequence); } hex[3] = *++p_;
|
|
||||||
|
|
||||||
if(!std::isxdigit(hex[0])) throwError(QJsonParseError::IllegalUTF8String);
|
|
||||||
if(!std::isxdigit(hex[1])) throwError(QJsonParseError::IllegalUTF8String);
|
|
||||||
if(!std::isxdigit(hex[2])) throwError(QJsonParseError::IllegalUTF8String);
|
|
||||||
if(!std::isxdigit(hex[3])) throwError(QJsonParseError::IllegalUTF8String);
|
|
||||||
|
|
||||||
w2 |= (to_hex(hex[0]) << 12);
|
|
||||||
w2 |= (to_hex(hex[1]) << 8);
|
|
||||||
w2 |= (to_hex(hex[2]) << 4);
|
|
||||||
w2 |= (to_hex(hex[3]));
|
|
||||||
|
|
||||||
hexChar.append(QChar(w2));
|
|
||||||
}
|
|
||||||
|
|
||||||
s.append(hexChar.toUtf8());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
s.append('\\');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
s.append(*p_);
|
|
||||||
}
|
|
||||||
++p_;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(*p_ != Quote || p_ == end_) {
|
|
||||||
throwError(QJsonParseError::UnterminatedString);
|
|
||||||
}
|
|
||||||
|
|
||||||
++p_;
|
|
||||||
|
|
||||||
return QString::fromUtf8(s, s.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: getNull
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValue QJsonParser::getNull() {
|
|
||||||
if(p_ == end_ || *p_++ != 'n') { throwError(QJsonParseError::IllegalValue); }
|
|
||||||
if(p_ == end_ || *p_++ != 'u') { throwError(QJsonParseError::IllegalValue); }
|
|
||||||
if(p_ == end_ || *p_++ != 'l') { throwError(QJsonParseError::IllegalValue); }
|
|
||||||
if(p_ == end_ || *p_++ != 'l') { throwError(QJsonParseError::IllegalValue); }
|
|
||||||
|
|
||||||
return QJsonValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: getTrue
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValue QJsonParser::getTrue() {
|
|
||||||
if(p_ == end_ || *p_++ != 't') { throwError(QJsonParseError::IllegalValue); }
|
|
||||||
if(p_ == end_ || *p_++ != 'r') { throwError(QJsonParseError::IllegalValue); }
|
|
||||||
if(p_ == end_ || *p_++ != 'u') { throwError(QJsonParseError::IllegalValue); }
|
|
||||||
if(p_ == end_ || *p_++ != 'e') { throwError(QJsonParseError::IllegalValue); }
|
|
||||||
|
|
||||||
return QJsonValue(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: getFalse
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValue QJsonParser::getFalse() {
|
|
||||||
if(p_ == end_ || *p_++ != 'f') { throwError(QJsonParseError::IllegalValue); }
|
|
||||||
if(p_ == end_ || *p_++ != 'a') { throwError(QJsonParseError::IllegalValue); }
|
|
||||||
if(p_ == end_ || *p_++ != 'l') { throwError(QJsonParseError::IllegalValue); }
|
|
||||||
if(p_ == end_ || *p_++ != 's') { throwError(QJsonParseError::IllegalValue); }
|
|
||||||
if(p_ == end_ || *p_++ != 'e') { throwError(QJsonParseError::IllegalValue); }
|
|
||||||
|
|
||||||
return QJsonValue(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: getNumber
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValue QJsonParser::getNumber() {
|
|
||||||
// JSON numbers fit the regex: -?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?
|
|
||||||
|
|
||||||
const char *const first = p_;
|
|
||||||
|
|
||||||
// -?
|
|
||||||
if(p_ != end_ && *p_ == '-') {
|
|
||||||
++p_;
|
|
||||||
}
|
|
||||||
|
|
||||||
// (0|[1-9][0-9]*)
|
|
||||||
if(p_ != end_) {
|
|
||||||
if(*p_ >= '1' && *p_ <= '9') {
|
|
||||||
while(p_ != end_ && std::isdigit(*p_)) {
|
|
||||||
++p_;
|
|
||||||
}
|
|
||||||
} else if(*p_ == '0') {
|
|
||||||
++p_;
|
|
||||||
} else {
|
|
||||||
throwError(QJsonParseError::IllegalNumber);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// (\.[0-9]+)?
|
|
||||||
if(p_ != end_ && *p_ == '.') {
|
|
||||||
++p_;
|
|
||||||
if(!std::isdigit(*p_)) {
|
|
||||||
throwError(QJsonParseError::IllegalNumber);
|
|
||||||
}
|
|
||||||
|
|
||||||
while(p_ != end_ && std::isdigit(*p_)) {
|
|
||||||
++p_;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ([eE][+-]?[0-9]+)?
|
|
||||||
if(p_ != end_ && (*p_ == 'e' || *p_ == 'E')) {
|
|
||||||
++p_;
|
|
||||||
if(p_ != end_ && (*p_ == '+' || *p_ == '-')) {
|
|
||||||
++p_;
|
|
||||||
}
|
|
||||||
if(!std::isdigit(*p_)) {
|
|
||||||
throwError(QJsonParseError::IllegalNumber);
|
|
||||||
}
|
|
||||||
while(p_ != end_ && std::isdigit(*p_)) {
|
|
||||||
++p_;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(p_ == end_) {
|
|
||||||
throwError(QJsonParseError::TerminationByNumber);
|
|
||||||
}
|
|
||||||
|
|
||||||
return QJsonValue(QByteArray::fromRawData(first, p_ - first).toDouble());
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: state
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonParseError QJsonParser::state() const {
|
|
||||||
return state_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: throwError
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void QJsonParser::throwError(QJsonParseError::ParseError e) {
|
|
||||||
QJsonParseError err;
|
|
||||||
err.error = e;
|
|
||||||
err.offset = p_ - begin_;
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,81 +0,0 @@
|
||||||
/*****************************************************************************
|
|
||||||
* gta5view Grand Theft Auto V Profile Viewer
|
|
||||||
* Copyright (C) 2016 Syping
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
// NOTE: this is not part of the "public" Qt API, so using this class directly
|
|
||||||
// is not recomended
|
|
||||||
|
|
||||||
#ifndef QJSON_PARSER_H_
|
|
||||||
#define QJSON_PARSER_H_
|
|
||||||
|
|
||||||
#include <QtCore/QtGlobal>
|
|
||||||
|
|
||||||
#if QT_VERSION < 0x050000
|
|
||||||
|
|
||||||
#include "QJsonParseError.h"
|
|
||||||
#include <QPair>
|
|
||||||
class QJsonRoot;
|
|
||||||
class QJsonObject;
|
|
||||||
class QJsonArray;
|
|
||||||
class QJsonValue;
|
|
||||||
|
|
||||||
class QJsonParser {
|
|
||||||
friend class QJsonDocument;
|
|
||||||
|
|
||||||
public:
|
|
||||||
QJsonParser(const char *begin, const char *end);
|
|
||||||
|
|
||||||
public:
|
|
||||||
QJsonRoot *parse();
|
|
||||||
|
|
||||||
public:
|
|
||||||
QJsonParseError state() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
static const char ArrayBegin = '[';
|
|
||||||
static const char ArrayEnd = ']';
|
|
||||||
static const char NameSeparator = ':';
|
|
||||||
static const char ValueSeparator = ',';
|
|
||||||
static const char ObjectBegin = '{';
|
|
||||||
static const char ObjectEnd = '}';
|
|
||||||
static const char Quote = '"';
|
|
||||||
|
|
||||||
private:
|
|
||||||
char peek();
|
|
||||||
QJsonObject *getObject();
|
|
||||||
QJsonArray *getArray();
|
|
||||||
QJsonValue getValue();
|
|
||||||
QString getString();
|
|
||||||
QJsonValue getTrue();
|
|
||||||
QJsonValue getFalse();
|
|
||||||
QJsonValue getNull();
|
|
||||||
QJsonValue getNumber();
|
|
||||||
QPair<QString, QJsonValue> getPair();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void throwError(QJsonParseError::ParseError e);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QJsonParseError state_;
|
|
||||||
const char *const begin_;
|
|
||||||
const char *const end_;
|
|
||||||
const char * p_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1 +0,0 @@
|
||||||
#include "QJsonRoot.h"
|
|
|
@ -1,45 +0,0 @@
|
||||||
/*****************************************************************************
|
|
||||||
* gta5view Grand Theft Auto V Profile Viewer
|
|
||||||
* Copyright (C) 2016 Syping
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef QJSON_ROOT_H_
|
|
||||||
#define QJSON_ROOT_H_
|
|
||||||
|
|
||||||
#include <QtCore/QtGlobal>
|
|
||||||
|
|
||||||
#if QT_VERSION < 0x050000
|
|
||||||
|
|
||||||
class QJsonObject;
|
|
||||||
class QJsonArray;
|
|
||||||
|
|
||||||
class QJsonRoot {
|
|
||||||
public:
|
|
||||||
virtual ~QJsonRoot() {};
|
|
||||||
|
|
||||||
public:
|
|
||||||
virtual QJsonRoot *clone() const = 0;
|
|
||||||
|
|
||||||
public:
|
|
||||||
virtual QJsonArray *toArray() = 0;
|
|
||||||
virtual QJsonObject *toObject() = 0;
|
|
||||||
virtual const QJsonArray *toArray() const = 0;
|
|
||||||
virtual const QJsonObject *toObject() const = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1 +0,0 @@
|
||||||
#include "QJsonValue.h"
|
|
|
@ -1,391 +0,0 @@
|
||||||
/*****************************************************************************
|
|
||||||
* gta5view Grand Theft Auto V Profile Viewer
|
|
||||||
* Copyright (C) 2016 Syping
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
#include "QJsonValue.h"
|
|
||||||
#include "QJsonArray.h"
|
|
||||||
#include "QJsonObject.h"
|
|
||||||
|
|
||||||
#if QT_VERSION < 0x050000
|
|
||||||
#include <QtCore/QtAlgorithms>
|
|
||||||
#include <QtCore/qmath.h>
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: QJsonValue
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValue::QJsonValue(Type type) : type_(type) {
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: QJsonValue
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValue::QJsonValue(bool b) : type_(Bool) {
|
|
||||||
value_.b = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: QJsonValue
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValue::QJsonValue(double n) : type_(Double) {
|
|
||||||
value_.n = n;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: QJsonValue
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValue::QJsonValue(const QString &s) : type_(String) {
|
|
||||||
value_.s = new QString(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: QJsonValue
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValue::QJsonValue(QLatin1String s) : type_(String) {
|
|
||||||
value_.s = new QString(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef QT_NO_CAST_FROM_ASCII
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: QJsonValue
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValue::QJsonValue(const char *s) : type_(String) {
|
|
||||||
value_.s = new QString(QString::fromUtf8(s));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: QJsonValue
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValue::QJsonValue(const QJsonArray &a) : type_(Array) {
|
|
||||||
value_.r = a.clone();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: QJsonValue
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValue::QJsonValue(const QJsonObject &o) : type_(Object) {
|
|
||||||
value_.r = o.clone();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: QJsonValue
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValue::QJsonValue(int n) : type_(Double) {
|
|
||||||
value_.n = n;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: QJsonValue
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValue::QJsonValue(qint64 n) : type_(Double) {
|
|
||||||
value_.n = n;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: QJsonValue
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValue::QJsonValue(const QJsonValue &other) : type_(other.type_) {
|
|
||||||
|
|
||||||
switch(other.type_) {
|
|
||||||
case Bool:
|
|
||||||
value_.b = other.value_.b;
|
|
||||||
break;
|
|
||||||
case Double:
|
|
||||||
value_.n = other.value_.n;
|
|
||||||
break;
|
|
||||||
case String:
|
|
||||||
value_.s = new QString(*other.value_.s);
|
|
||||||
break;
|
|
||||||
case Array:
|
|
||||||
case Object:
|
|
||||||
value_.r = other.value_.r->clone();
|
|
||||||
break;
|
|
||||||
case Undefined:
|
|
||||||
case Null:
|
|
||||||
value_ = other.value_;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: ~QJsonValue
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValue::~QJsonValue() {
|
|
||||||
switch(type_) {
|
|
||||||
case Null:
|
|
||||||
case Bool:
|
|
||||||
case Double:
|
|
||||||
case Undefined:
|
|
||||||
break;
|
|
||||||
case String:
|
|
||||||
delete value_.s;
|
|
||||||
break;
|
|
||||||
case Object:
|
|
||||||
case Array:
|
|
||||||
delete value_.r;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: operator=
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValue &QJsonValue::operator=(const QJsonValue &other) {
|
|
||||||
QJsonValue(other).swap(*this);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: operator!=
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonValue::operator!=(const QJsonValue &other) const {
|
|
||||||
return !(*this == other);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: operator==
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonValue::operator==(const QJsonValue &other) const {
|
|
||||||
if(type_ == other.type_) {
|
|
||||||
switch(type_) {
|
|
||||||
case Null:
|
|
||||||
return true;
|
|
||||||
case Bool:
|
|
||||||
return value_.b == other.value_.b;
|
|
||||||
case Double:
|
|
||||||
return value_.n == other.value_.n;
|
|
||||||
case Undefined:
|
|
||||||
return true;
|
|
||||||
case String:
|
|
||||||
return *value_.s == *other.value_.s;
|
|
||||||
case Array:
|
|
||||||
return *(value_.r->toArray()) == *(other.value_.r->toArray());
|
|
||||||
case Object:
|
|
||||||
return *(value_.r->toObject()) == *(other.value_.r->toObject());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: isArray
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonValue::isArray() const {
|
|
||||||
return type_ == Array;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: isBool
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonValue::isBool() const {
|
|
||||||
return type_ == Bool;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: isDouble
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonValue::isDouble() const {
|
|
||||||
return type_ == Double;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: isNull
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonValue::isNull() const {
|
|
||||||
return type_ == Null;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: isObject
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonValue::isObject() const {
|
|
||||||
return type_ == Object;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: isString
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonValue::isString() const {
|
|
||||||
return type_ == String;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: isUndefined
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonValue::isUndefined() const {
|
|
||||||
return type_ == Undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: type
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValue::Type QJsonValue::type() const {
|
|
||||||
return type_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: toArray
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonArray QJsonValue::toArray(const QJsonArray &defaultValue) const {
|
|
||||||
if(isArray()) {
|
|
||||||
return *(value_.r->toArray());
|
|
||||||
}
|
|
||||||
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: toArray
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonArray QJsonValue::toArray() const {
|
|
||||||
return toArray(QJsonArray());
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: toBool
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonValue::toBool(bool defaultValue) const {
|
|
||||||
if(isBool()) {
|
|
||||||
return value_.b;
|
|
||||||
}
|
|
||||||
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: toDouble
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
double QJsonValue::toDouble(double defaultValue) const {
|
|
||||||
if(isDouble()) {
|
|
||||||
return value_.n;
|
|
||||||
}
|
|
||||||
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: toInt
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
int QJsonValue::toInt(int defaultValue) const {
|
|
||||||
if(isDouble() && qFloor(value_.n) == value_.n) {
|
|
||||||
return value_.n;
|
|
||||||
}
|
|
||||||
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: toObject
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonObject QJsonValue::toObject(const QJsonObject &defaultValue) const {
|
|
||||||
if(isObject()) {
|
|
||||||
return *(value_.r->toObject());
|
|
||||||
}
|
|
||||||
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: toObject
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonObject QJsonValue::toObject() const {
|
|
||||||
return toObject(QJsonObject());
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: toString
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QString QJsonValue::toString(const QString &defaultValue) const {
|
|
||||||
|
|
||||||
if(isString()) {
|
|
||||||
return *value_.s;
|
|
||||||
}
|
|
||||||
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: toVariant
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QVariant QJsonValue::toVariant() const {
|
|
||||||
switch(type_) {
|
|
||||||
case Null:
|
|
||||||
return QVariant();
|
|
||||||
case Bool:
|
|
||||||
return QVariant::fromValue(value_.b);
|
|
||||||
case Double:
|
|
||||||
return QVariant::fromValue(value_.n);
|
|
||||||
case String:
|
|
||||||
return QVariant::fromValue(*value_.s);
|
|
||||||
case Array:
|
|
||||||
return value_.r->toArray()->toVariantList();
|
|
||||||
case Object:
|
|
||||||
return value_.r->toObject()->toVariantMap();
|
|
||||||
case Undefined:
|
|
||||||
return QVariant();
|
|
||||||
}
|
|
||||||
|
|
||||||
return QVariant();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: fromVariant
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValue QJsonValue::fromVariant(const QVariant &variant) {
|
|
||||||
if(variant.isNull()) {
|
|
||||||
return QJsonValue(Null);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(variant.type()) {
|
|
||||||
case QVariant::Bool:
|
|
||||||
return QJsonValue(variant.toBool());
|
|
||||||
case QVariant::Int:
|
|
||||||
return QJsonValue(variant.toInt());
|
|
||||||
case QVariant::Double:
|
|
||||||
case QVariant::LongLong:
|
|
||||||
case QVariant::ULongLong:
|
|
||||||
case QVariant::UInt:
|
|
||||||
return QJsonValue(variant.toDouble());
|
|
||||||
case QVariant::String:
|
|
||||||
return QJsonValue(variant.toString());
|
|
||||||
case QVariant::List:
|
|
||||||
return QJsonArray::fromVariantList(variant.toList());
|
|
||||||
case QVariant::StringList:
|
|
||||||
return QJsonArray::fromStringList(variant.toStringList());
|
|
||||||
case QVariant::Map:
|
|
||||||
return QJsonObject::fromVariantMap(variant.toMap());
|
|
||||||
default:
|
|
||||||
const QString s = variant.toString();
|
|
||||||
if(!s.isEmpty()) {
|
|
||||||
return QJsonValue(s);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return QJsonValue(Null);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: swap
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void QJsonValue::swap(QJsonValue &other) {
|
|
||||||
qSwap(type_, other.type_);
|
|
||||||
qSwap(value_, other.value_);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,120 +0,0 @@
|
||||||
/*****************************************************************************
|
|
||||||
* gta5view Grand Theft Auto V Profile Viewer
|
|
||||||
* Copyright (C) 2016 Syping
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef QJSON_VALUE_H_
|
|
||||||
#define QJSON_VALUE_H_
|
|
||||||
|
|
||||||
#include <QtCore/QtGlobal>
|
|
||||||
|
|
||||||
#if QT_VERSION >= 0x050000
|
|
||||||
#include <QtCore/QJsonValue>
|
|
||||||
#else
|
|
||||||
|
|
||||||
class QString;
|
|
||||||
|
|
||||||
#include <QtCore/QVariant>
|
|
||||||
|
|
||||||
class QJsonRoot;
|
|
||||||
class QJsonArray;
|
|
||||||
class QJsonObject;
|
|
||||||
|
|
||||||
class QJsonValue {
|
|
||||||
public:
|
|
||||||
enum Type {
|
|
||||||
Null = 0x0,
|
|
||||||
Bool = 0x1,
|
|
||||||
Double = 0x2,
|
|
||||||
String = 0x3,
|
|
||||||
Array = 0x4,
|
|
||||||
Object = 0x5,
|
|
||||||
Undefined = 0x80
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
|
||||||
QJsonValue(Type type = Null);
|
|
||||||
QJsonValue(bool b);
|
|
||||||
QJsonValue(double n);
|
|
||||||
QJsonValue(int n);
|
|
||||||
QJsonValue(qint64 n);
|
|
||||||
QJsonValue(const QString &s);
|
|
||||||
QJsonValue(QLatin1String s);
|
|
||||||
#ifndef QT_NO_CAST_FROM_ASCII
|
|
||||||
QJsonValue(const char *s);
|
|
||||||
#endif
|
|
||||||
QJsonValue(const QJsonArray &a);
|
|
||||||
QJsonValue(const QJsonObject &o);
|
|
||||||
QJsonValue(const QJsonValue &other);
|
|
||||||
|
|
||||||
~QJsonValue();
|
|
||||||
|
|
||||||
private:
|
|
||||||
// to protect against incorrect usage due to passing a const char *
|
|
||||||
QJsonValue(const void *);
|
|
||||||
|
|
||||||
public:
|
|
||||||
QJsonValue &operator=(const QJsonValue &other);
|
|
||||||
|
|
||||||
public:
|
|
||||||
bool operator!=(const QJsonValue &other) const;
|
|
||||||
bool operator==(const QJsonValue &other) const;
|
|
||||||
|
|
||||||
public:
|
|
||||||
bool isArray() const;
|
|
||||||
bool isBool() const;
|
|
||||||
bool isDouble() const;
|
|
||||||
bool isNull() const;
|
|
||||||
bool isObject() const;
|
|
||||||
bool isString() const;
|
|
||||||
bool isUndefined() const;
|
|
||||||
|
|
||||||
public:
|
|
||||||
QJsonArray toArray(const QJsonArray &defaultValue) const;
|
|
||||||
QJsonArray toArray() const;
|
|
||||||
bool toBool(bool defaultValue = false) const;
|
|
||||||
double toDouble(double defaultValue = 0) const;
|
|
||||||
int toInt(int defaultValue = 0) const;
|
|
||||||
QJsonObject toObject(const QJsonObject &defaultValue) const;
|
|
||||||
QJsonObject toObject() const;
|
|
||||||
QString toString(const QString &defaultValue = QString()) const;
|
|
||||||
QVariant toVariant() const;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Type type() const;
|
|
||||||
|
|
||||||
public:
|
|
||||||
static QJsonValue fromVariant(const QVariant &variant);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void swap(QJsonValue &other);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Type type_;
|
|
||||||
|
|
||||||
union ValueType {
|
|
||||||
bool b;
|
|
||||||
double n;
|
|
||||||
QString *s;
|
|
||||||
QJsonRoot *r; // OJsonObject or QJsonArray
|
|
||||||
};
|
|
||||||
|
|
||||||
ValueType value_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1 +0,0 @@
|
||||||
#include "QJsonValueRef.h"
|
|
|
@ -1,228 +0,0 @@
|
||||||
/*****************************************************************************
|
|
||||||
* gta5view Grand Theft Auto V Profile Viewer
|
|
||||||
* Copyright (C) 2016 Syping
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
#include "QJsonValueRef.h"
|
|
||||||
|
|
||||||
#if QT_VERSION < 0x050000
|
|
||||||
|
|
||||||
#include "QJsonArray.h"
|
|
||||||
#include "QJsonObject.h"
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
// Desc:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValueRef::QJsonValueRef(QJsonArray *array, int idx) : p_(array), index_(idx) {
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
// Desc:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValueRef::QJsonValueRef(QJsonObject *object, const QString &key) : p_(object), index_(0), key_(key) {
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
// Desc:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValueRef::operator QJsonValue() const {
|
|
||||||
return toValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
// Desc:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValueRef &QJsonValueRef::operator=(const QJsonValue &val) {
|
|
||||||
|
|
||||||
if(QJsonObject *const o = p_->toObject()) {
|
|
||||||
o->values_[key_] = val;
|
|
||||||
} else if(QJsonArray *const a = p_->toArray()) {
|
|
||||||
a->values_[index_] = val;
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
// Desc:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValueRef &QJsonValueRef::operator=(const QJsonValueRef &ref) {
|
|
||||||
|
|
||||||
if(QJsonObject *const o = p_->toObject()) {
|
|
||||||
o->values_[key_] = ref;
|
|
||||||
} else if(QJsonArray *const a = p_->toArray()) {
|
|
||||||
a->values_[index_] = ref;
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: type
|
|
||||||
// Desc:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValue::Type QJsonValueRef::type() const {
|
|
||||||
return toValue().type();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: isNull
|
|
||||||
// Desc:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonValueRef::isNull() const {
|
|
||||||
return toValue().isNull();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: isBool
|
|
||||||
// Desc:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonValueRef::isBool() const {
|
|
||||||
return toValue().isBool();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: isDouble
|
|
||||||
// Desc:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonValueRef::isDouble() const {
|
|
||||||
return toValue().isDouble();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: isString
|
|
||||||
// Desc:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonValueRef::isString() const {
|
|
||||||
return toValue().isString();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: isArray
|
|
||||||
// Desc:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonValueRef::isArray() const {
|
|
||||||
return toValue().isArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: isObject
|
|
||||||
// Desc:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonValueRef::isObject() const {
|
|
||||||
return toValue().isObject();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: isUndefined
|
|
||||||
// Desc:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonValueRef::isUndefined() const {
|
|
||||||
return toValue().isUndefined();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: toBool
|
|
||||||
// Desc:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonValueRef::toBool() const {
|
|
||||||
return toValue().toBool();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: toDouble
|
|
||||||
// Desc:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
double QJsonValueRef::toDouble() const {
|
|
||||||
return toValue().toDouble();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: toInt
|
|
||||||
// Desc:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
int QJsonValueRef::toInt(int defaultValue) const {
|
|
||||||
return toValue().toInt(defaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: toString
|
|
||||||
// Desc:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QString QJsonValueRef::toString() const {
|
|
||||||
return toValue().toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: toArray
|
|
||||||
// Desc:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonArray QJsonValueRef::toArray() const {
|
|
||||||
return toValue().toArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: toObject
|
|
||||||
// Desc:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonObject QJsonValueRef::toObject() const {
|
|
||||||
return toValue().toObject();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: operator==
|
|
||||||
// Desc:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonValueRef::operator==(const QJsonValue &other) const {
|
|
||||||
return toValue() == other;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: operator!=
|
|
||||||
// Desc:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool QJsonValueRef::operator!=(const QJsonValue &other) const {
|
|
||||||
return toValue() != other;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: toValue
|
|
||||||
// Desc:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
QJsonValue QJsonValueRef::toValue() const {
|
|
||||||
if(QJsonObject *const o = p_->toObject()) {
|
|
||||||
return o->values_[key_];
|
|
||||||
} else if(QJsonArray *const a = p_->toArray()) {
|
|
||||||
return a->values_[index_];
|
|
||||||
}
|
|
||||||
|
|
||||||
return QJsonValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Name: swap
|
|
||||||
// Desc:
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void QJsonValueRef::swap(QJsonValueRef &other) {
|
|
||||||
qSwap(p_, other.p_);
|
|
||||||
qSwap(key_, other.key_);
|
|
||||||
qSwap(index_, other.index_);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,79 +0,0 @@
|
||||||
/*****************************************************************************
|
|
||||||
* gta5view Grand Theft Auto V Profile Viewer
|
|
||||||
* Copyright (C) 2016 Syping
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef QJSON_VALUEREF_H_
|
|
||||||
#define QJSON_VALUEREF_H_
|
|
||||||
|
|
||||||
#include <QtCore/QtGlobal>
|
|
||||||
|
|
||||||
#if QT_VERSION >= 0x050000
|
|
||||||
#include <QtCore/QJsonValueRef>
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include "QJsonValue.h"
|
|
||||||
class QJsonRoot;
|
|
||||||
|
|
||||||
class QJsonValueRef {
|
|
||||||
public:
|
|
||||||
QJsonValueRef(QJsonArray *array, int idx);
|
|
||||||
|
|
||||||
// slight variant from official APIs implementation
|
|
||||||
QJsonValueRef(QJsonObject *object, const QString &key);
|
|
||||||
|
|
||||||
public:
|
|
||||||
operator QJsonValue() const;
|
|
||||||
|
|
||||||
public:
|
|
||||||
QJsonValueRef &operator=(const QJsonValue &val);
|
|
||||||
QJsonValueRef &operator=(const QJsonValueRef &val);
|
|
||||||
|
|
||||||
public:
|
|
||||||
QJsonValue::Type type() const;
|
|
||||||
bool isNull() const;
|
|
||||||
bool isBool() const;
|
|
||||||
bool isDouble() const;
|
|
||||||
bool isString() const;
|
|
||||||
bool isArray() const;
|
|
||||||
bool isObject() const;
|
|
||||||
bool isUndefined() const;
|
|
||||||
|
|
||||||
public:
|
|
||||||
bool toBool() const;
|
|
||||||
double toDouble() const;
|
|
||||||
QString toString() const;
|
|
||||||
QJsonArray toArray() const;
|
|
||||||
QJsonObject toObject() const;
|
|
||||||
int toInt(int defaultValue = 0) const;
|
|
||||||
|
|
||||||
public:
|
|
||||||
bool operator==(const QJsonValue &other) const;
|
|
||||||
bool operator!=(const QJsonValue &other) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
QJsonValue toValue() const;
|
|
||||||
void swap(QJsonValueRef &other);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QJsonRoot *p_;
|
|
||||||
int index_;
|
|
||||||
QString key_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
BIN
res/qt4/qt_de.qm
BIN
res/qt4/qt_de.qm
Binary file not shown.
BIN
res/qt4/qt_fr.qm
BIN
res/qt4/qt_fr.qm
Binary file not shown.
BIN
res/qt4/qt_ko.qm
BIN
res/qt4/qt_ko.qm
Binary file not shown.
BIN
res/qt4/qt_ru.qm
BIN
res/qt4/qt_ru.qm
Binary file not shown.
BIN
res/qt4/qt_uk.qm
BIN
res/qt4/qt_uk.qm
Binary file not shown.
Binary file not shown.
|
@ -1,10 +0,0 @@
|
||||||
<RCC>
|
|
||||||
<qresource prefix="/tr">
|
|
||||||
<file>qt_de.qm</file>
|
|
||||||
<file>qt_fr.qm</file>
|
|
||||||
<file>qt_ko.qm</file>
|
|
||||||
<file>qt_ru.qm</file>
|
|
||||||
<file>qt_uk.qm</file>
|
|
||||||
<file>qt_zh_TW.qm</file>
|
|
||||||
</qresource>
|
|
||||||
</RCC>
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue