diff --git a/story-editor-legacy/CMakeLists.txt b/story-editor-legacy/CMakeLists.txt deleted file mode 100644 index 44b970e..0000000 --- a/story-editor-legacy/CMakeLists.txt +++ /dev/null @@ -1,200 +0,0 @@ -cmake_minimum_required(VERSION 3.11) - -project(story-editor VERSION 0.1 LANGUAGES CXX C) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(CMAKE_AUTOUIC ON) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) - -set(CMAKE_C_STANDARD 11) -set(CMAKE_CXX_STANDARD 20) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -find_package(QT NAMES Qt6 REQUIRED COMPONENTS Widgets OpenGLWidgets Multimedia OpenGL) -find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Widgets Gui OpenGLWidgets Multimedia OpenGL ) - -set(PROJECT_SOURCES - src/main.cpp - src/main_window.h - src/main_window.cpp - src/toolbar.h - src/toolbar.cpp - src/ost-editor.qrc - src/story_project.cpp - src/story_project.h - src/media_node_model.h - src/media_node_model.cpp - src/story_graph_model.cpp - src/story_graph_model.h - src/story_node_base.cpp - src/story_node_base.h - src/story_graph_scene.h - src/story_graph_scene.cpp - src/resource_model.h - src/resource_model.cpp - src/resources_dock.h - src/resources_dock.cpp - src/script_editor_dock.h - src/script_editor_dock.cpp - src/memory_view_dock.h - src/memory_view_dock.cpp - src/osthmi_dock.h - src/osthmi_dock.cpp - src/log_dock.h - src/log_dock.cpp - src/vm_dock.h - src/vm_dock.cpp - src/new_project_dialog.h - src/new_project_dialog.cpp - src/dock_widget_base.h - src/dock_widget_base.cpp - src/code_editor.h - src/code_editor.cpp - src/graph.h - src/graph.cpp - src/event_node_model.h - src/event_node_model.cpp - src/highlighter.h - src/highlighter.cpp - src/dr_mp3.h - src/media_converter.h - src/media_converter.cpp - src/ost-hmi.ui - src/ost-vm.ui - src/ost-data.ui - src/ost-script.ui - src/ost-resources.ui - src/ost-log.ui - src/about.ui - src/media-node.ui - src/event-node.ui - src/choose-file.ui - src/new-project.ui - ../software/chip32/chip32_assembler.cpp - ../software/chip32/chip32_vm.c - ../software/library/miniaudio.c - ../software/library/miniaudio.h -) - -include_directories(../software/chip32) -include_directories(../software/library) - -add_subdirectory(QHexView) - -set(CMAKE_AUTOMOC ON) - -set(NODEEDITOR_SOURCE_FILES - ./nodeeditor/src/AbstractGraphModel.cpp - ./nodeeditor/src/AbstractNodeGeometry.cpp - ./nodeeditor/src/BasicGraphicsScene.cpp - ./nodeeditor/src/ConnectionGraphicsObject.cpp - ./nodeeditor/src/ConnectionPainter.cpp - ./nodeeditor/src/ConnectionState.cpp - ./nodeeditor/src/ConnectionStyle.cpp - ./nodeeditor/src/DataFlowGraphModel.cpp - ./nodeeditor/src/DataFlowGraphicsScene.cpp - ./nodeeditor/src/DefaultHorizontalNodeGeometry.cpp - ./nodeeditor/src/DefaultVerticalNodeGeometry.cpp - ./nodeeditor/src/Definitions.cpp - ./nodeeditor/src/GraphicsView.cpp - ./nodeeditor/src/GraphicsViewStyle.cpp - ./nodeeditor/src/NodeDelegateModelRegistry.cpp - ./nodeeditor/src/NodeConnectionInteraction.cpp - ./nodeeditor/src/NodeDelegateModel.cpp - ./nodeeditor/src/NodeGraphicsObject.cpp - ./nodeeditor/src/DefaultNodePainter.cpp - ./nodeeditor/src/NodeState.cpp - ./nodeeditor/src/NodeStyle.cpp - ./nodeeditor/src/StyleCollection.cpp - ./nodeeditor/src/UndoCommands.cpp - ./nodeeditor/src/locateNode.cpp - ./nodeeditor/resources/resources.qrc -) - -set(NODEEDITOR_HEADER_FILES - ./nodeeditor/include/QtNodes/internal/AbstractGraphModel.hpp - ./nodeeditor/include/QtNodes/internal/AbstractNodeGeometry.hpp - ./nodeeditor/include/QtNodes/internal/AbstractNodePainter.hpp - ./nodeeditor/include/QtNodes/internal/BasicGraphicsScene.hpp - ./nodeeditor/include/QtNodes/internal/Compiler.hpp - ./nodeeditor/include/QtNodes/internal/ConnectionGraphicsObject.hpp - ./nodeeditor/include/QtNodes/internal/ConnectionIdHash.hpp - ./nodeeditor/include/QtNodes/internal/ConnectionIdUtils.hpp - ./nodeeditor/include/QtNodes/internal/ConnectionState.hpp - ./nodeeditor/include/QtNodes/internal/ConnectionStyle.hpp - ./nodeeditor/include/QtNodes/internal/DataFlowGraphicsScene.hpp - ./nodeeditor/include/QtNodes/internal/DataFlowGraphModel.hpp - ./nodeeditor/include/QtNodes/internal/DefaultNodePainter.hpp - ./nodeeditor/include/QtNodes/internal/Definitions.hpp - ./nodeeditor/include/QtNodes/internal/Export.hpp - ./nodeeditor/include/QtNodes/internal/GraphicsView.hpp - ./nodeeditor/include/QtNodes/internal/GraphicsViewStyle.hpp - ./nodeeditor/include/QtNodes/internal/locateNode.hpp - ./nodeeditor/include/QtNodes/internal/NodeData.hpp - ./nodeeditor/include/QtNodes/internal/NodeDelegateModel.hpp - ./nodeeditor/include/QtNodes/internal/NodeDelegateModelRegistry.hpp - ./nodeeditor/include/QtNodes/internal/NodeGraphicsObject.hpp - ./nodeeditor/include/QtNodes/internal/NodeState.hpp - ./nodeeditor/include/QtNodes/internal/NodeStyle.hpp - ./nodeeditor/include/QtNodes/internal/OperatingSystem.hpp - ./nodeeditor/include/QtNodes/internal/QStringStdHash.hpp - ./nodeeditor/include/QtNodes/internal/QUuidStdHash.hpp - ./nodeeditor/include/QtNodes/internal/Serializable.hpp - ./nodeeditor/include/QtNodes/internal/Style.hpp - ./nodeeditor/include/QtNodes/internal/StyleCollection.hpp - ./nodeeditor/include/QtNodes/internal/ConnectionPainter.hpp - ./nodeeditor/include/QtNodes/internal/DefaultHorizontalNodeGeometry.hpp - ./nodeeditor/include/QtNodes/internal/DefaultVerticalNodeGeometry.hpp - ./nodeeditor/include/QtNodes/internal/NodeConnectionInteraction.hpp - ./nodeeditor/include/QtNodes/internal/UndoCommands.hpp -) - -if (WIN32) - list(APPEND PROJECT_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/icon.rc") -endif() - -qt_add_executable(${PROJECT_NAME} - MANUAL_FINALIZATION - ${PROJECT_SOURCES} - ${NODEEDITOR_SOURCE_FILES} - ${NODEEDITOR_HEADER_FILES} -) - -target_compile_definitions(${PROJECT_NAME} PUBLIC NODE_EDITOR_STATIC) -target_include_directories(${PROJECT_NAME} PUBLIC nodeeditor/include nodeeditor/include/QtNodes/internal) - -target_link_libraries(${PROJECT_NAME} PUBLIC - Qt${QT_VERSION_MAJOR}::Widgets - Qt${QT_VERSION_MAJOR}::Core - Qt${QT_VERSION_MAJOR}::Widgets - Qt${QT_VERSION_MAJOR}::Gui - Qt${QT_VERSION_MAJOR}::OpenGLWidgets - Qt${QT_VERSION_MAJOR}::OpenGL - Qt${QT_VERSION_MAJOR}::Multimedia - QHexView - ) - - - - -if (UNIX) - target_link_libraries(${PROJECT_NAME} PUBLIC dl) -endif (UNIX) - -set_target_properties(${PROJECT_NAME} PROPERTIES - MACOSX_BUNDLE_GUI_IDENTIFIER storyeditor.d8s.eu - MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} - MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} - MACOSX_BUNDLE TRUE - WIN32_EXECUTABLE TRUE -) - -install(TARGETS ${PROJECT_NAME} - BUNDLE DESTINATION . - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) - -if(QT_VERSION_MAJOR EQUAL 6) - qt_finalize_executable(${PROJECT_NAME}) -endif() diff --git a/story-editor-legacy/assets/build.png b/story-editor-legacy/assets/build.png deleted file mode 100644 index b22ec59..0000000 Binary files a/story-editor-legacy/assets/build.png and /dev/null differ diff --git a/story-editor-legacy/assets/build.svg b/story-editor-legacy/assets/build.svg deleted file mode 100644 index 38bbfc9..0000000 --- a/story-editor-legacy/assets/build.svg +++ /dev/null @@ -1,131 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/story-editor-legacy/assets/check-mark.png b/story-editor-legacy/assets/check-mark.png deleted file mode 100644 index 9a25900..0000000 Binary files a/story-editor-legacy/assets/check-mark.png and /dev/null differ diff --git a/story-editor-legacy/assets/close-outline.svg b/story-editor-legacy/assets/close-outline.svg deleted file mode 100644 index 6673e6f..0000000 --- a/story-editor-legacy/assets/close-outline.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/story-editor-legacy/assets/file-document-plus-outline.png b/story-editor-legacy/assets/file-document-plus-outline.png deleted file mode 100644 index 65856af..0000000 Binary files a/story-editor-legacy/assets/file-document-plus-outline.png and /dev/null differ diff --git a/story-editor-legacy/assets/file-document-plus-outline.svg b/story-editor-legacy/assets/file-document-plus-outline.svg deleted file mode 100644 index 958e091..0000000 --- a/story-editor-legacy/assets/file-document-plus-outline.svg +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - diff --git a/story-editor-legacy/assets/floppy.svg b/story-editor-legacy/assets/floppy.svg deleted file mode 100644 index 9d1a063..0000000 --- a/story-editor-legacy/assets/floppy.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/story-editor-legacy/assets/folder-open-outline.svg b/story-editor-legacy/assets/folder-open-outline.svg deleted file mode 100644 index 28af2ad..0000000 --- a/story-editor-legacy/assets/folder-open-outline.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/story-editor-legacy/assets/folder-open.svg b/story-editor-legacy/assets/folder-open.svg deleted file mode 100644 index 1257da2..0000000 --- a/story-editor-legacy/assets/folder-open.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/story-editor-legacy/assets/home.png b/story-editor-legacy/assets/home.png deleted file mode 100644 index f7698bf..0000000 Binary files a/story-editor-legacy/assets/home.png and /dev/null differ diff --git a/story-editor-legacy/assets/left.png b/story-editor-legacy/assets/left.png deleted file mode 100644 index 7fd799b..0000000 Binary files a/story-editor-legacy/assets/left.png and /dev/null differ diff --git a/story-editor-legacy/assets/pause-button.png b/story-editor-legacy/assets/pause-button.png deleted file mode 100644 index 9aa3e3c..0000000 Binary files a/story-editor-legacy/assets/pause-button.png and /dev/null differ diff --git a/story-editor-legacy/assets/play-circle-green.png b/story-editor-legacy/assets/play-circle-green.png deleted file mode 100644 index 8c7d84b..0000000 Binary files a/story-editor-legacy/assets/play-circle-green.png and /dev/null differ diff --git a/story-editor-legacy/assets/play-circle-green.svg b/story-editor-legacy/assets/play-circle-green.svg deleted file mode 100644 index ac6e09a..0000000 --- a/story-editor-legacy/assets/play-circle-green.svg +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - diff --git a/story-editor-legacy/assets/play-circle.png b/story-editor-legacy/assets/play-circle.png deleted file mode 100644 index d90b7a3..0000000 Binary files a/story-editor-legacy/assets/play-circle.png and /dev/null differ diff --git a/story-editor-legacy/assets/play-circle.svg b/story-editor-legacy/assets/play-circle.svg deleted file mode 100644 index e152677..0000000 --- a/story-editor-legacy/assets/play-circle.svg +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - diff --git a/story-editor-legacy/assets/right.png b/story-editor-legacy/assets/right.png deleted file mode 100644 index e274d8b..0000000 Binary files a/story-editor-legacy/assets/right.png and /dev/null differ diff --git a/story-editor-legacy/assets/volume-high.svg b/story-editor-legacy/assets/volume-high.svg deleted file mode 100644 index e261a16..0000000 --- a/story-editor-legacy/assets/volume-high.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/story-editor-legacy/assets/volume-off.png b/story-editor-legacy/assets/volume-off.png deleted file mode 100644 index 181a0c3..0000000 Binary files a/story-editor-legacy/assets/volume-off.png and /dev/null differ diff --git a/story-editor-legacy/assets/volume-off.svg b/story-editor-legacy/assets/volume-off.svg deleted file mode 100644 index 39affc4..0000000 --- a/story-editor-legacy/assets/volume-off.svg +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - diff --git a/story-editor-legacy/assets/welcome.png b/story-editor-legacy/assets/welcome.png deleted file mode 100644 index efc8524..0000000 Binary files a/story-editor-legacy/assets/welcome.png and /dev/null differ diff --git a/story-editor-legacy/example.asm b/story-editor-legacy/example.asm deleted file mode 100644 index 2a29af7..0000000 --- a/story-editor-legacy/example.asm +++ /dev/null @@ -1,96 +0,0 @@ -; jump over the data, to our entry label - jump .entry - -; Constant elements are separated by commas -$imageBird DC8, "example.bmp", 8 ; string of chars, followed by one byte -$soundChoice DC8, "choose1.snd" -$yaya DC8, "yaya.bmp" -$rabbit DC8, "rabbit.bmp" -$someConstant DC32, 12456789 - -; Liste des noeuds à appeler -$ChoiceObject DC32, 2, .MEDIA_02, .MEDIA_03 - -; DVsxx to declare a variable in RAM, followed by the number of elements -$MyArray DV8, 10 ; array of 10 bytes -$RamData1 DV32, 1 ; one 32-bit integer -$ChoiceMem DV32, 10 ; 10 elements for the choices, to be generated - -; label definition -.entry: ;; comment here should work - - - ; Syscall test: show image and play sound - lcons r0, $imageBird ; image name address in ROM located in R0 (null terminated) - lcons r1, $soundChoice ; set to 0 if no sound - syscall 1 - lcons r0, $ChoiceObject - jump .media ; no return possible, so a jump is enough - -; Generic media choice manager -.media: - ; Les adresses des différents medias sont dans la stack -; Arguments: - ; r0: address d'une structure de type "media choice" -; Local: - ; t0: loop counter - ; t1: increment 1 - ; t2: increment 4 - ; t3: current media address - -.media_loop_start: - load t0, @r0, 4 ; Le premier élément est le nombre de choix possibles, t0 = 3 (exemple) - lcons t1, 1 - lcons t2, 4 - mov t3, r0 -.media_loop: - add t3, t2 ; @++ - - -; ------- On appelle un autre media node - push r0 ; save r0 - load r0, @t3, 4 ; r0 = content in ram at address in T4 - call r0 - pop r0 - ; TODO: wait for event - - sub t0, t1 ; i-- - skipnz t0 ; if (r0) goto start_loop; - jump .media_loop_start - jump .media_loop - -.MEDIA_02: - lcons r0, $yaya ; image name address in ROM located in R0 (null terminated) - lcons r1, $soundChoice ; set to 0 if no sound - syscall 1 - ret - -.MEDIA_03: - lcons r0, $rabbit - lcons r1, $soundChoice - syscall 1 - ret - -.SYSCALL_TEST: - ; syscall test: wait for event - lcons r0, 0xFF ; wait for all event, blocking - syscall 2 - -; We create a stupid loop just for RAM variable testing - - lcons r0, 4 ; prepare loop: 4 iterations - lcons r6, $RamData1 ; store address to R6 - store @r6, r0, 4 ; save R0 in RAM - lcons r1, 1 -.loop: - load r0, @r6, 4 ; load this variable - sub r0, r1 - store @r6, r0, 4 ; save R0 in RAM - skipz r0 ; skip loop if R0 == 0 - jump .loop - - - mov r0, r2 ; copy R2 into R0 (blank space between , and R2) -mov R0,R2 ; copy R2 into R0 (NO blank space between , and R2) - - halt diff --git a/story-editor-legacy/icon.rc b/story-editor-legacy/icon.rc deleted file mode 100644 index 28fac41..0000000 --- a/story-editor-legacy/icon.rc +++ /dev/null @@ -1 +0,0 @@ -IDI_ICON1 ICON DISCARDABLE "story-editor-logo.ico" diff --git a/story-editor-legacy/nodeeditor/CMakeLists.txt b/story-editor-legacy/nodeeditor/CMakeLists.txt deleted file mode 100644 index ccfa378..0000000 --- a/story-editor-legacy/nodeeditor/CMakeLists.txt +++ /dev/null @@ -1,274 +0,0 @@ -cmake_minimum_required(VERSION 3.8) - -cmake_policy(SET CMP0072 NEW) # new in 3.11. The NEW behavior for this policy is to set OpenGL_GL_PREFERENCE to GLVND. -cmake_policy(SET CMP0068 NEW) # new in 3.9. The NEW behavior of this policy is to ignore the RPATH settings for install_name on macOS. - - -project(QtNodesLibrary CXX) - -set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) - -set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) -set(CMAKE_DISABLE_SOURCE_CHANGES ON) -set(OpenGL_GL_PREFERENCE LEGACY) -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) - -get_directory_property(_has_parent PARENT_DIRECTORY) -if(_has_parent) - set(is_root_project OFF) -else() - set(is_root_project ON) -endif() - -set(QT_NODES_DEVELOPER_DEFAULTS "${is_root_project}" CACHE BOOL "Turns on default settings for development of QtNodes") - -option(BUILD_TESTING "Build tests" "${QT_NODES_DEVELOPER_DEFAULTS}") -option(BUILD_EXAMPLES "Build Examples" "${QT_NODES_DEVELOPER_DEFAULTS}") -option(BUILD_DOCS "Build Documentation" "${QT_NODES_DEVELOPER_DEFAULTS}") -option(BUILD_SHARED_LIBS "Build as shared library" ON) -option(BUILD_DEBUG_POSTFIX_D "Append d suffix to debug libraries" OFF) -option(QT_NODES_FORCE_TEST_COLOR "Force colorized unit test output" OFF) - -enable_testing() - -if(QT_NODES_DEVELOPER_DEFAULTS) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin") - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") -endif() - -if(BUILD_DEBUG_POSTFIX_D) - set(CMAKE_DEBUG_POSTFIX "d") - set(CMAKE_RELEASE_POSTFIX "") - set(CMAKE_RELWITHDEBINFO_POSTFIX "rd") - set(CMAKE_MINSIZEREL_POSTFIX "s") -endif() - -add_subdirectory(external) - -find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets) -find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Widgets Gui OpenGL) -message(STATUS "QT_VERSION: ${QT_VERSION}, QT_DIR: ${QT_DIR}") - -if (${QT_VERSION} VERSION_LESS 5.11.0) - message(FATAL_ERROR "Requires qt version >= 5.11.0, Your current version is ${QT_VERSION}") -endif() - -if (${QT_VERSION_MAJOR} EQUAL 6) - qt_add_resources(RESOURCES ./resources/resources.qrc) -else() - qt5_add_resources(RESOURCES ./resources/resources.qrc) -endif() - -# Unfortunately, as we have a split include/src, AUTOMOC doesn't work. -# We'll have to manually specify some files -set(CMAKE_AUTOMOC ON) - -set(CPP_SOURCE_FILES - src/AbstractGraphModel.cpp - src/AbstractNodeGeometry.cpp - src/BasicGraphicsScene.cpp - src/ConnectionGraphicsObject.cpp - src/ConnectionPainter.cpp - src/ConnectionState.cpp - src/ConnectionStyle.cpp - src/DataFlowGraphModel.cpp - src/DataFlowGraphicsScene.cpp - src/DefaultHorizontalNodeGeometry.cpp - src/DefaultVerticalNodeGeometry.cpp - src/Definitions.cpp - src/GraphicsView.cpp - src/GraphicsViewStyle.cpp - src/NodeDelegateModelRegistry.cpp - src/NodeConnectionInteraction.cpp - src/NodeDelegateModel.cpp - src/NodeGraphicsObject.cpp - src/DefaultNodePainter.cpp - src/NodeState.cpp - src/NodeStyle.cpp - src/StyleCollection.cpp - src/UndoCommands.cpp - src/locateNode.cpp -) - -set(HPP_HEADER_FILES - include/QtNodes/internal/AbstractGraphModel.hpp - include/QtNodes/internal/AbstractNodeGeometry.hpp - include/QtNodes/internal/AbstractNodePainter.hpp - include/QtNodes/internal/BasicGraphicsScene.hpp - include/QtNodes/internal/Compiler.hpp - include/QtNodes/internal/ConnectionGraphicsObject.hpp - include/QtNodes/internal/ConnectionIdHash.hpp - include/QtNodes/internal/ConnectionIdUtils.hpp - include/QtNodes/internal/ConnectionState.hpp - include/QtNodes/internal/ConnectionStyle.hpp - include/QtNodes/internal/DataFlowGraphicsScene.hpp - include/QtNodes/internal/DataFlowGraphModel.hpp - include/QtNodes/internal/DefaultNodePainter.hpp - include/QtNodes/internal/Definitions.hpp - include/QtNodes/internal/Export.hpp - include/QtNodes/internal/GraphicsView.hpp - include/QtNodes/internal/GraphicsViewStyle.hpp - include/QtNodes/internal/locateNode.hpp - include/QtNodes/internal/NodeData.hpp - include/QtNodes/internal/NodeDelegateModel.hpp - include/QtNodes/internal/NodeDelegateModelRegistry.hpp - include/QtNodes/internal/NodeGraphicsObject.hpp - include/QtNodes/internal/NodeState.hpp - include/QtNodes/internal/NodeStyle.hpp - include/QtNodes/internal/OperatingSystem.hpp - include/QtNodes/internal/QStringStdHash.hpp - include/QtNodes/internal/QUuidStdHash.hpp - include/QtNodes/internal/Serializable.hpp - include/QtNodes/internal/Style.hpp - include/QtNodes/internal/StyleCollection.hpp - include/QtNodes/internal/ConnectionPainter.hpp - include/QtNodes/internal/DefaultHorizontalNodeGeometry.hpp - include/QtNodes/internal/DefaultVerticalNodeGeometry.hpp - include/QtNodes/internal/NodeConnectionInteraction.hpp - include/QtNodes/internal/UndoCommands.hpp -) - -# If we want to give the option to build a static library, -# set BUILD_SHARED_LIBS option to OFF -add_library(QtNodes - ${CPP_SOURCE_FILES} - ${HPP_HEADER_FILES} - ${RESOURCES} -) - -add_library(QtNodes::QtNodes ALIAS QtNodes) - - -target_include_directories(QtNodes - PUBLIC - $ - $ - PRIVATE - $ - $ -) - -target_link_libraries(QtNodes - PUBLIC - Qt${QT_VERSION_MAJOR}::Core - Qt${QT_VERSION_MAJOR}::Widgets - Qt${QT_VERSION_MAJOR}::Gui - Qt${QT_VERSION_MAJOR}::OpenGL -) - -target_compile_definitions(QtNodes - PUBLIC - NODE_EDITOR_SHARED - PRIVATE - NODE_EDITOR_EXPORTS - #NODE_DEBUG_DRAWING - QT_NO_KEYWORDS -) - - -target_compile_options(QtNodes - PRIVATE - $<$:/W4 /wd4127 /EHsc /utf-8> - $<$:-Wall -Wextra> - $<$:-Wall -Wextra -Werror> -) -if(NOT "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC") - # Clang-Cl on MSVC identifies as "Clang" but behaves more like MSVC: - target_compile_options(QtNodes - PRIVATE - $<$:-Wall -Wextra> - ) -endif() - -if(QT_NODES_DEVELOPER_DEFAULTS) - target_compile_features(QtNodes PUBLIC cxx_std_14) - set_target_properties(QtNodes PROPERTIES CXX_EXTENSIONS OFF) -endif() - - -set_target_properties(QtNodes - PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib - LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin -) - -###### -# Moc -## - -file(GLOB_RECURSE HEADERS_TO_MOC include/QtNodes/internal/*.hpp) - -if (${QT_VERSION_MAJOR} EQUAL 6) - qt_wrap_cpp(nodes_moc - ${HEADERS_TO_MOC} - TARGET QtNodes - OPTIONS --no-notes # Don't display a note for the headers which don't produce a moc_*.cpp - ) -else() - qt5_wrap_cpp(nodes_moc - ${HEADERS_TO_MOC} - TARGET QtNodes - OPTIONS --no-notes # Don't display a note for the headers which don't produce a moc_*.cpp - ) -endif() - -target_sources(QtNodes PRIVATE ${nodes_moc}) - -########### -# Examples -## - -if(BUILD_EXAMPLES) - add_subdirectory(examples) -endif() - -if(BUILD_DOCS) - add_subdirectory(docs) -endif() - -################## -# Automated Tests -## - -if(BUILD_TESTING) - #add_subdirectory(test) -endif() - -############### -# Installation -## - -include(GNUInstallDirs) - -set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/QtNodes) - -install(TARGETS QtNodes - EXPORT QtNodesTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} -) - -install(DIRECTORY include/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) - -install(EXPORT QtNodesTargets - FILE QtNodesTargets.cmake - NAMESPACE QtNodes:: - DESTINATION ${INSTALL_CONFIGDIR} -) - -include(CMakePackageConfigHelpers) - -configure_package_config_file(${CMAKE_CURRENT_LIST_DIR}/cmake/QtNodesConfig.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/QtNodesConfig.cmake - INSTALL_DESTINATION ${INSTALL_CONFIGDIR} -) - -install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/QtNodesConfig.cmake - DESTINATION ${INSTALL_CONFIGDIR} -) diff --git a/story-editor-legacy/nodeeditor/LICENSE.rst b/story-editor-legacy/nodeeditor/LICENSE.rst deleted file mode 100644 index c485d7f..0000000 --- a/story-editor-legacy/nodeeditor/LICENSE.rst +++ /dev/null @@ -1,28 +0,0 @@ -BSD-3-Clause license -==================== - -Copyright (c) 2022, Dmitry Pinaev -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of copyright holder, nor the names of its contributors may - be used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/story-editor-legacy/nodeeditor/README.rst b/story-editor-legacy/nodeeditor/README.rst deleted file mode 100644 index 553fc41..0000000 --- a/story-editor-legacy/nodeeditor/README.rst +++ /dev/null @@ -1,261 +0,0 @@ -QtNodes -####### - -Introduction -============ - -**QtNodes** is conceived as a general-purpose Qt-based library aimed at -developing Node Editors for various applications. The library could be used for -simple graph visualization and editing or extended further for using the -`Dataflow paradigm `_ . - -The library is written using the Model-View approach. The whole graph structure -is defined by a class derived from ``AbstractGraphModel``. It is possible to -create or add Nodes and Connections. The underlying data structures could be of -any arbitrary type or representation. - -An instance of ``AbstractGraphModel`` could or could not be attached to -specialized ``QGraphicsScene`` and ``QGraphicsView`` objects. I.e. the so-called -"headless" `modus operandi` is possible. - -Documentation -============= - -`Read the Docs for QtNodes `_ - -Warning - Many classes were changed in the version ``3.0``. If you had a large project - based on ``2.x.x``, make sure you read the documentation first and see the - examples before checking out the new code. - -Branches --------- - -There are branchses ``v2`` and ``v3`` for versions ``2.x.x`` and ``3.x`` -respectively. The branch ``master`` contains the latest dev state. - - -.. contents:: Navigation - :depth: 2 - - -Data Flow Paradigm -================== - -The extended model class ``DataFlowGraphModel`` allows to register "processing -algorithms" represented by nodes and is equipped with a set of Qt's signals and -slots for propagating the data though the nodes. - -The node's algorithm is triggered upon arriving of any new input data. The -computed result is propagated to the output connections. Each new connection -fetches available data and propagates is further. Each change in the source node -is immediately propagated through all the connections updating the whole graph. - - -Supported Environments -====================== - -Platforms ---------- - -* Linux (x64, gcc-7.0, clang-7) |ImageLink|_ -* OSX (Apple Clang - LLVM 3.6) |ImageLink|_ - -.. |ImageLink| image:: https://travis-ci.org/paceholder/nodeeditor.svg?branch=master -.. _ImageLink: https://travis-ci.org/paceholder/nodeeditor - - -* Windows (Win32, x64, msvc2017, MinGW 5.3) |AppveyorImage|_ - -.. |AppveyorImage| image:: https://ci.appveyor.com/api/projects/status/wxp47wv3uyyiujjw/branch/master?svg=true -.. _AppveyorImage: https://ci.appveyor.com/project/paceholder/nodeeditor/branch/master) - -Dependencies ------------- - -* Qt >5.15 -* CMake 3.8 -* Catch2 - - -Current State (v3) -================== - -* Model-based graph -* Headless mode - You can create, populate, modify the derivative of ``AbstractGraphModel`` - without adding it to the actual Flow Scene. The library is now designed to be - general-purpose graph visualization and modification tool, without - specialization on only data propagation. -* Automatic data propagation built on top of the graph-model code - The library could be used for both pure graph visualization purposes and for - originally implemented data propagation. -* Dynamic ports -* Datatype-aware connections -* Embedded Qt widgets -* One-output to many-input connections -* JSON-based interface styles -* Saving scenes to JSON files -* Custom Node Geometry -* Vertical and Horizontal graph layouts -* Undo/Redo, Duplication (CTRL+D) - - -Building -======== - -Linux ------ - -:: - - git clone git@github.com:paceholder/nodeeditor.git - cd nodeeditor - mkdir build - cd build - cmake .. - make -j && make install - - -Qt Creator ----------- - -1. Open `CMakeLists.txt` as project. -2. If you don't have the `Catch2` library installed, go to `Build Settings`, disable the checkbox `BUILD_TESTING`. -3. `Build -> Run CMake` -4. `Build -> Build All` -5. Click the button `Run` - - -With Cmake using `vcpkg` -^^^^^^^^^^^^^^^^^^^^^^^^ - -1. Install `vcpkg` -2. Add the following flag in configuration step of `CMake` - -:: - - -DCMAKE_TOOLCHAIN_FILE=/scripts/buildsystems/scripts/buildsystems/vcpkg.cmake - - -Help Needed -=========== - -#. Python wrappring using PySide. -#. QML frontend. -#. Wirting a ClangFormat config. - -Any suggestions are welcome! - - -Contribution -============ - -#. Be polite, respectful and collaborative. -#. For submitting a bug: - - #. Describe your environment (Qt version, compiler, OS etc) - #. Describe steps to reproduce the issue - -#. For submitting a pull request: - - #. Create a proposal task first. We can come up with a better design together. - #. Create a pull-request. If applicable, create a simple example for your - problem, describe the changes in details, provide use cases. - -#. For submitting a development request: - - #. Describe your issue in details - #. Provide some use cases. - -#. I maintain this probject in my free time, when I am not busy with my work or - my family. **If I do not react or do not answer for too long, please ping - me**. - - -Citing -====== - -:: - - Dmitry Pinaev et al, Qt Nodes, (2022), GitHub repository, https://github.com/paceholder/nodeeditor - -BibTeX:: - - @misc{Pinaev2022, - author = {Dmitry Pinaev et al}, - title = {QtNodes. Node Editor}, - year = {2017}, - publisher = {GitHub}, - journal = {GitHub repository}, - howpublished = {\url{https://github.com/paceholder/nodeeditor}}, - commit = {877ddb8c447a7a061a5022e9956a3194132e3dd9} - } - -Support -======= - -If you like the project you could donate me on PayPal |ImagePaypal|_ - -.. |ImagePaypal| image:: https://img.shields.io/badge/Donate-PayPal-green.svg -.. _ImagePaypal: https://www.paypal.com/paypalme/DmitryPinaev - - -If you send more than $100, I'll forward $100 to some fund supporting sick -children and report to you back. - - -Thanks -====== - -The version 3 was released with a generous help of -`Davide Faconti `_ - - -Showcase -======== - -Youtube videos --------------- - -.. image:: https://img.youtube.com/vi/pxMXjSvlOFw/0.jpg - :target: https://www.youtube.com/watch?v=pxMXjSvlOFw - -| - -.. image:: https://img.youtube.com/vi/i_pB-Y0hCYQ/0.jpg - :target: https://www.youtube.com/watch?v=i_pB-Y0hCYQ - -CANdevStudio ------------- - -`CANdevStudio `_ is a cost-effective, -cross-platform replacement for CAN simulation software. CANdevStudio enables to -simulate CAN signals such as ignition status, doors status or reverse gear by -every automotive developer. Thanks to modularity it is easy to implement new, -custom features. - - -.. image:: docs/_static/showcase_CANdevStudio.png - - -Chigraph --------- - -`Chigraph `_ is a visual programming -language for beginners that is unique in that it is an intuitive flow graph: - -.. image:: docs/_static/chigraph.png - - -It features easy bindings to C/C++, package management, and a cool interface. - - -Spkgen particle editor ----------------------- - -`Spkgen `_ is an editor for the SPARK -particles engine that uses a node-based interface to create particles effects for -games - -.. image:: docs/_static/spkgen.png diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/AbstractGraphModel b/story-editor-legacy/nodeeditor/include/QtNodes/AbstractGraphModel deleted file mode 100644 index 0ad0ac0..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/AbstractGraphModel +++ /dev/null @@ -1 +0,0 @@ -#include "internal/AbstractGraphModel.hpp" diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/AbstractNodePainter b/story-editor-legacy/nodeeditor/include/QtNodes/AbstractNodePainter deleted file mode 100644 index a62405c..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/AbstractNodePainter +++ /dev/null @@ -1 +0,0 @@ -#include "internal/AbstractNodePainter.hpp" diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/BasicGraphicsScene b/story-editor-legacy/nodeeditor/include/QtNodes/BasicGraphicsScene deleted file mode 100644 index 7d17e8d..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/BasicGraphicsScene +++ /dev/null @@ -1 +0,0 @@ -#include "internal/BasicGraphicsScene.hpp" diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/ConnectionIdUtils b/story-editor-legacy/nodeeditor/include/QtNodes/ConnectionIdUtils deleted file mode 100644 index 4c97c07..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/ConnectionIdUtils +++ /dev/null @@ -1 +0,0 @@ -#include "internal/ConnectionIdUtils.hpp" diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/ConnectionStyle b/story-editor-legacy/nodeeditor/include/QtNodes/ConnectionStyle deleted file mode 100644 index b771bf3..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/ConnectionStyle +++ /dev/null @@ -1 +0,0 @@ -#include "internal/ConnectionStyle.hpp" diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/DataFlowGraphModel b/story-editor-legacy/nodeeditor/include/QtNodes/DataFlowGraphModel deleted file mode 100644 index 28e8cbe..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/DataFlowGraphModel +++ /dev/null @@ -1 +0,0 @@ -#include "internal/DataFlowGraphModel.hpp" diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/DataFlowGraphicsScene b/story-editor-legacy/nodeeditor/include/QtNodes/DataFlowGraphicsScene deleted file mode 100644 index 3585527..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/DataFlowGraphicsScene +++ /dev/null @@ -1 +0,0 @@ -#include "internal/DataFlowGraphicsScene.hpp" diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/DefaultNodePainter b/story-editor-legacy/nodeeditor/include/QtNodes/DefaultNodePainter deleted file mode 100644 index c808518..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/DefaultNodePainter +++ /dev/null @@ -1 +0,0 @@ -#include "internal/DefaultNodePainter.hpp" diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/Definitions b/story-editor-legacy/nodeeditor/include/QtNodes/Definitions deleted file mode 100644 index 2ac05a0..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/Definitions +++ /dev/null @@ -1 +0,0 @@ -#include "internal/Definitions.hpp" diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/GraphicsView b/story-editor-legacy/nodeeditor/include/QtNodes/GraphicsView deleted file mode 100644 index da4e21a..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/GraphicsView +++ /dev/null @@ -1 +0,0 @@ -#include "internal/GraphicsView.hpp" diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/GraphicsViewStyle b/story-editor-legacy/nodeeditor/include/QtNodes/GraphicsViewStyle deleted file mode 100644 index 8a98541..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/GraphicsViewStyle +++ /dev/null @@ -1 +0,0 @@ -#include "internal/GraphicsViewStyle.hpp" diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/NodeData b/story-editor-legacy/nodeeditor/include/QtNodes/NodeData deleted file mode 100644 index 5fcbd7b..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/NodeData +++ /dev/null @@ -1 +0,0 @@ -#include "internal/NodeData.hpp" diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/NodeDelegateModel b/story-editor-legacy/nodeeditor/include/QtNodes/NodeDelegateModel deleted file mode 100644 index 70f25f7..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/NodeDelegateModel +++ /dev/null @@ -1 +0,0 @@ -#include "internal/NodeDelegateModel.hpp" diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/NodeDelegateModelRegistry b/story-editor-legacy/nodeeditor/include/QtNodes/NodeDelegateModelRegistry deleted file mode 100644 index 9d78da5..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/NodeDelegateModelRegistry +++ /dev/null @@ -1 +0,0 @@ -#include "internal/NodeDelegateModelRegistry.hpp" diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/NodeGeometry b/story-editor-legacy/nodeeditor/include/QtNodes/NodeGeometry deleted file mode 100644 index 46a70a6..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/NodeGeometry +++ /dev/null @@ -1,2 +0,0 @@ -#include "internal/NodeGeometry.hpp" - diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/NodeState b/story-editor-legacy/nodeeditor/include/QtNodes/NodeState deleted file mode 100644 index 5b531fd..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/NodeState +++ /dev/null @@ -1 +0,0 @@ -#include "internal/NodeState.hpp" diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/NodeStyle b/story-editor-legacy/nodeeditor/include/QtNodes/NodeStyle deleted file mode 100644 index d96092d..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/NodeStyle +++ /dev/null @@ -1 +0,0 @@ -#include "internal/NodeStyle.hpp" diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/StyleCollection b/story-editor-legacy/nodeeditor/include/QtNodes/StyleCollection deleted file mode 100644 index e1f93ec..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/StyleCollection +++ /dev/null @@ -1 +0,0 @@ -#include "internal/StyleCollection.hpp" diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/UndoCommands b/story-editor-legacy/nodeeditor/include/QtNodes/UndoCommands deleted file mode 100644 index 2ff49a5..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/UndoCommands +++ /dev/null @@ -1 +0,0 @@ -#include "internal/UndoCommands.hpp" diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/internal/AbstractGraphModel.hpp b/story-editor-legacy/nodeeditor/include/QtNodes/internal/AbstractGraphModel.hpp deleted file mode 100644 index 96d2c64..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/internal/AbstractGraphModel.hpp +++ /dev/null @@ -1,249 +0,0 @@ -#pragma once - -#include "Export.hpp" - -#include -#include - -#include -#include -#include - -#include "ConnectionIdHash.hpp" -#include "Definitions.hpp" - -namespace QtNodes { - -/** - * The central class in the Model-View approach. It delivers all kinds - * of information from the backing user data structures that represent - * the graph. The class allows to modify the graph structure: create - * and remove nodes and connections. - * - * We use two types of the unique ids for graph manipulations: - * - NodeId - * - ConnectionId - */ -class NODE_EDITOR_PUBLIC AbstractGraphModel : public QObject -{ - Q_OBJECT -public: - /// Generates a new unique NodeId. - virtual NodeId newNodeId() = 0; - - /// @brief Returns the full set of unique Node Ids. - /** - * Model creator is responsible for generating unique `unsigned int` - * Ids for all the nodes in the graph. From an Id it should be - * possible to trace back to the model's internal representation of - * the node. - */ - virtual std::unordered_set allNodeIds() const = 0; - - /** - * A collection of all input and output connections for the given `nodeId`. - */ - virtual std::unordered_set allConnectionIds(NodeId const nodeId) const = 0; - - /// @brief Returns all connected Node Ids for given port. - /** - * The returned set of nodes and port indices correspond to the type - * opposite to the given `portType`. - */ - virtual std::unordered_set connections(NodeId nodeId, - PortType portType, - PortIndex index) const - = 0; - - /// Checks if two nodes with the given `connectionId` are connected. - virtual bool connectionExists(ConnectionId const connectionId) const = 0; - - /// Creates a new node instance in the derived class. - /** - * The model is responsible for generating a unique `NodeId`. - * @param[in] nodeType is free to be used and interpreted by the - * model on its own, it helps to distinguish between possible node - * types and create a correct instance inside. - */ - virtual NodeId addNode(QString const nodeType = QString()) = 0; - - /// Model decides if a conection with a given connection Id possible. - /** - * The default implementation compares corresponding data types. - * - * It is possible to override the function and connect non-equal - * data types. - */ - virtual bool connectionPossible(ConnectionId const connectionId) const = 0; - - /// Defines if detaching the connection is possible. - virtual bool detachPossible(ConnectionId const) const { return true; } - - /// Creates a new connection between two nodes. - /** - * Default implementation emits signal - * `connectionCreated(connectionId)` - * - * In the derived classes user must emite the signal to notify the - * scene about the changes. - */ - virtual void addConnection(ConnectionId const connectionId) = 0; - - /** - * @returns `true` if there is data in the model associated with the - * given `nodeId`. - */ - virtual bool nodeExists(NodeId const nodeId) const = 0; - - /// @brief Returns node-related data for requested NodeRole. - /** - * @returns Node Caption, Node Caption Visibility, Node Position etc. - */ - virtual QVariant nodeData(NodeId nodeId, NodeRole role) const = 0; - - /** - * A utility function that unwraps the `QVariant` value returned from the - * standard `QVariant AbstractGraphModel::nodeData(NodeId, NodeRole)` function. - */ - template - T nodeData(NodeId nodeId, NodeRole role) const - { - return nodeData(nodeId, role).value(); - } - - virtual NodeFlags nodeFlags(NodeId nodeId) const - { - Q_UNUSED(nodeId); - return NodeFlag::NoFlags; - } - - /// @brief Sets node properties. - /** - * Sets: Node Caption, Node Caption Visibility, - * Shyle, State, Node Position etc. - * @see NodeRole. - */ - virtual bool setNodeData(NodeId nodeId, NodeRole role, QVariant value) = 0; - - /// @brief Returns port-related data for requested NodeRole. - /** - * @returns Port Data Type, Port Data, Connection Policy, Port - * Caption. - */ - virtual QVariant portData(NodeId nodeId, PortType portType, PortIndex index, PortRole role) const - = 0; - - /** - * A utility function that unwraps the `QVariant` value returned from the - * standard `QVariant AbstractGraphModel::portData(...)` function. - */ - template - T portData(NodeId nodeId, PortType portType, PortIndex index, PortRole role) const - { - return portData(nodeId, portType, index, role).value(); - } - - virtual bool setPortData(NodeId nodeId, - PortType portType, - PortIndex index, - QVariant const &value, - PortRole role = PortRole::Data) - = 0; - - virtual bool deleteConnection(ConnectionId const connectionId) = 0; - - virtual bool deleteNode(NodeId const nodeId) = 0; - - /** - * Reimplement the function if you want to store/restore the node's - * inner state during undo/redo node deletion operations. - */ - virtual QJsonObject saveNode(NodeId const) const { return {}; } - - /** - * Reimplement the function if you want to support: - * - * - graph save/restore operations, - * - undo/redo operations after deleting the node. - * - * QJsonObject must contain following fields: - * - * - * ``` - * { - * id : 5, - * position : { x : 100, y : 200 }, - * internal-data { - * "your model specific data here" - * } - * } - * ``` - * - * The function must do almost exacly the same thing as the normal addNode(). - * The main difference is in a model-specific `inner-data` processing. - */ - virtual void loadNode(QJsonObject const &) {} - -public: - /** - * Function clears connections attached to the ports that are scheduled to be - * deleted. It must be called right before the model removes its old port data. - * - * @param nodeId Defines the node to be modified - * @param portType Is either PortType::In or PortType::Out - * @param first Index of the first port to be removed - * @param last Index of the last port to be removed - */ - void portsAboutToBeDeleted(NodeId const nodeId, - PortType const portType, - PortIndex const first, - PortIndex const last); - - /** - * Signal emitted when model no longer has the old data associated with the - * given port indices and when the node must be repainted. - */ - void portsDeleted(); - - /** - * Signal emitted when model is about to create new ports on the given node. - * @param first Is the first index of the new port after insertion. - * @param last Is the last index of the new port after insertion. - * - * Function caches existing connections that are located after the `last` port - * index. For such connections the new "post-insertion" addresses are computed - * and stored until the function AbstractGraphModel::portsInserted is called. - */ - void portsAboutToBeInserted(NodeId const nodeId, - PortType const portType, - PortIndex const first, - PortIndex const last); - - /** - * Function re-creates the connections that were shifted during the port - * insertion. After that the node is updated. - */ - void portsInserted(); - -Q_SIGNALS: - void connectionCreated(ConnectionId const connectionId); - - void connectionDeleted(ConnectionId const connectionId); - - void nodeCreated(NodeId const nodeId); - - void nodeDeleted(NodeId const nodeId); - - void nodeUpdated(NodeId const nodeId); - - void nodeFlagsUpdated(NodeId const nodeId); - - void nodePositionUpdated(NodeId const nodeId); - - void modelReset(); - -private: - std::vector _shiftedByDynamicPortsConnections; -}; - -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/internal/AbstractNodeGeometry.hpp b/story-editor-legacy/nodeeditor/include/QtNodes/internal/AbstractNodeGeometry.hpp deleted file mode 100644 index 36cc9a2..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/internal/AbstractNodeGeometry.hpp +++ /dev/null @@ -1,82 +0,0 @@ -#pragma once - -#include "Definitions.hpp" -#include "Export.hpp" - -#include -#include -#include - -namespace QtNodes { - -class AbstractGraphModel; - -class NODE_EDITOR_PUBLIC AbstractNodeGeometry -{ -public: - AbstractNodeGeometry(AbstractGraphModel &, double marginsRatio = 0.2); - virtual ~AbstractNodeGeometry() {} - - /** - * The node's size plus some additional margin around it to account for drawing - * effects (for example shadows) or node's parts outside the size rectangle - * (for example port points). - * - * The default implementation returns QSize + 20 percent of width and heights - * at each side of the rectangle. - */ - virtual QRectF boundingRect(NodeId const nodeId) const; - - virtual void setMarginsRatio(double marginsRatio); - - /// A direct rectangle defining the borders of the node's rectangle. - virtual QSize size(NodeId const nodeId) const = 0; - - /** - * The function is triggeren when a nuber of ports is changed or when an - * embedded widget needs an update. - */ - virtual void recomputeSize(NodeId const nodeId) const = 0; - - /// Port position in node's coordinate system. - virtual QPointF portPosition(NodeId const nodeId, - PortType const portType, - PortIndex const index) const - = 0; - - /// A convenience function using the `portPosition` and a given transformation. - virtual QPointF portScenePosition(NodeId const nodeId, - PortType const portType, - PortIndex const index, - QTransform const &t) const; - - /// Defines where to draw port label. The point corresponds to a font baseline. - virtual QPointF portTextPosition(NodeId const nodeId, - PortType const portType, - PortIndex const portIndex) const - = 0; - - /** - * Defines where to start drawing the caption. The point corresponds to a font - * baseline. - */ - virtual QPointF captionPosition(NodeId const nodeId) const = 0; - - /// Caption rect is needed for estimating the total node size. - virtual QRectF captionRect(NodeId const nodeId) const = 0; - - /// Position for an embedded widget. Return any value if you don't embed. - virtual QPointF widgetPosition(NodeId const nodeId) const = 0; - - virtual PortIndex checkPortHit(NodeId const nodeId, - PortType const portType, - QPointF const nodePoint) const; - - virtual QRect resizeHandleRect(NodeId const nodeId) const = 0; - -protected: - AbstractGraphModel &_graphModel; - double _marginsRatio{0.0}; -}; - -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/internal/AbstractNodePainter.hpp b/story-editor-legacy/nodeeditor/include/QtNodes/internal/AbstractNodePainter.hpp deleted file mode 100644 index cd4c7d6..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/internal/AbstractNodePainter.hpp +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include - -#include "Export.hpp" - -class QPainter; - -namespace QtNodes { - -class NodeGraphicsObject; -class NodeDataModel; - -/// Class enables custom painting. -class NODE_EDITOR_PUBLIC AbstractNodePainter -{ -public: - virtual ~AbstractNodePainter() = default; - - /** - * Reimplement this function in order to have a custom painting. - * - * Useful functions: - * `NodeGraphicsObject::nodeScene()->nodeGeometry()` - * `NodeGraphicsObject::graphModel()` - */ - virtual void paint(QPainter *painter, NodeGraphicsObject &ngo) const = 0; -}; -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/internal/BasicGraphicsScene.hpp b/story-editor-legacy/nodeeditor/include/QtNodes/internal/BasicGraphicsScene.hpp deleted file mode 100644 index 0cc6abd..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/internal/BasicGraphicsScene.hpp +++ /dev/null @@ -1,184 +0,0 @@ -#pragma once - -#include -#include -#include - -#include -#include -#include -#include - -#include "AbstractGraphModel.hpp" -#include "AbstractNodeGeometry.hpp" -#include "ConnectionIdHash.hpp" -#include "Definitions.hpp" -#include "Export.hpp" - -#include "QUuidStdHash.hpp" - -class QUndoStack; - -namespace QtNodes { - -class AbstractGraphModel; -class AbstractNodePainter; -class ConnectionGraphicsObject; -class NodeGraphicsObject; -class NodeStyle; - -/// An instance of QGraphicsScene, holds connections and nodes. -class NODE_EDITOR_PUBLIC BasicGraphicsScene : public QGraphicsScene -{ - Q_OBJECT -public: - BasicGraphicsScene(AbstractGraphModel &graphModel, QObject *parent = nullptr); - - // Scenes without models are not supported - BasicGraphicsScene() = delete; - - ~BasicGraphicsScene(); - -public: - /// @returns associated AbstractGraphModel. - AbstractGraphModel const &graphModel() const; - - AbstractGraphModel &graphModel(); - - AbstractNodeGeometry &nodeGeometry(); - - AbstractNodePainter &nodePainter(); - - void setNodePainter(std::unique_ptr newPainter); - - QUndoStack &undoStack(); - - void setDropShadowEffect(bool enable); - - bool isDropShadowEffectEnabled() const; - -public: - /// Creates a "draft" instance of ConnectionGraphicsObject. - /** - * The scene caches a "draft" connection which has one loose end. - * After attachment the "draft" instance is deleted and instead a - * normal "full" connection is created. - * Function @returns the "draft" instance for further geometry - * manipulations. - */ - std::unique_ptr const &makeDraftConnection( - ConnectionId const newConnectionId); - - /// Deletes "draft" connection. - /** - * The function is called when user releases the mouse button during - * the construction of the new connection without attaching it to any - * node. - */ - void resetDraftConnection(); - - /// Deletes all the nodes. Connections are removed automatically. - void clearScene(); - -public: - /// @returns NodeGraphicsObject associated with the given nodeId. - /** - * @returns nullptr when the object is not found. - */ - NodeGraphicsObject *nodeGraphicsObject(NodeId nodeId); - - /// @returns ConnectionGraphicsObject corresponding to `connectionId`. - /** - * @returns `nullptr` when the object is not found. - */ - ConnectionGraphicsObject *connectionGraphicsObject(ConnectionId connectionId); - - Qt::Orientation orientation() const { return _orientation; } - - void setOrientation(Qt::Orientation const orientation); - -public: - /// Can @return an instance of the scene context menu in subclass. - /** - * Default implementation returns `nullptr`. - */ - virtual QMenu *createSceneMenu(QPointF const scenePos); - -Q_SIGNALS: - void nodeMoved(NodeId const nodeId, QPointF const &newLocation); - - void nodeClicked(NodeId const nodeId); - - void nodeSelected(NodeId const nodeId); - - void nodeDoubleClicked(NodeId const nodeId); - - void nodeHovered(NodeId const nodeId, QPoint const screenPos); - - void nodeHoverLeft(NodeId const nodeId); - - void connectionHovered(ConnectionId const connectionId, QPoint const screenPos); - - void connectionHoverLeft(ConnectionId const connectionId); - - /// Signal allows showing custom context menu upon clicking a node. - void nodeContextMenu(NodeId const nodeId, QPointF const pos); - -private: - /// @brief Creates Node and Connection graphics objects. - /** - * Function is used to populate an empty scene in the constructor. We - * perform depth-first AbstractGraphModel traversal. The connections are - * created by checking non-empty node `Out` ports. - */ - void traverseGraphAndPopulateGraphicsObjects(); - - /// Redraws adjacent nodes for given `connectionId` - void updateAttachedNodes(ConnectionId const connectionId, PortType const portType); - -public Q_SLOTS: - /// Slot called when the `connectionId` is erased form the AbstractGraphModel. - void onConnectionDeleted(ConnectionId const connectionId); - - /// Slot called when the `connectionId` is created in the AbstractGraphModel. - void onConnectionCreated(ConnectionId const connectionId); - - void onNodeDeleted(NodeId const nodeId); - - void onNodeCreated(NodeId const nodeId); - - void onNodePositionUpdated(NodeId const nodeId); - - void onNodeUpdated(NodeId const nodeId); - - void onNodeClicked(NodeId const nodeId); - - void onModelReset(); - -private: - AbstractGraphModel &_graphModel; - - using UniqueNodeGraphicsObject = std::unique_ptr; - - using UniqueConnectionGraphicsObject = std::unique_ptr; - - std::unordered_map _nodeGraphicsObjects; - - std::unordered_map _connectionGraphicsObjects; - - std::unique_ptr _draftConnection; - - std::unique_ptr _nodeGeometry; - - std::unique_ptr _nodePainter; - - bool _nodeDrag; - - QUndoStack *_undoStack; - - Qt::Orientation _orientation; - - bool _dropShadowEffect{false}; -}; - -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/internal/Compiler.hpp b/story-editor-legacy/nodeeditor/include/QtNodes/internal/Compiler.hpp deleted file mode 100644 index 9842657..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/internal/Compiler.hpp +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once - -#if defined(__MINGW32__) || defined(__MINGW64__) -#define NODE_EDITOR_COMPILER "MinGW" -#define NODE_EDITOR_COMPILER_MINGW -#elif defined(__clang__) -#define NODE_EDITOR_COMPILER "Clang" -#define NODE_EDITOR_COMPILER_CLANG -#elif defined(_MSC_VER) -#define NODE_EDITOR_COMPILER "Microsoft Visual C++" -#define NODE_EDITOR_COMPILER_MICROSOFT -#elif defined(__GNUC__) -#define NODE_EDITOR_COMPILER "GNU" -#define NODE_EDITOR_COMPILER_GNU -#define NODE_EDITOR_COMPILER_GNU_VERSION_MAJOR __GNUC__ -#define NODE_EDITOR_COMPILER_GNU_VERSION_MINOR __GNUC_MINOR__ -#define NODE_EDITOR_COMPILER_GNU_VERSION_PATCH __GNUC_PATCHLEVEL__ -#elif defined(__BORLANDC__) -#define NODE_EDITOR_COMPILER "Borland C++ Builder" -#define NODE_EDITOR_COMPILER_BORLAND -#elif defined(__CODEGEARC__) -#define NODE_EDITOR_COMPILER "CodeGear C++ Builder" -#define NODE_EDITOR_COMPILER_CODEGEAR -#elif defined(__INTEL_COMPILER) || defined(__ICL) -#define NODE_EDITOR_COMPILER "Intel C++" -#define NODE_EDITOR_COMPILER_INTEL -#elif defined(__xlC__) || defined(__IBMCPP__) -#define NODE_EDITOR_COMPILER "IBM XL C++" -#define NODE_EDITOR_COMPILER_IBM -#elif defined(__HP_aCC) -#define NODE_EDITOR_COMPILER "HP aC++" -#define NODE_EDITOR_COMPILER_HP -#elif defined(__WATCOMC__) -#define NODE_EDITOR_COMPILER "Watcom C++" -#define NODE_EDITOR_COMPILER_WATCOM -#endif - -#ifndef NODE_EDITOR_COMPILER -#error "Current compiler is not supported." -#endif diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/internal/ConnectionGraphicsObject.hpp b/story-editor-legacy/nodeeditor/include/QtNodes/internal/ConnectionGraphicsObject.hpp deleted file mode 100644 index f0e569d..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/internal/ConnectionGraphicsObject.hpp +++ /dev/null @@ -1,96 +0,0 @@ -#pragma once - -#include - -#include -#include - -#include "ConnectionState.hpp" -#include "Definitions.hpp" - -class QGraphicsSceneMouseEvent; - -namespace QtNodes { - -class AbstractGraphModel; -class BasicGraphicsScene; - -/// Graphic Object for connection. Adds itself to scene -class ConnectionGraphicsObject : public QGraphicsObject -{ - Q_OBJECT -public: - // Needed for qgraphicsitem_cast - enum { Type = UserType + 2 }; - - int type() const override { return Type; } - -public: - ConnectionGraphicsObject(BasicGraphicsScene &scene, ConnectionId const connectionId); - - ~ConnectionGraphicsObject() = default; - -public: - AbstractGraphModel &graphModel() const; - - BasicGraphicsScene *nodeScene() const; - - ConnectionId const &connectionId() const; - - QRectF boundingRect() const override; - - QPainterPath shape() const override; - - QPointF const &endPoint(PortType portType) const; - - QPointF out() const { return _out; } - - QPointF in() const { return _in; } - - std::pair pointsC1C2() const; - - void setEndPoint(PortType portType, QPointF const &point); - - /// Updates the position of both ends - void move(); - - ConnectionState const &connectionState() const; - - ConnectionState &connectionState(); - -protected: - void paint(QPainter *painter, - QStyleOptionGraphicsItem const *option, - QWidget *widget = 0) override; - - void mousePressEvent(QGraphicsSceneMouseEvent *event) override; - - void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override; - - void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; - - void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override; - - void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override; - -private: - void initializePosition(); - - void addGraphicsEffect(); - - std::pair pointsC1C2Horizontal() const; - - std::pair pointsC1C2Vertical() const; - -private: - ConnectionId _connectionId; - - AbstractGraphModel &_graphModel; - - ConnectionState _connectionState; - - mutable QPointF _out; - mutable QPointF _in; -}; - -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/internal/ConnectionIdHash.hpp b/story-editor-legacy/nodeeditor/include/QtNodes/internal/ConnectionIdHash.hpp deleted file mode 100644 index 09eaced..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/internal/ConnectionIdHash.hpp +++ /dev/null @@ -1,55 +0,0 @@ -#pragma once - -#include - -#include "Definitions.hpp" - -inline void hash_combine(std::size_t &seed) -{ - Q_UNUSED(seed); -} - -template -inline void hash_combine(std::size_t &seed, const T &v, Rest... rest) -{ - std::hash hasher; - seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - hash_combine(seed, rest...); -} - -namespace std { -template<> -struct hash -{ - inline std::size_t operator()(QtNodes::ConnectionId const &id) const - { - std::size_t h = 0; - hash_combine(h, id.outNodeId, id.outPortIndex, id.inNodeId, id.inPortIndex); - return h; - } -}; - -template<> -struct hash> -{ - inline std::size_t operator()(std::pair const &nodePort) const - { - std::size_t h = 0; - hash_combine(h, nodePort.first, nodePort.second); - return h; - } -}; - -template<> -struct hash> -{ - using Key = std::tuple; - - inline std::size_t operator()(Key const &key) const - { - std::size_t h = 0; - hash_combine(h, std::get<0>(key), std::get<1>(key), std::get<2>(key)); - return h; - } -}; -} // namespace std diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/internal/ConnectionIdUtils.hpp b/story-editor-legacy/nodeeditor/include/QtNodes/internal/ConnectionIdUtils.hpp deleted file mode 100644 index 7f70a1b..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/internal/ConnectionIdUtils.hpp +++ /dev/null @@ -1,151 +0,0 @@ -#pragma once - -#include "Definitions.hpp" - -#include - -#include -#include - -namespace QtNodes { - -inline PortIndex getNodeId(PortType portType, ConnectionId connectionId) -{ - NodeId id = InvalidNodeId; - - if (portType == PortType::Out) { - id = connectionId.outNodeId; - } else if (portType == PortType::In) { - id = connectionId.inNodeId; - } - - return id; -} - -inline PortIndex getPortIndex(PortType portType, ConnectionId connectionId) -{ - PortIndex index = InvalidPortIndex; - - if (portType == PortType::Out) { - index = connectionId.outPortIndex; - } else if (portType == PortType::In) { - index = connectionId.inPortIndex; - } - - return index; -} - -inline PortType oppositePort(PortType port) -{ - PortType result = PortType::None; - - switch (port) { - case PortType::In: - result = PortType::Out; - break; - - case PortType::Out: - result = PortType::In; - break; - - case PortType::None: - result = PortType::None; - break; - - default: - break; - } - return result; -} - -inline bool isPortIndexValid(PortIndex index) -{ - return index != InvalidPortIndex; -} - -inline bool isPortTypeValid(PortType portType) -{ - return portType != PortType::None; -} - -/** - * Creates a connection Id instance filled just on one side. - */ -inline ConnectionId makeIncompleteConnectionId(NodeId const connectedNodeId, - PortType const connectedPort, - PortIndex const connectedPortIndex) -{ - return (connectedPort == PortType::In) - ? ConnectionId{InvalidNodeId, InvalidPortIndex, connectedNodeId, connectedPortIndex} - : ConnectionId{connectedNodeId, connectedPortIndex, InvalidNodeId, InvalidPortIndex}; -} - -/** - * Turns a full connection Id into an incomplete one by removing the - * data on the given side - */ -inline ConnectionId makeIncompleteConnectionId(ConnectionId connectionId, - PortType const portToDisconnect) -{ - if (portToDisconnect == PortType::Out) { - connectionId.outNodeId = InvalidNodeId; - connectionId.outPortIndex = InvalidPortIndex; - } else { - connectionId.inNodeId = InvalidNodeId; - connectionId.inPortIndex = InvalidPortIndex; - } - - return connectionId; -} - -inline ConnectionId makeCompleteConnectionId(ConnectionId incompleteConnectionId, - NodeId const nodeId, - PortIndex const portIndex) -{ - if (incompleteConnectionId.outNodeId == InvalidNodeId) { - incompleteConnectionId.outNodeId = nodeId; - incompleteConnectionId.outPortIndex = portIndex; - } else { - incompleteConnectionId.inNodeId = nodeId; - incompleteConnectionId.inPortIndex = portIndex; - } - - return incompleteConnectionId; -} - -inline std::ostream &operator<<(std::ostream &ostr, ConnectionId const connectionId) -{ - ostr << "(" << connectionId.outNodeId << ", " - << (isPortIndexValid(connectionId.outPortIndex) ? std::to_string(connectionId.outPortIndex) - : "INVALID") - << ", " << connectionId.inNodeId << ", " - << (isPortIndexValid(connectionId.inPortIndex) ? std::to_string(connectionId.inPortIndex) - : "INVALID") - << ")" << std::endl; - - return ostr; -} - -inline QJsonObject toJson(ConnectionId const &connId) -{ - QJsonObject connJson; - - connJson["outNodeId"] = static_cast(connId.outNodeId); - connJson["outPortIndex"] = static_cast(connId.outPortIndex); - connJson["intNodeId"] = static_cast(connId.inNodeId); - connJson["inPortIndex"] = static_cast(connId.inPortIndex); - - return connJson; -} - -inline ConnectionId fromJson(QJsonObject const &connJson) -{ - ConnectionId connId{static_cast(connJson["outNodeId"].toInt(InvalidNodeId)), - static_cast(connJson["outPortIndex"].toInt(InvalidPortIndex)), - static_cast(connJson["intNodeId"].toInt(InvalidNodeId)), - static_cast(connJson["inPortIndex"].toInt(InvalidPortIndex))}; - - return connId; -} - -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/internal/ConnectionPainter.hpp b/story-editor-legacy/nodeeditor/include/QtNodes/internal/ConnectionPainter.hpp deleted file mode 100644 index 8db24d8..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/internal/ConnectionPainter.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -#include -#include - -#include "Definitions.hpp" - -namespace QtNodes { - -class ConnectionGeometry; -class ConnectionGraphicsObject; - -class ConnectionPainter -{ -public: - static void paint(QPainter *painter, ConnectionGraphicsObject const &cgo); - - static QPainterPath getPainterStroke(ConnectionGraphicsObject const &cgo); -}; - -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/internal/ConnectionState.hpp b/story-editor-legacy/nodeeditor/include/QtNodes/internal/ConnectionState.hpp deleted file mode 100644 index ddd31cd..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/internal/ConnectionState.hpp +++ /dev/null @@ -1,60 +0,0 @@ -#pragma once - -#include - -#include "Export.hpp" - -#include "Definitions.hpp" - -class QPointF; - -namespace QtNodes { - -class ConnectionGraphicsObject; - -/// Stores currently draggind end. -/// Remembers last hovered Node. -class NODE_EDITOR_PUBLIC ConnectionState -{ -public: - /// Defines whether we construct a new connection - /// or it is already binding two nodes. - enum LooseEnd { Pending = 0, Connected = 1 }; - -public: - ConnectionState(ConnectionGraphicsObject &cgo) - : _cgo(cgo) - , _hovered(false) - {} - - ConnectionState(ConnectionState const &) = delete; - ConnectionState(ConnectionState &&) = delete; - - ConnectionState &operator=(ConnectionState const &) = delete; - ConnectionState &operator=(ConnectionState &&) = delete; - - ~ConnectionState(); - -public: - PortType requiredPort() const; - bool requiresPort() const; - - bool hovered() const; - void setHovered(bool hovered); - -public: - /// Caches NodeId for further interaction. - void setLastHoveredNode(NodeId const nodeId); - - NodeId lastHoveredNode() const; - - void resetLastHoveredNode(); - -private: - ConnectionGraphicsObject &_cgo; - - bool _hovered; - - NodeId _lastHoveredNode{InvalidNodeId}; -}; -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/internal/ConnectionStyle.hpp b/story-editor-legacy/nodeeditor/include/QtNodes/internal/ConnectionStyle.hpp deleted file mode 100644 index b718bcf..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/internal/ConnectionStyle.hpp +++ /dev/null @@ -1,54 +0,0 @@ -#pragma once - -#include - -#include "Export.hpp" -#include "Style.hpp" - -namespace QtNodes { - -class NODE_EDITOR_PUBLIC ConnectionStyle : public Style -{ -public: - ConnectionStyle(); - - ConnectionStyle(QString jsonText); - - ~ConnectionStyle() = default; - -public: - static void setConnectionStyle(QString jsonText); - -public: - void loadJson(QJsonObject const &json) override; - - QJsonObject toJson() const override; - -public: - QColor constructionColor() const; - QColor normalColor() const; - QColor normalColor(QString typeId) const; - QColor selectedColor() const; - QColor selectedHaloColor() const; - QColor hoveredColor() const; - - float lineWidth() const; - float constructionLineWidth() const; - float pointDiameter() const; - - bool useDataDefinedColors() const; - -private: - QColor ConstructionColor; - QColor NormalColor; - QColor SelectedColor; - QColor SelectedHaloColor; - QColor HoveredColor; - - float LineWidth; - float ConstructionLineWidth; - float PointDiameter; - - bool UseDataDefinedColors; -}; -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/internal/DataFlowGraphModel.hpp b/story-editor-legacy/nodeeditor/include/QtNodes/internal/DataFlowGraphModel.hpp deleted file mode 100644 index 2688002..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/internal/DataFlowGraphModel.hpp +++ /dev/null @@ -1,135 +0,0 @@ -#pragma once - -#include "AbstractGraphModel.hpp" -#include "ConnectionIdUtils.hpp" -#include "NodeDelegateModelRegistry.hpp" -#include "Serializable.hpp" -#include "StyleCollection.hpp" - -#include "Export.hpp" - -#include - -#include - -namespace QtNodes { - -class NODE_EDITOR_PUBLIC DataFlowGraphModel : public AbstractGraphModel, public Serializable -{ - Q_OBJECT - -public: - struct NodeGeometryData - { - QSize size; - QPointF pos; - }; - -public: - DataFlowGraphModel(std::shared_ptr registry); - - std::shared_ptr dataModelRegistry() { return _registry; } - -public: - std::unordered_set allNodeIds() const override; - - std::unordered_set allConnectionIds(NodeId const nodeId) const override; - - std::unordered_set connections(NodeId nodeId, - PortType portType, - PortIndex portIndex) const override; - - bool connectionExists(ConnectionId const connectionId) const override; - - NodeId addNode(QString const nodeType) override; - - bool connectionPossible(ConnectionId const connectionId) const override; - - void addConnection(ConnectionId const connectionId) override; - - bool nodeExists(NodeId const nodeId) const override; - - QVariant nodeData(NodeId nodeId, NodeRole role) const override; - - NodeFlags nodeFlags(NodeId nodeId) const override; - - bool setNodeData(NodeId nodeId, NodeRole role, QVariant value) override; - - QVariant portData(NodeId nodeId, - PortType portType, - PortIndex portIndex, - PortRole role) const override; - - bool setPortData(NodeId nodeId, - PortType portType, - PortIndex portIndex, - QVariant const &value, - PortRole role = PortRole::Data) override; - - bool deleteConnection(ConnectionId const connectionId) override; - - bool deleteNode(NodeId const nodeId) override; - - QJsonObject saveNode(NodeId const) const override; - - QJsonObject save() const override; - - void loadNode(QJsonObject const &nodeJson) override; - - void load(QJsonObject const &json) override; - - /** - * Fetches the NodeDelegateModel for the given `nodeId` and tries to cast the - * stored pointer to the given type - */ - template - NodeDelegateModelType *delegateModel(NodeId const nodeId) - { - auto it = _models.find(nodeId); - if (it == _models.end()) - return nullptr; - - auto model = dynamic_cast(it->second.get()); - - return model; - } - -Q_SIGNALS: - void inPortDataWasSet(NodeId const, PortType const, PortIndex const); - -private: - NodeId newNodeId() override { return _nextNodeId++; } - - void sendConnectionCreation(ConnectionId const connectionId); - - void sendConnectionDeletion(ConnectionId const connectionId); - -private Q_SLOTS: - /** - * Fuction is called in three cases: - * - * - By underlying NodeDelegateModel when a node has new data to propagate. - * @see DataFlowGraphModel::addNode - * - When a new connection is created. - * @see DataFlowGraphModel::addConnection - * - When a node restored from JSON an needs to send data downstream. - * @see DataFlowGraphModel::loadNode - */ - void onOutPortDataUpdated(NodeId const nodeId, PortIndex const portIndex); - - /// Function is called after detaching a connection. - void propagateEmptyDataTo(NodeId const nodeId, PortIndex const portIndex); - -private: - std::shared_ptr _registry; - - NodeId _nextNodeId; - - std::unordered_map> _models; - - std::unordered_set _connectivity; - - mutable std::unordered_map _nodeGeometryData; -}; - -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/internal/DataFlowGraphicsScene.hpp b/story-editor-legacy/nodeeditor/include/QtNodes/internal/DataFlowGraphicsScene.hpp deleted file mode 100644 index 25698eb..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/internal/DataFlowGraphicsScene.hpp +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once - -#include "BasicGraphicsScene.hpp" -#include "DataFlowGraphModel.hpp" -#include "Export.hpp" - -namespace QtNodes { - -/// @brief An advanced scene working with data-propagating graphs. -/** - * The class represents a scene that existed in v2.x but built wit the - * new model-view approach in mind. - */ -class NODE_EDITOR_PUBLIC DataFlowGraphicsScene : public BasicGraphicsScene -{ - Q_OBJECT -public: - DataFlowGraphicsScene(DataFlowGraphModel &graphModel, QObject *parent = nullptr); - - ~DataFlowGraphicsScene() = default; - -public: - std::vector selectedNodes() const; - -public: - QMenu *createSceneMenu(QPointF const scenePos) override; - -public Q_SLOTS: - void save() const; - - void load(); - -Q_SIGNALS: - void sceneLoaded(); - -private: - DataFlowGraphModel &_graphModel; -}; - -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/internal/DefaultHorizontalNodeGeometry.hpp b/story-editor-legacy/nodeeditor/include/QtNodes/internal/DefaultHorizontalNodeGeometry.hpp deleted file mode 100644 index f5f6607..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/internal/DefaultHorizontalNodeGeometry.hpp +++ /dev/null @@ -1,58 +0,0 @@ -#pragma once - -#include "AbstractNodeGeometry.hpp" - -#include - -namespace QtNodes { - -class AbstractGraphModel; -class BasicGraphicsScene; - -class NODE_EDITOR_PUBLIC DefaultHorizontalNodeGeometry : public AbstractNodeGeometry -{ -public: - DefaultHorizontalNodeGeometry(AbstractGraphModel &graphModel); - -public: - QSize size(NodeId const nodeId) const override; - - void recomputeSize(NodeId const nodeId) const override; - - QPointF portPosition(NodeId const nodeId, - PortType const portType, - PortIndex const index) const override; - - QPointF portTextPosition(NodeId const nodeId, - PortType const portType, - PortIndex const PortIndex) const override; - QPointF captionPosition(NodeId const nodeId) const override; - - QRectF captionRect(NodeId const nodeId) const override; - - QPointF widgetPosition(NodeId const nodeId) const override; - - QRect resizeHandleRect(NodeId const nodeId) const override; - -private: - QRectF portTextRect(NodeId const nodeId, - PortType const portType, - PortIndex const portIndex) const; - - /// Finds max number of ports and multiplies by (a port height + interval) - unsigned int maxVerticalPortsExtent(NodeId const nodeId) const; - - unsigned int maxPortsTextAdvance(NodeId const nodeId, PortType const portType) const; - -private: - // Some variables are mutable because we need to change drawing - // metrics corresponding to fontMetrics but this doesn't change - // constness of the Node. - - mutable unsigned int _portSize; - unsigned int _portSpasing; - mutable QFontMetrics _fontMetrics; - mutable QFontMetrics _boldFontMetrics; -}; - -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/internal/DefaultNodePainter.hpp b/story-editor-legacy/nodeeditor/include/QtNodes/internal/DefaultNodePainter.hpp deleted file mode 100644 index 484969f..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/internal/DefaultNodePainter.hpp +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -#include - -#include "AbstractNodePainter.hpp" -#include "Definitions.hpp" - -namespace QtNodes { - -class BasicGraphicsScene; -class GraphModel; -class NodeGeometry; -class NodeGraphicsObject; -class NodeState; - -/// @ Lightweight class incapsulating paint code. -class NODE_EDITOR_PUBLIC DefaultNodePainter : public AbstractNodePainter -{ -public: - void paint(QPainter *painter, NodeGraphicsObject &ngo) const override; - - void drawNodeRect(QPainter *painter, NodeGraphicsObject &ngo) const; - - void drawConnectionPoints(QPainter *painter, NodeGraphicsObject &ngo) const; - - void drawFilledConnectionPoints(QPainter *painter, NodeGraphicsObject &ngo) const; - - void drawNodeCaption(QPainter *painter, NodeGraphicsObject &ngo) const; - - void drawEntryLabels(QPainter *painter, NodeGraphicsObject &ngo) const; - - void drawResizeRect(QPainter *painter, NodeGraphicsObject &ngo) const; -}; -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/internal/DefaultVerticalNodeGeometry.hpp b/story-editor-legacy/nodeeditor/include/QtNodes/internal/DefaultVerticalNodeGeometry.hpp deleted file mode 100644 index ae9b628..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/internal/DefaultVerticalNodeGeometry.hpp +++ /dev/null @@ -1,60 +0,0 @@ -#pragma once - -#include "AbstractNodeGeometry.hpp" - -#include - -namespace QtNodes { - -class AbstractGraphModel; -class BasicGraphicsScene; - -class NODE_EDITOR_PUBLIC DefaultVerticalNodeGeometry : public AbstractNodeGeometry -{ -public: - DefaultVerticalNodeGeometry(AbstractGraphModel &graphModel); - -public: - QSize size(NodeId const nodeId) const override; - - void recomputeSize(NodeId const nodeId) const override; - - QPointF portPosition(NodeId const nodeId, - PortType const portType, - PortIndex const index) const override; - - QPointF portTextPosition(NodeId const nodeId, - PortType const portType, - PortIndex const PortIndex) const override; - - QPointF captionPosition(NodeId const nodeId) const override; - - QRectF captionRect(NodeId const nodeId) const override; - - QPointF widgetPosition(NodeId const nodeId) const override; - - QRect resizeHandleRect(NodeId const nodeId) const override; - -private: - QRectF portTextRect(NodeId const nodeId, - PortType const portType, - PortIndex const portIndex) const; - /// Finds - unsigned int maxHorizontalPortsExtent(NodeId const nodeId) const; - - unsigned int maxPortsTextAdvance(NodeId const nodeId, PortType const portType) const; - - unsigned int portCaptionsHeight(NodeId const nodeId, PortType const portType) const; - -private: - // Some variables are mutable because we need to change drawing - // metrics corresponding to fontMetrics but this doesn't change - // constness of the Node. - - mutable unsigned int _portSize; - unsigned int _portSpasing; - mutable QFontMetrics _fontMetrics; - mutable QFontMetrics _boldFontMetrics; -}; - -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/internal/Definitions.hpp b/story-editor-legacy/nodeeditor/include/QtNodes/internal/Definitions.hpp deleted file mode 100644 index 26b94ab..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/internal/Definitions.hpp +++ /dev/null @@ -1,125 +0,0 @@ -#pragma once - -#include "Export.hpp" - -#include - -#include - -/** - * @file - * Important definitions used throughout the library. - */ - -namespace QtNodes { -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) -NODE_EDITOR_PUBLIC Q_NAMESPACE -#else -Q_NAMESPACE_EXPORT(NODE_EDITOR_PUBLIC) -#endif - - /** - * Constants used for fetching QVariant data from GraphModel. - */ - enum class NodeRole { - Type = 0, ///< Type of the current node, usually a string. - Position = 1, ///< `QPointF` positon of the node on the scene. - Size = 2, ///< `QSize` for resizable nodes. - CaptionVisible = 3, ///< `bool` for caption visibility. - Caption = 4, ///< `QString` for node caption. - Style = 5, ///< Custom NodeStyle as QJsonDocument - InternalData = 6, ///< Node-stecific user data as QJsonObject - InPortCount = 7, ///< `unsigned int` - OutPortCount = 9, ///< `unsigned int` - Widget = 10, ///< Optional `QWidget*` or `nullptr` - Id = 11 ///< Return node ID - }; -Q_ENUM_NS(NodeRole) - -/** - * Specific flags regulating node features and appeaarence. - */ -enum NodeFlag { - NoFlags = 0x0, ///< Default NodeFlag - Resizable = 0x1, ///< Lets the node be resizable - Locked = 0x2 -}; - -Q_DECLARE_FLAGS(NodeFlags, NodeFlag) -Q_FLAG_NS(NodeFlags) -Q_DECLARE_OPERATORS_FOR_FLAGS(NodeFlags) - -/** - * Constants for fetching port-related information from the GraphModel. - */ -enum class PortRole { - Data = 0, ///< `std::shared_ptr`. - DataType = 1, ///< `QString` describing the port data type. - ConnectionPolicyRole = 2, ///< `enum` ConnectionPolicyRole - CaptionVisible = 3, ///< `bool` for caption visibility. - Caption = 4, ///< `QString` for port caption. -}; -Q_ENUM_NS(PortRole) - -/** - * Defines how many connections are possible to attach to ports. The - * values are fetched using PortRole::ConnectionPolicy. - */ -enum class ConnectionPolicy { - One, ///< Just one connection for each port. - Many, ///< Any number of connections possible for the port. -}; -Q_ENUM_NS(ConnectionPolicy) - -/** - * Used for distinguishing input and output node ports. - */ -enum class PortType { - In = 0, ///< Input node port (from the left). - Out = 1, ///< Output node port (from the right). - None = 2 -}; -Q_ENUM_NS(PortType) - -using PortCount = unsigned int; - -/// ports are consecutively numbered starting from zero. -using PortIndex = unsigned int; - -static constexpr PortIndex InvalidPortIndex = std::numeric_limits::max(); - -/// Unique Id associated with each node in the GraphModel. -using NodeId = unsigned int; - -static constexpr NodeId InvalidNodeId = std::numeric_limits::max(); - -/** - * A unique connection identificator that stores - * out `NodeId`, out `PortIndex`, in `NodeId`, in `PortIndex` - */ -struct ConnectionId -{ - NodeId outNodeId; - PortIndex outPortIndex; - NodeId inNodeId; - PortIndex inPortIndex; -}; - -inline bool operator==(ConnectionId const &a, ConnectionId const &b) -{ - return a.outNodeId == b.outNodeId && a.outPortIndex == b.outPortIndex - && a.inNodeId == b.inNodeId && a.inPortIndex == b.inPortIndex; -} - -inline bool operator!=(ConnectionId const &a, ConnectionId const &b) -{ - return !(a == b); -} - -inline void invertConnection(ConnectionId &id) -{ - std::swap(id.outNodeId, id.inNodeId); - std::swap(id.outPortIndex, id.inPortIndex); -} - -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/internal/Export.hpp b/story-editor-legacy/nodeeditor/include/QtNodes/internal/Export.hpp deleted file mode 100644 index 41e6e3d..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/internal/Export.hpp +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once - -#include "Compiler.hpp" -#include "OperatingSystem.hpp" - -#ifdef NODE_EDITOR_PLATFORM_WINDOWS -#define NODE_EDITOR_EXPORT __declspec(dllexport) -#define NODE_EDITOR_IMPORT __declspec(dllimport) -#define NODE_EDITOR_LOCAL -#elif NODE_EDITOR_COMPILER_GNU_VERSION_MAJOR >= 4 || defined(NODE_EDITOR_COMPILER_CLANG) -#define NODE_EDITOR_EXPORT __attribute__((visibility("default"))) -#define NODE_EDITOR_IMPORT __attribute__((visibility("default"))) -#define NODE_EDITOR_LOCAL __attribute__((visibility("hidden"))) -#else -#define NODE_EDITOR_EXPORT -#define NODE_EDITOR_IMPORT -#define NODE_EDITOR_LOCAL -#endif - -#ifdef __cplusplus -#define NODE_EDITOR_DEMANGLED extern "C" -#else -#define NODE_EDITOR_DEMANGLED -#endif - -#if defined(NODE_EDITOR_SHARED) && !defined(NODE_EDITOR_STATIC) -#ifdef NODE_EDITOR_EXPORTS -#define NODE_EDITOR_PUBLIC NODE_EDITOR_EXPORT -#else -#define NODE_EDITOR_PUBLIC NODE_EDITOR_IMPORT -#endif -#define NODE_EDITOR_PRIVATE NODE_EDITOR_LOCAL -#elif !defined(NODE_EDITOR_SHARED) && defined(NODE_EDITOR_STATIC) -#define NODE_EDITOR_PUBLIC -#define NODE_EDITOR_PRIVATE -#elif defined(NODE_EDITOR_SHARED) && defined(NODE_EDITOR_STATIC) -#ifdef NODE_EDITOR_EXPORTS -#error "Cannot build as shared and static simultaneously." -#else -#error "Cannot link against shared and static simultaneously." -#endif -#else -#ifdef NODE_EDITOR_EXPORTS -#error "Choose whether to build as shared or static." -#else -#error "Choose whether to link against shared or static." -#endif -#endif diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/internal/GraphicsView.hpp b/story-editor-legacy/nodeeditor/include/QtNodes/internal/GraphicsView.hpp deleted file mode 100644 index 5206812..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/internal/GraphicsView.hpp +++ /dev/null @@ -1,97 +0,0 @@ -#pragma once - -#include - -#include "Export.hpp" - -namespace QtNodes { - -class BasicGraphicsScene; - -/** - * @brief A central view able to render objects from `BasicGraphicsScene`. - */ -class NODE_EDITOR_PUBLIC GraphicsView : public QGraphicsView -{ - Q_OBJECT -public: - struct ScaleRange - { - double minimum = 0; - double maximum = 0; - }; - -public: - GraphicsView(QWidget *parent = Q_NULLPTR); - GraphicsView(BasicGraphicsScene *scene, QWidget *parent = Q_NULLPTR); - - GraphicsView(const GraphicsView &) = delete; - GraphicsView operator=(const GraphicsView &) = delete; - - QAction *clearSelectionAction() const; - - QAction *deleteSelectionAction() const; - - void setScene(BasicGraphicsScene *scene); - - void centerScene(); - - /// @brief max=0/min=0 indicates infinite zoom in/out - void setScaleRange(double minimum = 0, double maximum = 0); - - void setScaleRange(ScaleRange range); - - double getScale() const; - -public Q_SLOTS: - void scaleUp(); - - void scaleDown(); - - void setupScale(double scale); - - void onDeleteSelectedObjects(); - - void onDuplicateSelectedObjects(); - - void onCopySelectedObjects(); - - void onPasteObjects(); - -Q_SIGNALS: - void scaleChanged(double scale); - -protected: - void contextMenuEvent(QContextMenuEvent *event) override; - - void wheelEvent(QWheelEvent *event) override; - - void keyPressEvent(QKeyEvent *event) override; - - void keyReleaseEvent(QKeyEvent *event) override; - - void mousePressEvent(QMouseEvent *event) override; - - void mouseMoveEvent(QMouseEvent *event) override; - - void drawBackground(QPainter *painter, const QRectF &r) override; - - void showEvent(QShowEvent *event) override; - -protected: - BasicGraphicsScene *nodeScene(); - - /// Computes scene position for pasting the copied/duplicated node groups. - QPointF scenePastePosition(); - -private: - QAction *_clearSelectionAction = nullptr; - QAction *_deleteSelectionAction = nullptr; - QAction *_duplicateSelectionAction = nullptr; - QAction *_copySelectionAction = nullptr; - QAction *_pasteAction = nullptr; - - QPointF _clickPos; - ScaleRange _scaleRange; -}; -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/internal/GraphicsViewStyle.hpp b/story-editor-legacy/nodeeditor/include/QtNodes/internal/GraphicsViewStyle.hpp deleted file mode 100644 index 32f51b9..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/internal/GraphicsViewStyle.hpp +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once - -#include - -#include "Export.hpp" -#include "Style.hpp" - -namespace QtNodes { - -class NODE_EDITOR_PUBLIC GraphicsViewStyle : public Style -{ -public: - GraphicsViewStyle(); - - GraphicsViewStyle(QString jsonText); - - ~GraphicsViewStyle() = default; - -public: - static void setStyle(QString jsonText); - -private: - void loadJson(QJsonObject const &json) override; - - QJsonObject toJson() const override; - -public: - QColor BackgroundColor; - QColor FineGridColor; - QColor CoarseGridColor; -}; -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/internal/NodeConnectionInteraction.hpp b/story-editor-legacy/nodeeditor/include/QtNodes/internal/NodeConnectionInteraction.hpp deleted file mode 100644 index aaefedf..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/internal/NodeConnectionInteraction.hpp +++ /dev/null @@ -1,68 +0,0 @@ -#pragma once - -#include - -#include - -#include "Definitions.hpp" - -namespace QtNodes { - -class ConnectionGraphicsObject; -class NodeGraphicsObject; -class BasicGraphicsScene; - -/// Class wraps conecting and disconnecting checks. -/** - * An instance should be created on the stack and destroyed - * automatically when the operation is completed - */ -class NodeConnectionInteraction -{ -public: - NodeConnectionInteraction(NodeGraphicsObject &ngo, - ConnectionGraphicsObject &cgo, - BasicGraphicsScene &scene); - - /** - * Can connect when following conditions are met: - * 1. Connection 'requires' a port. - * 2. Connection loose end is above the node port. - * 3. Source and target `nodeId`s are different. - * 4. GraphModel permits connection. - */ - bool canConnect(PortIndex *portIndex) const; - - /// Creates a new connectino if possible. - /** - * 1. Check conditions from 'canConnect'. - * 2. Creates new connection with `GraphModel::addConnection`. - * 3. Adjust connection geometry. - */ - bool tryConnect() const; - - /** - * 1. Delete connection with `GraphModel::deleteConnection`. - * 2. Create a "draft" connection with incomplete `ConnectionId`. - * 3. Repaint both previously connected nodes. - */ - bool disconnect(PortType portToDisconnect) const; - -private: - PortType connectionRequiredPort() const; - - QPointF connectionEndScenePosition(PortType) const; - - QPointF nodePortScenePosition(PortType portType, PortIndex portIndex) const; - - PortIndex nodePortIndexUnderScenePoint(PortType portType, QPointF const &p) const; - -private: - NodeGraphicsObject &_ngo; - - ConnectionGraphicsObject &_cgo; - - BasicGraphicsScene &_scene; -}; - -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/internal/NodeData.hpp b/story-editor-legacy/nodeeditor/include/QtNodes/internal/NodeData.hpp deleted file mode 100644 index 1ef7480..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/internal/NodeData.hpp +++ /dev/null @@ -1,43 +0,0 @@ -#pragma once - -#include - -#include -#include - -#include "Export.hpp" - -namespace QtNodes { - -/** - * `id` represents an internal unique data type for the given port. - * `name` is a normal text description. - */ -struct NODE_EDITOR_PUBLIC NodeDataType -{ - QString id; - QString name; -}; - -/** - * Class represents data transferred between nodes. - * @param type is used for comparing the types - * The actual data is stored in subtypes - */ -class NODE_EDITOR_PUBLIC NodeData -{ -public: - virtual ~NodeData() = default; - - virtual bool sameType(NodeData const &nodeData) const - { - return (this->type().id == nodeData.type().id); - } - - /// Type for inner use - virtual NodeDataType type() const = 0; -}; - -} // namespace QtNodes -Q_DECLARE_METATYPE(QtNodes::NodeDataType) -Q_DECLARE_METATYPE(std::shared_ptr) diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/internal/NodeDelegateModel.hpp b/story-editor-legacy/nodeeditor/include/QtNodes/internal/NodeDelegateModel.hpp deleted file mode 100644 index 6301164..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/internal/NodeDelegateModel.hpp +++ /dev/null @@ -1,133 +0,0 @@ -#pragma once - -#include - -#include - -#include "Definitions.hpp" -#include "Export.hpp" -#include "NodeData.hpp" -#include "NodeStyle.hpp" -#include "Serializable.hpp" - -namespace QtNodes { - -class StyleCollection; - -/** - * The class wraps Node-specific data operations and propagates it to - * the nesting DataFlowGraphModel which is a subclass of - * AbstractGraphModel. - * This class is the same what has been called NodeDataModel before v3. - */ -class NODE_EDITOR_PUBLIC NodeDelegateModel : public QObject, public Serializable -{ - Q_OBJECT - -public: - NodeDelegateModel(); - - virtual ~NodeDelegateModel() = default; - - /// It is possible to hide caption in GUI - virtual bool captionVisible() const { return true; } - - /// Caption is used in GUI - virtual QString caption() const = 0; - - /// It is possible to hide port caption in GUI - virtual bool portCaptionVisible(PortType, PortIndex) const { return false; } - - /// Port caption is used in GUI to label individual ports - virtual QString portCaption(PortType, PortIndex) const { return QString(); } - - /// Name makes this model unique - virtual QString name() const = 0; - -public: - QJsonObject save() const override; - - void load(QJsonObject const &) override; - -public: - virtual unsigned int nPorts(PortType portType) const = 0; - - virtual NodeDataType dataType(PortType portType, PortIndex portIndex) const = 0; - -public: - virtual ConnectionPolicy portConnectionPolicy(PortType, PortIndex) const; - - NodeStyle const &nodeStyle() const; - - void setNodeStyle(NodeStyle const &style); - -public: - virtual void setInData(std::shared_ptr nodeData, PortIndex const portIndex) = 0; - - virtual std::shared_ptr outData(PortIndex const port) = 0; - - /** - * It is recommented to preform a lazy initialization for the - * embedded widget and create it inside this function, not in the - * constructor of the current model. - * - * Our Model Registry is able to shortly instantiate models in order - * to call the non-static `Model::name()`. If the embedded widget is - * allocated in the constructor but not actually embedded into some - * QGraphicsProxyWidget, we'll gonna have a dangling pointer. - */ - virtual QWidget *embeddedWidget() = 0; - - virtual bool resizable() const { return false; } - -public Q_SLOTS: - - virtual void inputConnectionCreated(ConnectionId const &) {} - - virtual void inputConnectionDeleted(ConnectionId const &) {} - - virtual void outputConnectionCreated(ConnectionId const &) {} - - virtual void outputConnectionDeleted(ConnectionId const &) {} - -Q_SIGNALS: - - /// Triggers the updates in the nodes downstream. - void dataUpdated(PortIndex const index); - - /// Triggers the propagation of the empty data downstream. - void dataInvalidated(PortIndex const index); - - void computingStarted(); - - void computingFinished(); - - void embeddedWidgetSizeUpdated(); - - /// Call this function before deleting the data associated with ports. - /** - * The function notifies the Graph Model and makes it remove and recompute the - * affected connection addresses. - */ - void portsAboutToBeDeleted(PortType const portType, PortIndex const first, PortIndex const last); - - /// Call this function when data and port moditications are finished. - void portsDeleted(); - - /// Call this function before inserting the data associated with ports. - /** - * The function notifies the Graph Model and makes it recompute the affected - * connection addresses. - */ - void portsAboutToBeInserted(PortType const portType, - PortIndex const first, - PortIndex const last); - - /// Call this function when data and port moditications are finished. - void portsInserted(); - -private: - NodeStyle _nodeStyle; -}; - -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/internal/NodeDelegateModelRegistry.hpp b/story-editor-legacy/nodeeditor/include/QtNodes/internal/NodeDelegateModelRegistry.hpp deleted file mode 100644 index 4f230a4..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/internal/NodeDelegateModelRegistry.hpp +++ /dev/null @@ -1,171 +0,0 @@ -#pragma once - -#include "Export.hpp" -#include "NodeData.hpp" -#include "NodeDelegateModel.hpp" -#include "QStringStdHash.hpp" - -#include - -#include -#include -#include -#include -#include -#include -#include - -namespace QtNodes { - -/// Class uses map for storing models (name, model) -class NODE_EDITOR_PUBLIC NodeDelegateModelRegistry -{ -public: - using RegistryItemPtr = std::unique_ptr; - using RegistryItemCreator = std::function; - using RegisteredModelCreatorsMap = std::unordered_map; - using RegisteredModelsCategoryMap = std::unordered_map; - using CategoriesSet = std::set; - - //using RegisteredTypeConvertersMap = std::map; - - NodeDelegateModelRegistry() = default; - ~NodeDelegateModelRegistry() = default; - - NodeDelegateModelRegistry(NodeDelegateModelRegistry const &) = delete; - NodeDelegateModelRegistry(NodeDelegateModelRegistry &&) = default; - - NodeDelegateModelRegistry &operator=(NodeDelegateModelRegistry const &) = delete; - - NodeDelegateModelRegistry &operator=(NodeDelegateModelRegistry &&) = default; - -public: - template - void registerModel(RegistryItemCreator creator, QString const &category = "Nodes") - { - QString const name = computeName(HasStaticMethodName{}, creator); - if (!_registeredItemCreators.count(name)) { - _registeredItemCreators[name] = std::move(creator); - _categories.insert(category); - _registeredModelsCategory[name] = category; - } - } - - template - void registerModel(QString const &category = "Nodes") - { - RegistryItemCreator creator = []() { return std::make_unique(); }; - registerModel(std::move(creator), category); - } - -#if 0 - template - void - registerModel(RegistryItemCreator creator, - QString const& category = "Nodes") - { - registerModel(std::move(creator), category); - } - - - template - void - registerModel(ModelCreator&& creator, QString const& category = "Nodes") - { - using ModelType = compute_model_type_t; - registerModel(std::forward(creator), category); - } - - - template - void - registerModel(QString const& category, ModelCreator&& creator) - { - registerModel(std::forward(creator), category); - } - - - void - registerTypeConverter(TypeConverterId const& id, - TypeConverter typeConverter) - { - _registeredTypeConverters[id] = std::move(typeConverter); - } - -#endif - - std::unique_ptr create(QString const &modelName); - - RegisteredModelCreatorsMap const ®isteredModelCreators() const; - - RegisteredModelsCategoryMap const ®isteredModelsCategoryAssociation() const; - - CategoriesSet const &categories() const; - -#if 0 - TypeConverter - getTypeConverter(NodeDataType const& d1, - NodeDataType const& d2) const; -#endif - -private: - RegisteredModelsCategoryMap _registeredModelsCategory; - - CategoriesSet _categories; - - RegisteredModelCreatorsMap _registeredItemCreators; - -#if 0 - RegisteredTypeConvertersMap _registeredTypeConverters; -#endif - -private: - // If the registered ModelType class has the static member method - // `static QString Name();`, use it. Otherwise use the non-static - // method: `virtual QString name() const;` - template - struct HasStaticMethodName : std::false_type - {}; - - template - struct HasStaticMethodName< - T, - typename std::enable_if::value>::type> - : std::true_type - {}; - - template - static QString computeName(std::true_type, RegistryItemCreator const &) - { - return ModelType::Name(); - } - - template - static QString computeName(std::false_type, RegistryItemCreator const &creator) - { - return creator()->name(); - } - - template - struct UnwrapUniquePtr - { - // Assert always fires, but the compiler doesn't know this: - static_assert(!std::is_same::value, - "The ModelCreator must return a std::unique_ptr, where T " - "inherits from NodeDelegateModel"); - }; - - template - struct UnwrapUniquePtr> - { - static_assert(std::is_base_of::value, - "The ModelCreator must return a std::unique_ptr, where T " - "inherits from NodeDelegateModel"); - using type = T; - }; - - template - using compute_model_type_t = typename UnwrapUniquePtr::type; -}; - -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/internal/NodeGraphicsObject.hpp b/story-editor-legacy/nodeeditor/include/QtNodes/internal/NodeGraphicsObject.hpp deleted file mode 100644 index ef042f7..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/internal/NodeGraphicsObject.hpp +++ /dev/null @@ -1,91 +0,0 @@ -#pragma once - -#include -#include - -#include "NodeState.hpp" - -class QGraphicsProxyWidget; - -namespace QtNodes { - -class BasicGraphicsScene; -class AbstractGraphModel; - -class NodeGraphicsObject : public QGraphicsObject -{ - Q_OBJECT -public: - // Needed for qgraphicsitem_cast - enum { Type = UserType + 1 }; - - int type() const override { return Type; } - -public: - NodeGraphicsObject(BasicGraphicsScene &scene, NodeId node); - - ~NodeGraphicsObject() override = default; - -public: - AbstractGraphModel &graphModel() const; - - BasicGraphicsScene *nodeScene() const; - - NodeId nodeId() { return _nodeId; } - - NodeId nodeId() const { return _nodeId; } - - NodeState &nodeState() { return _nodeState; } - - NodeState const &nodeState() const { return _nodeState; } - - QRectF boundingRect() const override; - - void setGeometryChanged(); - - /// Visits all attached connections and corrects - /// their corresponding end points. - void moveConnections() const; - - /// Repaints the node once with reacting ports. - void reactToConnection(ConnectionGraphicsObject const *cgo); - -protected: - void paint(QPainter *painter, - QStyleOptionGraphicsItem const *option, - QWidget *widget = 0) override; - - QVariant itemChange(GraphicsItemChange change, const QVariant &value) override; - - void mousePressEvent(QGraphicsSceneMouseEvent *event) override; - - void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override; - - void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; - - void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override; - - void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override; - - void hoverMoveEvent(QGraphicsSceneHoverEvent *) override; - - void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override; - - void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override; - -private: - void embedQWidget(); - - void setLockedState(); - -private: - NodeId _nodeId; - - AbstractGraphModel &_graphModel; - - NodeState _nodeState; - - // either nullptr or owned by parent QGraphicsItem - QGraphicsProxyWidget *_proxyWidget; -}; -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/internal/NodeState.hpp b/story-editor-legacy/nodeeditor/include/QtNodes/internal/NodeState.hpp deleted file mode 100644 index 1894021..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/internal/NodeState.hpp +++ /dev/null @@ -1,52 +0,0 @@ -#pragma once - -#include -#include - -#include -#include -#include - -#include "Export.hpp" - -#include "Definitions.hpp" -#include "NodeData.hpp" - -namespace QtNodes { - -class ConnectionGraphicsObject; -class NodeGraphicsObject; - -/// Stores bool for hovering connections and resizing flag. -class NODE_EDITOR_PUBLIC NodeState -{ -public: - NodeState(NodeGraphicsObject &ngo); - -public: - bool hovered() const { return _hovered; } - - void setHovered(bool hovered = true) { _hovered = hovered; } - - void setResizing(bool resizing); - - bool resizing() const; - - ConnectionGraphicsObject const *connectionForReaction() const; - - void storeConnectionForReaction(ConnectionGraphicsObject const *cgo); - - void resetConnectionForReaction(); - -private: - NodeGraphicsObject &_ngo; - - bool _hovered; - - bool _resizing; - - // QPointer tracks the QObject inside and is automatically cleared - // when the object is destroyed. - QPointer _connectionForReaction; -}; -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/internal/NodeStyle.hpp b/story-editor-legacy/nodeeditor/include/QtNodes/internal/NodeStyle.hpp deleted file mode 100644 index 5eca749..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/internal/NodeStyle.hpp +++ /dev/null @@ -1,53 +0,0 @@ -#pragma once - -#include - -#include "Export.hpp" -#include "Style.hpp" - -namespace QtNodes { - -class NODE_EDITOR_PUBLIC NodeStyle : public Style -{ -public: - NodeStyle(); - - NodeStyle(QString jsonText); - - NodeStyle(QJsonObject const &json); - - virtual ~NodeStyle() = default; - -public: - static void setNodeStyle(QString jsonText); - -public: - void loadJson(QJsonObject const &json) override; - - QJsonObject toJson() const override; - -public: - QColor NormalBoundaryColor; - QColor SelectedBoundaryColor; - QColor GradientColor0; - QColor GradientColor1; - QColor GradientColor2; - QColor GradientColor3; - QColor ShadowColor; - QColor FontColor; - QColor FontColorFaded; - - QColor ConnectionPointColor; - QColor FilledConnectionPointColor; - - QColor WarningColor; - QColor ErrorColor; - - float PenWidth; - float HoveredPenWidth; - - float ConnectionPointDiameter; - - float Opacity; -}; -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/internal/OperatingSystem.hpp b/story-editor-legacy/nodeeditor/include/QtNodes/internal/OperatingSystem.hpp deleted file mode 100644 index 8264db4..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/internal/OperatingSystem.hpp +++ /dev/null @@ -1,49 +0,0 @@ -#pragma once - -#if defined(__CYGWIN__) || defined(__CYGWIN32__) -#define NODE_EDITOR_PLATFORM "Cygwin" -#define NODE_EDITOR_PLATFORM_CYGWIN -#define NODE_EDITOR_PLATFORM_UNIX -#define NODE_EDITOR_PLATFORM_WINDOWS -#elif defined(_WIN16) || defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) \ - || defined(__TOS_WIN__) || defined(__WINDOWS__) -#define NODE_EDITOR_PLATFORM "Windows" -#define NODE_EDITOR_PLATFORM_WINDOWS -#elif defined(macintosh) || defined(Macintosh) || defined(__TOS_MACOS__) \ - || (defined(__APPLE__) && defined(__MACH__)) -#define NODE_EDITOR_PLATFORM "Mac" -#define NODE_EDITOR_PLATFORM_MAC -#define NODE_EDITOR_PLATFORM_UNIX -#elif defined(linux) || defined(__linux) || defined(__linux__) || defined(__TOS_LINUX__) -#define NODE_EDITOR_PLATFORM "Linux" -#define NODE_EDITOR_PLATFORM_LINUX -#define NODE_EDITOR_PLATFORM_UNIX -#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__bsdi__) \ - || defined(__DragonFly__) -#define NODE_EDITOR_PLATFORM "BSD" -#define NODE_EDITOR_PLATFORM_BSD -#define NODE_EDITOR_PLATFORM_UNIX -#elif defined(sun) || defined(__sun) -#define NODE_EDITOR_PLATFORM "Solaris" -#define NODE_EDITOR_PLATFORM_SOLARIS -#define NODE_EDITOR_PLATFORM_UNIX -#elif defined(_AIX) || defined(__TOS_AIX__) -#define NODE_EDITOR_PLATFORM "AIX" -#define NODE_EDITOR_PLATFORM_AIX -#define NODE_EDITOR_PLATFORM_UNIX -#elif defined(hpux) || defined(_hpux) || defined(__hpux) -#define NODE_EDITOR_PLATFORM "HPUX" -#define NODE_EDITOR_PLATFORM_HPUX -#define NODE_EDITOR_PLATFORM_UNIX -#elif defined(__QNX__) -#define NODE_EDITOR_PLATFORM "QNX" -#define NODE_EDITOR_PLATFORM_QNX -#define NODE_EDITOR_PLATFORM_UNIX -#elif defined(unix) || defined(__unix) || defined(__unix__) -#define NODE_EDITOR_PLATFORM "Unix" -#define NODE_EDITOR_PLATFORM_UNIX -#endif - -#ifndef NODE_EDITOR_PLATFORM -#error "Current platform is not supported." -#endif diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/internal/QStringStdHash.hpp b/story-editor-legacy/nodeeditor/include/QtNodes/internal/QStringStdHash.hpp deleted file mode 100644 index 617d9b5..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/internal/QStringStdHash.hpp +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -#include - -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - -// As of 5.14 there is a specialization std::hash - -#include - -#include -#include - -namespace std { -template<> -struct hash -{ - inline std::size_t operator()(QString const &s) const { return qHash(s); } -}; -} // namespace std - -#endif diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/internal/QUuidStdHash.hpp b/story-editor-legacy/nodeeditor/include/QtNodes/internal/QUuidStdHash.hpp deleted file mode 100644 index 224bc9f..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/internal/QUuidStdHash.hpp +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include - -#include -#include - -namespace std { -template<> -struct hash -{ - inline std::size_t operator()(QUuid const &uid) const { return qHash(uid); } -}; -} // namespace std diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/internal/Serializable.hpp b/story-editor-legacy/nodeeditor/include/QtNodes/internal/Serializable.hpp deleted file mode 100644 index 71137d9..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/internal/Serializable.hpp +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include - -namespace QtNodes { - -class Serializable -{ -public: - virtual ~Serializable() = default; - - virtual QJsonObject save() const { return {}; } - - virtual void load(QJsonObject const & /*p*/) {} -}; -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/internal/Style.hpp b/story-editor-legacy/nodeeditor/include/QtNodes/internal/Style.hpp deleted file mode 100644 index f878083..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/internal/Style.hpp +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include - -namespace QtNodes { - -class Style // : public QObject -{ - //Q_OBJECT - -public: - virtual ~Style() = default; - -public: - virtual void loadJson(QJsonObject const &json) = 0; - - virtual QJsonObject toJson() const = 0; - - /// Loads from utf-8 byte array. - virtual void loadJsonFromByteArray(QByteArray const &byteArray) - { - auto json = QJsonDocument::fromJson(byteArray).object(); - - loadJson(json); - } - - virtual void loadJsonText(QString jsonText) { loadJsonFromByteArray(jsonText.toUtf8()); } - - virtual void loadJsonFile(QString fileName) - { - QFile file(fileName); - - if (!file.open(QIODevice::ReadOnly)) { - qWarning() << "Couldn't open file " << fileName; - - return; - } - - loadJsonFromByteArray(file.readAll()); - } -}; - -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/internal/StyleCollection.hpp b/story-editor-legacy/nodeeditor/include/QtNodes/internal/StyleCollection.hpp deleted file mode 100644 index 92a1a40..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/internal/StyleCollection.hpp +++ /dev/null @@ -1,43 +0,0 @@ -#pragma once - -#include "Export.hpp" - -#include "ConnectionStyle.hpp" -#include "GraphicsViewStyle.hpp" -#include "NodeStyle.hpp" - -namespace QtNodes { - -class NODE_EDITOR_PUBLIC StyleCollection -{ -public: - static NodeStyle const &nodeStyle(); - - static ConnectionStyle const &connectionStyle(); - - static GraphicsViewStyle const &flowViewStyle(); - -public: - static void setNodeStyle(NodeStyle); - - static void setConnectionStyle(ConnectionStyle); - - static void setGraphicsViewStyle(GraphicsViewStyle); - -private: - StyleCollection() = default; - - StyleCollection(StyleCollection const &) = delete; - - StyleCollection &operator=(StyleCollection const &) = delete; - - static StyleCollection &instance(); - -private: - NodeStyle _nodeStyle; - - ConnectionStyle _connectionStyle; - - GraphicsViewStyle _flowViewStyle; -}; -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/internal/UndoCommands.hpp b/story-editor-legacy/nodeeditor/include/QtNodes/internal/UndoCommands.hpp deleted file mode 100644 index 2202617..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/internal/UndoCommands.hpp +++ /dev/null @@ -1,123 +0,0 @@ -#pragma once - -#include "Definitions.hpp" - -#include -#include -#include - -#include - -namespace QtNodes { - -class BasicGraphicsScene; - -class CreateCommand : public QUndoCommand -{ -public: - CreateCommand(BasicGraphicsScene *scene, QString const name, QPointF const &mouseScenePos); - - void undo() override; - void redo() override; - -private: - BasicGraphicsScene *_scene; - NodeId _nodeId; - QJsonObject _sceneJson; -}; - -/** - * Selected scene objects are serialized and then removed from the scene. - * The deleted elements could be restored in `undo`. - */ -class DeleteCommand : public QUndoCommand -{ -public: - DeleteCommand(BasicGraphicsScene *scene); - - void undo() override; - void redo() override; - -private: - BasicGraphicsScene *_scene; - QJsonObject _sceneJson; -}; - -class CopyCommand : public QUndoCommand -{ -public: - CopyCommand(BasicGraphicsScene *scene); -}; - -class PasteCommand : public QUndoCommand -{ -public: - PasteCommand(BasicGraphicsScene *scene, QPointF const &mouseScenePos); - - void undo() override; - void redo() override; - -private: - QJsonObject takeSceneJsonFromClipboard(); - QJsonObject makeNewNodeIdsInScene(QJsonObject const &sceneJson); - -private: - BasicGraphicsScene *_scene; - QPointF const &_mouseScenePos; - QJsonObject _newSceneJson; -}; - -class DisconnectCommand : public QUndoCommand -{ -public: - DisconnectCommand(BasicGraphicsScene *scene, ConnectionId const); - - void undo() override; - void redo() override; - -private: - BasicGraphicsScene *_scene; - - ConnectionId _connId; -}; - -class ConnectCommand : public QUndoCommand -{ -public: - ConnectCommand(BasicGraphicsScene *scene, ConnectionId const); - - void undo() override; - void redo() override; - -private: - BasicGraphicsScene *_scene; - - ConnectionId _connId; -}; - -class MoveNodeCommand : public QUndoCommand -{ -public: - MoveNodeCommand(BasicGraphicsScene *scene, QPointF const &diff); - - void undo() override; - void redo() override; - - /** - * A command ID is used in command compression. It must be an integer unique to - * this command's class, or -1 if the command doesn't support compression. - */ - int id() const override; - - /** - * Several sequential movements could be merged into one command. - */ - bool mergeWith(QUndoCommand const *c) override; - -private: - BasicGraphicsScene *_scene; - std::unordered_set _selectedNodes; - QPointF _diff; -}; - -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/include/QtNodes/internal/locateNode.hpp b/story-editor-legacy/nodeeditor/include/QtNodes/internal/locateNode.hpp deleted file mode 100644 index cf41f83..0000000 --- a/story-editor-legacy/nodeeditor/include/QtNodes/internal/locateNode.hpp +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include -#include - -class QGraphicsScene; - -namespace QtNodes { - -class NodeGraphicsObject; - -NodeGraphicsObject *locateNodeAt(QPointF scenePoint, - QGraphicsScene &scene, - QTransform const &viewTransform); - -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/resources/DefaultStyle.json b/story-editor-legacy/nodeeditor/resources/DefaultStyle.json deleted file mode 100644 index da8dfe8..0000000 --- a/story-editor-legacy/nodeeditor/resources/DefaultStyle.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "GraphicsViewStyle": { - "BackgroundColor": [53, 53, 53], - "FineGridColor": [60, 60, 60], - "CoarseGridColor": [25, 25, 25] - }, - "NodeStyle": { - "NormalBoundaryColor": [255, 255, 255], - "SelectedBoundaryColor": [255, 165, 0], - "GradientColor0": "gray", - "GradientColor1": [80, 80, 80], - "GradientColor2": [64, 64, 64], - "GradientColor3": [58, 58, 58], - "ShadowColor": [20, 20, 20], - "FontColor" : "white", - "FontColorFaded" : "gray", - "ConnectionPointColor": [169, 169, 169], - "FilledConnectionPointColor": "cyan", - "ErrorColor": "red", - "WarningColor": [128, 128, 0], - - "PenWidth": 1.0, - "HoveredPenWidth": 1.5, - - "ConnectionPointDiameter": 8.0, - - "Opacity": 0.8 - }, - "ConnectionStyle": { - "ConstructionColor": "gray", - "NormalColor": "darkcyan", - "SelectedColor": [100, 100, 100], - "SelectedHaloColor": "orange", - "HoveredColor": "lightcyan", - - "LineWidth": 3.0, - "ConstructionLineWidth": 2.0, - "PointDiameter": 10.0, - - "UseDataDefinedColors": false - } -} diff --git a/story-editor-legacy/nodeeditor/resources/resources.qrc b/story-editor-legacy/nodeeditor/resources/resources.qrc deleted file mode 100644 index a0b5ef8..0000000 --- a/story-editor-legacy/nodeeditor/resources/resources.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - DefaultStyle.json - - diff --git a/story-editor-legacy/nodeeditor/src/AbstractGraphModel.cpp b/story-editor-legacy/nodeeditor/src/AbstractGraphModel.cpp deleted file mode 100644 index 10709b7..0000000 --- a/story-editor-legacy/nodeeditor/src/AbstractGraphModel.cpp +++ /dev/null @@ -1,105 +0,0 @@ -#include "AbstractGraphModel.hpp" - -#include - -namespace QtNodes { - -void AbstractGraphModel::portsAboutToBeDeleted(NodeId const nodeId, - PortType const portType, - PortIndex const first, - PortIndex const last) -{ - _shiftedByDynamicPortsConnections.clear(); - - auto portCountRole = portType == PortType::In ? NodeRole::InPortCount : NodeRole::OutPortCount; - - unsigned int portCount = nodeData(nodeId, portCountRole).toUInt(); - - if (first > portCount - 1) - return; - - if (last < first) - return; - - auto clampedLast = std::min(last, portCount - 1); - - for (PortIndex portIndex = first; portIndex <= clampedLast; ++portIndex) { - std::unordered_set conns = connections(nodeId, portType, portIndex); - - for (auto connectionId : conns) { - deleteConnection(connectionId); - } - } - - std::size_t const nRemovedPorts = clampedLast - first + 1; - - for (PortIndex portIndex = clampedLast + 1; portIndex < portCount; ++portIndex) { - std::unordered_set conns = connections(nodeId, portType, portIndex); - - for (auto connectionId : conns) { - // Erases the information about the port on one side; - auto c = makeIncompleteConnectionId(connectionId, portType); - - c = makeCompleteConnectionId(c, nodeId, portIndex - nRemovedPorts); - - _shiftedByDynamicPortsConnections.push_back(c); - - deleteConnection(connectionId); - } - } -} - -void AbstractGraphModel::portsDeleted() -{ - for (auto const connectionId : _shiftedByDynamicPortsConnections) { - addConnection(connectionId); - } - - _shiftedByDynamicPortsConnections.clear(); -} - -void AbstractGraphModel::portsAboutToBeInserted(NodeId const nodeId, - PortType const portType, - PortIndex const first, - PortIndex const last) -{ - _shiftedByDynamicPortsConnections.clear(); - - auto portCountRole = portType == PortType::In ? NodeRole::InPortCount : NodeRole::OutPortCount; - - unsigned int portCount = nodeData(nodeId, portCountRole).toUInt(); - - if (first > portCount) - return; - - if (last < first) - return; - - std::size_t const nNewPorts = last - first + 1; - - for (PortIndex portIndex = first; portIndex < portCount; ++portIndex) { - std::unordered_set conns = connections(nodeId, portType, portIndex); - - for (auto connectionId : conns) { - // Erases the information about the port on one side; - auto c = makeIncompleteConnectionId(connectionId, portType); - - c = makeCompleteConnectionId(c, nodeId, portIndex + nNewPorts); - - _shiftedByDynamicPortsConnections.push_back(c); - - deleteConnection(connectionId); - } - } -} - -void AbstractGraphModel::portsInserted() -{ - for (auto const connectionId : _shiftedByDynamicPortsConnections) { - addConnection(connectionId); - } - - _shiftedByDynamicPortsConnections.clear(); -} - -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/src/AbstractNodeGeometry.cpp b/story-editor-legacy/nodeeditor/src/AbstractNodeGeometry.cpp deleted file mode 100644 index 08c8181..0000000 --- a/story-editor-legacy/nodeeditor/src/AbstractNodeGeometry.cpp +++ /dev/null @@ -1,81 +0,0 @@ -#include "AbstractNodeGeometry.hpp" - -#include "AbstractGraphModel.hpp" -#include "StyleCollection.hpp" - -#include - -#include - -namespace QtNodes { - -AbstractNodeGeometry::AbstractNodeGeometry(AbstractGraphModel &graphModel, double marginsRatio) - : _graphModel(graphModel) - , _marginsRatio(marginsRatio) -{ - // -} - -QRectF AbstractNodeGeometry::boundingRect(NodeId const nodeId) const -{ - QSize s = size(nodeId); - - int widthMargin = s.width() * _marginsRatio; - int heightMargin = s.height() * _marginsRatio; - - QMargins margins(widthMargin, heightMargin, widthMargin, heightMargin); - - QRectF r(QPointF(0, 0), s); - - return r.marginsAdded(margins); -} - -void AbstractNodeGeometry::setMarginsRatio(double marginsRatio) -{ - _marginsRatio = marginsRatio; -} - -QPointF AbstractNodeGeometry::portScenePosition(NodeId const nodeId, - PortType const portType, - PortIndex const index, - QTransform const &t) const -{ - QPointF result = portPosition(nodeId, portType, index); - - return t.map(result); -} - -PortIndex AbstractNodeGeometry::checkPortHit(NodeId const nodeId, - PortType const portType, - QPointF const nodePoint) const -{ - auto const &nodeStyle = StyleCollection::nodeStyle(); - - PortIndex result = InvalidPortIndex; - - if (portType == PortType::None) - return result; - - double const tolerance = 2.0 * nodeStyle.ConnectionPointDiameter; - - size_t const n = _graphModel.nodeData(nodeId, - (portType == PortType::Out) - ? NodeRole::OutPortCount - : NodeRole::InPortCount); - - for (unsigned int portIndex = 0; portIndex < n; ++portIndex) { - auto pp = portPosition(nodeId, portType, portIndex); - - QPointF p = pp - nodePoint; - auto distance = std::sqrt(QPointF::dotProduct(p, p)); - - if (distance < tolerance) { - result = portIndex; - break; - } - } - - return result; -} - -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/src/BasicGraphicsScene.cpp b/story-editor-legacy/nodeeditor/src/BasicGraphicsScene.cpp deleted file mode 100644 index 1c36716..0000000 --- a/story-editor-legacy/nodeeditor/src/BasicGraphicsScene.cpp +++ /dev/null @@ -1,308 +0,0 @@ -#include "BasicGraphicsScene.hpp" - -#include "AbstractNodeGeometry.hpp" -#include "ConnectionGraphicsObject.hpp" -#include "ConnectionIdUtils.hpp" -#include "DefaultHorizontalNodeGeometry.hpp" -#include "DefaultNodePainter.hpp" -#include "DefaultVerticalNodeGeometry.hpp" -#include "GraphicsView.hpp" -#include "NodeGraphicsObject.hpp" - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -namespace QtNodes { - -BasicGraphicsScene::BasicGraphicsScene(AbstractGraphModel &graphModel, QObject *parent) - : QGraphicsScene(parent) - , _graphModel(graphModel) - , _nodeGeometry(std::make_unique(_graphModel)) - , _nodePainter(std::make_unique()) - , _nodeDrag(false) - , _undoStack(new QUndoStack(this)) - , _orientation(Qt::Horizontal) -{ - setItemIndexMethod(QGraphicsScene::NoIndex); - - connect(&_graphModel, - &AbstractGraphModel::connectionCreated, - this, - &BasicGraphicsScene::onConnectionCreated); - - connect(&_graphModel, - &AbstractGraphModel::connectionDeleted, - this, - &BasicGraphicsScene::onConnectionDeleted); - - connect(&_graphModel, - &AbstractGraphModel::nodeCreated, - this, - &BasicGraphicsScene::onNodeCreated); - - connect(&_graphModel, - &AbstractGraphModel::nodeDeleted, - this, - &BasicGraphicsScene::onNodeDeleted); - - connect(&_graphModel, - &AbstractGraphModel::nodePositionUpdated, - this, - &BasicGraphicsScene::onNodePositionUpdated); - - connect(&_graphModel, - &AbstractGraphModel::nodeUpdated, - this, - &BasicGraphicsScene::onNodeUpdated); - - connect(this, &BasicGraphicsScene::nodeClicked, this, &BasicGraphicsScene::onNodeClicked); - - connect(&_graphModel, &AbstractGraphModel::modelReset, this, &BasicGraphicsScene::onModelReset); - - traverseGraphAndPopulateGraphicsObjects(); -} - -BasicGraphicsScene::~BasicGraphicsScene() = default; - -AbstractGraphModel const &BasicGraphicsScene::graphModel() const -{ - return _graphModel; -} - -AbstractGraphModel &BasicGraphicsScene::graphModel() -{ - return _graphModel; -} - -AbstractNodeGeometry &BasicGraphicsScene::nodeGeometry() -{ - return *_nodeGeometry; -} - -AbstractNodePainter &BasicGraphicsScene::nodePainter() -{ - return *_nodePainter; -} - -void BasicGraphicsScene::setNodePainter(std::unique_ptr newPainter) -{ - _nodePainter = std::move(newPainter); -} - -QUndoStack &BasicGraphicsScene::undoStack() -{ - return *_undoStack; -} - -void BasicGraphicsScene::setDropShadowEffect(bool enable) -{ - _dropShadowEffect = enable; -} - -bool BasicGraphicsScene::isDropShadowEffectEnabled() const -{ - return _dropShadowEffect; -} - -std::unique_ptr const &BasicGraphicsScene::makeDraftConnection( - ConnectionId const incompleteConnectionId) -{ - _draftConnection = std::make_unique(*this, incompleteConnectionId); - - _draftConnection->grabMouse(); - - return _draftConnection; -} - -void BasicGraphicsScene::resetDraftConnection() -{ - _draftConnection.reset(); -} - -void BasicGraphicsScene::clearScene() -{ - auto const &allNodeIds = graphModel().allNodeIds(); - - for (auto nodeId : allNodeIds) { - graphModel().deleteNode(nodeId); - } -} - -NodeGraphicsObject *BasicGraphicsScene::nodeGraphicsObject(NodeId nodeId) -{ - NodeGraphicsObject *ngo = nullptr; - auto it = _nodeGraphicsObjects.find(nodeId); - if (it != _nodeGraphicsObjects.end()) { - ngo = it->second.get(); - } - - return ngo; -} - -ConnectionGraphicsObject *BasicGraphicsScene::connectionGraphicsObject(ConnectionId connectionId) -{ - ConnectionGraphicsObject *cgo = nullptr; - auto it = _connectionGraphicsObjects.find(connectionId); - if (it != _connectionGraphicsObjects.end()) { - cgo = it->second.get(); - } - - return cgo; -} - -void BasicGraphicsScene::setOrientation(Qt::Orientation const orientation) -{ - if (_orientation != orientation) { - _orientation = orientation; - - switch (_orientation) { - case Qt::Horizontal: - _nodeGeometry = std::make_unique(_graphModel); - break; - - case Qt::Vertical: - _nodeGeometry = std::make_unique(_graphModel); - break; - } - - onModelReset(); - } -} - -QMenu *BasicGraphicsScene::createSceneMenu(QPointF const scenePos) -{ - Q_UNUSED(scenePos); - return nullptr; -} - -void BasicGraphicsScene::traverseGraphAndPopulateGraphicsObjects() -{ - auto allNodeIds = _graphModel.allNodeIds(); - - // First create all the nodes. - for (NodeId const nodeId : allNodeIds) { - _nodeGraphicsObjects[nodeId] = std::make_unique(*this, nodeId); - } - - // Then for each node check output connections and insert them. - for (NodeId const nodeId : allNodeIds) { - unsigned int nOutPorts = _graphModel.nodeData(nodeId, NodeRole::OutPortCount); - - for (PortIndex index = 0; index < nOutPorts; ++index) { - auto const &outConnectionIds = _graphModel.connections(nodeId, PortType::Out, index); - - for (auto cid : outConnectionIds) { - _connectionGraphicsObjects[cid] = std::make_unique(*this, - cid); - } - } - } -} - -void BasicGraphicsScene::updateAttachedNodes(ConnectionId const connectionId, - PortType const portType) -{ - auto node = nodeGraphicsObject(getNodeId(portType, connectionId)); - - if (node) { - node->update(); - } -} - -void BasicGraphicsScene::onConnectionDeleted(ConnectionId const connectionId) -{ - auto it = _connectionGraphicsObjects.find(connectionId); - if (it != _connectionGraphicsObjects.end()) { - _connectionGraphicsObjects.erase(it); - } - - // TODO: do we need it? - if (_draftConnection && _draftConnection->connectionId() == connectionId) { - _draftConnection.reset(); - } - - updateAttachedNodes(connectionId, PortType::Out); - updateAttachedNodes(connectionId, PortType::In); -} - -void BasicGraphicsScene::onConnectionCreated(ConnectionId const connectionId) -{ - _connectionGraphicsObjects[connectionId] - = std::make_unique(*this, connectionId); - - updateAttachedNodes(connectionId, PortType::Out); - updateAttachedNodes(connectionId, PortType::In); -} - -void BasicGraphicsScene::onNodeDeleted(NodeId const nodeId) -{ - auto it = _nodeGraphicsObjects.find(nodeId); - if (it != _nodeGraphicsObjects.end()) { - _nodeGraphicsObjects.erase(it); - } -} - -void BasicGraphicsScene::onNodeCreated(NodeId const nodeId) -{ - _nodeGraphicsObjects[nodeId] = std::make_unique(*this, nodeId); -} - -void BasicGraphicsScene::onNodePositionUpdated(NodeId const nodeId) -{ - auto node = nodeGraphicsObject(nodeId); - if (node) { - node->setPos(_graphModel.nodeData(nodeId, NodeRole::Position).value()); - node->update(); - _nodeDrag = true; - } -} - -void BasicGraphicsScene::onNodeUpdated(NodeId const nodeId) -{ - auto node = nodeGraphicsObject(nodeId); - - if (node) { - node->setGeometryChanged(); - - _nodeGeometry->recomputeSize(nodeId); - - node->update(); - node->moveConnections(); - } -} - -void BasicGraphicsScene::onNodeClicked(NodeId const nodeId) -{ - if (_nodeDrag) - Q_EMIT nodeMoved(nodeId, _graphModel.nodeData(nodeId, NodeRole::Position).value()); - _nodeDrag = false; -} - -void BasicGraphicsScene::onModelReset() -{ - _connectionGraphicsObjects.clear(); - _nodeGraphicsObjects.clear(); - - clear(); - - traverseGraphAndPopulateGraphicsObjects(); -} - -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/src/ConnectionGraphicsObject.cpp b/story-editor-legacy/nodeeditor/src/ConnectionGraphicsObject.cpp deleted file mode 100644 index 6a871c0..0000000 --- a/story-editor-legacy/nodeeditor/src/ConnectionGraphicsObject.cpp +++ /dev/null @@ -1,380 +0,0 @@ -#include "ConnectionGraphicsObject.hpp" - -#include "AbstractGraphModel.hpp" -#include "AbstractNodeGeometry.hpp" -#include "BasicGraphicsScene.hpp" -#include "ConnectionIdUtils.hpp" -#include "ConnectionPainter.hpp" -#include "ConnectionState.hpp" -#include "ConnectionStyle.hpp" -#include "NodeConnectionInteraction.hpp" -#include "NodeGraphicsObject.hpp" -#include "StyleCollection.hpp" -#include "locateNode.hpp" - -#include -#include -#include -#include -#include - -#include - -#include - -namespace QtNodes { - -ConnectionGraphicsObject::ConnectionGraphicsObject(BasicGraphicsScene &scene, - ConnectionId const connectionId) - : _connectionId(connectionId) - , _graphModel(scene.graphModel()) - , _connectionState(*this) - , _out{0, 0} - , _in{0, 0} -{ - scene.addItem(this); - - setFlag(QGraphicsItem::ItemIsMovable, true); - setFlag(QGraphicsItem::ItemIsFocusable, true); - setFlag(QGraphicsItem::ItemIsSelectable, true); - - setAcceptHoverEvents(true); - - //addGraphicsEffect(); - - setZValue(-1.0); - - initializePosition(); -} - -void ConnectionGraphicsObject::initializePosition() -{ - // This function is only called when the ConnectionGraphicsObject - // is newly created. At this moment both end coordinates are (0, 0) - // in Connection G.O. coordinates. The position of the whole - // Connection G. O. in scene coordinate system is also (0, 0). - // By moving the whole object to the Node Port position - // we position both connection ends correctly. - - if (_connectionState.requiredPort() != PortType::None) { - PortType attachedPort = oppositePort(_connectionState.requiredPort()); - - PortIndex portIndex = getPortIndex(attachedPort, _connectionId); - NodeId nodeId = getNodeId(attachedPort, _connectionId); - - NodeGraphicsObject *ngo = nodeScene()->nodeGraphicsObject(nodeId); - - if (ngo) { - QTransform nodeSceneTransform = ngo->sceneTransform(); - - AbstractNodeGeometry &geometry = nodeScene()->nodeGeometry(); - - QPointF pos = geometry.portScenePosition(nodeId, - attachedPort, - portIndex, - nodeSceneTransform); - - this->setPos(pos); - } - } - - move(); -} - -AbstractGraphModel &ConnectionGraphicsObject::graphModel() const -{ - return _graphModel; -} - -BasicGraphicsScene *ConnectionGraphicsObject::nodeScene() const -{ - return dynamic_cast(scene()); -} - -ConnectionId const &ConnectionGraphicsObject::connectionId() const -{ - return _connectionId; -} - -QRectF ConnectionGraphicsObject::boundingRect() const -{ - auto points = pointsC1C2(); - - // `normalized()` fixes inverted rects. - QRectF basicRect = QRectF(_out, _in).normalized(); - - QRectF c1c2Rect = QRectF(points.first, points.second).normalized(); - - QRectF commonRect = basicRect.united(c1c2Rect); - - auto const &connectionStyle = StyleCollection::connectionStyle(); - float const diam = connectionStyle.pointDiameter(); - QPointF const cornerOffset(diam, diam); - - // Expand rect by port circle diameter - commonRect.setTopLeft(commonRect.topLeft() - cornerOffset); - commonRect.setBottomRight(commonRect.bottomRight() + 2 * cornerOffset); - - return commonRect; -} - -QPainterPath ConnectionGraphicsObject::shape() const -{ -#ifdef DEBUG_DRAWING - - //QPainterPath path; - - //path.addRect(boundingRect()); - //return path; - -#else - return ConnectionPainter::getPainterStroke(*this); -#endif -} - -QPointF const &ConnectionGraphicsObject::endPoint(PortType portType) const -{ - Q_ASSERT(portType != PortType::None); - - return (portType == PortType::Out ? _out : _in); -} - -void ConnectionGraphicsObject::setEndPoint(PortType portType, QPointF const &point) -{ - if (portType == PortType::In) - _in = point; - else - _out = point; -} - -void ConnectionGraphicsObject::move() -{ - auto moveEnd = [this](ConnectionId cId, PortType portType) { - NodeId nodeId = getNodeId(portType, cId); - - if (nodeId == InvalidNodeId) - return; - - NodeGraphicsObject *ngo = nodeScene()->nodeGraphicsObject(nodeId); - - if (ngo) { - AbstractNodeGeometry &geometry = nodeScene()->nodeGeometry(); - - QPointF scenePos = geometry.portScenePosition(nodeId, - portType, - getPortIndex(portType, cId), - ngo->sceneTransform()); - - QPointF connectionPos = sceneTransform().inverted().map(scenePos); - - setEndPoint(portType, connectionPos); - } - }; - - moveEnd(_connectionId, PortType::Out); - moveEnd(_connectionId, PortType::In); - - prepareGeometryChange(); - - update(); -} - -ConnectionState const &ConnectionGraphicsObject::connectionState() const -{ - return _connectionState; -} - -ConnectionState &ConnectionGraphicsObject::connectionState() -{ - return _connectionState; -} - -void ConnectionGraphicsObject::paint(QPainter *painter, - QStyleOptionGraphicsItem const *option, - QWidget *) -{ - if (!scene()) - return; - - painter->setClipRect(option->exposedRect); - - ConnectionPainter::paint(painter, *this); -} - -void ConnectionGraphicsObject::mousePressEvent(QGraphicsSceneMouseEvent *event) -{ - QGraphicsItem::mousePressEvent(event); -} - -void ConnectionGraphicsObject::mouseMoveEvent(QGraphicsSceneMouseEvent *event) -{ - prepareGeometryChange(); - - auto view = static_cast(event->widget()); - auto ngo = locateNodeAt(event->scenePos(), *nodeScene(), view->transform()); - if (ngo) { - ngo->reactToConnection(this); - - _connectionState.setLastHoveredNode(ngo->nodeId()); - } else { - _connectionState.resetLastHoveredNode(); - } - - //------------------- - - auto requiredPort = _connectionState.requiredPort(); - - if (requiredPort != PortType::None) { - setEndPoint(requiredPort, event->pos()); - } - - //------------------- - - update(); - - event->accept(); -} - -void ConnectionGraphicsObject::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - QGraphicsItem::mouseReleaseEvent(event); - - ungrabMouse(); - event->accept(); - - auto view = static_cast(event->widget()); - - Q_ASSERT(view); - - auto ngo = locateNodeAt(event->scenePos(), *nodeScene(), view->transform()); - - bool wasConnected = false; - - if (ngo) { - NodeConnectionInteraction interaction(*ngo, *this, *nodeScene()); - - wasConnected = interaction.tryConnect(); - } - - // If connection attempt was unsuccessful - if (!wasConnected) { - // Resulting unique_ptr is not used and automatically deleted. - nodeScene()->resetDraftConnection(); - } -} - -void ConnectionGraphicsObject::hoverEnterEvent(QGraphicsSceneHoverEvent *event) -{ - _connectionState.setHovered(true); - - update(); - - // Signal - nodeScene()->connectionHovered(connectionId(), event->screenPos()); - - event->accept(); -} - -void ConnectionGraphicsObject::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) -{ - _connectionState.setHovered(false); - - update(); - - // Signal - nodeScene()->connectionHoverLeft(connectionId()); - - event->accept(); -} - -std::pair ConnectionGraphicsObject::pointsC1C2() const -{ - switch (nodeScene()->orientation()) { - case Qt::Horizontal: - return pointsC1C2Horizontal(); - break; - - case Qt::Vertical: - return pointsC1C2Vertical(); - break; - } - - throw std::logic_error("Unreachable code after switch statement"); -} - -void ConnectionGraphicsObject::addGraphicsEffect() -{ - auto effect = new QGraphicsBlurEffect; - - effect->setBlurRadius(5); - setGraphicsEffect(effect); - - //auto effect = new QGraphicsDropShadowEffect; - //auto effect = new ConnectionBlurEffect(this); - //effect->setOffset(4, 4); - //effect->setColor(QColor(Qt::gray).darker(800)); -} - -std::pair ConnectionGraphicsObject::pointsC1C2Horizontal() const -{ - double const defaultOffset = 200; - - double xDistance = _in.x() - _out.x(); - - double horizontalOffset = qMin(defaultOffset, std::abs(xDistance)); - - double verticalOffset = 0; - - double ratioX = 0.5; - - if (xDistance <= 0) { - double yDistance = _in.y() - _out.y() + 20; - - double vector = yDistance < 0 ? -1.0 : 1.0; - - verticalOffset = qMin(defaultOffset, std::abs(yDistance)) * vector; - - ratioX = 1.0; - } - - horizontalOffset *= ratioX; - - QPointF c1(_out.x() + horizontalOffset, _out.y() + verticalOffset); - - QPointF c2(_in.x() - horizontalOffset, _in.y() - verticalOffset); - - return std::make_pair(c1, c2); -} - -std::pair ConnectionGraphicsObject::pointsC1C2Vertical() const -{ - double const defaultOffset = 200; - - double yDistance = _in.y() - _out.y(); - - double verticalOffset = qMin(defaultOffset, std::abs(yDistance)); - - double horizontalOffset = 0; - - double ratioY = 0.5; - - if (yDistance <= 0) { - double xDistance = _in.x() - _out.x() + 20; - - double vector = xDistance < 0 ? -1.0 : 1.0; - - horizontalOffset = qMin(defaultOffset, std::abs(xDistance)) * vector; - - ratioY = 1.0; - } - - verticalOffset *= ratioY; - - QPointF c1(_out.x() + horizontalOffset, _out.y() + verticalOffset); - - QPointF c2(_in.x() - horizontalOffset, _in.y() - verticalOffset); - - return std::make_pair(c1, c2); -} - -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/src/ConnectionPainter.cpp b/story-editor-legacy/nodeeditor/src/ConnectionPainter.cpp deleted file mode 100644 index 97002ef..0000000 --- a/story-editor-legacy/nodeeditor/src/ConnectionPainter.cpp +++ /dev/null @@ -1,254 +0,0 @@ -#include "ConnectionPainter.hpp" - -#include - -#include "AbstractGraphModel.hpp" -#include "ConnectionGraphicsObject.hpp" -#include "ConnectionState.hpp" -#include "Definitions.hpp" -#include "NodeData.hpp" -#include "StyleCollection.hpp" - -namespace QtNodes { - -static QPainterPath cubicPath(ConnectionGraphicsObject const &connection) -{ - QPointF const &in = connection.endPoint(PortType::In); - QPointF const &out = connection.endPoint(PortType::Out); - - auto const c1c2 = connection.pointsC1C2(); - - // cubic spline - QPainterPath cubic(out); - - cubic.cubicTo(c1c2.first, c1c2.second, in); - - return cubic; -} - -QPainterPath ConnectionPainter::getPainterStroke(ConnectionGraphicsObject const &connection) -{ - auto cubic = cubicPath(connection); - - QPointF const &out = connection.endPoint(PortType::Out); - QPainterPath result(out); - - unsigned segments = 20; - - for (auto i = 0ul; i < segments; ++i) { - double ratio = double(i + 1) / segments; - result.lineTo(cubic.pointAtPercent(ratio)); - } - - QPainterPathStroker stroker; - stroker.setWidth(10.0); - - return stroker.createStroke(result); -} - -#ifdef NODE_DEBUG_DRAWING -static void debugDrawing(QPainter *painter, ConnectionGraphicsObject const &cgo) -{ - Q_UNUSED(painter); - - { - QPointF const &in = cgo.endPoint(PortType::In); - QPointF const &out = cgo.endPoint(PortType::Out); - - auto const points = cgo.pointsC1C2(); - - painter->setPen(Qt::red); - painter->setBrush(Qt::red); - - painter->drawLine(QLineF(out, points.first)); - painter->drawLine(QLineF(points.first, points.second)); - painter->drawLine(QLineF(points.second, in)); - painter->drawEllipse(points.first, 3, 3); - painter->drawEllipse(points.second, 3, 3); - - painter->setBrush(Qt::NoBrush); - painter->drawPath(cubicPath(cgo)); - } - - { - painter->setPen(Qt::yellow); - painter->drawRect(cgo.boundingRect()); - } -} - -#endif - -static void drawSketchLine(QPainter *painter, ConnectionGraphicsObject const &cgo) -{ - ConnectionState const &state = cgo.connectionState(); - - if (state.requiresPort()) { - auto const &connectionStyle = QtNodes::StyleCollection::connectionStyle(); - - QPen pen; - pen.setWidth(connectionStyle.constructionLineWidth()); - pen.setColor(connectionStyle.constructionColor()); - pen.setStyle(Qt::DashLine); - - painter->setPen(pen); - painter->setBrush(Qt::NoBrush); - - auto cubic = cubicPath(cgo); - - // cubic spline - painter->drawPath(cubic); - } -} - -static void drawHoveredOrSelected(QPainter *painter, ConnectionGraphicsObject const &cgo) -{ - bool const hovered = cgo.connectionState().hovered(); - bool const selected = cgo.isSelected(); - - // drawn as a fat background - if (hovered || selected) { - auto const &connectionStyle = QtNodes::StyleCollection::connectionStyle(); - - double const lineWidth = connectionStyle.lineWidth(); - - QPen pen; - pen.setWidth(2 * lineWidth); - pen.setColor(selected ? connectionStyle.selectedHaloColor() - : connectionStyle.hoveredColor()); - - painter->setPen(pen); - painter->setBrush(Qt::NoBrush); - - // cubic spline - auto const cubic = cubicPath(cgo); - painter->drawPath(cubic); - } -} - -static void drawNormalLine(QPainter *painter, ConnectionGraphicsObject const &cgo) -{ - ConnectionState const &state = cgo.connectionState(); - - if (state.requiresPort()) - return; - - // colors - - auto const &connectionStyle = QtNodes::StyleCollection::connectionStyle(); - - QColor normalColorOut = connectionStyle.normalColor(); - QColor normalColorIn = connectionStyle.normalColor(); - QColor selectedColor = connectionStyle.selectedColor(); - - bool useGradientColor = false; - - AbstractGraphModel const &graphModel = cgo.graphModel(); - - if (connectionStyle.useDataDefinedColors()) { - using QtNodes::PortType; - - auto const cId = cgo.connectionId(); - - auto dataTypeOut = graphModel - .portData(cId.outNodeId, - PortType::Out, - cId.outPortIndex, - PortRole::DataType) - .value(); - - auto dataTypeIn - = graphModel.portData(cId.inNodeId, PortType::In, cId.inPortIndex, PortRole::DataType) - .value(); - - useGradientColor = (dataTypeOut.id != dataTypeIn.id); - - normalColorOut = connectionStyle.normalColor(dataTypeOut.id); - normalColorIn = connectionStyle.normalColor(dataTypeIn.id); - selectedColor = normalColorOut.darker(200); - } - - // geometry - - double const lineWidth = connectionStyle.lineWidth(); - - // draw normal line - QPen p; - - p.setWidth(lineWidth); - - bool const selected = cgo.isSelected(); - - auto cubic = cubicPath(cgo); - if (useGradientColor) { - painter->setBrush(Qt::NoBrush); - - QColor cOut = normalColorOut; - if (selected) - cOut = cOut.darker(200); - p.setColor(cOut); - painter->setPen(p); - - unsigned int const segments = 60; - - for (unsigned int i = 0ul; i < segments; ++i) { - double ratioPrev = double(i) / segments; - double ratio = double(i + 1) / segments; - - if (i == segments / 2) { - QColor cIn = normalColorIn; - if (selected) - cIn = cIn.darker(200); - - p.setColor(cIn); - painter->setPen(p); - } - painter->drawLine(cubic.pointAtPercent(ratioPrev), cubic.pointAtPercent(ratio)); - } - - { - QIcon icon(":convert.png"); - - QPixmap pixmap = icon.pixmap(QSize(22, 22)); - painter->drawPixmap(cubic.pointAtPercent(0.50) - - QPoint(pixmap.width() / 2, pixmap.height() / 2), - pixmap); - } - } else { - p.setColor(normalColorOut); - - if (selected) { - p.setColor(selectedColor); - } - - painter->setPen(p); - painter->setBrush(Qt::NoBrush); - - painter->drawPath(cubic); - } -} - -void ConnectionPainter::paint(QPainter *painter, ConnectionGraphicsObject const &cgo) -{ - drawHoveredOrSelected(painter, cgo); - - drawSketchLine(painter, cgo); - - drawNormalLine(painter, cgo); - -#ifdef NODE_DEBUG_DRAWING - debugDrawing(painter, cgo); -#endif - - // draw end points - auto const &connectionStyle = QtNodes::StyleCollection::connectionStyle(); - - double const pointDiameter = connectionStyle.pointDiameter(); - - painter->setPen(connectionStyle.constructionColor()); - painter->setBrush(connectionStyle.constructionColor()); - double const pointRadius = pointDiameter / 2.0; - painter->drawEllipse(cgo.out(), pointRadius, pointRadius); - painter->drawEllipse(cgo.in(), pointRadius, pointRadius); -} - -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/src/ConnectionState.cpp b/story-editor-legacy/nodeeditor/src/ConnectionState.cpp deleted file mode 100644 index 52ec9b5..0000000 --- a/story-editor-legacy/nodeeditor/src/ConnectionState.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include "ConnectionState.hpp" - -#include -#include - -#include "BasicGraphicsScene.hpp" -#include "ConnectionGraphicsObject.hpp" -#include "NodeGraphicsObject.hpp" - -namespace QtNodes { - -ConnectionState::~ConnectionState() -{ - //resetLastHoveredNode(); -} - -PortType ConnectionState::requiredPort() const -{ - PortType t = PortType::None; - - if (_cgo.connectionId().outNodeId == InvalidNodeId) { - t = PortType::Out; - } else if (_cgo.connectionId().inNodeId == InvalidNodeId) { - t = PortType::In; - } - - return t; -} - -bool ConnectionState::requiresPort() const -{ - const ConnectionId &id = _cgo.connectionId(); - return id.outNodeId == InvalidNodeId || id.inNodeId == InvalidNodeId; -} - -bool ConnectionState::hovered() const -{ - return _hovered; -} - -void ConnectionState::setHovered(bool hovered) -{ - _hovered = hovered; -} - -void ConnectionState::setLastHoveredNode(NodeId const nodeId) -{ - _lastHoveredNode = nodeId; -} - -NodeId ConnectionState::lastHoveredNode() const -{ - return _lastHoveredNode; -} - -void ConnectionState::resetLastHoveredNode() -{ - if (_lastHoveredNode != InvalidNodeId) { - auto ngo = _cgo.nodeScene()->nodeGraphicsObject(_lastHoveredNode); - ngo->update(); - } - - _lastHoveredNode = InvalidNodeId; -} - -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/src/ConnectionStyle.cpp b/story-editor-legacy/nodeeditor/src/ConnectionStyle.cpp deleted file mode 100644 index 8126589..0000000 --- a/story-editor-legacy/nodeeditor/src/ConnectionStyle.cpp +++ /dev/null @@ -1,205 +0,0 @@ -#include "ConnectionStyle.hpp" - -#include "StyleCollection.hpp" - -#include -#include -#include - -#include - -#include - -using QtNodes::ConnectionStyle; - -inline void initResources() -{ - Q_INIT_RESOURCE(resources); -} - -ConnectionStyle::ConnectionStyle() -{ - // Explicit resources inialization for preventing the static initialization - // order fiasco: https://isocpp.org/wiki/faq/ctors#static-init-order - initResources(); - - // This configuration is stored inside the compiled unit and is loaded statically - loadJsonFile(":DefaultStyle.json"); -} - -ConnectionStyle::ConnectionStyle(QString jsonText) -{ - loadJsonFile(":DefaultStyle.json"); - loadJsonText(jsonText); -} - -void ConnectionStyle::setConnectionStyle(QString jsonText) -{ - ConnectionStyle style(jsonText); - - StyleCollection::setConnectionStyle(style); -} - -#ifdef STYLE_DEBUG -#define CONNECTION_STYLE_CHECK_UNDEFINED_VALUE(v, variable) \ - { \ - if (v.type() == QJsonValue::Undefined || v.type() == QJsonValue::Null) \ - qWarning() << "Undefined value for parameter:" << #variable; \ - } -#else -#define CONNECTION_STYLE_CHECK_UNDEFINED_VALUE(v, variable) -#endif - -#define CONNECTION_VALUE_EXISTS(v) \ - (v.type() != QJsonValue::Undefined && v.type() != QJsonValue::Null) - -#define CONNECTION_STYLE_READ_COLOR(values, variable) \ - { \ - auto valueRef = values[#variable]; \ - CONNECTION_STYLE_CHECK_UNDEFINED_VALUE(valueRef, variable) \ - if (CONNECTION_VALUE_EXISTS(valueRef)) { \ - if (valueRef.isArray()) { \ - auto colorArray = valueRef.toArray(); \ - std::vector rgb; \ - rgb.reserve(3); \ - for (auto it = colorArray.begin(); it != colorArray.end(); ++it) { \ - rgb.push_back((*it).toInt()); \ - } \ - variable = QColor(rgb[0], rgb[1], rgb[2]); \ - } else { \ - variable = QColor(valueRef.toString()); \ - } \ - } \ - } - -#define CONNECTION_STYLE_WRITE_COLOR(values, variable) \ - { \ - values[#variable] = variable.name(); \ - } - -#define CONNECTION_STYLE_READ_FLOAT(values, variable) \ - { \ - auto valueRef = values[#variable]; \ - CONNECTION_STYLE_CHECK_UNDEFINED_VALUE(valueRef, variable) \ - if (CONNECTION_VALUE_EXISTS(valueRef)) \ - variable = valueRef.toDouble(); \ - } - -#define CONNECTION_STYLE_WRITE_FLOAT(values, variable) \ - { \ - values[#variable] = variable; \ - } - -#define CONNECTION_STYLE_READ_BOOL(values, variable) \ - { \ - auto valueRef = values[#variable]; \ - CONNECTION_STYLE_CHECK_UNDEFINED_VALUE(valueRef, variable) \ - if (CONNECTION_VALUE_EXISTS(valueRef)) \ - variable = valueRef.toBool(); \ - } - -#define CONNECTION_STYLE_WRITE_BOOL(values, variable) \ - { \ - values[#variable] = variable; \ - } - -void ConnectionStyle::loadJson(QJsonObject const &json) -{ - QJsonValue nodeStyleValues = json["ConnectionStyle"]; - - QJsonObject obj = nodeStyleValues.toObject(); - - CONNECTION_STYLE_READ_COLOR(obj, ConstructionColor); - CONNECTION_STYLE_READ_COLOR(obj, NormalColor); - CONNECTION_STYLE_READ_COLOR(obj, SelectedColor); - CONNECTION_STYLE_READ_COLOR(obj, SelectedHaloColor); - CONNECTION_STYLE_READ_COLOR(obj, HoveredColor); - - CONNECTION_STYLE_READ_FLOAT(obj, LineWidth); - CONNECTION_STYLE_READ_FLOAT(obj, ConstructionLineWidth); - CONNECTION_STYLE_READ_FLOAT(obj, PointDiameter); - - CONNECTION_STYLE_READ_BOOL(obj, UseDataDefinedColors); -} - -QJsonObject ConnectionStyle::toJson() const -{ - QJsonObject obj; - - CONNECTION_STYLE_WRITE_COLOR(obj, ConstructionColor); - CONNECTION_STYLE_WRITE_COLOR(obj, NormalColor); - CONNECTION_STYLE_WRITE_COLOR(obj, SelectedColor); - CONNECTION_STYLE_WRITE_COLOR(obj, SelectedHaloColor); - CONNECTION_STYLE_WRITE_COLOR(obj, HoveredColor); - - CONNECTION_STYLE_WRITE_FLOAT(obj, LineWidth); - CONNECTION_STYLE_WRITE_FLOAT(obj, ConstructionLineWidth); - CONNECTION_STYLE_WRITE_FLOAT(obj, PointDiameter); - - CONNECTION_STYLE_WRITE_BOOL(obj, UseDataDefinedColors); - - QJsonObject root; - root["ConnectionStyle"] = obj; - - return root; -} - -QColor ConnectionStyle::constructionColor() const -{ - return ConstructionColor; -} - -QColor ConnectionStyle::normalColor() const -{ - return NormalColor; -} - -QColor ConnectionStyle::normalColor(QString typeId) const -{ - std::size_t hash = qHash(typeId); - - std::size_t const hue_range = 0xFF; - - std::mt19937 gen(static_cast(hash)); - std::uniform_int_distribution distrib(0, hue_range); - - int hue = distrib(gen); - int sat = 120 + hash % 129; - - return QColor::fromHsl(hue, sat, 160); -} - -QColor ConnectionStyle::selectedColor() const -{ - return SelectedColor; -} - -QColor ConnectionStyle::selectedHaloColor() const -{ - return SelectedHaloColor; -} - -QColor ConnectionStyle::hoveredColor() const -{ - return HoveredColor; -} - -float ConnectionStyle::lineWidth() const -{ - return LineWidth; -} - -float ConnectionStyle::constructionLineWidth() const -{ - return ConstructionLineWidth; -} - -float ConnectionStyle::pointDiameter() const -{ - return PointDiameter; -} - -bool ConnectionStyle::useDataDefinedColors() const -{ - return UseDataDefinedColors; -} diff --git a/story-editor-legacy/nodeeditor/src/DataFlowGraphModel.cpp b/story-editor-legacy/nodeeditor/src/DataFlowGraphModel.cpp deleted file mode 100644 index fdf46e8..0000000 --- a/story-editor-legacy/nodeeditor/src/DataFlowGraphModel.cpp +++ /dev/null @@ -1,536 +0,0 @@ -#include "DataFlowGraphModel.hpp" -#include "ConnectionIdHash.hpp" - -#include - -#include - -namespace QtNodes { - -DataFlowGraphModel::DataFlowGraphModel(std::shared_ptr registry) - : _registry(std::move(registry)) - , _nextNodeId{0} -{} - -std::unordered_set DataFlowGraphModel::allNodeIds() const -{ - std::unordered_set nodeIds; - for_each(_models.begin(), _models.end(), [&nodeIds](auto const &p) { nodeIds.insert(p.first); }); - - return nodeIds; -} - -std::unordered_set DataFlowGraphModel::allConnectionIds(NodeId const nodeId) const -{ - std::unordered_set result; - - std::copy_if(_connectivity.begin(), - _connectivity.end(), - std::inserter(result, std::end(result)), - [&nodeId](ConnectionId const &cid) { - return cid.inNodeId == nodeId || cid.outNodeId == nodeId; - }); - - return result; -} - -std::unordered_set DataFlowGraphModel::connections(NodeId nodeId, - PortType portType, - PortIndex portIndex) const -{ - std::unordered_set result; - - std::copy_if(_connectivity.begin(), - _connectivity.end(), - std::inserter(result, std::end(result)), - [&portType, &portIndex, &nodeId](ConnectionId const &cid) { - return (getNodeId(portType, cid) == nodeId - && getPortIndex(portType, cid) == portIndex); - }); - - return result; -} - -bool DataFlowGraphModel::connectionExists(ConnectionId const connectionId) const -{ - return (_connectivity.find(connectionId) != _connectivity.end()); -} - -NodeId DataFlowGraphModel::addNode(QString const nodeType) -{ - std::unique_ptr model = _registry->create(nodeType); - - if (model) { - NodeId newId = newNodeId(); - - connect(model.get(), - &NodeDelegateModel::dataUpdated, - [newId, this](PortIndex const portIndex) { - onOutPortDataUpdated(newId, portIndex); - }); - - connect(model.get(), - &NodeDelegateModel::portsAboutToBeDeleted, - this, - [newId, this](PortType const portType, PortIndex const first, PortIndex const last) { - portsAboutToBeDeleted(newId, portType, first, last); - }); - - connect(model.get(), - &NodeDelegateModel::portsDeleted, - this, - &DataFlowGraphModel::portsDeleted); - - connect(model.get(), - &NodeDelegateModel::portsAboutToBeInserted, - this, - [newId, this](PortType const portType, PortIndex const first, PortIndex const last) { - portsAboutToBeInserted(newId, portType, first, last); - }); - - connect(model.get(), - &NodeDelegateModel::portsInserted, - this, - &DataFlowGraphModel::portsInserted); - - _models[newId] = std::move(model); - - Q_EMIT nodeCreated(newId); - - return newId; - } - - return InvalidNodeId; -} - -bool DataFlowGraphModel::connectionPossible(ConnectionId const connectionId) const -{ - auto getDataType = [&](PortType const portType) { - return portData(getNodeId(portType, connectionId), - portType, - getPortIndex(portType, connectionId), - PortRole::DataType) - .value(); - }; - - auto portVacant = [&](PortType const portType) { - NodeId const nodeId = getNodeId(portType, connectionId); - PortIndex const portIndex = getPortIndex(portType, connectionId); - auto const connected = connections(nodeId, portType, portIndex); - - auto policy = portData(nodeId, portType, portIndex, PortRole::ConnectionPolicyRole) - .value(); - - return connected.empty() || (policy == ConnectionPolicy::Many); - }; - - return getDataType(PortType::Out).id == getDataType(PortType::In).id - && portVacant(PortType::Out) && portVacant(PortType::In); -} - -void DataFlowGraphModel::addConnection(ConnectionId const connectionId) -{ - _connectivity.insert(connectionId); - - sendConnectionCreation(connectionId); - - QVariant const portDataToPropagate = portData(connectionId.outNodeId, - PortType::Out, - connectionId.outPortIndex, - PortRole::Data); - - setPortData(connectionId.inNodeId, - PortType::In, - connectionId.inPortIndex, - portDataToPropagate, - PortRole::Data); -} - -void DataFlowGraphModel::sendConnectionCreation(ConnectionId const connectionId) -{ - Q_EMIT connectionCreated(connectionId); - - auto iti = _models.find(connectionId.inNodeId); - auto ito = _models.find(connectionId.outNodeId); - if (iti != _models.end() && ito != _models.end()) { - auto &modeli = iti->second; - auto &modelo = ito->second; - modeli->inputConnectionCreated(connectionId); - modelo->outputConnectionCreated(connectionId); - } -} - -void DataFlowGraphModel::sendConnectionDeletion(ConnectionId const connectionId) -{ - Q_EMIT connectionDeleted(connectionId); - - auto iti = _models.find(connectionId.inNodeId); - auto ito = _models.find(connectionId.outNodeId); - if (iti != _models.end() && ito != _models.end()) { - auto &modeli = iti->second; - auto &modelo = ito->second; - modeli->inputConnectionDeleted(connectionId); - modelo->outputConnectionDeleted(connectionId); - } -} - -bool DataFlowGraphModel::nodeExists(NodeId const nodeId) const -{ - return (_models.find(nodeId) != _models.end()); -} - -QVariant DataFlowGraphModel::nodeData(NodeId nodeId, NodeRole role) const -{ - QVariant result; - - auto it = _models.find(nodeId); - if (it == _models.end()) - return result; - - auto &model = it->second; - - switch (role) { - case NodeRole::Id: - break; - case NodeRole::Type: - result = model->name(); - break; - - case NodeRole::Position: - result = _nodeGeometryData[nodeId].pos; - break; - - case NodeRole::Size: - result = _nodeGeometryData[nodeId].size; - break; - - case NodeRole::CaptionVisible: - result = model->captionVisible(); - break; - - case NodeRole::Caption: - result = model->caption(); - break; - - case NodeRole::Style: { - auto style = StyleCollection::nodeStyle(); - result = style.toJson().toVariantMap(); - } break; - - case NodeRole::InternalData: { - QJsonObject nodeJson; - - nodeJson["internal-data"] = _models.at(nodeId)->save(); - - result = nodeJson.toVariantMap(); - break; - } - - case NodeRole::InPortCount: - result = model->nPorts(PortType::In); - break; - - case NodeRole::OutPortCount: - result = model->nPorts(PortType::Out); - break; - - case NodeRole::Widget: { - auto w = model->embeddedWidget(); - result = QVariant::fromValue(w); - } break; - } - - return result; -} - -NodeFlags DataFlowGraphModel::nodeFlags(NodeId nodeId) const -{ - auto it = _models.find(nodeId); - - if (it != _models.end() && it->second->resizable()) - return NodeFlag::Resizable; - - return NodeFlag::NoFlags; -} - -bool DataFlowGraphModel::setNodeData(NodeId nodeId, NodeRole role, QVariant value) -{ - Q_UNUSED(nodeId); - Q_UNUSED(role); - Q_UNUSED(value); - - bool result = false; - - switch (role) { - case NodeRole::Id: - break; - case NodeRole::Type: - break; - case NodeRole::Position: { - _nodeGeometryData[nodeId].pos = value.value(); - - Q_EMIT nodePositionUpdated(nodeId); - - result = true; - } break; - - case NodeRole::Size: { - _nodeGeometryData[nodeId].size = value.value(); - result = true; - } break; - - case NodeRole::CaptionVisible: - break; - - case NodeRole::Caption: - break; - - case NodeRole::Style: - break; - - case NodeRole::InternalData: - break; - - case NodeRole::InPortCount: - break; - - case NodeRole::OutPortCount: - break; - - case NodeRole::Widget: - break; - } - - return result; -} - -QVariant DataFlowGraphModel::portData(NodeId nodeId, - PortType portType, - PortIndex portIndex, - PortRole role) const -{ - QVariant result; - - auto it = _models.find(nodeId); - if (it == _models.end()) - return result; - - auto &model = it->second; - - switch (role) { - case PortRole::Data: - if (portType == PortType::Out) - result = QVariant::fromValue(model->outData(portIndex)); - break; - - case PortRole::DataType: - result = QVariant::fromValue(model->dataType(portType, portIndex)); - break; - - case PortRole::ConnectionPolicyRole: - result = QVariant::fromValue(model->portConnectionPolicy(portType, portIndex)); - break; - - case PortRole::CaptionVisible: - result = model->portCaptionVisible(portType, portIndex); - break; - - case PortRole::Caption: - result = model->portCaption(portType, portIndex); - - break; - } - - return result; -} - -bool DataFlowGraphModel::setPortData( - NodeId nodeId, PortType portType, PortIndex portIndex, QVariant const &value, PortRole role) -{ - Q_UNUSED(nodeId); - - QVariant result; - - auto it = _models.find(nodeId); - if (it == _models.end()) - return false; - - auto &model = it->second; - - switch (role) { - case PortRole::Data: - if (portType == PortType::In) { - model->setInData(value.value>(), portIndex); - - // Triggers repainting on the scene. - Q_EMIT inPortDataWasSet(nodeId, portType, portIndex); - } - break; - - default: - break; - } - - return false; -} - -bool DataFlowGraphModel::deleteConnection(ConnectionId const connectionId) -{ - bool disconnected = false; - - auto it = _connectivity.find(connectionId); - - if (it != _connectivity.end()) { - disconnected = true; - - _connectivity.erase(it); - } - - if (disconnected) { - sendConnectionDeletion(connectionId); - - propagateEmptyDataTo(getNodeId(PortType::In, connectionId), - getPortIndex(PortType::In, connectionId)); - } - - return disconnected; -} - -bool DataFlowGraphModel::deleteNode(NodeId const nodeId) -{ - // Delete connections to this node first. - auto connectionIds = allConnectionIds(nodeId); - for (auto &cId : connectionIds) { - deleteConnection(cId); - } - - _nodeGeometryData.erase(nodeId); - _models.erase(nodeId); - - Q_EMIT nodeDeleted(nodeId); - - return true; -} - -QJsonObject DataFlowGraphModel::saveNode(NodeId const nodeId) const -{ - QJsonObject nodeJson; - - nodeJson["id"] = static_cast(nodeId); - - nodeJson["internal-data"] = _models.at(nodeId)->save(); - - { - QPointF const pos = nodeData(nodeId, NodeRole::Position).value(); - - QJsonObject posJson; - posJson["x"] = pos.x(); - posJson["y"] = pos.y(); - nodeJson["position"] = posJson; - } - - return nodeJson; -} - -QJsonObject DataFlowGraphModel::save() const -{ - QJsonObject sceneJson; - - QJsonArray nodesJsonArray; - for (auto const nodeId : allNodeIds()) { - nodesJsonArray.append(saveNode(nodeId)); - } - sceneJson["nodes"] = nodesJsonArray; - - QJsonArray connJsonArray; - for (auto const &cid : _connectivity) { - connJsonArray.append(toJson(cid)); - } - sceneJson["connections"] = connJsonArray; - - return sceneJson; -} - -void DataFlowGraphModel::loadNode(QJsonObject const &nodeJson) -{ - // Possibility of the id clash when reading it from json and not generating a - // new value. - // 1. When restoring a scene from a file. - // Conflict is not possible because the scene must be cleared by the time of - // loading. - // 2. When undoing the deletion command. Conflict is not possible - // because all the new ids were created past the removed nodes. - NodeId restoredNodeId = nodeJson["id"].toInt(); - - _nextNodeId = std::max(_nextNodeId, restoredNodeId + 1); - - QJsonObject const internalDataJson = nodeJson["internal-data"].toObject(); - - QString delegateModelName = internalDataJson["model-name"].toString(); - - std::unique_ptr model = _registry->create(delegateModelName); - - if (model) { - connect(model.get(), - &NodeDelegateModel::dataUpdated, - [restoredNodeId, this](PortIndex const portIndex) { - onOutPortDataUpdated(restoredNodeId, portIndex); - }); - - _models[restoredNodeId] = std::move(model); - - Q_EMIT nodeCreated(restoredNodeId); - - QJsonObject posJson = nodeJson["position"].toObject(); - QPointF const pos(posJson["x"].toDouble(), posJson["y"].toDouble()); - - setNodeData(restoredNodeId, NodeRole::Position, pos); - - _models[restoredNodeId]->load(internalDataJson); - } else { - throw std::logic_error(std::string("No registered model with name ") - + delegateModelName.toLocal8Bit().data()); - } -} - -void DataFlowGraphModel::load(QJsonObject const &jsonDocument) -{ - QJsonArray nodesJsonArray = jsonDocument["nodes"].toArray(); - - for (QJsonValueRef nodeJson : nodesJsonArray) { - loadNode(nodeJson.toObject()); - } - - QJsonArray connectionJsonArray = jsonDocument["connections"].toArray(); - - for (QJsonValueRef connection : connectionJsonArray) { - QJsonObject connJson = connection.toObject(); - - ConnectionId connId = fromJson(connJson); - - // Restore the connection - addConnection(connId); - } -} - -void DataFlowGraphModel::onOutPortDataUpdated(NodeId const nodeId, PortIndex const portIndex) -{ - std::unordered_set const &connected = connections(nodeId, - PortType::Out, - portIndex); - - QVariant const portDataToPropagate = portData(nodeId, PortType::Out, portIndex, PortRole::Data); - - for (auto const &cn : connected) { - setPortData(cn.inNodeId, PortType::In, cn.inPortIndex, portDataToPropagate, PortRole::Data); - } -} - -void DataFlowGraphModel::propagateEmptyDataTo(NodeId const nodeId, PortIndex const portIndex) -{ - QVariant emptyData{}; - - setPortData(nodeId, PortType::In, portIndex, emptyData, PortRole::Data); -} - -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/src/DataFlowGraphicsScene.cpp b/story-editor-legacy/nodeeditor/src/DataFlowGraphicsScene.cpp deleted file mode 100644 index 506f722..0000000 --- a/story-editor-legacy/nodeeditor/src/DataFlowGraphicsScene.cpp +++ /dev/null @@ -1,189 +0,0 @@ -#include "DataFlowGraphicsScene.hpp" - -#include "ConnectionGraphicsObject.hpp" -#include "GraphicsView.hpp" -#include "NodeDelegateModelRegistry.hpp" -#include "NodeGraphicsObject.hpp" -#include "UndoCommands.hpp" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -namespace QtNodes { - -DataFlowGraphicsScene::DataFlowGraphicsScene(DataFlowGraphModel &graphModel, QObject *parent) - : BasicGraphicsScene(graphModel, parent) - , _graphModel(graphModel) -{ - connect(&_graphModel, - &DataFlowGraphModel::inPortDataWasSet, - [this](NodeId const nodeId, PortType const, PortIndex const) { onNodeUpdated(nodeId); }); -} - -// TODO constructor for an empyt scene? - -std::vector DataFlowGraphicsScene::selectedNodes() const -{ - QList graphicsItems = selectedItems(); - - std::vector result; - result.reserve(graphicsItems.size()); - - for (QGraphicsItem *item : graphicsItems) { - auto ngo = qgraphicsitem_cast(item); - - if (ngo != nullptr) { - result.push_back(ngo->nodeId()); - } - } - - return result; -} - -QMenu *DataFlowGraphicsScene::createSceneMenu(QPointF const scenePos) -{ - QMenu *modelMenu = new QMenu(); - - // Add filterbox to the context menu - auto *txtBox = new QLineEdit(modelMenu); - txtBox->setPlaceholderText(QStringLiteral("Filter")); - txtBox->setClearButtonEnabled(true); - - auto *txtBoxAction = new QWidgetAction(modelMenu); - txtBoxAction->setDefaultWidget(txtBox); - - // 1. - modelMenu->addAction(txtBoxAction); - - // Add result treeview to the context menu - QTreeWidget *treeView = new QTreeWidget(modelMenu); - treeView->header()->close(); - - auto *treeViewAction = new QWidgetAction(modelMenu); - treeViewAction->setDefaultWidget(treeView); - - // 2. - modelMenu->addAction(treeViewAction); - - auto registry = _graphModel.dataModelRegistry(); - - for (auto const &cat : registry->categories()) { - auto item = new QTreeWidgetItem(treeView); - item->setText(0, cat); - item->setFlags(item->flags() & ~Qt::ItemIsSelectable); - } - - for (auto const &assoc : registry->registeredModelsCategoryAssociation()) { - QList parent = treeView->findItems(assoc.second, Qt::MatchExactly); - - if (parent.count() <= 0) - continue; - - auto item = new QTreeWidgetItem(parent.first()); - item->setText(0, assoc.first); - } - - treeView->expandAll(); - - connect(treeView, - &QTreeWidget::itemClicked, - [this, modelMenu, scenePos](QTreeWidgetItem *item, int) { - if (!(item->flags() & (Qt::ItemIsSelectable))) { - return; - } - - this->undoStack().push(new CreateCommand(this, item->text(0), scenePos)); - - modelMenu->close(); - }); - - //Setup filtering - connect(txtBox, &QLineEdit::textChanged, [treeView](const QString &text) { - QTreeWidgetItemIterator categoryIt(treeView, QTreeWidgetItemIterator::HasChildren); - while (*categoryIt) - (*categoryIt++)->setHidden(true); - QTreeWidgetItemIterator it(treeView, QTreeWidgetItemIterator::NoChildren); - while (*it) { - auto modelName = (*it)->text(0); - const bool match = (modelName.contains(text, Qt::CaseInsensitive)); - (*it)->setHidden(!match); - if (match) { - QTreeWidgetItem *parent = (*it)->parent(); - while (parent) { - parent->setHidden(false); - parent = parent->parent(); - } - } - ++it; - } - }); - - // make sure the text box gets focus so the user doesn't have to click on it - txtBox->setFocus(); - - // QMenu's instance auto-destruction - modelMenu->setAttribute(Qt::WA_DeleteOnClose); - - return modelMenu; -} - -void DataFlowGraphicsScene::save() const -{ - QString fileName = QFileDialog::getSaveFileName(nullptr, - tr("Open Flow Scene"), - QDir::homePath(), - tr("Flow Scene Files (*.flow)")); - - if (!fileName.isEmpty()) { - if (!fileName.endsWith("flow", Qt::CaseInsensitive)) - fileName += ".flow"; - - QFile file(fileName); - if (file.open(QIODevice::WriteOnly)) { - file.write(QJsonDocument(_graphModel.save()).toJson()); - } - } -} - -void DataFlowGraphicsScene::load() -{ - QString fileName = QFileDialog::getOpenFileName(nullptr, - tr("Open Flow Scene"), - QDir::homePath(), - tr("Flow Scene Files (*.flow)")); - - if (!QFileInfo::exists(fileName)) - return; - - QFile file(fileName); - - if (!file.open(QIODevice::ReadOnly)) - return; - - clearScene(); - - QByteArray const wholeFile = file.readAll(); - - _graphModel.load(QJsonDocument::fromJson(wholeFile).object()); - - Q_EMIT sceneLoaded(); -} - -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/src/DefaultHorizontalNodeGeometry.cpp b/story-editor-legacy/nodeeditor/src/DefaultHorizontalNodeGeometry.cpp deleted file mode 100644 index cf1e80d..0000000 --- a/story-editor-legacy/nodeeditor/src/DefaultHorizontalNodeGeometry.cpp +++ /dev/null @@ -1,239 +0,0 @@ -#include "DefaultHorizontalNodeGeometry.hpp" - -#include "AbstractGraphModel.hpp" -#include "NodeData.hpp" - -#include -#include -#include - -namespace QtNodes { - -DefaultHorizontalNodeGeometry::DefaultHorizontalNodeGeometry(AbstractGraphModel &graphModel) - : AbstractNodeGeometry(graphModel) - , _portSize(20) - , _portSpasing(10) - , _fontMetrics(QFont()) - , _boldFontMetrics(QFont()) -{ - QFont f({ "Arial", 10 }); - f.setBold(true); - _boldFontMetrics = QFontMetrics(f); - - _portSize = _fontMetrics.height(); -} - -QSize DefaultHorizontalNodeGeometry::size(NodeId const nodeId) const -{ - return _graphModel.nodeData(nodeId, NodeRole::Size); -} - -void DefaultHorizontalNodeGeometry::recomputeSize(NodeId const nodeId) const -{ - unsigned int height = maxVerticalPortsExtent(nodeId); - - if (auto w = _graphModel.nodeData(nodeId, NodeRole::Widget)) { - height = std::max(height, static_cast(w->height())); - } - - QRectF const capRect = captionRect(nodeId); - - height += capRect.height(); - - height += _portSpasing; // space above caption - height += _portSpasing; // space below caption - - unsigned int inPortWidth = maxPortsTextAdvance(nodeId, PortType::In); - unsigned int outPortWidth = maxPortsTextAdvance(nodeId, PortType::Out); - - unsigned int width = inPortWidth + outPortWidth + 4 * _portSpasing; - - if (auto w = _graphModel.nodeData(nodeId, NodeRole::Widget)) { - width += w->width(); - } - - width = std::max(width, static_cast(capRect.width()) + 2 * _portSpasing); - - QSize size(width, height); - - _graphModel.setNodeData(nodeId, NodeRole::Size, size); -} - -QPointF DefaultHorizontalNodeGeometry::portPosition(NodeId const nodeId, - PortType const portType, - PortIndex const portIndex) const -{ - unsigned int const step = _portSize + _portSpasing; - - QPointF result; - - double totalHeight = 15.0; - - totalHeight += captionRect(nodeId).height(); - totalHeight += _portSpasing; - - totalHeight += step * portIndex; - totalHeight += step / 2.0; - - QSize size = _graphModel.nodeData(nodeId, NodeRole::Size); - - switch (portType) { - case PortType::In: { - double x = 0.0; - - result = QPointF(x, totalHeight); - break; - } - - case PortType::Out: { - double x = size.width(); - - result = QPointF(x, totalHeight); - break; - } - - default: - break; - } - - return result; -} - -QPointF DefaultHorizontalNodeGeometry::portTextPosition(NodeId const nodeId, - PortType const portType, - PortIndex const portIndex) const -{ - QPointF p = portPosition(nodeId, portType, portIndex); - - QRectF rect = portTextRect(nodeId, portType, portIndex); - - p.setY(p.y() + rect.height() / 4.0); - - QSize size = _graphModel.nodeData(nodeId, NodeRole::Size); - - switch (portType) { - case PortType::In: - p.setX(_portSpasing); - break; - - case PortType::Out: - p.setX(size.width() - _portSpasing - rect.width()); - break; - - default: - break; - } - - return p; -} - -QRectF DefaultHorizontalNodeGeometry::captionRect(NodeId const nodeId) const -{ - if (!_graphModel.nodeData(nodeId, NodeRole::CaptionVisible)) - return QRect(); - - QString name = _graphModel.nodeData(nodeId, NodeRole::Caption); - - return _boldFontMetrics.boundingRect(name); -} - -QPointF DefaultHorizontalNodeGeometry::captionPosition(NodeId const nodeId) const -{ - QSize size = _graphModel.nodeData(nodeId, NodeRole::Size); - return QPointF(0.5 * (size.width() - captionRect(nodeId).width()), - 0.5 * _portSpasing + captionRect(nodeId).height()); -} - -QPointF DefaultHorizontalNodeGeometry::widgetPosition(NodeId const nodeId) const -{ - QSize size = _graphModel.nodeData(nodeId, NodeRole::Size); - - unsigned int captionHeight = captionRect(nodeId).height(); - - if (auto w = _graphModel.nodeData(nodeId, NodeRole::Widget)) { - // If the widget wants to use as much vertical space as possible, - // place it immediately after the caption. - if (w->sizePolicy().verticalPolicy() & QSizePolicy::ExpandFlag) { - return QPointF(2.0 * _portSpasing + maxPortsTextAdvance(nodeId, PortType::In), - captionHeight); - } else { - return QPointF(2.0 * _portSpasing + maxPortsTextAdvance(nodeId, PortType::In), - (captionHeight + size.height() - w->height()) / 2.0); - } - } - return QPointF(); -} - -QRect DefaultHorizontalNodeGeometry::resizeHandleRect(NodeId const nodeId) const -{ - QSize size = _graphModel.nodeData(nodeId, NodeRole::Size); - - unsigned int rectSize = 7; - - return QRect(size.width() - _portSpasing, size.height() - _portSpasing, rectSize, rectSize); -} - -QRectF DefaultHorizontalNodeGeometry::portTextRect(NodeId const nodeId, - PortType const portType, - PortIndex const portIndex) const -{ - QString s; - if (_graphModel.portData(nodeId, portType, portIndex, PortRole::CaptionVisible)) { - s = _graphModel.portData(nodeId, portType, portIndex, PortRole::Caption); - } else { - auto portData = _graphModel.portData(nodeId, portType, portIndex, PortRole::DataType); - - s = portData.value().name; - } - - return _fontMetrics.boundingRect(s); -} - -unsigned int DefaultHorizontalNodeGeometry::maxVerticalPortsExtent(NodeId const nodeId) const -{ - PortCount nInPorts = _graphModel.nodeData(nodeId, NodeRole::InPortCount); - - PortCount nOutPorts = _graphModel.nodeData(nodeId, NodeRole::OutPortCount); - - unsigned int maxNumOfEntries = std::max(nInPorts, nOutPorts); - unsigned int step = _portSize + _portSpasing; - - return step * maxNumOfEntries; -} - -unsigned int DefaultHorizontalNodeGeometry::maxPortsTextAdvance(NodeId const nodeId, - PortType const portType) const -{ - unsigned int width = 0; - - size_t const n = _graphModel - .nodeData(nodeId, - (portType == PortType::Out) ? NodeRole::OutPortCount - : NodeRole::InPortCount) - .toUInt(); - - for (PortIndex portIndex = 0ul; portIndex < n; ++portIndex) { - QString name; - - if (_graphModel.portData(nodeId, portType, portIndex, PortRole::CaptionVisible)) { - name = _graphModel.portData(nodeId, portType, portIndex, PortRole::Caption); - } else { - NodeDataType portData = _graphModel.portData(nodeId, - portType, - portIndex, - PortRole::DataType); - - name = portData.name; - } - -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) - width = std::max(unsigned(_fontMetrics.horizontalAdvance(name)), width); -#else - width = std::max(unsigned(_fontMetrics.width(name)), width); -#endif - } - - return width; -} - -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/src/DefaultNodePainter.cpp b/story-editor-legacy/nodeeditor/src/DefaultNodePainter.cpp deleted file mode 100644 index afe0cc2..0000000 --- a/story-editor-legacy/nodeeditor/src/DefaultNodePainter.cpp +++ /dev/null @@ -1,284 +0,0 @@ -#include "DefaultNodePainter.hpp" - -#include - -#include - -#include "AbstractGraphModel.hpp" -#include "AbstractNodeGeometry.hpp" -#include "BasicGraphicsScene.hpp" -#include "ConnectionGraphicsObject.hpp" -#include "ConnectionIdUtils.hpp" -#include "NodeGraphicsObject.hpp" -#include "NodeState.hpp" -#include "StyleCollection.hpp" - -namespace QtNodes { - -void DefaultNodePainter::paint(QPainter *painter, NodeGraphicsObject &ngo) const -{ - // TODO? - //AbstractNodeGeometry & geometry = ngo.nodeScene()->nodeGeometry(); - //geometry.recomputeSizeIfFontChanged(painter->font()); - - drawNodeRect(painter, ngo); - - drawConnectionPoints(painter, ngo); - - drawFilledConnectionPoints(painter, ngo); - - drawNodeCaption(painter, ngo); - - drawEntryLabels(painter, ngo); - - drawResizeRect(painter, ngo); -} - -void DefaultNodePainter::drawNodeRect(QPainter *painter, NodeGraphicsObject &ngo) const -{ - AbstractGraphModel &model = ngo.graphModel(); - - NodeId const nodeId = ngo.nodeId(); - - AbstractNodeGeometry &geometry = ngo.nodeScene()->nodeGeometry(); - - QSize size = geometry.size(nodeId); - - QJsonDocument json = QJsonDocument::fromVariant(model.nodeData(nodeId, NodeRole::Style)); - - NodeStyle nodeStyle(json.object()); - - auto color = ngo.isSelected() ? nodeStyle.SelectedBoundaryColor : nodeStyle.NormalBoundaryColor; - -// if (ngo.nodeState().hovered()) { -// QPen p(color, nodeStyle.HoveredPenWidth); -// painter->setPen(p); -// } else { -// QPen p(color, nodeStyle.PenWidth); -// painter->setPen(p); -// } - QPen pen = painter->pen(); - pen.setBrush(color); - pen.setWidth(2); - painter->setPen(pen); - painter->setBrush(nodeStyle.GradientColor0); - - QRectF boundary(0, 0, size.width(), size.height()); - painter->drawRect(boundary); -} - -void DefaultNodePainter::drawConnectionPoints(QPainter *painter, NodeGraphicsObject &ngo) const -{ - AbstractGraphModel &model = ngo.graphModel(); - NodeId const nodeId = ngo.nodeId(); - AbstractNodeGeometry &geometry = ngo.nodeScene()->nodeGeometry(); - - QJsonDocument json = QJsonDocument::fromVariant(model.nodeData(nodeId, NodeRole::Style)); - NodeStyle nodeStyle(json.object()); - - auto const &connectionStyle = StyleCollection::connectionStyle(); - - float diameter = nodeStyle.ConnectionPointDiameter; - auto reducedDiameter = diameter * 0.6; - - for (PortType portType : {PortType::Out, PortType::In}) { - size_t const n = model - .nodeData(nodeId, - (portType == PortType::Out) ? NodeRole::OutPortCount - : NodeRole::InPortCount) - .toUInt(); - - for (PortIndex portIndex = 0; portIndex < n; ++portIndex) { - QPointF p = geometry.portPosition(nodeId, portType, portIndex); - - auto const &dataType = model.portData(nodeId, portType, portIndex, PortRole::DataType) - .value(); - - double r = 1.0; - - NodeState const &state = ngo.nodeState(); - - if (auto const *cgo = state.connectionForReaction()) { - PortType requiredPort = cgo->connectionState().requiredPort(); - - if (requiredPort == portType) { - ConnectionId possibleConnectionId = makeCompleteConnectionId(cgo->connectionId(), - nodeId, - portIndex); - - bool const possible = model.connectionPossible(possibleConnectionId); - - auto cp = cgo->sceneTransform().map(cgo->endPoint(requiredPort)); - cp = ngo.sceneTransform().inverted().map(cp); - - auto diff = cp - p; - double dist = std::sqrt(QPointF::dotProduct(diff, diff)); - - if (possible) { - double const thres = 40.0; - r = (dist < thres) ? (2.0 - dist / thres) : 1.0; - } else { - double const thres = 80.0; - r = (dist < thres) ? (dist / thres) : 1.0; - } - } - } - - if (connectionStyle.useDataDefinedColors()) { - painter->setBrush(connectionStyle.normalColor(dataType.id)); - } else { - painter->setBrush(nodeStyle.ConnectionPointColor); - } - - painter->drawEllipse(p, reducedDiameter * r, reducedDiameter * r); - } - } - - if (ngo.nodeState().connectionForReaction()) { - ngo.nodeState().resetConnectionForReaction(); - } -} - -void DefaultNodePainter::drawFilledConnectionPoints(QPainter *painter, NodeGraphicsObject &ngo) const -{ - AbstractGraphModel &model = ngo.graphModel(); - NodeId const nodeId = ngo.nodeId(); - AbstractNodeGeometry &geometry = ngo.nodeScene()->nodeGeometry(); - - QJsonDocument json = QJsonDocument::fromVariant(model.nodeData(nodeId, NodeRole::Style)); - NodeStyle nodeStyle(json.object()); - - auto diameter = nodeStyle.ConnectionPointDiameter; - - for (PortType portType : {PortType::Out, PortType::In}) { - size_t const n = model - .nodeData(nodeId, - (portType == PortType::Out) ? NodeRole::OutPortCount - : NodeRole::InPortCount) - .toUInt(); - - for (PortIndex portIndex = 0; portIndex < n; ++portIndex) { - QPointF p = geometry.portPosition(nodeId, portType, portIndex); - - auto const &connected = model.connections(nodeId, portType, portIndex); - - if (!connected.empty()) { - auto const &dataType = model - .portData(nodeId, portType, portIndex, PortRole::DataType) - .value(); - - auto const &connectionStyle = StyleCollection::connectionStyle(); - if (connectionStyle.useDataDefinedColors()) { - QColor const c = connectionStyle.normalColor(dataType.id); - painter->setPen(c); - painter->setBrush(c); - } else { - painter->setPen(nodeStyle.FilledConnectionPointColor); - painter->setBrush(nodeStyle.FilledConnectionPointColor); - } - - painter->drawEllipse(p, diameter * 0.4, diameter * 0.4); - } - } - } -} - -void DefaultNodePainter::drawNodeCaption(QPainter *painter, NodeGraphicsObject &ngo) const -{ - AbstractGraphModel &model = ngo.graphModel(); - NodeId const nodeId = ngo.nodeId(); - AbstractNodeGeometry &geometry = ngo.nodeScene()->nodeGeometry(); - - if (!model.nodeData(nodeId, NodeRole::CaptionVisible).toBool()) - return; - - QString const name = model.nodeData(nodeId, NodeRole::Caption).toString(); - - QFont f({ "Arial", 10 }); - f.setBold(true); - - QPointF position = geometry.captionPosition(nodeId); - - QJsonDocument json = QJsonDocument::fromVariant(model.nodeData(nodeId, NodeRole::Style)); - NodeStyle nodeStyle(json.object()); - - - painter->setBrush(QBrush("#f7aa1b")); - QFontMetrics metrics(f); - auto fontRect = metrics.boundingRect(name); - - QSize sizeH = geometry.size(nodeId); - QRectF titleRect; - - int w = sizeH.width(); -// titleRect.setX(2); -// titleRect.setY(2); - titleRect.setWidth(w); - titleRect.setHeight(fontRect.height() + position.ry()); - QPen pen = painter->pen(); - pen.setWidth(0); - painter->setPen(pen); - painter->drawRect(titleRect); - - painter->setFont(f); - painter->setPen(Qt::black); - painter->drawText(position, name); - - f.setBold(false); - painter->setFont(f); -} - -void DefaultNodePainter::drawEntryLabels(QPainter *painter, NodeGraphicsObject &ngo) const -{ - AbstractGraphModel &model = ngo.graphModel(); - NodeId const nodeId = ngo.nodeId(); - AbstractNodeGeometry &geometry = ngo.nodeScene()->nodeGeometry(); - - QJsonDocument json = QJsonDocument::fromVariant(model.nodeData(nodeId, NodeRole::Style)); - NodeStyle nodeStyle(json.object()); - - for (PortType portType : {PortType::Out, PortType::In}) { - unsigned int n = model.nodeData(nodeId, - (portType == PortType::Out) - ? NodeRole::OutPortCount - : NodeRole::InPortCount); - - for (PortIndex portIndex = 0; portIndex < n; ++portIndex) { - auto const &connected = model.connections(nodeId, portType, portIndex); - - QPointF p = geometry.portTextPosition(nodeId, portType, portIndex); - - if (connected.empty()) - painter->setPen(nodeStyle.FontColorFaded); - else - painter->setPen(nodeStyle.FontColor); - - QString s; - - if (model.portData(nodeId, portType, portIndex, PortRole::CaptionVisible)) { - s = model.portData(nodeId, portType, portIndex, PortRole::Caption); - } else { - auto portData = model.portData(nodeId, portType, portIndex, PortRole::DataType); - - s = portData.value().name; - } - - painter->drawText(p, s); - } - } -} - -void DefaultNodePainter::drawResizeRect(QPainter *painter, NodeGraphicsObject &ngo) const -{ - AbstractGraphModel &model = ngo.graphModel(); - NodeId const nodeId = ngo.nodeId(); - AbstractNodeGeometry &geometry = ngo.nodeScene()->nodeGeometry(); - - if (model.nodeFlags(nodeId) & NodeFlag::Resizable) { - painter->setBrush(Qt::gray); - - painter->drawEllipse(geometry.resizeHandleRect(nodeId)); - } -} - -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/src/DefaultVerticalNodeGeometry.cpp b/story-editor-legacy/nodeeditor/src/DefaultVerticalNodeGeometry.cpp deleted file mode 100644 index 4c3c0bd..0000000 --- a/story-editor-legacy/nodeeditor/src/DefaultVerticalNodeGeometry.cpp +++ /dev/null @@ -1,300 +0,0 @@ -#include "DefaultVerticalNodeGeometry.hpp" - -#include "AbstractGraphModel.hpp" -#include "NodeData.hpp" - -#include -#include -#include - -namespace QtNodes { - -DefaultVerticalNodeGeometry::DefaultVerticalNodeGeometry(AbstractGraphModel &graphModel) - : AbstractNodeGeometry(graphModel) - , _portSize(20) - , _portSpasing(10) - , _fontMetrics(QFont()) - , _boldFontMetrics(QFont()) -{ - QFont f({ "Arial", 10 }); - f.setBold(true); - _boldFontMetrics = QFontMetrics(f); - - _portSize = _fontMetrics.height(); -} - -QSize DefaultVerticalNodeGeometry::size(NodeId const nodeId) const -{ - return _graphModel.nodeData(nodeId, NodeRole::Size); -} - -void DefaultVerticalNodeGeometry::recomputeSize(NodeId const nodeId) const -{ - unsigned int height = _portSpasing; // maxHorizontalPortsExtent(nodeId); - - if (auto w = _graphModel.nodeData(nodeId, NodeRole::Widget)) { - height = std::max(height, static_cast(w->height())); - } - - QRectF const capRect = captionRect(nodeId); - - height += capRect.height(); - - height += _portSpasing; - height += _portSpasing; - - PortCount nInPorts = _graphModel.nodeData(nodeId, NodeRole::InPortCount); - PortCount nOutPorts = _graphModel.nodeData(nodeId, NodeRole::OutPortCount); - - // Adding double step (top and bottom) to reserve space for port captions. - - height += portCaptionsHeight(nodeId, PortType::In); - height += portCaptionsHeight(nodeId, PortType::Out); - - unsigned int inPortWidth = maxPortsTextAdvance(nodeId, PortType::In); - unsigned int outPortWidth = maxPortsTextAdvance(nodeId, PortType::Out); - - unsigned int totalInPortsWidth = nInPorts > 0 - ? inPortWidth * nInPorts + _portSpasing * (nInPorts - 1) - : 0; - - unsigned int totalOutPortsWidth = nOutPorts > 0 ? outPortWidth * nOutPorts - + _portSpasing * (nOutPorts - 1) - : 0; - - unsigned int width = std::max(totalInPortsWidth, totalOutPortsWidth); - - if (auto w = _graphModel.nodeData(nodeId, NodeRole::Widget)) { - width = std::max(width, static_cast(w->width())); - } - - width = std::max(width, static_cast(capRect.width())); - - width += _portSpasing; - width += _portSpasing; - - QSize size(width, height); - - _graphModel.setNodeData(nodeId, NodeRole::Size, size); -} - -QPointF DefaultVerticalNodeGeometry::portPosition(NodeId const nodeId, - PortType const portType, - PortIndex const portIndex) const -{ - QPointF result; - - QSize size = _graphModel.nodeData(nodeId, NodeRole::Size); - - switch (portType) { - case PortType::In: { - unsigned int inPortWidth = maxPortsTextAdvance(nodeId, PortType::In) + _portSpasing; - - PortCount nInPorts = _graphModel.nodeData(nodeId, NodeRole::InPortCount); - - double x = (size.width() - (nInPorts - 1) * inPortWidth) / 2.0 + portIndex * inPortWidth; - - double y = 0.0; - - result = QPointF(x, y); - - break; - } - - case PortType::Out: { - unsigned int outPortWidth = maxPortsTextAdvance(nodeId, PortType::Out) + _portSpasing; - PortCount nOutPorts = _graphModel.nodeData(nodeId, NodeRole::OutPortCount); - - double x = (size.width() - (nOutPorts - 1) * outPortWidth) / 2.0 + portIndex * outPortWidth; - - double y = size.height(); - - result = QPointF(x, y); - - break; - } - - default: - break; - } - - return result; -} - -QPointF DefaultVerticalNodeGeometry::portTextPosition(NodeId const nodeId, - PortType const portType, - PortIndex const portIndex) const -{ - QPointF p = portPosition(nodeId, portType, portIndex); - - QRectF rect = portTextRect(nodeId, portType, portIndex); - - p.setX(p.x() - rect.width() / 2.0); - - QSize size = _graphModel.nodeData(nodeId, NodeRole::Size); - - switch (portType) { - case PortType::In: - p.setY(5.0 + rect.height()); - break; - - case PortType::Out: - p.setY(size.height() - 5.0); - break; - - default: - break; - } - - return p; -} - -QRectF DefaultVerticalNodeGeometry::captionRect(NodeId const nodeId) const -{ - if (!_graphModel.nodeData(nodeId, NodeRole::CaptionVisible)) - return QRect(); - - QString name = _graphModel.nodeData(nodeId, NodeRole::Caption); - - return _boldFontMetrics.boundingRect(name); -} - -QPointF DefaultVerticalNodeGeometry::captionPosition(NodeId const nodeId) const -{ - QSize size = _graphModel.nodeData(nodeId, NodeRole::Size); - - unsigned int step = portCaptionsHeight(nodeId, PortType::In); - step += _portSpasing; - - auto rect = captionRect(nodeId); - - return QPointF(0.5 * (size.width() - rect.width()), step + rect.height()); -} - -QPointF DefaultVerticalNodeGeometry::widgetPosition(NodeId const nodeId) const -{ - QSize size = _graphModel.nodeData(nodeId, NodeRole::Size); - - unsigned int captionHeight = captionRect(nodeId).height(); - - if (auto w = _graphModel.nodeData(nodeId, NodeRole::Widget)) { - // If the widget wants to use as much vertical space as possible, - // place it immediately after the caption. - if (w->sizePolicy().verticalPolicy() & QSizePolicy::ExpandFlag) { - return QPointF(_portSpasing + maxPortsTextAdvance(nodeId, PortType::In), captionHeight); - } else { - return QPointF(_portSpasing + maxPortsTextAdvance(nodeId, PortType::In), - (captionHeight + size.height() - w->height()) / 2.0); - } - } - return QPointF(); -} - -QRect DefaultVerticalNodeGeometry::resizeHandleRect(NodeId const nodeId) const -{ - QSize size = _graphModel.nodeData(nodeId, NodeRole::Size); - - unsigned int rectSize = 7; - - return QRect(size.width() - rectSize, size.height() - rectSize, rectSize, rectSize); -} - -QRectF DefaultVerticalNodeGeometry::portTextRect(NodeId const nodeId, - PortType const portType, - PortIndex const portIndex) const -{ - QString s; - if (_graphModel.portData(nodeId, portType, portIndex, PortRole::CaptionVisible)) { - s = _graphModel.portData(nodeId, portType, portIndex, PortRole::Caption); - } else { - auto portData = _graphModel.portData(nodeId, portType, portIndex, PortRole::DataType); - - s = portData.value().name; - } - - return _fontMetrics.boundingRect(s); -} - -unsigned int DefaultVerticalNodeGeometry::maxHorizontalPortsExtent(NodeId const nodeId) const -{ - PortCount nInPorts = _graphModel.nodeData(nodeId, NodeRole::InPortCount); - - PortCount nOutPorts = _graphModel.nodeData(nodeId, NodeRole::OutPortCount); - - unsigned int maxNumOfEntries = std::max(nInPorts, nOutPorts); - unsigned int step = _portSize + _portSpasing; - - return step * maxNumOfEntries; -} - -unsigned int DefaultVerticalNodeGeometry::maxPortsTextAdvance(NodeId const nodeId, - PortType const portType) const -{ - unsigned int width = 0; - - size_t const n = _graphModel - .nodeData(nodeId, - (portType == PortType::Out) ? NodeRole::OutPortCount - : NodeRole::InPortCount) - .toUInt(); - - for (PortIndex portIndex = 0ul; portIndex < n; ++portIndex) { - QString name; - - if (_graphModel.portData(nodeId, portType, portIndex, PortRole::CaptionVisible)) { - name = _graphModel.portData(nodeId, portType, portIndex, PortRole::Caption); - } else { - NodeDataType portData = _graphModel.portData(nodeId, - portType, - portIndex, - PortRole::DataType); - - name = portData.name; - } - -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) - width = std::max(unsigned(_fontMetrics.horizontalAdvance(name)), width); -#else - width = std::max(unsigned(_fontMetrics.width(name)), width); -#endif - } - - return width; -} - -unsigned int DefaultVerticalNodeGeometry::portCaptionsHeight(NodeId const nodeId, - PortType const portType) const -{ - unsigned int h = 0; - - switch (portType) { - case PortType::In: { - PortCount nInPorts = _graphModel.nodeData(nodeId, NodeRole::InPortCount); - for (PortIndex i = 0; i < nInPorts; ++i) { - if (_graphModel.portData(nodeId, PortType::In, i, PortRole::CaptionVisible)) { - h += _portSpasing; - break; - } - } - break; - } - - case PortType::Out: { - PortCount nOutPorts = _graphModel.nodeData(nodeId, NodeRole::OutPortCount); - for (PortIndex i = 0; i < nOutPorts; ++i) { - if (_graphModel.portData(nodeId, PortType::Out, i, PortRole::CaptionVisible)) { - h += _portSpasing; - break; - } - } - break; - } - - default: - break; - } - - return h; -} - -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/src/Definitions.cpp b/story-editor-legacy/nodeeditor/src/Definitions.cpp deleted file mode 100644 index dc8baa3..0000000 --- a/story-editor-legacy/nodeeditor/src/Definitions.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "Definitions.hpp" diff --git a/story-editor-legacy/nodeeditor/src/GraphicsView.cpp b/story-editor-legacy/nodeeditor/src/GraphicsView.cpp deleted file mode 100644 index 1ffa8f5..0000000 --- a/story-editor-legacy/nodeeditor/src/GraphicsView.cpp +++ /dev/null @@ -1,405 +0,0 @@ -#include "GraphicsView.hpp" - -#include "BasicGraphicsScene.hpp" -#include "ConnectionGraphicsObject.hpp" -#include "NodeGraphicsObject.hpp" -#include "StyleCollection.hpp" -#include "UndoCommands.hpp" - -#include - -#include -#include - -#include - -#include -#include -#include - -#include -#include - -#include -#include - -using QtNodes::BasicGraphicsScene; -using QtNodes::GraphicsView; - -GraphicsView::GraphicsView(QWidget *parent) - : QGraphicsView(parent) - , _clearSelectionAction(Q_NULLPTR) - , _deleteSelectionAction(Q_NULLPTR) - , _duplicateSelectionAction(Q_NULLPTR) - , _copySelectionAction(Q_NULLPTR) - , _pasteAction(Q_NULLPTR) -{ - setDragMode(QGraphicsView::ScrollHandDrag); - setRenderHint(QPainter::Antialiasing); - - auto const &flowViewStyle = StyleCollection::flowViewStyle(); - - setBackgroundBrush(flowViewStyle.BackgroundColor); - - setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - - setTransformationAnchor(QGraphicsView::AnchorUnderMouse); - - setCacheMode(QGraphicsView::CacheBackground); - setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); - - setScaleRange(0.3, 2); - - // Sets the scene rect to its maximum possible ranges to avoid autu scene range - // re-calculation when expanding the all QGraphicsItems common rect. - int maxSize = 32767; - setSceneRect(-maxSize, -maxSize, (maxSize * 2), (maxSize * 2)); -} - -GraphicsView::GraphicsView(BasicGraphicsScene *scene, QWidget *parent) - : GraphicsView(parent) -{ - setScene(scene); -} - -QAction *GraphicsView::clearSelectionAction() const -{ - return _clearSelectionAction; -} - -QAction *GraphicsView::deleteSelectionAction() const -{ - return _deleteSelectionAction; -} - -void GraphicsView::setScene(BasicGraphicsScene *scene) -{ - QGraphicsView::setScene(scene); - - { - // setup actions - delete _clearSelectionAction; - _clearSelectionAction = new QAction(QStringLiteral("Clear Selection"), this); - _clearSelectionAction->setShortcut(Qt::Key_Escape); - - connect(_clearSelectionAction, &QAction::triggered, scene, &QGraphicsScene::clearSelection); - - addAction(_clearSelectionAction); - } - - { - delete _deleteSelectionAction; - _deleteSelectionAction = new QAction(QStringLiteral("Delete Selection"), this); - _deleteSelectionAction->setShortcutContext(Qt::ShortcutContext::WidgetShortcut); - _deleteSelectionAction->setShortcut(QKeySequence(QKeySequence::Delete)); - connect(_deleteSelectionAction, - &QAction::triggered, - this, - &GraphicsView::onDeleteSelectedObjects); - - addAction(_deleteSelectionAction); - } - - { - delete _duplicateSelectionAction; - _duplicateSelectionAction = new QAction(QStringLiteral("Duplicate Selection"), this); - _duplicateSelectionAction->setShortcutContext(Qt::ShortcutContext::WidgetShortcut); - _duplicateSelectionAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_D)); - connect(_duplicateSelectionAction, - &QAction::triggered, - this, - &GraphicsView::onDuplicateSelectedObjects); - - addAction(_duplicateSelectionAction); - } - - { - delete _copySelectionAction; - _copySelectionAction = new QAction(QStringLiteral("Copy Selection"), this); - _copySelectionAction->setShortcutContext(Qt::ShortcutContext::WidgetShortcut); - _copySelectionAction->setShortcut(QKeySequence(QKeySequence::Copy)); - connect(_copySelectionAction, - &QAction::triggered, - this, - &GraphicsView::onCopySelectedObjects); - - addAction(_copySelectionAction); - } - - { - delete _pasteAction; - _pasteAction = new QAction(QStringLiteral("Copy Selection"), this); - _pasteAction->setShortcutContext(Qt::ShortcutContext::WidgetShortcut); - _pasteAction->setShortcut(QKeySequence(QKeySequence::Paste)); - connect(_pasteAction, &QAction::triggered, this, &GraphicsView::onPasteObjects); - - addAction(_pasteAction); - } - - auto undoAction = scene->undoStack().createUndoAction(this, tr("&Undo")); - undoAction->setShortcuts(QKeySequence::Undo); - addAction(undoAction); - - auto redoAction = scene->undoStack().createRedoAction(this, tr("&Redo")); - redoAction->setShortcuts(QKeySequence::Redo); - addAction(redoAction); -} - -void GraphicsView::centerScene() -{ - if (scene()) { - scene()->setSceneRect(QRectF()); - - QRectF sceneRect = scene()->sceneRect(); - - if (sceneRect.width() > this->rect().width() || sceneRect.height() > this->rect().height()) { - fitInView(sceneRect, Qt::KeepAspectRatio); - } - - centerOn(sceneRect.center()); - } -} - -void GraphicsView::contextMenuEvent(QContextMenuEvent *event) -{ - if (itemAt(event->pos())) { - QGraphicsView::contextMenuEvent(event); - return; - } - - auto const scenePos = mapToScene(event->pos()); - - QMenu *menu = nodeScene()->createSceneMenu(scenePos); - - if (menu) { - menu->exec(event->globalPos()); - } -} - -void GraphicsView::wheelEvent(QWheelEvent *event) -{ - QPoint delta = event->angleDelta(); - - if (delta.y() == 0) { - event->ignore(); - return; - } - - double const d = delta.y() / std::abs(delta.y()); - - if (d > 0.0) - scaleUp(); - else - scaleDown(); -} - -double GraphicsView::getScale() const -{ - return transform().m11(); -} - -void GraphicsView::setScaleRange(double minimum, double maximum) -{ - if (maximum < minimum) - std::swap(minimum, maximum); - minimum = std::max(0.0, minimum); - maximum = std::max(0.0, maximum); - - _scaleRange = {minimum, maximum}; - - setupScale(transform().m11()); -} - -void GraphicsView::setScaleRange(ScaleRange range) -{ - setScaleRange(range.minimum, range.maximum); -} - -void GraphicsView::scaleUp() -{ - double const step = 1.2; - double const factor = std::pow(step, 1.0); - - if (_scaleRange.maximum > 0) { - QTransform t = transform(); - t.scale(factor, factor); - if (t.m11() >= _scaleRange.maximum) { - setupScale(t.m11()); - return; - } - } - - scale(factor, factor); - Q_EMIT scaleChanged(transform().m11()); -} - -void GraphicsView::scaleDown() -{ - double const step = 1.2; - double const factor = std::pow(step, -1.0); - - if (_scaleRange.minimum > 0) { - QTransform t = transform(); - t.scale(factor, factor); - if (t.m11() <= _scaleRange.minimum) { - setupScale(t.m11()); - return; - } - } - - scale(factor, factor); - Q_EMIT scaleChanged(transform().m11()); -} - -void GraphicsView::setupScale(double scale) -{ - scale = std::max(_scaleRange.minimum, std::min(_scaleRange.maximum, scale)); - - if (scale <= 0) - return; - - if (scale == transform().m11()) - return; - - QTransform matrix; - matrix.scale(scale, scale); - setTransform(matrix, false); - - Q_EMIT scaleChanged(scale); -} - -void GraphicsView::onDeleteSelectedObjects() -{ - nodeScene()->undoStack().push(new DeleteCommand(nodeScene())); -} - -void GraphicsView::onDuplicateSelectedObjects() -{ - QPointF const pastePosition = scenePastePosition(); - - nodeScene()->undoStack().push(new CopyCommand(nodeScene())); - nodeScene()->undoStack().push(new PasteCommand(nodeScene(), pastePosition)); -} - -void GraphicsView::onCopySelectedObjects() -{ - nodeScene()->undoStack().push(new CopyCommand(nodeScene())); -} - -void GraphicsView::onPasteObjects() -{ - QPointF const pastePosition = scenePastePosition(); - nodeScene()->undoStack().push(new PasteCommand(nodeScene(), pastePosition)); -} - -void GraphicsView::keyPressEvent(QKeyEvent *event) -{ - switch (event->key()) { - case Qt::Key_Shift: - setDragMode(QGraphicsView::RubberBandDrag); - break; - - default: - break; - } - - QGraphicsView::keyPressEvent(event); -} - -void GraphicsView::keyReleaseEvent(QKeyEvent *event) -{ - switch (event->key()) { - case Qt::Key_Shift: - setDragMode(QGraphicsView::ScrollHandDrag); - break; - - default: - break; - } - QGraphicsView::keyReleaseEvent(event); -} - -void GraphicsView::mousePressEvent(QMouseEvent *event) -{ - QGraphicsView::mousePressEvent(event); - if (event->button() == Qt::LeftButton) { - _clickPos = mapToScene(event->pos()); - } -} - -void GraphicsView::mouseMoveEvent(QMouseEvent *event) -{ - QGraphicsView::mouseMoveEvent(event); - if (scene()->mouseGrabberItem() == nullptr && event->buttons() == Qt::LeftButton) { - // Make sure shift is not being pressed - if ((event->modifiers() & Qt::ShiftModifier) == 0) { - QPointF difference = _clickPos - mapToScene(event->pos()); - setSceneRect(sceneRect().translated(difference.x(), difference.y())); - } - } -} - -void GraphicsView::drawBackground(QPainter *painter, const QRectF &r) -{ - QGraphicsView::drawBackground(painter, r); - - auto drawGrid = [&](double gridStep) { - QRect windowRect = rect(); - QPointF tl = mapToScene(windowRect.topLeft()); - QPointF br = mapToScene(windowRect.bottomRight()); - - double left = std::floor(tl.x() / gridStep - 0.5); - double right = std::floor(br.x() / gridStep + 1.0); - double bottom = std::floor(tl.y() / gridStep - 0.5); - double top = std::floor(br.y() / gridStep + 1.0); - - // vertical lines - for (int xi = int(left); xi <= int(right); ++xi) { - QLineF line(xi * gridStep, bottom * gridStep, xi * gridStep, top * gridStep); - - painter->drawLine(line); - } - - // horizontal lines - for (int yi = int(bottom); yi <= int(top); ++yi) { - QLineF line(left * gridStep, yi * gridStep, right * gridStep, yi * gridStep); - painter->drawLine(line); - } - }; - - auto const &flowViewStyle = StyleCollection::flowViewStyle(); - - QPen pfine(flowViewStyle.FineGridColor, 1.0); - - painter->setPen(pfine); - drawGrid(15); - - QPen p(flowViewStyle.CoarseGridColor, 1.0); - - painter->setPen(p); - drawGrid(150); -} - -void GraphicsView::showEvent(QShowEvent *event) -{ - QGraphicsView::showEvent(event); - - centerScene(); -} - -BasicGraphicsScene *GraphicsView::nodeScene() -{ - return dynamic_cast(scene()); -} - -QPointF GraphicsView::scenePastePosition() -{ - QPoint origin = mapFromGlobal(QCursor::pos()); - - QRect const viewRect = rect(); - if (!viewRect.contains(origin)) - origin = viewRect.center(); - - return mapToScene(origin); -} diff --git a/story-editor-legacy/nodeeditor/src/GraphicsViewStyle.cpp b/story-editor-legacy/nodeeditor/src/GraphicsViewStyle.cpp deleted file mode 100644 index ae02a2c..0000000 --- a/story-editor-legacy/nodeeditor/src/GraphicsViewStyle.cpp +++ /dev/null @@ -1,94 +0,0 @@ -#include "GraphicsViewStyle.hpp" - -#include -#include -#include -#include - -#include "StyleCollection.hpp" - -using QtNodes::GraphicsViewStyle; - -inline void initResources() -{ - Q_INIT_RESOURCE(resources); -} - -GraphicsViewStyle::GraphicsViewStyle() -{ - // Explicit resources inialization for preventing the static initialization - // order fiasco: https://isocpp.org/wiki/faq/ctors#static-init-order - initResources(); - - // This configuration is stored inside the compiled unit and is loaded statically - loadJsonFile(":DefaultStyle.json"); -} - -GraphicsViewStyle::GraphicsViewStyle(QString jsonText) -{ - loadJsonText(jsonText); -} - -void GraphicsViewStyle::setStyle(QString jsonText) -{ - GraphicsViewStyle style(jsonText); - - StyleCollection::setGraphicsViewStyle(style); -} - -#ifdef STYLE_DEBUG -#define FLOW_VIEW_STYLE_CHECK_UNDEFINED_VALUE(v, variable) \ - { \ - if (v.type() == QJsonValue::Undefined || v.type() == QJsonValue::Null) \ - qWarning() << "Undefined value for parameter:" << #variable; \ - } -#else -#define FLOW_VIEW_STYLE_CHECK_UNDEFINED_VALUE(v, variable) -#endif - -#define FLOW_VIEW_STYLE_READ_COLOR(values, variable) \ - { \ - auto valueRef = values[#variable]; \ - FLOW_VIEW_STYLE_CHECK_UNDEFINED_VALUE(valueRef, variable) \ - if (valueRef.isArray()) { \ - auto colorArray = valueRef.toArray(); \ - std::vector rgb; \ - rgb.reserve(3); \ - for (auto it = colorArray.begin(); it != colorArray.end(); ++it) { \ - rgb.push_back((*it).toInt()); \ - } \ - variable = QColor(rgb[0], rgb[1], rgb[2]); \ - } else { \ - variable = QColor(valueRef.toString()); \ - } \ - } - -#define FLOW_VIEW_STYLE_WRITE_COLOR(values, variable) \ - { \ - values[#variable] = variable.name(); \ - } - -void GraphicsViewStyle::loadJson(QJsonObject const &json) -{ - QJsonValue nodeStyleValues = json["GraphicsViewStyle"]; - - QJsonObject obj = nodeStyleValues.toObject(); - - FLOW_VIEW_STYLE_READ_COLOR(obj, BackgroundColor); - FLOW_VIEW_STYLE_READ_COLOR(obj, FineGridColor); - FLOW_VIEW_STYLE_READ_COLOR(obj, CoarseGridColor); -} - -QJsonObject GraphicsViewStyle::toJson() const -{ - QJsonObject obj; - - FLOW_VIEW_STYLE_WRITE_COLOR(obj, BackgroundColor); - FLOW_VIEW_STYLE_WRITE_COLOR(obj, FineGridColor); - FLOW_VIEW_STYLE_WRITE_COLOR(obj, CoarseGridColor); - - QJsonObject root; - root["GraphicsViewStyle"] = obj; - - return root; -} diff --git a/story-editor-legacy/nodeeditor/src/NodeConnectionInteraction.cpp b/story-editor-legacy/nodeeditor/src/NodeConnectionInteraction.cpp deleted file mode 100644 index 9af05fc..0000000 --- a/story-editor-legacy/nodeeditor/src/NodeConnectionInteraction.cpp +++ /dev/null @@ -1,152 +0,0 @@ -#include "NodeConnectionInteraction.hpp" - -#include "AbstractNodeGeometry.hpp" -#include "BasicGraphicsScene.hpp" -#include "ConnectionGraphicsObject.hpp" -#include "ConnectionIdUtils.hpp" -#include "NodeGraphicsObject.hpp" -#include "UndoCommands.hpp" - -#include - -#include - -namespace QtNodes { - -NodeConnectionInteraction::NodeConnectionInteraction(NodeGraphicsObject &ngo, - ConnectionGraphicsObject &cgo, - BasicGraphicsScene &scene) - : _ngo(ngo) - , _cgo(cgo) - , _scene(scene) -{} - -bool NodeConnectionInteraction::canConnect(PortIndex *portIndex) const -{ - // 1. Connection requires a port. - - PortType requiredPort = _cgo.connectionState().requiredPort(); - - if (requiredPort == PortType::None) { - return false; - } - - NodeId connectedNodeId = getNodeId(oppositePort(requiredPort), _cgo.connectionId()); - - // 2. Forbid connecting the node to itself. - - if (_ngo.nodeId() == connectedNodeId) - return false; - - // 3. Connection loose end is above the node port. - - QPointF connectionPoint = _cgo.sceneTransform().map(_cgo.endPoint(requiredPort)); - - *portIndex = nodePortIndexUnderScenePoint(requiredPort, connectionPoint); - - if (*portIndex == InvalidPortIndex) { - return false; - } - - // 4. Model allows connection. - - AbstractGraphModel &model = _ngo.nodeScene()->graphModel(); - - ConnectionId connectionId = makeCompleteConnectionId(_cgo.connectionId(), // incomplete - _ngo.nodeId(), // missing node id - *portIndex); // missing port index - - return model.connectionPossible(connectionId); -} - -bool NodeConnectionInteraction::tryConnect() const -{ - // 1. Check conditions from 'canConnect'. - - PortIndex targetPortIndex = InvalidPortIndex; - if (!canConnect(&targetPortIndex)) { - return false; - } - - // 2. Create new connection. - - ConnectionId incompleteConnectionId = _cgo.connectionId(); - - ConnectionId newConnectionId = makeCompleteConnectionId(incompleteConnectionId, - _ngo.nodeId(), - targetPortIndex); - - _ngo.nodeScene()->resetDraftConnection(); - - _ngo.nodeScene()->undoStack().push(new ConnectCommand(_ngo.nodeScene(), newConnectionId)); - - return true; -} - -bool NodeConnectionInteraction::disconnect(PortType portToDisconnect) const -{ - ConnectionId connectionId = _cgo.connectionId(); - - _scene.undoStack().push(new DisconnectCommand(&_scene, connectionId)); - - AbstractNodeGeometry &geometry = _scene.nodeGeometry(); - - QPointF scenePos = geometry.portScenePosition(_ngo.nodeId(), - portToDisconnect, - getPortIndex(portToDisconnect, connectionId), - _ngo.sceneTransform()); - - // Converted to "draft" connection with the new incomplete id. - ConnectionId incompleteConnectionId = makeIncompleteConnectionId(connectionId, portToDisconnect); - - // Grabs the mouse - auto const &draftConnection = _scene.makeDraftConnection(incompleteConnectionId); - - QPointF const looseEndPos = draftConnection->mapFromScene(scenePos); - draftConnection->setEndPoint(portToDisconnect, looseEndPos); - - // Repaint connection points. - NodeId connectedNodeId = getNodeId(oppositePort(portToDisconnect), connectionId); - _scene.nodeGraphicsObject(connectedNodeId)->update(); - - NodeId disconnectedNodeId = getNodeId(portToDisconnect, connectionId); - _scene.nodeGraphicsObject(disconnectedNodeId)->update(); - - return true; -} - -// ------------------ util functions below - -PortType NodeConnectionInteraction::connectionRequiredPort() const -{ - auto const &state = _cgo.connectionState(); - - return state.requiredPort(); -} - -QPointF NodeConnectionInteraction::nodePortScenePosition(PortType portType, - PortIndex portIndex) const -{ - AbstractNodeGeometry &geometry = _scene.nodeGeometry(); - - QPointF p = geometry.portScenePosition(_ngo.nodeId(), - portType, - portIndex, - _ngo.sceneTransform()); - - return p; -} - -PortIndex NodeConnectionInteraction::nodePortIndexUnderScenePoint(PortType portType, - QPointF const &scenePoint) const -{ - AbstractNodeGeometry &geometry = _scene.nodeGeometry(); - - QTransform sceneTransform = _ngo.sceneTransform(); - - QPointF nodePoint = sceneTransform.inverted().map(scenePoint); - - return geometry.checkPortHit(_ngo.nodeId(), portType, nodePoint); -} - -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/src/NodeDelegateModel.cpp b/story-editor-legacy/nodeeditor/src/NodeDelegateModel.cpp deleted file mode 100644 index 94e47ad..0000000 --- a/story-editor-legacy/nodeeditor/src/NodeDelegateModel.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include "NodeDelegateModel.hpp" - -#include "StyleCollection.hpp" - -namespace QtNodes { - -NodeDelegateModel::NodeDelegateModel() - : _nodeStyle(StyleCollection::nodeStyle()) -{ - // Derived classes can initialize specific style here -} - -QJsonObject NodeDelegateModel::save() const -{ - QJsonObject modelJson; - - modelJson["model-name"] = name(); - - return modelJson; -} - -void NodeDelegateModel::load(QJsonObject const &) -{ - // -} - -ConnectionPolicy NodeDelegateModel::portConnectionPolicy(PortType portType, PortIndex) const -{ - auto result = ConnectionPolicy::One; - switch (portType) { - case PortType::In: - result = ConnectionPolicy::One; - break; - case PortType::Out: - result = ConnectionPolicy::Many; - break; - case PortType::None: - break; - } - - return result; -} - -NodeStyle const &NodeDelegateModel::nodeStyle() const -{ - return _nodeStyle; -} - -void NodeDelegateModel::setNodeStyle(NodeStyle const &style) -{ - _nodeStyle = style; -} - -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/src/NodeDelegateModelRegistry.cpp b/story-editor-legacy/nodeeditor/src/NodeDelegateModelRegistry.cpp deleted file mode 100644 index 11a1f84..0000000 --- a/story-editor-legacy/nodeeditor/src/NodeDelegateModelRegistry.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "NodeDelegateModelRegistry.hpp" - -#include -#include - -using QtNodes::NodeDataType; -using QtNodes::NodeDelegateModel; -using QtNodes::NodeDelegateModelRegistry; - -std::unique_ptr NodeDelegateModelRegistry::create(QString const &modelName) -{ - auto it = _registeredItemCreators.find(modelName); - - if (it != _registeredItemCreators.end()) { - return it->second(); - } - - return nullptr; -} - -NodeDelegateModelRegistry::RegisteredModelCreatorsMap const & -NodeDelegateModelRegistry::registeredModelCreators() const -{ - return _registeredItemCreators; -} - -NodeDelegateModelRegistry::RegisteredModelsCategoryMap const & -NodeDelegateModelRegistry::registeredModelsCategoryAssociation() const -{ - return _registeredModelsCategory; -} - -NodeDelegateModelRegistry::CategoriesSet const &NodeDelegateModelRegistry::categories() const -{ - return _categories; -} diff --git a/story-editor-legacy/nodeeditor/src/NodeGraphicsObject.cpp b/story-editor-legacy/nodeeditor/src/NodeGraphicsObject.cpp deleted file mode 100644 index a25a4aa..0000000 --- a/story-editor-legacy/nodeeditor/src/NodeGraphicsObject.cpp +++ /dev/null @@ -1,364 +0,0 @@ -#include "NodeGraphicsObject.hpp" - -#include -#include - -#include -#include - -#include "AbstractGraphModel.hpp" -#include "AbstractNodeGeometry.hpp" -#include "AbstractNodePainter.hpp" -#include "BasicGraphicsScene.hpp" -#include "ConnectionGraphicsObject.hpp" -#include "ConnectionIdUtils.hpp" -#include "NodeConnectionInteraction.hpp" -#include "StyleCollection.hpp" -#include "UndoCommands.hpp" - -namespace QtNodes { - -NodeGraphicsObject::NodeGraphicsObject(BasicGraphicsScene &scene, NodeId nodeId) - : _nodeId(nodeId) - , _graphModel(scene.graphModel()) - , _nodeState(*this) - , _proxyWidget(nullptr) -{ - scene.addItem(this); - - setFlag(QGraphicsItem::ItemDoesntPropagateOpacityToChildren, true); - setFlag(QGraphicsItem::ItemIsFocusable, true); - - setLockedState(); - - setCacheMode(QGraphicsItem::DeviceCoordinateCache); - - QJsonObject nodeStyleJson = _graphModel.nodeData(_nodeId, NodeRole::Style).toJsonObject(); - - NodeStyle nodeStyle(nodeStyleJson); - - if (scene.isDropShadowEffectEnabled()) - { - auto effect = new QGraphicsDropShadowEffect; - effect->setOffset(4, 4); - effect->setBlurRadius(20); - effect->setColor(nodeStyle.ShadowColor); - - setGraphicsEffect(effect); - } - - setOpacity(nodeStyle.Opacity); - - setAcceptHoverEvents(true); - - setZValue(0); - - embedQWidget(); - - nodeScene()->nodeGeometry().recomputeSize(_nodeId); - - QPointF const pos = _graphModel.nodeData(_nodeId, NodeRole::Position); - - setPos(pos); - - connect(&_graphModel, &AbstractGraphModel::nodeFlagsUpdated, [this](NodeId const nodeId) { - if (_nodeId == nodeId) - setLockedState(); - }); -} - -AbstractGraphModel &NodeGraphicsObject::graphModel() const -{ - return _graphModel; -} - -BasicGraphicsScene *NodeGraphicsObject::nodeScene() const -{ - return dynamic_cast(scene()); -} - -void NodeGraphicsObject::embedQWidget() -{ - AbstractNodeGeometry &geometry = nodeScene()->nodeGeometry(); - geometry.recomputeSize(_nodeId); - - if (auto w = _graphModel.nodeData(_nodeId, NodeRole::Widget).value()) { - _proxyWidget = new QGraphicsProxyWidget(this); - - _proxyWidget->setWidget(w); - - _proxyWidget->setPreferredWidth(5); - - geometry.recomputeSize(_nodeId); - - if (w->sizePolicy().verticalPolicy() & QSizePolicy::ExpandFlag) { - unsigned int widgetHeight = geometry.size(_nodeId).height() - - geometry.captionRect(_nodeId).height(); - - // If the widget wants to use as much vertical space as possible, set - // it to have the geom's equivalentWidgetHeight. - _proxyWidget->setMinimumHeight(widgetHeight); - } - - _proxyWidget->setPos(geometry.widgetPosition(_nodeId)); - - //update(); - - _proxyWidget->setOpacity(1.0); - _proxyWidget->setFlag(QGraphicsItem::ItemIgnoresParentOpacity); - } -} - -void NodeGraphicsObject::setLockedState() -{ - NodeFlags flags = _graphModel.nodeFlags(_nodeId); - - bool const locked = flags.testFlag(NodeFlag::Locked); - - setFlag(QGraphicsItem::ItemIsMovable, !locked); - setFlag(QGraphicsItem::ItemIsSelectable, !locked); - setFlag(QGraphicsItem::ItemSendsScenePositionChanges, !locked); -} - -QRectF NodeGraphicsObject::boundingRect() const -{ - AbstractNodeGeometry &geometry = nodeScene()->nodeGeometry(); - return geometry.boundingRect(_nodeId); - //return NodeGeometry(_nodeId, _graphModel, nodeScene()).boundingRect(); -} - -void NodeGraphicsObject::setGeometryChanged() -{ - prepareGeometryChange(); -} - -void NodeGraphicsObject::moveConnections() const -{ - auto const &connected = _graphModel.allConnectionIds(_nodeId); - - for (auto &cnId : connected) { - auto cgo = nodeScene()->connectionGraphicsObject(cnId); - - if (cgo) - cgo->move(); - } -} - -void NodeGraphicsObject::reactToConnection(ConnectionGraphicsObject const *cgo) -{ - _nodeState.storeConnectionForReaction(cgo); - - update(); -} - -void NodeGraphicsObject::paint(QPainter *painter, QStyleOptionGraphicsItem const *option, QWidget *) -{ - painter->setClipRect(option->exposedRect); - - nodeScene()->nodePainter().paint(painter, *this); -} - -QVariant NodeGraphicsObject::itemChange(GraphicsItemChange change, const QVariant &value) -{ - if (change == ItemScenePositionHasChanged && scene()) { - moveConnections(); - } - - return QGraphicsObject::itemChange(change, value); -} - -void NodeGraphicsObject::mousePressEvent(QGraphicsSceneMouseEvent *event) -{ - //if (_nodeState.locked()) - //return; - - AbstractNodeGeometry &geometry = nodeScene()->nodeGeometry(); - - for (PortType portToCheck : {PortType::In, PortType::Out}) { - QPointF nodeCoord = sceneTransform().inverted().map(event->scenePos()); - - PortIndex const portIndex = geometry.checkPortHit(_nodeId, portToCheck, nodeCoord); - - if (portIndex == InvalidPortIndex) - continue; - - auto const &connected = _graphModel.connections(_nodeId, portToCheck, portIndex); - - // Start dragging existing connection. - if (!connected.empty() && portToCheck == PortType::In) { - auto const &cnId = *connected.begin(); - - // Need ConnectionGraphicsObject - - NodeConnectionInteraction interaction(*this, - *nodeScene()->connectionGraphicsObject(cnId), - *nodeScene()); - - if (_graphModel.detachPossible(cnId)) - interaction.disconnect(portToCheck); - } else // initialize new Connection - { - if (portToCheck == PortType::Out) { - auto const outPolicy = _graphModel - .portData(_nodeId, - portToCheck, - portIndex, - PortRole::ConnectionPolicyRole) - .value(); - - if (!connected.empty() && outPolicy == ConnectionPolicy::One) { - for (auto &cnId : connected) { - _graphModel.deleteConnection(cnId); - } - } - } // if port == out - - ConnectionId const incompleteConnectionId = makeIncompleteConnectionId(_nodeId, - portToCheck, - portIndex); - - nodeScene()->makeDraftConnection(incompleteConnectionId); - } - } - - if (_graphModel.nodeFlags(_nodeId) & NodeFlag::Resizable) { - auto pos = event->pos(); - bool const hit = geometry.resizeHandleRect(_nodeId).contains(QPoint(pos.x(), pos.y())); - _nodeState.setResizing(hit); - } - - QGraphicsObject::mousePressEvent(event); - - if (isSelected()) { - Q_EMIT nodeScene()->nodeSelected(_nodeId); - } -} - -void NodeGraphicsObject::mouseMoveEvent(QGraphicsSceneMouseEvent *event) -{ - // Deselect all other items after this one is selected. - // Unless we press a CTRL button to add the item to the selected group before - // starting moving. - if (!isSelected()) { - if (!event->modifiers().testFlag(Qt::ControlModifier)) - scene()->clearSelection(); - - setSelected(true); - } - - if (_nodeState.resizing()) { - auto diff = event->pos() - event->lastPos(); - - if (auto w = _graphModel.nodeData(_nodeId, NodeRole::Widget)) { - prepareGeometryChange(); - - auto oldSize = w->size(); - - oldSize += QSize(diff.x(), diff.y()); - - w->resize(oldSize); - - AbstractNodeGeometry &geometry = nodeScene()->nodeGeometry(); - - // Passes the new size to the model. - geometry.recomputeSize(_nodeId); - - update(); - - moveConnections(); - - event->accept(); - } - } else { - auto diff = event->pos() - event->lastPos(); - - nodeScene()->undoStack().push(new MoveNodeCommand(nodeScene(), diff)); - - event->accept(); - } - - QRectF r = nodeScene()->sceneRect(); - - r = r.united(mapToScene(boundingRect()).boundingRect()); - - nodeScene()->setSceneRect(r); -} - -void NodeGraphicsObject::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - _nodeState.setResizing(false); - - QGraphicsObject::mouseReleaseEvent(event); - - // position connections precisely after fast node move - moveConnections(); - - nodeScene()->nodeClicked(_nodeId); -} - -void NodeGraphicsObject::hoverEnterEvent(QGraphicsSceneHoverEvent *event) -{ - // bring all the colliding nodes to background - QList overlapItems = collidingItems(); - - for (QGraphicsItem *item : overlapItems) { - if (item->zValue() > 0.0) { - item->setZValue(0.0); - } - } - - // bring this node forward - setZValue(1.0); - - _nodeState.setHovered(true); - - update(); - - Q_EMIT nodeScene()->nodeHovered(_nodeId, event->screenPos()); - - event->accept(); -} - -void NodeGraphicsObject::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) -{ - _nodeState.setHovered(false); - - setZValue(0.0); - - update(); - - Q_EMIT nodeScene()->nodeHoverLeft(_nodeId); - - event->accept(); -} - -void NodeGraphicsObject::hoverMoveEvent(QGraphicsSceneHoverEvent *event) -{ - auto pos = event->pos(); - - //NodeGeometry geometry(_nodeId, _graphModel, nodeScene()); - AbstractNodeGeometry &geometry = nodeScene()->nodeGeometry(); - - if ((_graphModel.nodeFlags(_nodeId) | NodeFlag::Resizable) - && geometry.resizeHandleRect(_nodeId).contains(QPoint(pos.x(), pos.y()))) { - setCursor(QCursor(Qt::SizeFDiagCursor)); - } else { - setCursor(QCursor()); - } - - event->accept(); -} - -void NodeGraphicsObject::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) -{ - QGraphicsItem::mouseDoubleClickEvent(event); - - Q_EMIT nodeScene()->nodeDoubleClicked(_nodeId); -} - -void NodeGraphicsObject::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -{ - Q_EMIT nodeScene()->nodeContextMenu(_nodeId, mapToScene(event->pos())); -} - -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/src/NodeState.cpp b/story-editor-legacy/nodeeditor/src/NodeState.cpp deleted file mode 100644 index f6ed43e..0000000 --- a/story-editor-legacy/nodeeditor/src/NodeState.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "NodeState.hpp" - -#include "ConnectionGraphicsObject.hpp" -#include "NodeGraphicsObject.hpp" - -namespace QtNodes { - -NodeState::NodeState(NodeGraphicsObject &ngo) - : _ngo(ngo) - , _hovered(false) - , _resizing(false) - , _connectionForReaction{nullptr} -{ - Q_UNUSED(_ngo); -} - -void NodeState::setResizing(bool resizing) -{ - _resizing = resizing; -} - -bool NodeState::resizing() const -{ - return _resizing; -} - -ConnectionGraphicsObject const *NodeState::connectionForReaction() const -{ - return _connectionForReaction.data(); -} - -void NodeState::storeConnectionForReaction(ConnectionGraphicsObject const *cgo) -{ - _connectionForReaction = cgo; -} - -void NodeState::resetConnectionForReaction() -{ - _connectionForReaction.clear(); -} - -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/src/NodeStyle.cpp b/story-editor-legacy/nodeeditor/src/NodeStyle.cpp deleted file mode 100644 index a82bf8f..0000000 --- a/story-editor-legacy/nodeeditor/src/NodeStyle.cpp +++ /dev/null @@ -1,146 +0,0 @@ -#include "NodeStyle.hpp" - -#include - -#include -#include -#include - -#include - -#include "StyleCollection.hpp" - -using QtNodes::NodeStyle; - -inline void initResources() -{ - Q_INIT_RESOURCE(resources); -} - -NodeStyle::NodeStyle() -{ - // Explicit resources inialization for preventing the static initialization - // order fiasco: https://isocpp.org/wiki/faq/ctors#static-init-order - initResources(); - - // This configuration is stored inside the compiled unit and is loaded statically - loadJsonFile(":DefaultStyle.json"); -} - -NodeStyle::NodeStyle(QString jsonText) -{ - loadJsonText(jsonText); -} - -NodeStyle::NodeStyle(QJsonObject const &json) -{ - loadJson(json); -} - -void NodeStyle::setNodeStyle(QString jsonText) -{ - NodeStyle style(jsonText); - - StyleCollection::setNodeStyle(style); -} - -#ifdef STYLE_DEBUG -#define NODE_STYLE_CHECK_UNDEFINED_VALUE(v, variable) \ - { \ - if (v.type() == QJsonValue::Undefined || v.type() == QJsonValue::Null) \ - qWarning() << "Undefined value for parameter:" << #variable; \ - } -#else -#define NODE_STYLE_CHECK_UNDEFINED_VALUE(v, variable) -#endif - -#define NODE_STYLE_READ_COLOR(values, variable) \ - { \ - auto valueRef = values[#variable]; \ - NODE_STYLE_CHECK_UNDEFINED_VALUE(valueRef, variable) \ - if (valueRef.isArray()) { \ - auto colorArray = valueRef.toArray(); \ - std::vector rgb; \ - rgb.reserve(3); \ - for (auto it = colorArray.begin(); it != colorArray.end(); ++it) { \ - rgb.push_back((*it).toInt()); \ - } \ - variable = QColor(rgb[0], rgb[1], rgb[2]); \ - } else { \ - variable = QColor(valueRef.toString()); \ - } \ - } - -#define NODE_STYLE_WRITE_COLOR(values, variable) \ - { \ - values[#variable] = variable.name(); \ - } - -#define NODE_STYLE_READ_FLOAT(values, variable) \ - { \ - auto valueRef = values[#variable]; \ - NODE_STYLE_CHECK_UNDEFINED_VALUE(valueRef, variable) \ - variable = valueRef.toDouble(); \ - } - -#define NODE_STYLE_WRITE_FLOAT(values, variable) \ - { \ - values[#variable] = variable; \ - } - -void NodeStyle::loadJson(QJsonObject const &json) -{ - QJsonValue nodeStyleValues = json["NodeStyle"]; - - QJsonObject obj = nodeStyleValues.toObject(); - - NODE_STYLE_READ_COLOR(obj, NormalBoundaryColor); - NODE_STYLE_READ_COLOR(obj, SelectedBoundaryColor); - NODE_STYLE_READ_COLOR(obj, GradientColor0); - NODE_STYLE_READ_COLOR(obj, GradientColor1); - NODE_STYLE_READ_COLOR(obj, GradientColor2); - NODE_STYLE_READ_COLOR(obj, GradientColor3); - NODE_STYLE_READ_COLOR(obj, ShadowColor); - NODE_STYLE_READ_COLOR(obj, FontColor); - NODE_STYLE_READ_COLOR(obj, FontColorFaded); - NODE_STYLE_READ_COLOR(obj, ConnectionPointColor); - NODE_STYLE_READ_COLOR(obj, FilledConnectionPointColor); - NODE_STYLE_READ_COLOR(obj, WarningColor); - NODE_STYLE_READ_COLOR(obj, ErrorColor); - - NODE_STYLE_READ_FLOAT(obj, PenWidth); - NODE_STYLE_READ_FLOAT(obj, HoveredPenWidth); - NODE_STYLE_READ_FLOAT(obj, ConnectionPointDiameter); - - NODE_STYLE_READ_FLOAT(obj, Opacity); -} - -QJsonObject NodeStyle::toJson() const -{ - QJsonObject obj; - - NODE_STYLE_WRITE_COLOR(obj, NormalBoundaryColor); - NODE_STYLE_WRITE_COLOR(obj, SelectedBoundaryColor); - NODE_STYLE_WRITE_COLOR(obj, GradientColor0); - NODE_STYLE_WRITE_COLOR(obj, GradientColor1); - NODE_STYLE_WRITE_COLOR(obj, GradientColor2); - NODE_STYLE_WRITE_COLOR(obj, GradientColor3); - NODE_STYLE_WRITE_COLOR(obj, ShadowColor); - NODE_STYLE_WRITE_COLOR(obj, FontColor); - NODE_STYLE_WRITE_COLOR(obj, FontColorFaded); - NODE_STYLE_WRITE_COLOR(obj, ConnectionPointColor); - NODE_STYLE_WRITE_COLOR(obj, FilledConnectionPointColor); - NODE_STYLE_WRITE_COLOR(obj, WarningColor); - NODE_STYLE_WRITE_COLOR(obj, ErrorColor); - - NODE_STYLE_WRITE_FLOAT(obj, PenWidth); - NODE_STYLE_WRITE_FLOAT(obj, HoveredPenWidth); - NODE_STYLE_WRITE_FLOAT(obj, ConnectionPointDiameter); - - NODE_STYLE_WRITE_FLOAT(obj, Opacity); - - QJsonObject root; - root["NodeStyle"] = obj; - - return root; -} diff --git a/story-editor-legacy/nodeeditor/src/StyleCollection.cpp b/story-editor-legacy/nodeeditor/src/StyleCollection.cpp deleted file mode 100644 index c695728..0000000 --- a/story-editor-legacy/nodeeditor/src/StyleCollection.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include "StyleCollection.hpp" - -using QtNodes::ConnectionStyle; -using QtNodes::GraphicsViewStyle; -using QtNodes::NodeStyle; -using QtNodes::StyleCollection; - -NodeStyle const &StyleCollection::nodeStyle() -{ - return instance()._nodeStyle; -} - -ConnectionStyle const &StyleCollection::connectionStyle() -{ - return instance()._connectionStyle; -} - -GraphicsViewStyle const &StyleCollection::flowViewStyle() -{ - return instance()._flowViewStyle; -} - -void StyleCollection::setNodeStyle(NodeStyle nodeStyle) -{ - instance()._nodeStyle = nodeStyle; -} - -void StyleCollection::setConnectionStyle(ConnectionStyle connectionStyle) -{ - instance()._connectionStyle = connectionStyle; -} - -void StyleCollection::setGraphicsViewStyle(GraphicsViewStyle flowViewStyle) -{ - instance()._flowViewStyle = flowViewStyle; -} - -StyleCollection &StyleCollection::instance() -{ - static StyleCollection collection; - - return collection; -} diff --git a/story-editor-legacy/nodeeditor/src/UndoCommands.cpp b/story-editor-legacy/nodeeditor/src/UndoCommands.cpp deleted file mode 100644 index ea92812..0000000 --- a/story-editor-legacy/nodeeditor/src/UndoCommands.cpp +++ /dev/null @@ -1,464 +0,0 @@ -#include "UndoCommands.hpp" - -#include "BasicGraphicsScene.hpp" -#include "ConnectionGraphicsObject.hpp" -#include "ConnectionIdUtils.hpp" -#include "Definitions.hpp" -#include "NodeGraphicsObject.hpp" - -#include -#include -#include -#include -#include -#include - -#include - -namespace QtNodes { - -static QJsonObject serializeSelectedItems(BasicGraphicsScene *scene) -{ - QJsonObject serializedScene; - std::unordered_set selectedNodes; - - QJsonArray nodesJsonArray; - - for (QGraphicsItem *item : scene->selectedItems()) { - if (auto n = qgraphicsitem_cast(item)) { - - QJsonObject obj; - obj["id"] = static_cast(n->nodeId()); - nodesJsonArray.append(obj); - - selectedNodes.insert(n->nodeId()); - } - } - - QJsonArray connJsonArray; - - for (QGraphicsItem *item : scene->selectedItems()) { - if (auto c = qgraphicsitem_cast(item)) { - auto const &cid = c->connectionId(); - - if (selectedNodes.count(cid.outNodeId) > 0 && selectedNodes.count(cid.inNodeId) > 0) { - connJsonArray.append(toJson(cid)); - } - } - } - - serializedScene["nodes"] = nodesJsonArray; - serializedScene["connections"] = connJsonArray; - - return serializedScene; -} - -static void insertSerializedItems(QJsonObject const &json, BasicGraphicsScene *scene) -{ - AbstractGraphModel &graphModel = scene->graphModel(); - - QJsonArray const &nodesJsonArray = json["nodes"].toArray(); - - for (QJsonValue node : nodesJsonArray) { - QJsonObject obj = node.toObject(); - - graphModel.loadNode(obj); - - auto id = obj["id"].toInt(); - scene->nodeGraphicsObject(id)->setZValue(1.0); - scene->nodeGraphicsObject(id)->setSelected(true); - } - - QJsonArray const &connJsonArray = json["connections"].toArray(); - - for (QJsonValue connection : connJsonArray) { - QJsonObject connJson = connection.toObject(); - - ConnectionId connId = fromJson(connJson); - - // Restore the connection - graphModel.addConnection(connId); - - scene->connectionGraphicsObject(connId)->setSelected(true); - } -} - -static void deleteSerializedItems(QJsonObject &sceneJson, AbstractGraphModel &graphModel) -{ - QJsonArray connectionJsonArray = sceneJson["connections"].toArray(); - - for (QJsonValueRef connection : connectionJsonArray) { - QJsonObject connJson = connection.toObject(); - - ConnectionId connId = fromJson(connJson); - - graphModel.deleteConnection(connId); - } - - QJsonArray nodesJsonArray = sceneJson["nodes"].toArray(); - - for (QJsonValueRef node : nodesJsonArray) { - QJsonObject nodeJson = node.toObject(); - graphModel.deleteNode(nodeJson["id"].toInt()); - } -} - -static QPointF computeAverageNodePosition(QJsonObject const &sceneJson) -{ - QPointF averagePos(0, 0); - - QJsonArray nodesJsonArray = sceneJson["nodes"].toArray(); - - for (QJsonValueRef node : nodesJsonArray) { - QJsonObject nodeJson = node.toObject(); - - averagePos += QPointF(nodeJson["position"].toObject()["x"].toDouble(), - nodeJson["position"].toObject()["y"].toDouble()); - } - - averagePos /= static_cast(nodesJsonArray.size()); - - return averagePos; -} - -//------------------------------------- - -CreateCommand::CreateCommand(BasicGraphicsScene *scene, - QString const name, - QPointF const &mouseScenePos) - : _scene(scene) - , _sceneJson(QJsonObject()) -{ - _nodeId = _scene->graphModel().addNode(name); - if (_nodeId != InvalidNodeId) { - _scene->graphModel().setNodeData(_nodeId, NodeRole::Position, mouseScenePos); - } else { - setObsolete(true); - } -} - -void CreateCommand::undo() -{ - QJsonArray nodesJsonArray; - QJsonObject obj; - obj["id"] = static_cast(_scene->graphModel().nodeData(_nodeId, NodeRole::Id).toInt()); - nodesJsonArray.append(obj); - _sceneJson["nodes"] = nodesJsonArray; - _scene->graphModel().deleteNode(_nodeId); -} - -void CreateCommand::redo() -{ - if (_sceneJson.empty() || _sceneJson["nodes"].toArray().empty()) - return; - - insertSerializedItems(_sceneJson, _scene); -} - -//------------------------------------- - -DeleteCommand::DeleteCommand(BasicGraphicsScene *scene) - : _scene(scene) -{ - auto &graphModel = _scene->graphModel(); - - QJsonArray connJsonArray; - // Delete the selected connections first, ensuring that they won't be - // automatically deleted when selected nodes are deleted (deleting a - // node deletes some connections as well) - for (QGraphicsItem *item : _scene->selectedItems()) { - if (auto c = qgraphicsitem_cast(item)) { - auto const &cid = c->connectionId(); - - connJsonArray.append(toJson(cid)); - } - } - - QJsonArray nodesJsonArray; - // Delete the nodes; this will delete many of the connections. - // Selected connections were already deleted prior to this loop, - for (QGraphicsItem *item : _scene->selectedItems()) { - if (auto n = qgraphicsitem_cast(item)) { - // saving connections attached to the selected nodes - for (auto const &cid : graphModel.allConnectionIds(n->nodeId())) { - connJsonArray.append(toJson(cid)); - } - QJsonObject obj; - obj["id"] = static_cast(n->nodeId()); - nodesJsonArray.append(obj); - } - } - - // If nothing is deleted, cancel this operation - if (connJsonArray.isEmpty() && nodesJsonArray.isEmpty()) - setObsolete(true); - - _sceneJson["nodes"] = nodesJsonArray; - _sceneJson["connections"] = connJsonArray; -} - -void DeleteCommand::undo() -{ - insertSerializedItems(_sceneJson, _scene); -} - -void DeleteCommand::redo() -{ - deleteSerializedItems(_sceneJson, _scene->graphModel()); -} - -//------------------------------------- - -void offsetNodeGroup(QJsonObject &sceneJson, QPointF const &diff) -{ - QJsonArray nodesJsonArray = sceneJson["nodes"].toArray(); - - QJsonArray newNodesJsonArray; - for (QJsonValueRef node : nodesJsonArray) { - QJsonObject obj = node.toObject(); - - QPointF oldPos(obj["position"].toObject()["x"].toDouble(), - obj["position"].toObject()["y"].toDouble()); - - oldPos += diff; - - QJsonObject posJson; - posJson["x"] = oldPos.x(); - posJson["y"] = oldPos.y(); - obj["position"] = posJson; - - newNodesJsonArray.append(obj); - } - - sceneJson["nodes"] = newNodesJsonArray; -} - -//------------------------------------- - -CopyCommand::CopyCommand(BasicGraphicsScene *scene) -{ - QJsonObject sceneJson = serializeSelectedItems(scene); - - if (sceneJson.empty() || sceneJson["nodes"].toArray().empty()) { - setObsolete(true); - return; - } - - QClipboard *clipboard = QApplication::clipboard(); - - QByteArray const data = QJsonDocument(sceneJson).toJson(); - - QMimeData *mimeData = new QMimeData(); - mimeData->setData("application/qt-nodes-graph", data); - mimeData->setText(data); - - clipboard->setMimeData(mimeData); - - // Copy command does not have any effective redo/undo operations. - // It copies the data to the clipboard and could be immediately removed - // from the stack. - setObsolete(true); -} - -//------------------------------------- - -PasteCommand::PasteCommand(BasicGraphicsScene *scene, QPointF const &mouseScenePos) - : _scene(scene) - , _mouseScenePos(mouseScenePos) -{ - _newSceneJson = takeSceneJsonFromClipboard(); - - if (_newSceneJson.empty() || _newSceneJson["nodes"].toArray().empty()) { - setObsolete(true); - return; - } - - _newSceneJson = makeNewNodeIdsInScene(_newSceneJson); - - QPointF averagePos = computeAverageNodePosition(_newSceneJson); - - offsetNodeGroup(_newSceneJson, _mouseScenePos - averagePos); -} - -void PasteCommand::undo() -{ - deleteSerializedItems(_newSceneJson, _scene->graphModel()); -} - -void PasteCommand::redo() -{ - _scene->clearSelection(); - - // Ignore if pasted in content does not generate nodes. - try { - insertSerializedItems(_newSceneJson, _scene); - } catch (...) { - // If the paste does not work, delete all selected nodes and connections - // `deleteNode(...)` implicitly removed connections - auto &graphModel = _scene->graphModel(); - - QJsonArray nodesJsonArray; - for (QGraphicsItem *item : _scene->selectedItems()) { - if (auto n = qgraphicsitem_cast(item)) { - graphModel.deleteNode(n->nodeId()); - } - } - - setObsolete(true); - } -} - -QJsonObject PasteCommand::takeSceneJsonFromClipboard() -{ - QClipboard const *clipboard = QApplication::clipboard(); - QMimeData const *mimeData = clipboard->mimeData(); - - QJsonDocument json; - if (mimeData->hasFormat("application/qt-nodes-graph")) { - json = QJsonDocument::fromJson(mimeData->data("application/qt-nodes-graph")); - } else if (mimeData->hasText()) { - json = QJsonDocument::fromJson(mimeData->text().toUtf8()); - } - - return json.object(); -} - -QJsonObject PasteCommand::makeNewNodeIdsInScene(QJsonObject const &sceneJson) -{ - AbstractGraphModel &graphModel = _scene->graphModel(); - - std::unordered_map mapNodeIds; - - QJsonArray nodesJsonArray = sceneJson["nodes"].toArray(); - - QJsonArray newNodesJsonArray; - for (QJsonValueRef node : nodesJsonArray) { - QJsonObject nodeJson = node.toObject(); - - NodeId oldNodeId = nodeJson["id"].toInt(); - - NodeId newNodeId = graphModel.newNodeId(); - - mapNodeIds[oldNodeId] = newNodeId; - - // Replace NodeId in json - nodeJson["id"] = static_cast(newNodeId); - - newNodesJsonArray.append(nodeJson); - } - - QJsonArray connectionJsonArray = sceneJson["connections"].toArray(); - - QJsonArray newConnJsonArray; - for (QJsonValueRef connection : connectionJsonArray) { - QJsonObject connJson = connection.toObject(); - - ConnectionId connId = fromJson(connJson); - - ConnectionId newConnId{mapNodeIds[connId.outNodeId], - connId.outPortIndex, - mapNodeIds[connId.inNodeId], - connId.inPortIndex}; - - newConnJsonArray.append(toJson(newConnId)); - } - - QJsonObject newSceneJson; - - newSceneJson["nodes"] = newNodesJsonArray; - newSceneJson["connections"] = newConnJsonArray; - - return newSceneJson; -} - -//------------------------------------- - -DisconnectCommand::DisconnectCommand(BasicGraphicsScene *scene, ConnectionId const connId) - : _scene(scene) - , _connId(connId) -{ - // -} - -void DisconnectCommand::undo() -{ - _scene->graphModel().addConnection(_connId); -} - -void DisconnectCommand::redo() -{ - _scene->graphModel().deleteConnection(_connId); -} - -//------ - -ConnectCommand::ConnectCommand(BasicGraphicsScene *scene, ConnectionId const connId) - : _scene(scene) - , _connId(connId) -{ - // -} - -void ConnectCommand::undo() -{ - _scene->graphModel().deleteConnection(_connId); -} - -void ConnectCommand::redo() -{ - _scene->graphModel().addConnection(_connId); -} - -//------ - -MoveNodeCommand::MoveNodeCommand(BasicGraphicsScene *scene, QPointF const &diff) - : _scene(scene) - , _diff(diff) -{ - _selectedNodes.clear(); - for (QGraphicsItem *item : _scene->selectedItems()) { - if (auto n = qgraphicsitem_cast(item)) { - _selectedNodes.insert(n->nodeId()); - } - } -} - -void MoveNodeCommand::undo() -{ - for (auto nodeId : _selectedNodes) { - auto oldPos = _scene->graphModel().nodeData(nodeId, NodeRole::Position).value(); - - oldPos -= _diff; - - _scene->graphModel().setNodeData(nodeId, NodeRole::Position, oldPos); - } -} - -void MoveNodeCommand::redo() -{ - for (auto nodeId : _selectedNodes) { - auto oldPos = _scene->graphModel().nodeData(nodeId, NodeRole::Position).value(); - - oldPos += _diff; - - _scene->graphModel().setNodeData(nodeId, NodeRole::Position, oldPos); - } -} - -int MoveNodeCommand::id() const -{ - return static_cast(typeid(MoveNodeCommand).hash_code()); -} - -bool MoveNodeCommand::mergeWith(QUndoCommand const *c) -{ - auto mc = static_cast(c); - - if (_selectedNodes == mc->_selectedNodes) { - _diff += mc->_diff; - return true; - } - return false; -} - -} // namespace QtNodes diff --git a/story-editor-legacy/nodeeditor/src/locateNode.cpp b/story-editor-legacy/nodeeditor/src/locateNode.cpp deleted file mode 100644 index ddba099..0000000 --- a/story-editor-legacy/nodeeditor/src/locateNode.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "locateNode.hpp" - -#include - -#include -#include - -#include "NodeGraphicsObject.hpp" - -namespace QtNodes { - -NodeGraphicsObject *locateNodeAt(QPointF scenePoint, - QGraphicsScene &scene, - QTransform const &viewTransform) -{ - // items under cursor - QList items = scene.items(scenePoint, - Qt::IntersectsItemShape, - Qt::DescendingOrder, - viewTransform); - - // items convertable to NodeGraphicsObject - std::vector filteredItems; - - std::copy_if(items.begin(), - items.end(), - std::back_inserter(filteredItems), - [](QGraphicsItem *item) { - return (qgraphicsitem_cast(item) != nullptr); - }); - - NodeGraphicsObject *node = nullptr; - - if (!filteredItems.empty()) { - QGraphicsItem *graphicsItem = filteredItems.front(); - node = dynamic_cast(graphicsItem); - } - - return node; -} - -} // namespace QtNodes diff --git a/story-editor-legacy/nsis-installer.nsi b/story-editor-legacy/nsis-installer.nsi deleted file mode 100644 index 7330313..0000000 --- a/story-editor-legacy/nsis-installer.nsi +++ /dev/null @@ -1,53 +0,0 @@ -# define installer name -!define APPNAME "StoryEditor" -!define COMPANYNAME "OpenStoryTeller" -!define DESCRIPTION "A story editor using graphical nodes, for the OpenStoryTeller project. http://openstoryteller.org" - -!define VERSIONMAJOR 1 -!define VERSIONMINOR 3 -!define VERSIONBUILD 4 -OutFile "build/story-editor-setup.exe" - -# set desktop as install directory -InstallDir "$PROGRAMFILES64\${APPNAME}" -Name "${COMPANYNAME} - ${APPNAME}" - -# default section start -Section - -# define output path -SetOutPath $INSTDIR - -# specify file to go in output path -File /r "build/story-editor\*" -File "story-editor-logo.ico" - -# define uninstaller name -WriteUninstaller $INSTDIR\uninstaller.exe - -# Create shortcut -SetShellVarContext all -CreateDirectory "$SMPROGRAMS\${COMPANYNAME}" -CreateShortCut "$SMPROGRAMS\${COMPANYNAME}\${APPNAME}.lnk" "$INSTDIR\story-editor.exe" "" "$INSTDIR\story-editor-logo.ico" -SetShellVarContext current - - -#------- -# default section end -SectionEnd - -# create a section to define what the uninstaller does. -# the section will always be named "Uninstall" -Section "Uninstall" - -# Always delete uninstaller first -Delete $INSTDIR\uninstaller.exe -Delete "$SMPROGRAMS\${COMPANYNAME}\${APPNAME}.lnk" -Delete $INSTDIR\story-editor-logo.ico - -# now delete installed file -Delete $INSTDIR\* - -# Delete the directory -RMDir /r $INSTDIR -SectionEnd diff --git a/story-editor-legacy/ost_convert/CMakeLists.txt b/story-editor-legacy/ost_convert/CMakeLists.txt deleted file mode 100644 index eb91a3a..0000000 --- a/story-editor-legacy/ost_convert/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -cmake_minimum_required(VERSION 3.5) - -set(PROJECT_NAME ost-convert) -project(${PROJECT_NAME} LANGUAGES CXX C) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -#========================================================================================================================= -# INCLUDES -#========================================================================================================================= -set(OST_CONVERT_ROOT ${CMAKE_CURRENT_SOURCE_DIR}) -set(OST_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/..) - -set(OST_CONVERT_INCLUDES - ${OST_ROOT}/common -) - -#========================================================================================================================= -# SOURCES -#========================================================================================================================= - - -#========================================================================================================================= -# TARGET -#========================================================================================================================= - -add_executable(${PROJECT_NAME} main.cpp ni_parser.c pack_archive.cpp zip.cpp miniz.c command_line.cpp) -target_include_directories(${PROJECT_NAME} PUBLIC ${OST_CONVERT_INCLUDES}) diff --git a/story-editor-legacy/ost_convert/command_line.cpp b/story-editor-legacy/ost_convert/command_line.cpp deleted file mode 100644 index 4588429..0000000 --- a/story-editor-legacy/ost_convert/command_line.cpp +++ /dev/null @@ -1,151 +0,0 @@ -#include "command_line.h" - -#include -#include - -CommandLine::CommandLine(std::string description) - : mDescription(std::move(description)) { -} - -void CommandLine::addArgument(std::vector const& flags, - Value const& value, std::string const& help) { - mArguments.emplace_back(Argument{flags, value, help}); -} - -void CommandLine::printHelp(std::ostream& os) const { - - // Print the general description. - os << mDescription << std::endl; - - // Find the argument with the longest combined flag length (in order - // to align the help messages). - - uint32_t maxFlagLength = 0; - - for (auto const& argument : mArguments) { - uint32_t flagLength = 0; - for (auto const& flag : argument.mFlags) { - // Plus comma and space. - flagLength += static_cast(flag.size()) + 2; - } - - maxFlagLength = std::max(maxFlagLength, flagLength); - } - - // Now print each argument. - for (auto const& argument : mArguments) { - - std::string flags; - for (auto const& flag : argument.mFlags) { - flags += flag + ", "; - } - - // Remove last comma and space and add padding according to the - // longest flags in order to align the help messages. - std::stringstream sstr; - sstr << std::left << std::setw(maxFlagLength) - << flags.substr(0, flags.size() - 2); - - // Print the help for each argument. This is a bit more involved - // since we do line wrapping for long descriptions. - size_t spacePos = 0; - size_t lineWidth = 0; - while (spacePos != std::string::npos) { - size_t nextspacePos = argument.mHelp.find_first_of(' ', spacePos + 1); - sstr << argument.mHelp.substr(spacePos, nextspacePos - spacePos); - lineWidth += nextspacePos - spacePos; - spacePos = nextspacePos; - - if (lineWidth > 60) { - os << sstr.str() << std::endl; - sstr = std::stringstream(); - sstr << std::left << std::setw(maxFlagLength - 1) << " "; - lineWidth = 0; - } - } - } -} - -void CommandLine::parse(int argc, char* argv[]) const { - - // Skip the first argument (name of the program). - int i = 1; - while (i < argc) { - - // First we have to identify wether the value is separated by a space - // or a '='. - std::string flag(argv[i]); - std::string value; - bool valueIsSeparate = false; - - // If there is an '=' in the flag, the part after the '=' is actually - // the value. - size_t equalPos = flag.find('='); - if (equalPos != std::string::npos) { - value = flag.substr(equalPos + 1); - flag = flag.substr(0, equalPos); - } - // Else the following argument is the value. - else if (i + 1 < argc) { - value = argv[i + 1]; - valueIsSeparate = true; - } - - // Search for an argument with the provided flag. - bool foundArgument = false; - - for (auto const& argument : mArguments) { - if (std::find(argument.mFlags.begin(), argument.mFlags.end(), flag) - != std::end(argument.mFlags)) { - - foundArgument = true; - - // In the case of booleans, there must not be a value present. - // So if the value is neither 'true' nor 'false' it is considered - // to be the next argument. - if (std::holds_alternative(argument.mValue)) { - if (!value.empty() && value != "true" && value != "false") { - valueIsSeparate = false; - } - *std::get(argument.mValue) = (value != "false"); - } - // In all other cases there must be a value. - else if (value.empty()) { - throw std::runtime_error( - "Failed to parse command line arguments: " - "Missing value for argument \"" + flag + "\"!"); - } - // For a std::string, we take the entire value. - else if (std::holds_alternative(argument.mValue)) { - *std::get(argument.mValue) = value; - } - // In all other cases we use a std::stringstream to - // convert the value. - else { - std::visit( - [&value](auto&& arg) { - std::stringstream sstr(value); - sstr >> *arg; - }, - argument.mValue); - } - - break; - } - } - - // Print a warning if there was an unknown argument. - if (!foundArgument) { - std::cerr << "Ignoring unknown command line argument \"" << flag - << "\"." << std::endl; - } - - // Advance to the next flag. - ++i; - - // If the value was separated, we have to advance our index once more. - if (foundArgument && valueIsSeparate) { - ++i; - } - } -} diff --git a/story-editor-legacy/ost_convert/command_line.h b/story-editor-legacy/ost_convert/command_line.h deleted file mode 100644 index 3e31bd3..0000000 --- a/story-editor-legacy/ost_convert/command_line.h +++ /dev/null @@ -1,80 +0,0 @@ -#ifndef COMMAND_LINE_HPP -#define COMMAND_LINE_HPP - -#include -#include -#include -#include - -// License: Public Domain -// original author: Simon Schneegans https://schneegans.github.io/tutorials/2019/08/06/commandline - -// This class is a simple and effective class to parse command line arguments. -// For each possible argument it stores a pointer to a variable. When the -// corresponding argument is set on the command line (given to the parse() -// method) the variable is set to the given value. If the option is not set, -// the variable is not touched. Hence it should be initialized to a default -// state. -// For each argument, several names (aliases) can be defined. Thus, the same -// boolean could be set via '--help' or '-h'. While not required, it is a good -// practice to precede the argument names with either '--' or '-'. Except for -// booleans, a value is expected to be given. Booleans are set to 'true' if no -// value is provided (that means they can be used as simple flags as in the -// '--help' case). Values can be given in two ways: Either the option name and -// the value should be separated by a space or by a '='. Here are some valid -// examples: -// --string="Foo Bar" -// --string "Foo Bar" -// --help -// --help=false -// --help true - -class CommandLine { - public: - - // These are the possible variables the options may point to. Bool and - // std::string are handled in a special way, all other values are parsed - // with a std::stringstream. This std::variant can be easily extended if - // the stream operator>> is overloaded. If not, you have to add a special - // case to the parse() method. - typedef std::variant Value; - - // The description is printed as part of the help message. - explicit CommandLine(std::string description); - - // Adds a possible option. A typical call would be like this: - // bool printHelp = false; - // cmd.addArgument({"--help", "-h"}, &printHelp, "Print this help message"); - // Then, after parse() has been called, printHelp will be true if the user - // provided the flag. - void addArgument(std::vector const& flags, - Value const& value, std::string const& help); - - // Prints the description given to the constructor and the help - // for each option. - void printHelp(std::ostream& os = std::cout) const; - - // The command line arguments are traversed from start to end. That means, - // if an option is set multiple times, the last will be the one which is - // finally used. This call will throw a std::runtime_error if a value is - // missing for a given option. Unknown flags will cause a warning on - // std::cerr. - void parse(int argc, char* argv[]) const; - - private: - struct Argument { - std::vector mFlags; - Value mValue; - std::string mHelp; - }; - - std::string mDescription; - std::vector mArguments; -}; - -#endif // COMMAND_LINE_HPP diff --git a/story-editor-legacy/ost_convert/json.hpp b/story-editor-legacy/ost_convert/json.hpp deleted file mode 100644 index 4d1a37a..0000000 --- a/story-editor-legacy/ost_convert/json.hpp +++ /dev/null @@ -1,24596 +0,0 @@ -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - -/****************************************************************************\ - * Note on documentation: The source files contain links to the online * - * documentation of the public API at https://json.nlohmann.me. This URL * - * contains the most recent documentation and should also be applicable to * - * previous versions; documentation for deprecated functions is not * - * removed, but marked deprecated. See "Generate documentation" section in * - * file docs/README.md. * -\****************************************************************************/ - -#ifndef INCLUDE_NLOHMANN_JSON_HPP_ -#define INCLUDE_NLOHMANN_JSON_HPP_ - -#include // all_of, find, for_each -#include // nullptr_t, ptrdiff_t, size_t -#include // hash, less -#include // initializer_list -#ifndef JSON_NO_IO - #include // istream, ostream -#endif // JSON_NO_IO -#include // random_access_iterator_tag -#include // unique_ptr -#include // accumulate -#include // string, stoi, to_string -#include // declval, forward, move, pair, swap -#include // vector - -// #include -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - - - -#include - -// #include -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - - - -// This file contains all macro definitions affecting or depending on the ABI - -#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK - #if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH) - #if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 11 || NLOHMANN_JSON_VERSION_PATCH != 2 - #warning "Already included a different version of the library!" - #endif - #endif -#endif - -#define NLOHMANN_JSON_VERSION_MAJOR 3 // NOLINT(modernize-macro-to-enum) -#define NLOHMANN_JSON_VERSION_MINOR 11 // NOLINT(modernize-macro-to-enum) -#define NLOHMANN_JSON_VERSION_PATCH 2 // NOLINT(modernize-macro-to-enum) - -#ifndef JSON_DIAGNOSTICS - #define JSON_DIAGNOSTICS 0 -#endif - -#ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON - #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0 -#endif - -#if JSON_DIAGNOSTICS - #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS _diag -#else - #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS -#endif - -#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON - #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp -#else - #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON -#endif - -#ifndef NLOHMANN_JSON_NAMESPACE_NO_VERSION - #define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0 -#endif - -// Construct the namespace ABI tags component -#define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) json_abi ## a ## b -#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b) \ - NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) - -#define NLOHMANN_JSON_ABI_TAGS \ - NLOHMANN_JSON_ABI_TAGS_CONCAT( \ - NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \ - NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON) - -// Construct the namespace version component -#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \ - _v ## major ## _ ## minor ## _ ## patch -#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \ - NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) - -#if NLOHMANN_JSON_NAMESPACE_NO_VERSION -#define NLOHMANN_JSON_NAMESPACE_VERSION -#else -#define NLOHMANN_JSON_NAMESPACE_VERSION \ - NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \ - NLOHMANN_JSON_VERSION_MINOR, \ - NLOHMANN_JSON_VERSION_PATCH) -#endif - -// Combine namespace components -#define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a ## b -#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \ - NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) - -#ifndef NLOHMANN_JSON_NAMESPACE -#define NLOHMANN_JSON_NAMESPACE \ - nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \ - NLOHMANN_JSON_ABI_TAGS, \ - NLOHMANN_JSON_NAMESPACE_VERSION) -#endif - -#ifndef NLOHMANN_JSON_NAMESPACE_BEGIN -#define NLOHMANN_JSON_NAMESPACE_BEGIN \ - namespace nlohmann \ - { \ - inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \ - NLOHMANN_JSON_ABI_TAGS, \ - NLOHMANN_JSON_NAMESPACE_VERSION) \ - { -#endif - -#ifndef NLOHMANN_JSON_NAMESPACE_END -#define NLOHMANN_JSON_NAMESPACE_END \ - } /* namespace (inline namespace) NOLINT(readability/namespace) */ \ - } // namespace nlohmann -#endif - -// #include -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - - - -#include // transform -#include // array -#include // forward_list -#include // inserter, front_inserter, end -#include // map -#include // string -#include // tuple, make_tuple -#include // is_arithmetic, is_same, is_enum, underlying_type, is_convertible -#include // unordered_map -#include // pair, declval -#include // valarray - -// #include -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - - - -#include // nullptr_t -#include // exception -#include // runtime_error -#include // to_string -#include // vector - -// #include -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - - - -#include // array -#include // size_t -#include // uint8_t -#include // string - -// #include -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - - - -#include // declval, pair -// #include -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - - - -#include - -// #include -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - - - -// #include - - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ - -template struct make_void -{ - using type = void; -}; -template using void_t = typename make_void::type; - -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END - - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ - -// https://en.cppreference.com/w/cpp/experimental/is_detected -struct nonesuch -{ - nonesuch() = delete; - ~nonesuch() = delete; - nonesuch(nonesuch const&) = delete; - nonesuch(nonesuch const&&) = delete; - void operator=(nonesuch const&) = delete; - void operator=(nonesuch&&) = delete; -}; - -template class Op, - class... Args> -struct detector -{ - using value_t = std::false_type; - using type = Default; -}; - -template class Op, class... Args> -struct detector>, Op, Args...> -{ - using value_t = std::true_type; - using type = Op; -}; - -template class Op, class... Args> -using is_detected = typename detector::value_t; - -template class Op, class... Args> -struct is_detected_lazy : is_detected { }; - -template class Op, class... Args> -using detected_t = typename detector::type; - -template class Op, class... Args> -using detected_or = detector; - -template class Op, class... Args> -using detected_or_t = typename detected_or::type; - -template class Op, class... Args> -using is_detected_exact = std::is_same>; - -template class Op, class... Args> -using is_detected_convertible = - std::is_convertible, To>; - -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END - -// #include - - -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-FileCopyrightText: 2016-2021 Evan Nemerson -// SPDX-License-Identifier: MIT - -/* Hedley - https://nemequ.github.io/hedley - * Created by Evan Nemerson - */ - -#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15) -#if defined(JSON_HEDLEY_VERSION) - #undef JSON_HEDLEY_VERSION -#endif -#define JSON_HEDLEY_VERSION 15 - -#if defined(JSON_HEDLEY_STRINGIFY_EX) - #undef JSON_HEDLEY_STRINGIFY_EX -#endif -#define JSON_HEDLEY_STRINGIFY_EX(x) #x - -#if defined(JSON_HEDLEY_STRINGIFY) - #undef JSON_HEDLEY_STRINGIFY -#endif -#define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x) - -#if defined(JSON_HEDLEY_CONCAT_EX) - #undef JSON_HEDLEY_CONCAT_EX -#endif -#define JSON_HEDLEY_CONCAT_EX(a,b) a##b - -#if defined(JSON_HEDLEY_CONCAT) - #undef JSON_HEDLEY_CONCAT -#endif -#define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b) - -#if defined(JSON_HEDLEY_CONCAT3_EX) - #undef JSON_HEDLEY_CONCAT3_EX -#endif -#define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c - -#if defined(JSON_HEDLEY_CONCAT3) - #undef JSON_HEDLEY_CONCAT3 -#endif -#define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c) - -#if defined(JSON_HEDLEY_VERSION_ENCODE) - #undef JSON_HEDLEY_VERSION_ENCODE -#endif -#define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision)) - -#if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR) - #undef JSON_HEDLEY_VERSION_DECODE_MAJOR -#endif -#define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000) - -#if defined(JSON_HEDLEY_VERSION_DECODE_MINOR) - #undef JSON_HEDLEY_VERSION_DECODE_MINOR -#endif -#define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000) - -#if defined(JSON_HEDLEY_VERSION_DECODE_REVISION) - #undef JSON_HEDLEY_VERSION_DECODE_REVISION -#endif -#define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000) - -#if defined(JSON_HEDLEY_GNUC_VERSION) - #undef JSON_HEDLEY_GNUC_VERSION -#endif -#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__) - #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) -#elif defined(__GNUC__) - #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0) -#endif - -#if defined(JSON_HEDLEY_GNUC_VERSION_CHECK) - #undef JSON_HEDLEY_GNUC_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_GNUC_VERSION) - #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_MSVC_VERSION) - #undef JSON_HEDLEY_MSVC_VERSION -#endif -#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL) - #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100) -#elif defined(_MSC_FULL_VER) && !defined(__ICL) - #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10) -#elif defined(_MSC_VER) && !defined(__ICL) - #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0) -#endif - -#if defined(JSON_HEDLEY_MSVC_VERSION_CHECK) - #undef JSON_HEDLEY_MSVC_VERSION_CHECK -#endif -#if !defined(JSON_HEDLEY_MSVC_VERSION) - #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0) -#elif defined(_MSC_VER) && (_MSC_VER >= 1400) - #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch))) -#elif defined(_MSC_VER) && (_MSC_VER >= 1200) - #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch))) -#else - #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor))) -#endif - -#if defined(JSON_HEDLEY_INTEL_VERSION) - #undef JSON_HEDLEY_INTEL_VERSION -#endif -#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL) - #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE) -#elif defined(__INTEL_COMPILER) && !defined(__ICL) - #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0) -#endif - -#if defined(JSON_HEDLEY_INTEL_VERSION_CHECK) - #undef JSON_HEDLEY_INTEL_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_INTEL_VERSION) - #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_INTEL_CL_VERSION) - #undef JSON_HEDLEY_INTEL_CL_VERSION -#endif -#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL) - #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0) -#endif - -#if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK) - #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_INTEL_CL_VERSION) - #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_PGI_VERSION) - #undef JSON_HEDLEY_PGI_VERSION -#endif -#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__) - #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__) -#endif - -#if defined(JSON_HEDLEY_PGI_VERSION_CHECK) - #undef JSON_HEDLEY_PGI_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_PGI_VERSION) - #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_SUNPRO_VERSION) - #undef JSON_HEDLEY_SUNPRO_VERSION -#endif -#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000) - #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10) -#elif defined(__SUNPRO_C) - #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf) -#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000) - #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10) -#elif defined(__SUNPRO_CC) - #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf) -#endif - -#if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK) - #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_SUNPRO_VERSION) - #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION) - #undef JSON_HEDLEY_EMSCRIPTEN_VERSION -#endif -#if defined(__EMSCRIPTEN__) - #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__) -#endif - -#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK) - #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION) - #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_ARM_VERSION) - #undef JSON_HEDLEY_ARM_VERSION -#endif -#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION) - #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100) -#elif defined(__CC_ARM) && defined(__ARMCC_VERSION) - #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100) -#endif - -#if defined(JSON_HEDLEY_ARM_VERSION_CHECK) - #undef JSON_HEDLEY_ARM_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_ARM_VERSION) - #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_IBM_VERSION) - #undef JSON_HEDLEY_IBM_VERSION -#endif -#if defined(__ibmxl__) - #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__) -#elif defined(__xlC__) && defined(__xlC_ver__) - #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff) -#elif defined(__xlC__) - #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0) -#endif - -#if defined(JSON_HEDLEY_IBM_VERSION_CHECK) - #undef JSON_HEDLEY_IBM_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_IBM_VERSION) - #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TI_VERSION) - #undef JSON_HEDLEY_TI_VERSION -#endif -#if \ - defined(__TI_COMPILER_VERSION__) && \ - ( \ - defined(__TMS470__) || defined(__TI_ARM__) || \ - defined(__MSP430__) || \ - defined(__TMS320C2000__) \ - ) -#if (__TI_COMPILER_VERSION__ >= 16000000) - #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif -#endif - -#if defined(JSON_HEDLEY_TI_VERSION_CHECK) - #undef JSON_HEDLEY_TI_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TI_VERSION) - #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TI_CL2000_VERSION) - #undef JSON_HEDLEY_TI_CL2000_VERSION -#endif -#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__) - #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif - -#if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK) - #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TI_CL2000_VERSION) - #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TI_CL430_VERSION) - #undef JSON_HEDLEY_TI_CL430_VERSION -#endif -#if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__) - #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif - -#if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK) - #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TI_CL430_VERSION) - #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TI_ARMCL_VERSION) - #undef JSON_HEDLEY_TI_ARMCL_VERSION -#endif -#if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__)) - #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif - -#if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK) - #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TI_ARMCL_VERSION) - #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TI_CL6X_VERSION) - #undef JSON_HEDLEY_TI_CL6X_VERSION -#endif -#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__) - #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif - -#if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK) - #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TI_CL6X_VERSION) - #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TI_CL7X_VERSION) - #undef JSON_HEDLEY_TI_CL7X_VERSION -#endif -#if defined(__TI_COMPILER_VERSION__) && defined(__C7000__) - #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif - -#if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK) - #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TI_CL7X_VERSION) - #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TI_CLPRU_VERSION) - #undef JSON_HEDLEY_TI_CLPRU_VERSION -#endif -#if defined(__TI_COMPILER_VERSION__) && defined(__PRU__) - #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif - -#if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK) - #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TI_CLPRU_VERSION) - #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_CRAY_VERSION) - #undef JSON_HEDLEY_CRAY_VERSION -#endif -#if defined(_CRAYC) - #if defined(_RELEASE_PATCHLEVEL) - #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL) - #else - #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0) - #endif -#endif - -#if defined(JSON_HEDLEY_CRAY_VERSION_CHECK) - #undef JSON_HEDLEY_CRAY_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_CRAY_VERSION) - #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_IAR_VERSION) - #undef JSON_HEDLEY_IAR_VERSION -#endif -#if defined(__IAR_SYSTEMS_ICC__) - #if __VER__ > 1000 - #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000)) - #else - #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0) - #endif -#endif - -#if defined(JSON_HEDLEY_IAR_VERSION_CHECK) - #undef JSON_HEDLEY_IAR_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_IAR_VERSION) - #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TINYC_VERSION) - #undef JSON_HEDLEY_TINYC_VERSION -#endif -#if defined(__TINYC__) - #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100) -#endif - -#if defined(JSON_HEDLEY_TINYC_VERSION_CHECK) - #undef JSON_HEDLEY_TINYC_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TINYC_VERSION) - #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_DMC_VERSION) - #undef JSON_HEDLEY_DMC_VERSION -#endif -#if defined(__DMC__) - #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf) -#endif - -#if defined(JSON_HEDLEY_DMC_VERSION_CHECK) - #undef JSON_HEDLEY_DMC_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_DMC_VERSION) - #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_COMPCERT_VERSION) - #undef JSON_HEDLEY_COMPCERT_VERSION -#endif -#if defined(__COMPCERT_VERSION__) - #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100) -#endif - -#if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK) - #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_COMPCERT_VERSION) - #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_PELLES_VERSION) - #undef JSON_HEDLEY_PELLES_VERSION -#endif -#if defined(__POCC__) - #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0) -#endif - -#if defined(JSON_HEDLEY_PELLES_VERSION_CHECK) - #undef JSON_HEDLEY_PELLES_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_PELLES_VERSION) - #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_MCST_LCC_VERSION) - #undef JSON_HEDLEY_MCST_LCC_VERSION -#endif -#if defined(__LCC__) && defined(__LCC_MINOR__) - #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__) -#endif - -#if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK) - #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_MCST_LCC_VERSION) - #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_GCC_VERSION) - #undef JSON_HEDLEY_GCC_VERSION -#endif -#if \ - defined(JSON_HEDLEY_GNUC_VERSION) && \ - !defined(__clang__) && \ - !defined(JSON_HEDLEY_INTEL_VERSION) && \ - !defined(JSON_HEDLEY_PGI_VERSION) && \ - !defined(JSON_HEDLEY_ARM_VERSION) && \ - !defined(JSON_HEDLEY_CRAY_VERSION) && \ - !defined(JSON_HEDLEY_TI_VERSION) && \ - !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \ - !defined(JSON_HEDLEY_TI_CL430_VERSION) && \ - !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \ - !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \ - !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \ - !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \ - !defined(__COMPCERT__) && \ - !defined(JSON_HEDLEY_MCST_LCC_VERSION) - #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION -#endif - -#if defined(JSON_HEDLEY_GCC_VERSION_CHECK) - #undef JSON_HEDLEY_GCC_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_GCC_VERSION) - #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_HAS_ATTRIBUTE) - #undef JSON_HEDLEY_HAS_ATTRIBUTE -#endif -#if \ - defined(__has_attribute) && \ - ( \ - (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \ - ) -# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute) -#else -# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0) -#endif - -#if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE) - #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE -#endif -#if defined(__has_attribute) - #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) -#else - #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE) - #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE -#endif -#if defined(__has_attribute) - #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) -#else - #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE) - #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE -#endif -#if \ - defined(__has_cpp_attribute) && \ - defined(__cplusplus) && \ - (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) - #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute) -#else - #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0) -#endif - -#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS) - #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS -#endif -#if !defined(__cplusplus) || !defined(__has_cpp_attribute) - #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0) -#elif \ - !defined(JSON_HEDLEY_PGI_VERSION) && \ - !defined(JSON_HEDLEY_IAR_VERSION) && \ - (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \ - (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0)) - #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute) -#else - #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0) -#endif - -#if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE) - #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE -#endif -#if defined(__has_cpp_attribute) && defined(__cplusplus) - #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) -#else - #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE) - #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE -#endif -#if defined(__has_cpp_attribute) && defined(__cplusplus) - #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) -#else - #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_HAS_BUILTIN) - #undef JSON_HEDLEY_HAS_BUILTIN -#endif -#if defined(__has_builtin) - #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin) -#else - #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0) -#endif - -#if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN) - #undef JSON_HEDLEY_GNUC_HAS_BUILTIN -#endif -#if defined(__has_builtin) - #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) -#else - #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_GCC_HAS_BUILTIN) - #undef JSON_HEDLEY_GCC_HAS_BUILTIN -#endif -#if defined(__has_builtin) - #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) -#else - #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_HAS_FEATURE) - #undef JSON_HEDLEY_HAS_FEATURE -#endif -#if defined(__has_feature) - #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature) -#else - #define JSON_HEDLEY_HAS_FEATURE(feature) (0) -#endif - -#if defined(JSON_HEDLEY_GNUC_HAS_FEATURE) - #undef JSON_HEDLEY_GNUC_HAS_FEATURE -#endif -#if defined(__has_feature) - #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) -#else - #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_GCC_HAS_FEATURE) - #undef JSON_HEDLEY_GCC_HAS_FEATURE -#endif -#if defined(__has_feature) - #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) -#else - #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_HAS_EXTENSION) - #undef JSON_HEDLEY_HAS_EXTENSION -#endif -#if defined(__has_extension) - #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension) -#else - #define JSON_HEDLEY_HAS_EXTENSION(extension) (0) -#endif - -#if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION) - #undef JSON_HEDLEY_GNUC_HAS_EXTENSION -#endif -#if defined(__has_extension) - #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) -#else - #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_GCC_HAS_EXTENSION) - #undef JSON_HEDLEY_GCC_HAS_EXTENSION -#endif -#if defined(__has_extension) - #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) -#else - #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE) - #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE -#endif -#if defined(__has_declspec_attribute) - #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute) -#else - #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0) -#endif - -#if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE) - #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE -#endif -#if defined(__has_declspec_attribute) - #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) -#else - #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE) - #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE -#endif -#if defined(__has_declspec_attribute) - #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) -#else - #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_HAS_WARNING) - #undef JSON_HEDLEY_HAS_WARNING -#endif -#if defined(__has_warning) - #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning) -#else - #define JSON_HEDLEY_HAS_WARNING(warning) (0) -#endif - -#if defined(JSON_HEDLEY_GNUC_HAS_WARNING) - #undef JSON_HEDLEY_GNUC_HAS_WARNING -#endif -#if defined(__has_warning) - #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) -#else - #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_GCC_HAS_WARNING) - #undef JSON_HEDLEY_GCC_HAS_WARNING -#endif -#if defined(__has_warning) - #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) -#else - #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if \ - (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ - defined(__clang__) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \ - JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \ - (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR)) - #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value) -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) - #define JSON_HEDLEY_PRAGMA(value) __pragma(value) -#else - #define JSON_HEDLEY_PRAGMA(value) -#endif - -#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH) - #undef JSON_HEDLEY_DIAGNOSTIC_PUSH -#endif -#if defined(JSON_HEDLEY_DIAGNOSTIC_POP) - #undef JSON_HEDLEY_DIAGNOSTIC_POP -#endif -#if defined(__clang__) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") -#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") -#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push)) - #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop)) -#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop") -#elif \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop") -#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") -#else - #define JSON_HEDLEY_DIAGNOSTIC_PUSH - #define JSON_HEDLEY_DIAGNOSTIC_POP -#endif - -/* JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ is for - HEDLEY INTERNAL USE ONLY. API subject to change without notice. */ -#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_) - #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ -#endif -#if defined(__cplusplus) -# if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat") -# if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions") -# if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions") -# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ - _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ - _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \ - xpr \ - JSON_HEDLEY_DIAGNOSTIC_POP -# else -# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ - _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ - xpr \ - JSON_HEDLEY_DIAGNOSTIC_POP -# endif -# else -# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ - xpr \ - JSON_HEDLEY_DIAGNOSTIC_POP -# endif -# endif -#endif -#if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x -#endif - -#if defined(JSON_HEDLEY_CONST_CAST) - #undef JSON_HEDLEY_CONST_CAST -#endif -#if defined(__cplusplus) -# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast(expr)) -#elif \ - JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) -# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \ - ((T) (expr)); \ - JSON_HEDLEY_DIAGNOSTIC_POP \ - })) -#else -# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr)) -#endif - -#if defined(JSON_HEDLEY_REINTERPRET_CAST) - #undef JSON_HEDLEY_REINTERPRET_CAST -#endif -#if defined(__cplusplus) - #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast(expr)) -#else - #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr)) -#endif - -#if defined(JSON_HEDLEY_STATIC_CAST) - #undef JSON_HEDLEY_STATIC_CAST -#endif -#if defined(__cplusplus) - #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast(expr)) -#else - #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr)) -#endif - -#if defined(JSON_HEDLEY_CPP_CAST) - #undef JSON_HEDLEY_CPP_CAST -#endif -#if defined(__cplusplus) -# if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast") -# define JSON_HEDLEY_CPP_CAST(T, expr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \ - ((T) (expr)) \ - JSON_HEDLEY_DIAGNOSTIC_POP -# elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0) -# define JSON_HEDLEY_CPP_CAST(T, expr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("diag_suppress=Pe137") \ - JSON_HEDLEY_DIAGNOSTIC_POP -# else -# define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr)) -# endif -#else -# define JSON_HEDLEY_CPP_CAST(T, expr) (expr) -#endif - -#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED) - #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations") - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") -#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)") -#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786)) -#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445") -#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") -#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996)) -#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") -#elif \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718") -#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)") -#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)") -#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215") -#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)") -#else - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED -#endif - -#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS) - #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"") -#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)") -#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161)) -#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675") -#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"") -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068)) -#elif \ - JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") -#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") -#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161") -#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161") -#else - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS -#endif - -#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES) - #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes") - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"") -#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") -#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)") -#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292)) -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030)) -#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098") -#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097") -#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)") -#elif \ - JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173") -#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097") -#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097") -#else - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES -#endif - -#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL) - #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wcast-qual") - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"") -#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)") -#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") -#else - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL -#endif - -#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION) - #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wunused-function") - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"") -#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"") -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505)) -#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142") -#else - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION -#endif - -#if defined(JSON_HEDLEY_DEPRECATED) - #undef JSON_HEDLEY_DEPRECATED -#endif -#if defined(JSON_HEDLEY_DEPRECATED_FOR) - #undef JSON_HEDLEY_DEPRECATED_FOR -#endif -#if \ - JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since)) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement)) -#elif \ - (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since))) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement))) -#elif defined(__cplusplus) && (__cplusplus >= 201402L) - #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]]) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]]) -#elif \ - JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) - #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__)) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__)) -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ - JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated) -#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated") - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated") -#else - #define JSON_HEDLEY_DEPRECATED(since) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) -#endif - -#if defined(JSON_HEDLEY_UNAVAILABLE) - #undef JSON_HEDLEY_UNAVAILABLE -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since))) -#else - #define JSON_HEDLEY_UNAVAILABLE(available_since) -#endif - -#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT) - #undef JSON_HEDLEY_WARN_UNUSED_RESULT -#endif -#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG) - #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) - #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__)) -#elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L) - #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) - #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]]) -#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) - #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) - #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) -#elif defined(_Check_return_) /* SAL */ - #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_ - #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_ -#else - #define JSON_HEDLEY_WARN_UNUSED_RESULT - #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) -#endif - -#if defined(JSON_HEDLEY_SENTINEL) - #undef JSON_HEDLEY_SENTINEL -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position))) -#else - #define JSON_HEDLEY_SENTINEL(position) -#endif - -#if defined(JSON_HEDLEY_NO_RETURN) - #undef JSON_HEDLEY_NO_RETURN -#endif -#if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define JSON_HEDLEY_NO_RETURN __noreturn -#elif \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) -#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - #define JSON_HEDLEY_NO_RETURN _Noreturn -#elif defined(__cplusplus) && (__cplusplus >= 201103L) - #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]]) -#elif \ - JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) - #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) -#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) - #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return") -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) -#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus) - #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;") -#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) - #define JSON_HEDLEY_NO_RETURN __attribute((noreturn)) -#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) - #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) -#else - #define JSON_HEDLEY_NO_RETURN -#endif - -#if defined(JSON_HEDLEY_NO_ESCAPE) - #undef JSON_HEDLEY_NO_ESCAPE -#endif -#if JSON_HEDLEY_HAS_ATTRIBUTE(noescape) - #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__)) -#else - #define JSON_HEDLEY_NO_ESCAPE -#endif - -#if defined(JSON_HEDLEY_UNREACHABLE) - #undef JSON_HEDLEY_UNREACHABLE -#endif -#if defined(JSON_HEDLEY_UNREACHABLE_RETURN) - #undef JSON_HEDLEY_UNREACHABLE_RETURN -#endif -#if defined(JSON_HEDLEY_ASSUME) - #undef JSON_HEDLEY_ASSUME -#endif -#if \ - JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_ASSUME(expr) __assume(expr) -#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume) - #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr) -#elif \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) - #if defined(__cplusplus) - #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr) - #else - #define JSON_HEDLEY_ASSUME(expr) _nassert(expr) - #endif -#endif -#if \ - (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable() -#elif defined(JSON_HEDLEY_ASSUME) - #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0) -#endif -#if !defined(JSON_HEDLEY_ASSUME) - #if defined(JSON_HEDLEY_UNREACHABLE) - #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1))) - #else - #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr) - #endif -#endif -#if defined(JSON_HEDLEY_UNREACHABLE) - #if \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) - #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value)) - #else - #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE() - #endif -#else - #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value) -#endif -#if !defined(JSON_HEDLEY_UNREACHABLE) - #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0) -#endif - -JSON_HEDLEY_DIAGNOSTIC_PUSH -#if JSON_HEDLEY_HAS_WARNING("-Wpedantic") - #pragma clang diagnostic ignored "-Wpedantic" -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus) - #pragma clang diagnostic ignored "-Wc++98-compat-pedantic" -#endif -#if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0) - #if defined(__clang__) - #pragma clang diagnostic ignored "-Wvariadic-macros" - #elif defined(JSON_HEDLEY_GCC_VERSION) - #pragma GCC diagnostic ignored "-Wvariadic-macros" - #endif -#endif -#if defined(JSON_HEDLEY_NON_NULL) - #undef JSON_HEDLEY_NON_NULL -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) - #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__))) -#else - #define JSON_HEDLEY_NON_NULL(...) -#endif -JSON_HEDLEY_DIAGNOSTIC_POP - -#if defined(JSON_HEDLEY_PRINTF_FORMAT) - #undef JSON_HEDLEY_PRINTF_FORMAT -#endif -#if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO) - #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check))) -#elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO) - #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check))) -#elif \ - JSON_HEDLEY_HAS_ATTRIBUTE(format) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check))) -#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0) - #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check)) -#else - #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) -#endif - -#if defined(JSON_HEDLEY_CONSTEXPR) - #undef JSON_HEDLEY_CONSTEXPR -#endif -#if defined(__cplusplus) - #if __cplusplus >= 201103L - #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr) - #endif -#endif -#if !defined(JSON_HEDLEY_CONSTEXPR) - #define JSON_HEDLEY_CONSTEXPR -#endif - -#if defined(JSON_HEDLEY_PREDICT) - #undef JSON_HEDLEY_PREDICT -#endif -#if defined(JSON_HEDLEY_LIKELY) - #undef JSON_HEDLEY_LIKELY -#endif -#if defined(JSON_HEDLEY_UNLIKELY) - #undef JSON_HEDLEY_UNLIKELY -#endif -#if defined(JSON_HEDLEY_UNPREDICTABLE) - #undef JSON_HEDLEY_UNPREDICTABLE -#endif -#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable) - #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr)) -#endif -#if \ - (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) -# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability)) -# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability)) -# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability)) -# define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 ) -# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 ) -#elif \ - (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) -# define JSON_HEDLEY_PREDICT(expr, expected, probability) \ - (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))) -# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \ - (__extension__ ({ \ - double hedley_probability_ = (probability); \ - ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \ - })) -# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \ - (__extension__ ({ \ - double hedley_probability_ = (probability); \ - ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \ - })) -# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) -# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) -#else -# define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)) -# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr)) -# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr)) -# define JSON_HEDLEY_LIKELY(expr) (!!(expr)) -# define JSON_HEDLEY_UNLIKELY(expr) (!!(expr)) -#endif -#if !defined(JSON_HEDLEY_UNPREDICTABLE) - #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5) -#endif - -#if defined(JSON_HEDLEY_MALLOC) - #undef JSON_HEDLEY_MALLOC -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_MALLOC __attribute__((__malloc__)) -#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) - #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory") -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_MALLOC __declspec(restrict) -#else - #define JSON_HEDLEY_MALLOC -#endif - -#if defined(JSON_HEDLEY_PURE) - #undef JSON_HEDLEY_PURE -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) -# define JSON_HEDLEY_PURE __attribute__((__pure__)) -#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) -# define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data") -#elif defined(__cplusplus) && \ - ( \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \ - ) -# define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;") -#else -# define JSON_HEDLEY_PURE -#endif - -#if defined(JSON_HEDLEY_CONST) - #undef JSON_HEDLEY_CONST -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(const) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_CONST __attribute__((__const__)) -#elif \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) - #define JSON_HEDLEY_CONST _Pragma("no_side_effect") -#else - #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE -#endif - -#if defined(JSON_HEDLEY_RESTRICT) - #undef JSON_HEDLEY_RESTRICT -#endif -#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus) - #define JSON_HEDLEY_RESTRICT restrict -#elif \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ - defined(__clang__) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_RESTRICT __restrict -#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus) - #define JSON_HEDLEY_RESTRICT _Restrict -#else - #define JSON_HEDLEY_RESTRICT -#endif - -#if defined(JSON_HEDLEY_INLINE) - #undef JSON_HEDLEY_INLINE -#endif -#if \ - (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ - (defined(__cplusplus) && (__cplusplus >= 199711L)) - #define JSON_HEDLEY_INLINE inline -#elif \ - defined(JSON_HEDLEY_GCC_VERSION) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0) - #define JSON_HEDLEY_INLINE __inline__ -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_INLINE __inline -#else - #define JSON_HEDLEY_INLINE -#endif - -#if defined(JSON_HEDLEY_ALWAYS_INLINE) - #undef JSON_HEDLEY_ALWAYS_INLINE -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) -# define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) -# define JSON_HEDLEY_ALWAYS_INLINE __forceinline -#elif defined(__cplusplus) && \ - ( \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \ - ) -# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;") -#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) -# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced") -#else -# define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE -#endif - -#if defined(JSON_HEDLEY_NEVER_INLINE) - #undef JSON_HEDLEY_NEVER_INLINE -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) - #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__)) -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) -#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0) - #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline") -#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus) - #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;") -#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never") -#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) - #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline)) -#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) - #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) -#else - #define JSON_HEDLEY_NEVER_INLINE -#endif - -#if defined(JSON_HEDLEY_PRIVATE) - #undef JSON_HEDLEY_PRIVATE -#endif -#if defined(JSON_HEDLEY_PUBLIC) - #undef JSON_HEDLEY_PUBLIC -#endif -#if defined(JSON_HEDLEY_IMPORT) - #undef JSON_HEDLEY_IMPORT -#endif -#if defined(_WIN32) || defined(__CYGWIN__) -# define JSON_HEDLEY_PRIVATE -# define JSON_HEDLEY_PUBLIC __declspec(dllexport) -# define JSON_HEDLEY_IMPORT __declspec(dllimport) -#else -# if \ - JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ - ( \ - defined(__TI_EABI__) && \ - ( \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \ - ) \ - ) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) -# define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden"))) -# define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default"))) -# else -# define JSON_HEDLEY_PRIVATE -# define JSON_HEDLEY_PUBLIC -# endif -# define JSON_HEDLEY_IMPORT extern -#endif - -#if defined(JSON_HEDLEY_NO_THROW) - #undef JSON_HEDLEY_NO_THROW -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__)) -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) - #define JSON_HEDLEY_NO_THROW __declspec(nothrow) -#else - #define JSON_HEDLEY_NO_THROW -#endif - -#if defined(JSON_HEDLEY_FALL_THROUGH) - #undef JSON_HEDLEY_FALL_THROUGH -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__)) -#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough) - #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]]) -#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough) - #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]]) -#elif defined(__fallthrough) /* SAL */ - #define JSON_HEDLEY_FALL_THROUGH __fallthrough -#else - #define JSON_HEDLEY_FALL_THROUGH -#endif - -#if defined(JSON_HEDLEY_RETURNS_NON_NULL) - #undef JSON_HEDLEY_RETURNS_NON_NULL -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__)) -#elif defined(_Ret_notnull_) /* SAL */ - #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_ -#else - #define JSON_HEDLEY_RETURNS_NON_NULL -#endif - -#if defined(JSON_HEDLEY_ARRAY_PARAM) - #undef JSON_HEDLEY_ARRAY_PARAM -#endif -#if \ - defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ - !defined(__STDC_NO_VLA__) && \ - !defined(__cplusplus) && \ - !defined(JSON_HEDLEY_PGI_VERSION) && \ - !defined(JSON_HEDLEY_TINYC_VERSION) - #define JSON_HEDLEY_ARRAY_PARAM(name) (name) -#else - #define JSON_HEDLEY_ARRAY_PARAM(name) -#endif - -#if defined(JSON_HEDLEY_IS_CONSTANT) - #undef JSON_HEDLEY_IS_CONSTANT -#endif -#if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR) - #undef JSON_HEDLEY_REQUIRE_CONSTEXPR -#endif -/* JSON_HEDLEY_IS_CONSTEXPR_ is for - HEDLEY INTERNAL USE ONLY. API subject to change without notice. */ -#if defined(JSON_HEDLEY_IS_CONSTEXPR_) - #undef JSON_HEDLEY_IS_CONSTEXPR_ -#endif -#if \ - JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ - (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr) -#endif -#if !defined(__cplusplus) -# if \ - JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ - JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24) -#if defined(__INTPTR_TYPE__) - #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*) -#else - #include - #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*) -#endif -# elif \ - ( \ - defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \ - !defined(JSON_HEDLEY_SUNPRO_VERSION) && \ - !defined(JSON_HEDLEY_PGI_VERSION) && \ - !defined(JSON_HEDLEY_IAR_VERSION)) || \ - (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0) -#if defined(__INTPTR_TYPE__) - #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0) -#else - #include - #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0) -#endif -# elif \ - defined(JSON_HEDLEY_GCC_VERSION) || \ - defined(JSON_HEDLEY_INTEL_VERSION) || \ - defined(JSON_HEDLEY_TINYC_VERSION) || \ - defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \ - defined(JSON_HEDLEY_TI_CL2000_VERSION) || \ - defined(JSON_HEDLEY_TI_CL6X_VERSION) || \ - defined(JSON_HEDLEY_TI_CL7X_VERSION) || \ - defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \ - defined(__clang__) -# define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \ - sizeof(void) != \ - sizeof(*( \ - 1 ? \ - ((void*) ((expr) * 0L) ) : \ -((struct { char v[sizeof(void) * 2]; } *) 1) \ - ) \ - ) \ - ) -# endif -#endif -#if defined(JSON_HEDLEY_IS_CONSTEXPR_) - #if !defined(JSON_HEDLEY_IS_CONSTANT) - #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr) - #endif - #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1)) -#else - #if !defined(JSON_HEDLEY_IS_CONSTANT) - #define JSON_HEDLEY_IS_CONSTANT(expr) (0) - #endif - #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr) -#endif - -#if defined(JSON_HEDLEY_BEGIN_C_DECLS) - #undef JSON_HEDLEY_BEGIN_C_DECLS -#endif -#if defined(JSON_HEDLEY_END_C_DECLS) - #undef JSON_HEDLEY_END_C_DECLS -#endif -#if defined(JSON_HEDLEY_C_DECL) - #undef JSON_HEDLEY_C_DECL -#endif -#if defined(__cplusplus) - #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" { - #define JSON_HEDLEY_END_C_DECLS } - #define JSON_HEDLEY_C_DECL extern "C" -#else - #define JSON_HEDLEY_BEGIN_C_DECLS - #define JSON_HEDLEY_END_C_DECLS - #define JSON_HEDLEY_C_DECL -#endif - -#if defined(JSON_HEDLEY_STATIC_ASSERT) - #undef JSON_HEDLEY_STATIC_ASSERT -#endif -#if \ - !defined(__cplusplus) && ( \ - (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \ - (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - defined(_Static_assert) \ - ) -# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message) -#elif \ - (defined(__cplusplus) && (__cplusplus >= 201103L)) || \ - JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) -# define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message)) -#else -# define JSON_HEDLEY_STATIC_ASSERT(expr, message) -#endif - -#if defined(JSON_HEDLEY_NULL) - #undef JSON_HEDLEY_NULL -#endif -#if defined(__cplusplus) - #if __cplusplus >= 201103L - #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr) - #elif defined(NULL) - #define JSON_HEDLEY_NULL NULL - #else - #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0) - #endif -#elif defined(NULL) - #define JSON_HEDLEY_NULL NULL -#else - #define JSON_HEDLEY_NULL ((void*) 0) -#endif - -#if defined(JSON_HEDLEY_MESSAGE) - #undef JSON_HEDLEY_MESSAGE -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") -# define JSON_HEDLEY_MESSAGE(msg) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ - JSON_HEDLEY_PRAGMA(message msg) \ - JSON_HEDLEY_DIAGNOSTIC_POP -#elif \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) -# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg) -#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) -# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg) -#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) -# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg)) -#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0) -# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg)) -#else -# define JSON_HEDLEY_MESSAGE(msg) -#endif - -#if defined(JSON_HEDLEY_WARNING) - #undef JSON_HEDLEY_WARNING -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") -# define JSON_HEDLEY_WARNING(msg) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ - JSON_HEDLEY_PRAGMA(clang warning msg) \ - JSON_HEDLEY_DIAGNOSTIC_POP -#elif \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) -# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg) -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) -# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg)) -#else -# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg) -#endif - -#if defined(JSON_HEDLEY_REQUIRE) - #undef JSON_HEDLEY_REQUIRE -#endif -#if defined(JSON_HEDLEY_REQUIRE_MSG) - #undef JSON_HEDLEY_REQUIRE_MSG -#endif -#if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if) -# if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat") -# define JSON_HEDLEY_REQUIRE(expr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ - __attribute__((diagnose_if(!(expr), #expr, "error"))) \ - JSON_HEDLEY_DIAGNOSTIC_POP -# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ - __attribute__((diagnose_if(!(expr), msg, "error"))) \ - JSON_HEDLEY_DIAGNOSTIC_POP -# else -# define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error"))) -# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error"))) -# endif -#else -# define JSON_HEDLEY_REQUIRE(expr) -# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) -#endif - -#if defined(JSON_HEDLEY_FLAGS) - #undef JSON_HEDLEY_FLAGS -#endif -#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion")) - #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__)) -#else - #define JSON_HEDLEY_FLAGS -#endif - -#if defined(JSON_HEDLEY_FLAGS_CAST) - #undef JSON_HEDLEY_FLAGS_CAST -#endif -#if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0) -# define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("warning(disable:188)") \ - ((T) (expr)); \ - JSON_HEDLEY_DIAGNOSTIC_POP \ - })) -#else -# define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr) -#endif - -#if defined(JSON_HEDLEY_EMPTY_BASES) - #undef JSON_HEDLEY_EMPTY_BASES -#endif -#if \ - (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases) -#else - #define JSON_HEDLEY_EMPTY_BASES -#endif - -/* Remaining macros are deprecated. */ - -#if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK) - #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK -#endif -#if defined(__clang__) - #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0) -#else - #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE) - #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE -#endif -#define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) - -#if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE) - #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE -#endif -#define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) - -#if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN) - #undef JSON_HEDLEY_CLANG_HAS_BUILTIN -#endif -#define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin) - -#if defined(JSON_HEDLEY_CLANG_HAS_FEATURE) - #undef JSON_HEDLEY_CLANG_HAS_FEATURE -#endif -#define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature) - -#if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION) - #undef JSON_HEDLEY_CLANG_HAS_EXTENSION -#endif -#define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension) - -#if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE) - #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE -#endif -#define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) - -#if defined(JSON_HEDLEY_CLANG_HAS_WARNING) - #undef JSON_HEDLEY_CLANG_HAS_WARNING -#endif -#define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning) - -#endif /* !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < X) */ - - -// This file contains all internal macro definitions (except those affecting ABI) -// You MUST include macro_unscope.hpp at the end of json.hpp to undef all of them - -// #include - - -// exclude unsupported compilers -#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK) - #if defined(__clang__) - #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400 - #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers" - #endif - #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER)) - #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800 - #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers" - #endif - #endif -#endif - -// C++ language standard detection -// if the user manually specified the used c++ version this is skipped -#if !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11) - #if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) - #define JSON_HAS_CPP_20 - #define JSON_HAS_CPP_17 - #define JSON_HAS_CPP_14 - #elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 - #define JSON_HAS_CPP_17 - #define JSON_HAS_CPP_14 - #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) - #define JSON_HAS_CPP_14 - #endif - // the cpp 11 flag is always specified because it is the minimal required version - #define JSON_HAS_CPP_11 -#endif - -#ifdef __has_include - #if __has_include() - #include - #endif -#endif - -#if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM) - #ifdef JSON_HAS_CPP_17 - #if defined(__cpp_lib_filesystem) - #define JSON_HAS_FILESYSTEM 1 - #elif defined(__cpp_lib_experimental_filesystem) - #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 - #elif !defined(__has_include) - #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 - #elif __has_include() - #define JSON_HAS_FILESYSTEM 1 - #elif __has_include() - #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 - #endif - - // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ - #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 - #undef JSON_HAS_FILESYSTEM - #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM - #endif - - // no filesystem support before GCC 8: https://en.cppreference.com/w/cpp/compiler_support - #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8 - #undef JSON_HAS_FILESYSTEM - #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM - #endif - - // no filesystem support before Clang 7: https://en.cppreference.com/w/cpp/compiler_support - #if defined(__clang_major__) && __clang_major__ < 7 - #undef JSON_HAS_FILESYSTEM - #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM - #endif - - // no filesystem support before MSVC 19.14: https://en.cppreference.com/w/cpp/compiler_support - #if defined(_MSC_VER) && _MSC_VER < 1914 - #undef JSON_HAS_FILESYSTEM - #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM - #endif - - // no filesystem support before iOS 13 - #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000 - #undef JSON_HAS_FILESYSTEM - #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM - #endif - - // no filesystem support before macOS Catalina - #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 - #undef JSON_HAS_FILESYSTEM - #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM - #endif - #endif -#endif - -#ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM - #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0 -#endif - -#ifndef JSON_HAS_FILESYSTEM - #define JSON_HAS_FILESYSTEM 0 -#endif - -#ifndef JSON_HAS_THREE_WAY_COMPARISON - #if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L \ - && defined(__cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907L - #define JSON_HAS_THREE_WAY_COMPARISON 1 - #else - #define JSON_HAS_THREE_WAY_COMPARISON 0 - #endif -#endif - -#ifndef JSON_HAS_RANGES - // ranges header shipping in GCC 11.1.0 (released 2021-04-27) has syntax error - #if defined(__GLIBCXX__) && __GLIBCXX__ == 20210427 - #define JSON_HAS_RANGES 0 - #elif defined(__cpp_lib_ranges) - #define JSON_HAS_RANGES 1 - #else - #define JSON_HAS_RANGES 0 - #endif -#endif - -#ifdef JSON_HAS_CPP_17 - #define JSON_INLINE_VARIABLE inline -#else - #define JSON_INLINE_VARIABLE -#endif - -#if JSON_HEDLEY_HAS_ATTRIBUTE(no_unique_address) - #define JSON_NO_UNIQUE_ADDRESS [[no_unique_address]] -#else - #define JSON_NO_UNIQUE_ADDRESS -#endif - -// disable documentation warnings on clang -#if defined(__clang__) - #pragma clang diagnostic push - #pragma clang diagnostic ignored "-Wdocumentation" - #pragma clang diagnostic ignored "-Wdocumentation-unknown-command" -#endif - -// allow disabling exceptions -#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION) - #define JSON_THROW(exception) throw exception - #define JSON_TRY try - #define JSON_CATCH(exception) catch(exception) - #define JSON_INTERNAL_CATCH(exception) catch(exception) -#else - #include - #define JSON_THROW(exception) std::abort() - #define JSON_TRY if(true) - #define JSON_CATCH(exception) if(false) - #define JSON_INTERNAL_CATCH(exception) if(false) -#endif - -// override exception macros -#if defined(JSON_THROW_USER) - #undef JSON_THROW - #define JSON_THROW JSON_THROW_USER -#endif -#if defined(JSON_TRY_USER) - #undef JSON_TRY - #define JSON_TRY JSON_TRY_USER -#endif -#if defined(JSON_CATCH_USER) - #undef JSON_CATCH - #define JSON_CATCH JSON_CATCH_USER - #undef JSON_INTERNAL_CATCH - #define JSON_INTERNAL_CATCH JSON_CATCH_USER -#endif -#if defined(JSON_INTERNAL_CATCH_USER) - #undef JSON_INTERNAL_CATCH - #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER -#endif - -// allow overriding assert -#if !defined(JSON_ASSERT) - #include // assert - #define JSON_ASSERT(x) assert(x) -#endif - -// allow to access some private functions (needed by the test suite) -#if defined(JSON_TESTS_PRIVATE) - #define JSON_PRIVATE_UNLESS_TESTED public -#else - #define JSON_PRIVATE_UNLESS_TESTED private -#endif - -/*! -@brief macro to briefly define a mapping between an enum and JSON -@def NLOHMANN_JSON_SERIALIZE_ENUM -@since version 3.4.0 -*/ -#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \ - template \ - inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \ - { \ - static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ - static const std::pair m[] = __VA_ARGS__; \ - auto it = std::find_if(std::begin(m), std::end(m), \ - [e](const std::pair& ej_pair) -> bool \ - { \ - return ej_pair.first == e; \ - }); \ - j = ((it != std::end(m)) ? it : std::begin(m))->second; \ - } \ - template \ - inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \ - { \ - static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ - static const std::pair m[] = __VA_ARGS__; \ - auto it = std::find_if(std::begin(m), std::end(m), \ - [&j](const std::pair& ej_pair) -> bool \ - { \ - return ej_pair.second == j; \ - }); \ - e = ((it != std::end(m)) ? it : std::begin(m))->first; \ - } - -// Ugly macros to avoid uglier copy-paste when specializing basic_json. They -// may be removed in the future once the class is split. - -#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \ - template class ObjectType, \ - template class ArrayType, \ - class StringType, class BooleanType, class NumberIntegerType, \ - class NumberUnsignedType, class NumberFloatType, \ - template class AllocatorType, \ - template class JSONSerializer, \ - class BinaryType> - -#define NLOHMANN_BASIC_JSON_TPL \ - basic_json - -// Macros to simplify conversion from/to types - -#define NLOHMANN_JSON_EXPAND( x ) x -#define NLOHMANN_JSON_GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, NAME,...) NAME -#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \ - NLOHMANN_JSON_PASTE64, \ - NLOHMANN_JSON_PASTE63, \ - NLOHMANN_JSON_PASTE62, \ - NLOHMANN_JSON_PASTE61, \ - NLOHMANN_JSON_PASTE60, \ - NLOHMANN_JSON_PASTE59, \ - NLOHMANN_JSON_PASTE58, \ - NLOHMANN_JSON_PASTE57, \ - NLOHMANN_JSON_PASTE56, \ - NLOHMANN_JSON_PASTE55, \ - NLOHMANN_JSON_PASTE54, \ - NLOHMANN_JSON_PASTE53, \ - NLOHMANN_JSON_PASTE52, \ - NLOHMANN_JSON_PASTE51, \ - NLOHMANN_JSON_PASTE50, \ - NLOHMANN_JSON_PASTE49, \ - NLOHMANN_JSON_PASTE48, \ - NLOHMANN_JSON_PASTE47, \ - NLOHMANN_JSON_PASTE46, \ - NLOHMANN_JSON_PASTE45, \ - NLOHMANN_JSON_PASTE44, \ - NLOHMANN_JSON_PASTE43, \ - NLOHMANN_JSON_PASTE42, \ - NLOHMANN_JSON_PASTE41, \ - NLOHMANN_JSON_PASTE40, \ - NLOHMANN_JSON_PASTE39, \ - NLOHMANN_JSON_PASTE38, \ - NLOHMANN_JSON_PASTE37, \ - NLOHMANN_JSON_PASTE36, \ - NLOHMANN_JSON_PASTE35, \ - NLOHMANN_JSON_PASTE34, \ - NLOHMANN_JSON_PASTE33, \ - NLOHMANN_JSON_PASTE32, \ - NLOHMANN_JSON_PASTE31, \ - NLOHMANN_JSON_PASTE30, \ - NLOHMANN_JSON_PASTE29, \ - NLOHMANN_JSON_PASTE28, \ - NLOHMANN_JSON_PASTE27, \ - NLOHMANN_JSON_PASTE26, \ - NLOHMANN_JSON_PASTE25, \ - NLOHMANN_JSON_PASTE24, \ - NLOHMANN_JSON_PASTE23, \ - NLOHMANN_JSON_PASTE22, \ - NLOHMANN_JSON_PASTE21, \ - NLOHMANN_JSON_PASTE20, \ - NLOHMANN_JSON_PASTE19, \ - NLOHMANN_JSON_PASTE18, \ - NLOHMANN_JSON_PASTE17, \ - NLOHMANN_JSON_PASTE16, \ - NLOHMANN_JSON_PASTE15, \ - NLOHMANN_JSON_PASTE14, \ - NLOHMANN_JSON_PASTE13, \ - NLOHMANN_JSON_PASTE12, \ - NLOHMANN_JSON_PASTE11, \ - NLOHMANN_JSON_PASTE10, \ - NLOHMANN_JSON_PASTE9, \ - NLOHMANN_JSON_PASTE8, \ - NLOHMANN_JSON_PASTE7, \ - NLOHMANN_JSON_PASTE6, \ - NLOHMANN_JSON_PASTE5, \ - NLOHMANN_JSON_PASTE4, \ - NLOHMANN_JSON_PASTE3, \ - NLOHMANN_JSON_PASTE2, \ - NLOHMANN_JSON_PASTE1)(__VA_ARGS__)) -#define NLOHMANN_JSON_PASTE2(func, v1) func(v1) -#define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2) -#define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3) -#define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4) -#define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5) -#define NLOHMANN_JSON_PASTE7(func, v1, v2, v3, v4, v5, v6) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE6(func, v2, v3, v4, v5, v6) -#define NLOHMANN_JSON_PASTE8(func, v1, v2, v3, v4, v5, v6, v7) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE7(func, v2, v3, v4, v5, v6, v7) -#define NLOHMANN_JSON_PASTE9(func, v1, v2, v3, v4, v5, v6, v7, v8) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE8(func, v2, v3, v4, v5, v6, v7, v8) -#define NLOHMANN_JSON_PASTE10(func, v1, v2, v3, v4, v5, v6, v7, v8, v9) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE9(func, v2, v3, v4, v5, v6, v7, v8, v9) -#define NLOHMANN_JSON_PASTE11(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE10(func, v2, v3, v4, v5, v6, v7, v8, v9, v10) -#define NLOHMANN_JSON_PASTE12(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE11(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) -#define NLOHMANN_JSON_PASTE13(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE12(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) -#define NLOHMANN_JSON_PASTE14(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE13(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) -#define NLOHMANN_JSON_PASTE15(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE14(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) -#define NLOHMANN_JSON_PASTE16(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE15(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) -#define NLOHMANN_JSON_PASTE17(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE16(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) -#define NLOHMANN_JSON_PASTE18(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE17(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) -#define NLOHMANN_JSON_PASTE19(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE18(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) -#define NLOHMANN_JSON_PASTE20(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE19(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) -#define NLOHMANN_JSON_PASTE21(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE20(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) -#define NLOHMANN_JSON_PASTE22(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE21(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) -#define NLOHMANN_JSON_PASTE23(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE22(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) -#define NLOHMANN_JSON_PASTE24(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE23(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) -#define NLOHMANN_JSON_PASTE25(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE24(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) -#define NLOHMANN_JSON_PASTE26(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE25(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) -#define NLOHMANN_JSON_PASTE27(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE26(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) -#define NLOHMANN_JSON_PASTE28(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE27(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) -#define NLOHMANN_JSON_PASTE29(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE28(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) -#define NLOHMANN_JSON_PASTE30(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE29(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) -#define NLOHMANN_JSON_PASTE31(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE30(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) -#define NLOHMANN_JSON_PASTE32(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE31(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) -#define NLOHMANN_JSON_PASTE33(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE32(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) -#define NLOHMANN_JSON_PASTE34(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE33(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) -#define NLOHMANN_JSON_PASTE35(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE34(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) -#define NLOHMANN_JSON_PASTE36(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE35(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) -#define NLOHMANN_JSON_PASTE37(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE36(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) -#define NLOHMANN_JSON_PASTE38(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE37(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) -#define NLOHMANN_JSON_PASTE39(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE38(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) -#define NLOHMANN_JSON_PASTE40(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE39(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) -#define NLOHMANN_JSON_PASTE41(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE40(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) -#define NLOHMANN_JSON_PASTE42(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE41(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) -#define NLOHMANN_JSON_PASTE43(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE42(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) -#define NLOHMANN_JSON_PASTE44(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE43(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) -#define NLOHMANN_JSON_PASTE45(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE44(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) -#define NLOHMANN_JSON_PASTE46(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE45(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) -#define NLOHMANN_JSON_PASTE47(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE46(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) -#define NLOHMANN_JSON_PASTE48(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE47(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) -#define NLOHMANN_JSON_PASTE49(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE48(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) -#define NLOHMANN_JSON_PASTE50(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE49(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) -#define NLOHMANN_JSON_PASTE51(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE50(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) -#define NLOHMANN_JSON_PASTE52(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE51(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) -#define NLOHMANN_JSON_PASTE53(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE52(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) -#define NLOHMANN_JSON_PASTE54(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE53(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) -#define NLOHMANN_JSON_PASTE55(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE54(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) -#define NLOHMANN_JSON_PASTE56(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE55(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) -#define NLOHMANN_JSON_PASTE57(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE56(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) -#define NLOHMANN_JSON_PASTE58(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE57(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) -#define NLOHMANN_JSON_PASTE59(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE58(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) -#define NLOHMANN_JSON_PASTE60(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE59(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) -#define NLOHMANN_JSON_PASTE61(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE60(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) -#define NLOHMANN_JSON_PASTE62(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE61(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) -#define NLOHMANN_JSON_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE62(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) -#define NLOHMANN_JSON_PASTE64(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE63(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) - -#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1; -#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1); -#define NLOHMANN_JSON_FROM_WITH_DEFAULT(v1) nlohmann_json_t.v1 = nlohmann_json_j.value(#v1, nlohmann_json_default_obj.v1); - -/*! -@brief macro -@def NLOHMANN_DEFINE_TYPE_INTRUSIVE -@since version 3.9.0 -*/ -#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \ - friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ - friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } - -#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \ - friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ - friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { Type nlohmann_json_default_obj; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) } - -/*! -@brief macro -@def NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE -@since version 3.9.0 -*/ -#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \ - inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ - inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } - -#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \ - inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ - inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { Type nlohmann_json_default_obj; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) } - - -// inspired from https://stackoverflow.com/a/26745591 -// allows to call any std function as if (e.g. with begin): -// using std::begin; begin(x); -// -// it allows using the detected idiom to retrieve the return type -// of such an expression -#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \ - namespace detail { \ - using std::std_name; \ - \ - template \ - using result_of_##std_name = decltype(std_name(std::declval()...)); \ - } \ - \ - namespace detail2 { \ - struct std_name##_tag \ - { \ - }; \ - \ - template \ - std_name##_tag std_name(T&&...); \ - \ - template \ - using result_of_##std_name = decltype(std_name(std::declval()...)); \ - \ - template \ - struct would_call_std_##std_name \ - { \ - static constexpr auto const value = ::nlohmann::detail:: \ - is_detected_exact::value; \ - }; \ - } /* namespace detail2 */ \ - \ - template \ - struct would_call_std_##std_name : detail2::would_call_std_##std_name \ - { \ - } - -#ifndef JSON_USE_IMPLICIT_CONVERSIONS - #define JSON_USE_IMPLICIT_CONVERSIONS 1 -#endif - -#if JSON_USE_IMPLICIT_CONVERSIONS - #define JSON_EXPLICIT -#else - #define JSON_EXPLICIT explicit -#endif - -#ifndef JSON_DISABLE_ENUM_SERIALIZATION - #define JSON_DISABLE_ENUM_SERIALIZATION 0 -#endif - -#ifndef JSON_USE_GLOBAL_UDLS - #define JSON_USE_GLOBAL_UDLS 1 -#endif - -#if JSON_HAS_THREE_WAY_COMPARISON - #include // partial_ordering -#endif - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ - -/////////////////////////// -// JSON type enumeration // -/////////////////////////// - -/*! -@brief the JSON type enumeration - -This enumeration collects the different JSON types. It is internally used to -distinguish the stored values, and the functions @ref basic_json::is_null(), -@ref basic_json::is_object(), @ref basic_json::is_array(), -@ref basic_json::is_string(), @ref basic_json::is_boolean(), -@ref basic_json::is_number() (with @ref basic_json::is_number_integer(), -@ref basic_json::is_number_unsigned(), and @ref basic_json::is_number_float()), -@ref basic_json::is_discarded(), @ref basic_json::is_primitive(), and -@ref basic_json::is_structured() rely on it. - -@note There are three enumeration entries (number_integer, number_unsigned, and -number_float), because the library distinguishes these three types for numbers: -@ref basic_json::number_unsigned_t is used for unsigned integers, -@ref basic_json::number_integer_t is used for signed integers, and -@ref basic_json::number_float_t is used for floating-point numbers or to -approximate integers which do not fit in the limits of their respective type. - -@sa see @ref basic_json::basic_json(const value_t value_type) -- create a JSON -value with the default value for a given type - -@since version 1.0.0 -*/ -enum class value_t : std::uint8_t -{ - null, ///< null value - object, ///< object (unordered set of name/value pairs) - array, ///< array (ordered collection of values) - string, ///< string value - boolean, ///< boolean value - number_integer, ///< number value (signed integer) - number_unsigned, ///< number value (unsigned integer) - number_float, ///< number value (floating-point) - binary, ///< binary array (ordered collection of bytes) - discarded ///< discarded by the parser callback function -}; - -/*! -@brief comparison operator for JSON types - -Returns an ordering that is similar to Python: -- order: null < boolean < number < object < array < string < binary -- furthermore, each type is not smaller than itself -- discarded values are not comparable -- binary is represented as a b"" string in python and directly comparable to a - string; however, making a binary array directly comparable with a string would - be surprising behavior in a JSON file. - -@since version 1.0.0 -*/ -#if JSON_HAS_THREE_WAY_COMPARISON - inline std::partial_ordering operator<=>(const value_t lhs, const value_t rhs) noexcept // *NOPAD* -#else - inline bool operator<(const value_t lhs, const value_t rhs) noexcept -#endif -{ - static constexpr std::array order = {{ - 0 /* null */, 3 /* object */, 4 /* array */, 5 /* string */, - 1 /* boolean */, 2 /* integer */, 2 /* unsigned */, 2 /* float */, - 6 /* binary */ - } - }; - - const auto l_index = static_cast(lhs); - const auto r_index = static_cast(rhs); -#if JSON_HAS_THREE_WAY_COMPARISON - if (l_index < order.size() && r_index < order.size()) - { - return order[l_index] <=> order[r_index]; // *NOPAD* - } - return std::partial_ordering::unordered; -#else - return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index]; -#endif -} - -// GCC selects the built-in operator< over an operator rewritten from -// a user-defined spaceship operator -// Clang, MSVC, and ICC select the rewritten candidate -// (see GCC bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105200) -#if JSON_HAS_THREE_WAY_COMPARISON && defined(__GNUC__) -inline bool operator<(const value_t lhs, const value_t rhs) noexcept -{ - return std::is_lt(lhs <=> rhs); // *NOPAD* -} -#endif - -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END - -// #include -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - - - -// #include - - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ - -/*! -@brief replace all occurrences of a substring by another string - -@param[in,out] s the string to manipulate; changed so that all - occurrences of @a f are replaced with @a t -@param[in] f the substring to replace with @a t -@param[in] t the string to replace @a f - -@pre The search string @a f must not be empty. **This precondition is -enforced with an assertion.** - -@since version 2.0.0 -*/ -template -inline void replace_substring(StringType& s, const StringType& f, - const StringType& t) -{ - JSON_ASSERT(!f.empty()); - for (auto pos = s.find(f); // find first occurrence of f - pos != StringType::npos; // make sure f was found - s.replace(pos, f.size(), t), // replace with t, and - pos = s.find(f, pos + t.size())) // find next occurrence of f - {} -} - -/*! - * @brief string escaping as described in RFC 6901 (Sect. 4) - * @param[in] s string to escape - * @return escaped string - * - * Note the order of escaping "~" to "~0" and "/" to "~1" is important. - */ -template -inline StringType escape(StringType s) -{ - replace_substring(s, StringType{"~"}, StringType{"~0"}); - replace_substring(s, StringType{"/"}, StringType{"~1"}); - return s; -} - -/*! - * @brief string unescaping as described in RFC 6901 (Sect. 4) - * @param[in] s string to unescape - * @return unescaped string - * - * Note the order of escaping "~1" to "/" and "~0" to "~" is important. - */ -template -static void unescape(StringType& s) -{ - replace_substring(s, StringType{"~1"}, StringType{"/"}); - replace_substring(s, StringType{"~0"}, StringType{"~"}); -} - -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END - -// #include -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - - - -#include // size_t - -// #include - - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ - -/// struct to capture the start position of the current token -struct position_t -{ - /// the total number of characters read - std::size_t chars_read_total = 0; - /// the number of characters read in the current line - std::size_t chars_read_current_line = 0; - /// the number of lines read - std::size_t lines_read = 0; - - /// conversion to size_t to preserve SAX interface - constexpr operator size_t() const - { - return chars_read_total; - } -}; - -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END - -// #include - -// #include -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-FileCopyrightText: 2018 The Abseil Authors -// SPDX-License-Identifier: MIT - - - -#include // array -#include // size_t -#include // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type -#include // index_sequence, make_index_sequence, index_sequence_for - -// #include - - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ - -template -using uncvref_t = typename std::remove_cv::type>::type; - -#ifdef JSON_HAS_CPP_14 - -// the following utilities are natively available in C++14 -using std::enable_if_t; -using std::index_sequence; -using std::make_index_sequence; -using std::index_sequence_for; - -#else - -// alias templates to reduce boilerplate -template -using enable_if_t = typename std::enable_if::type; - -// The following code is taken from https://github.com/abseil/abseil-cpp/blob/10cb35e459f5ecca5b2ff107635da0bfa41011b4/absl/utility/utility.h -// which is part of Google Abseil (https://github.com/abseil/abseil-cpp), licensed under the Apache License 2.0. - -//// START OF CODE FROM GOOGLE ABSEIL - -// integer_sequence -// -// Class template representing a compile-time integer sequence. An instantiation -// of `integer_sequence` has a sequence of integers encoded in its -// type through its template arguments (which is a common need when -// working with C++11 variadic templates). `absl::integer_sequence` is designed -// to be a drop-in replacement for C++14's `std::integer_sequence`. -// -// Example: -// -// template< class T, T... Ints > -// void user_function(integer_sequence); -// -// int main() -// { -// // user_function's `T` will be deduced to `int` and `Ints...` -// // will be deduced to `0, 1, 2, 3, 4`. -// user_function(make_integer_sequence()); -// } -template -struct integer_sequence -{ - using value_type = T; - static constexpr std::size_t size() noexcept - { - return sizeof...(Ints); - } -}; - -// index_sequence -// -// A helper template for an `integer_sequence` of `size_t`, -// `absl::index_sequence` is designed to be a drop-in replacement for C++14's -// `std::index_sequence`. -template -using index_sequence = integer_sequence; - -namespace utility_internal -{ - -template -struct Extend; - -// Note that SeqSize == sizeof...(Ints). It's passed explicitly for efficiency. -template -struct Extend, SeqSize, 0> -{ - using type = integer_sequence < T, Ints..., (Ints + SeqSize)... >; -}; - -template -struct Extend, SeqSize, 1> -{ - using type = integer_sequence < T, Ints..., (Ints + SeqSize)..., 2 * SeqSize >; -}; - -// Recursion helper for 'make_integer_sequence'. -// 'Gen::type' is an alias for 'integer_sequence'. -template -struct Gen -{ - using type = - typename Extend < typename Gen < T, N / 2 >::type, N / 2, N % 2 >::type; -}; - -template -struct Gen -{ - using type = integer_sequence; -}; - -} // namespace utility_internal - -// Compile-time sequences of integers - -// make_integer_sequence -// -// This template alias is equivalent to -// `integer_sequence`, and is designed to be a drop-in -// replacement for C++14's `std::make_integer_sequence`. -template -using make_integer_sequence = typename utility_internal::Gen::type; - -// make_index_sequence -// -// This template alias is equivalent to `index_sequence<0, 1, ..., N-1>`, -// and is designed to be a drop-in replacement for C++14's -// `std::make_index_sequence`. -template -using make_index_sequence = make_integer_sequence; - -// index_sequence_for -// -// Converts a typename pack into an index sequence of the same length, and -// is designed to be a drop-in replacement for C++14's -// `std::index_sequence_for()` -template -using index_sequence_for = make_index_sequence; - -//// END OF CODE FROM GOOGLE ABSEIL - -#endif - -// dispatch utility (taken from ranges-v3) -template struct priority_tag : priority_tag < N - 1 > {}; -template<> struct priority_tag<0> {}; - -// taken from ranges-v3 -template -struct static_const -{ - static JSON_INLINE_VARIABLE constexpr T value{}; -}; - -#ifndef JSON_HAS_CPP_17 - template - constexpr T static_const::value; -#endif - -template -inline constexpr std::array make_array(Args&& ... args) -{ - return std::array {{static_cast(std::forward(args))...}}; -} - -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END - -// #include -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - - - -#include // numeric_limits -#include // false_type, is_constructible, is_integral, is_same, true_type -#include // declval -#include // tuple - -// #include -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - - - -#include // random_access_iterator_tag - -// #include - -// #include - -// #include - - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ - -template -struct iterator_types {}; - -template -struct iterator_types < - It, - void_t> -{ - using difference_type = typename It::difference_type; - using value_type = typename It::value_type; - using pointer = typename It::pointer; - using reference = typename It::reference; - using iterator_category = typename It::iterator_category; -}; - -// This is required as some compilers implement std::iterator_traits in a way that -// doesn't work with SFINAE. See https://github.com/nlohmann/json/issues/1341. -template -struct iterator_traits -{ -}; - -template -struct iterator_traits < T, enable_if_t < !std::is_pointer::value >> - : iterator_types -{ -}; - -template -struct iterator_traits::value>> -{ - using iterator_category = std::random_access_iterator_tag; - using value_type = T; - using difference_type = ptrdiff_t; - using pointer = T*; - using reference = T&; -}; - -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END - -// #include - -// #include -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - - - -// #include - - -NLOHMANN_JSON_NAMESPACE_BEGIN - -NLOHMANN_CAN_CALL_STD_FUNC_IMPL(begin); - -NLOHMANN_JSON_NAMESPACE_END - -// #include -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - - - -// #include - - -NLOHMANN_JSON_NAMESPACE_BEGIN - -NLOHMANN_CAN_CALL_STD_FUNC_IMPL(end); - -NLOHMANN_JSON_NAMESPACE_END - -// #include - -// #include - -// #include -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - -#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_ - #define INCLUDE_NLOHMANN_JSON_FWD_HPP_ - - #include // int64_t, uint64_t - #include // map - #include // allocator - #include // string - #include // vector - - // #include - - - /*! - @brief namespace for Niels Lohmann - @see https://github.com/nlohmann - @since version 1.0.0 - */ - NLOHMANN_JSON_NAMESPACE_BEGIN - - /*! - @brief default JSONSerializer template argument - - This serializer ignores the template arguments and uses ADL - ([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl)) - for serialization. - */ - template - struct adl_serializer; - - /// a class to store JSON values - /// @sa https://json.nlohmann.me/api/basic_json/ - template class ObjectType = - std::map, - template class ArrayType = std::vector, - class StringType = std::string, class BooleanType = bool, - class NumberIntegerType = std::int64_t, - class NumberUnsignedType = std::uint64_t, - class NumberFloatType = double, - template class AllocatorType = std::allocator, - template class JSONSerializer = - adl_serializer, - class BinaryType = std::vector> - class basic_json; - - /// @brief JSON Pointer defines a string syntax for identifying a specific value within a JSON document - /// @sa https://json.nlohmann.me/api/json_pointer/ - template - class json_pointer; - - /*! - @brief default specialization - @sa https://json.nlohmann.me/api/json/ - */ - using json = basic_json<>; - - /// @brief a minimal map-like container that preserves insertion order - /// @sa https://json.nlohmann.me/api/ordered_map/ - template - struct ordered_map; - - /// @brief specialization that maintains the insertion order of object keys - /// @sa https://json.nlohmann.me/api/ordered_json/ - using ordered_json = basic_json; - - NLOHMANN_JSON_NAMESPACE_END - -#endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_ - - -NLOHMANN_JSON_NAMESPACE_BEGIN -/*! -@brief detail namespace with internal helper functions - -This namespace collects functions that should not be exposed, -implementations of some @ref basic_json methods, and meta-programming helpers. - -@since version 2.1.0 -*/ -namespace detail -{ - -///////////// -// helpers // -///////////// - -// Note to maintainers: -// -// Every trait in this file expects a non CV-qualified type. -// The only exceptions are in the 'aliases for detected' section -// (i.e. those of the form: decltype(T::member_function(std::declval()))) -// -// In this case, T has to be properly CV-qualified to constraint the function arguments -// (e.g. to_json(BasicJsonType&, const T&)) - -template struct is_basic_json : std::false_type {}; - -NLOHMANN_BASIC_JSON_TPL_DECLARATION -struct is_basic_json : std::true_type {}; - -// used by exceptions create() member functions -// true_type for pointer to possibly cv-qualified basic_json or std::nullptr_t -// false_type otherwise -template -struct is_basic_json_context : - std::integral_constant < bool, - is_basic_json::type>::type>::value - || std::is_same::value > -{}; - -////////////////////// -// json_ref helpers // -////////////////////// - -template -class json_ref; - -template -struct is_json_ref : std::false_type {}; - -template -struct is_json_ref> : std::true_type {}; - -////////////////////////// -// aliases for detected // -////////////////////////// - -template -using mapped_type_t = typename T::mapped_type; - -template -using key_type_t = typename T::key_type; - -template -using value_type_t = typename T::value_type; - -template -using difference_type_t = typename T::difference_type; - -template -using pointer_t = typename T::pointer; - -template -using reference_t = typename T::reference; - -template -using iterator_category_t = typename T::iterator_category; - -template -using to_json_function = decltype(T::to_json(std::declval()...)); - -template -using from_json_function = decltype(T::from_json(std::declval()...)); - -template -using get_template_function = decltype(std::declval().template get()); - -// trait checking if JSONSerializer::from_json(json const&, udt&) exists -template -struct has_from_json : std::false_type {}; - -// trait checking if j.get is valid -// use this trait instead of std::is_constructible or std::is_convertible, -// both rely on, or make use of implicit conversions, and thus fail when T -// has several constructors/operator= (see https://github.com/nlohmann/json/issues/958) -template -struct is_getable -{ - static constexpr bool value = is_detected::value; -}; - -template -struct has_from_json < BasicJsonType, T, enable_if_t < !is_basic_json::value >> -{ - using serializer = typename BasicJsonType::template json_serializer; - - static constexpr bool value = - is_detected_exact::value; -}; - -// This trait checks if JSONSerializer::from_json(json const&) exists -// this overload is used for non-default-constructible user-defined-types -template -struct has_non_default_from_json : std::false_type {}; - -template -struct has_non_default_from_json < BasicJsonType, T, enable_if_t < !is_basic_json::value >> -{ - using serializer = typename BasicJsonType::template json_serializer; - - static constexpr bool value = - is_detected_exact::value; -}; - -// This trait checks if BasicJsonType::json_serializer::to_json exists -// Do not evaluate the trait when T is a basic_json type, to avoid template instantiation infinite recursion. -template -struct has_to_json : std::false_type {}; - -template -struct has_to_json < BasicJsonType, T, enable_if_t < !is_basic_json::value >> -{ - using serializer = typename BasicJsonType::template json_serializer; - - static constexpr bool value = - is_detected_exact::value; -}; - -template -using detect_key_compare = typename T::key_compare; - -template -struct has_key_compare : std::integral_constant::value> {}; - -// obtains the actual object key comparator -template -struct actual_object_comparator -{ - using object_t = typename BasicJsonType::object_t; - using object_comparator_t = typename BasicJsonType::default_object_comparator_t; - using type = typename std::conditional < has_key_compare::value, - typename object_t::key_compare, object_comparator_t>::type; -}; - -template -using actual_object_comparator_t = typename actual_object_comparator::type; - -/////////////////// -// is_ functions // -/////////////////// - -// https://en.cppreference.com/w/cpp/types/conjunction -template struct conjunction : std::true_type { }; -template struct conjunction : B { }; -template -struct conjunction -: std::conditional(B::value), conjunction, B>::type {}; - -// https://en.cppreference.com/w/cpp/types/negation -template struct negation : std::integral_constant < bool, !B::value > { }; - -// Reimplementation of is_constructible and is_default_constructible, due to them being broken for -// std::pair and std::tuple until LWG 2367 fix (see https://cplusplus.github.io/LWG/lwg-defects.html#2367). -// This causes compile errors in e.g. clang 3.5 or gcc 4.9. -template -struct is_default_constructible : std::is_default_constructible {}; - -template -struct is_default_constructible> - : conjunction, is_default_constructible> {}; - -template -struct is_default_constructible> - : conjunction, is_default_constructible> {}; - -template -struct is_default_constructible> - : conjunction...> {}; - -template -struct is_default_constructible> - : conjunction...> {}; - - -template -struct is_constructible : std::is_constructible {}; - -template -struct is_constructible> : is_default_constructible> {}; - -template -struct is_constructible> : is_default_constructible> {}; - -template -struct is_constructible> : is_default_constructible> {}; - -template -struct is_constructible> : is_default_constructible> {}; - - -template -struct is_iterator_traits : std::false_type {}; - -template -struct is_iterator_traits> -{ - private: - using traits = iterator_traits; - - public: - static constexpr auto value = - is_detected::value && - is_detected::value && - is_detected::value && - is_detected::value && - is_detected::value; -}; - -template -struct is_range -{ - private: - using t_ref = typename std::add_lvalue_reference::type; - - using iterator = detected_t; - using sentinel = detected_t; - - // to be 100% correct, it should use https://en.cppreference.com/w/cpp/iterator/input_or_output_iterator - // and https://en.cppreference.com/w/cpp/iterator/sentinel_for - // but reimplementing these would be too much work, as a lot of other concepts are used underneath - static constexpr auto is_iterator_begin = - is_iterator_traits>::value; - - public: - static constexpr bool value = !std::is_same::value && !std::is_same::value && is_iterator_begin; -}; - -template -using iterator_t = enable_if_t::value, result_of_begin())>>; - -template -using range_value_t = value_type_t>>; - -// The following implementation of is_complete_type is taken from -// https://blogs.msdn.microsoft.com/vcblog/2015/12/02/partial-support-for-expression-sfinae-in-vs-2015-update-1/ -// and is written by Xiang Fan who agreed to using it in this library. - -template -struct is_complete_type : std::false_type {}; - -template -struct is_complete_type : std::true_type {}; - -template -struct is_compatible_object_type_impl : std::false_type {}; - -template -struct is_compatible_object_type_impl < - BasicJsonType, CompatibleObjectType, - enable_if_t < is_detected::value&& - is_detected::value >> -{ - using object_t = typename BasicJsonType::object_t; - - // macOS's is_constructible does not play well with nonesuch... - static constexpr bool value = - is_constructible::value && - is_constructible::value; -}; - -template -struct is_compatible_object_type - : is_compatible_object_type_impl {}; - -template -struct is_constructible_object_type_impl : std::false_type {}; - -template -struct is_constructible_object_type_impl < - BasicJsonType, ConstructibleObjectType, - enable_if_t < is_detected::value&& - is_detected::value >> -{ - using object_t = typename BasicJsonType::object_t; - - static constexpr bool value = - (is_default_constructible::value && - (std::is_move_assignable::value || - std::is_copy_assignable::value) && - (is_constructible::value && - std::is_same < - typename object_t::mapped_type, - typename ConstructibleObjectType::mapped_type >::value)) || - (has_from_json::value || - has_non_default_from_json < - BasicJsonType, - typename ConstructibleObjectType::mapped_type >::value); -}; - -template -struct is_constructible_object_type - : is_constructible_object_type_impl {}; - -template -struct is_compatible_string_type -{ - static constexpr auto value = - is_constructible::value; -}; - -template -struct is_constructible_string_type -{ - // launder type through decltype() to fix compilation failure on ICPC -#ifdef __INTEL_COMPILER - using laundered_type = decltype(std::declval()); -#else - using laundered_type = ConstructibleStringType; -#endif - - static constexpr auto value = - conjunction < - is_constructible, - is_detected_exact>::value; -}; - -template -struct is_compatible_array_type_impl : std::false_type {}; - -template -struct is_compatible_array_type_impl < - BasicJsonType, CompatibleArrayType, - enable_if_t < - is_detected::value&& - is_iterator_traits>>::value&& -// special case for types like std::filesystem::path whose iterator's value_type are themselves -// c.f. https://github.com/nlohmann/json/pull/3073 - !std::is_same>::value >> -{ - static constexpr bool value = - is_constructible>::value; -}; - -template -struct is_compatible_array_type - : is_compatible_array_type_impl {}; - -template -struct is_constructible_array_type_impl : std::false_type {}; - -template -struct is_constructible_array_type_impl < - BasicJsonType, ConstructibleArrayType, - enable_if_t::value >> - : std::true_type {}; - -template -struct is_constructible_array_type_impl < - BasicJsonType, ConstructibleArrayType, - enable_if_t < !std::is_same::value&& - !is_compatible_string_type::value&& - is_default_constructible::value&& -(std::is_move_assignable::value || - std::is_copy_assignable::value)&& -is_detected::value&& -is_iterator_traits>>::value&& -is_detected::value&& -// special case for types like std::filesystem::path whose iterator's value_type are themselves -// c.f. https://github.com/nlohmann/json/pull/3073 -!std::is_same>::value&& - is_complete_type < - detected_t>::value >> -{ - using value_type = range_value_t; - - static constexpr bool value = - std::is_same::value || - has_from_json::value || - has_non_default_from_json < - BasicJsonType, - value_type >::value; -}; - -template -struct is_constructible_array_type - : is_constructible_array_type_impl {}; - -template -struct is_compatible_integer_type_impl : std::false_type {}; - -template -struct is_compatible_integer_type_impl < - RealIntegerType, CompatibleNumberIntegerType, - enable_if_t < std::is_integral::value&& - std::is_integral::value&& - !std::is_same::value >> -{ - // is there an assert somewhere on overflows? - using RealLimits = std::numeric_limits; - using CompatibleLimits = std::numeric_limits; - - static constexpr auto value = - is_constructible::value && - CompatibleLimits::is_integer && - RealLimits::is_signed == CompatibleLimits::is_signed; -}; - -template -struct is_compatible_integer_type - : is_compatible_integer_type_impl {}; - -template -struct is_compatible_type_impl: std::false_type {}; - -template -struct is_compatible_type_impl < - BasicJsonType, CompatibleType, - enable_if_t::value >> -{ - static constexpr bool value = - has_to_json::value; -}; - -template -struct is_compatible_type - : is_compatible_type_impl {}; - -template -struct is_constructible_tuple : std::false_type {}; - -template -struct is_constructible_tuple> : conjunction...> {}; - -template -struct is_json_iterator_of : std::false_type {}; - -template -struct is_json_iterator_of : std::true_type {}; - -template -struct is_json_iterator_of : std::true_type -{}; - -// checks if a given type T is a template specialization of Primary -template