From 0f45635072fa0c87d46d593f8ad965d73a1e34f4 Mon Sep 17 00:00:00 2001 From: Jojo-1000 <33495614+Jojo-1000@users.noreply.github.com> Date: Thu, 9 Apr 2020 21:41:50 +0200 Subject: [PATCH] Rename directory structure (not building). --- CMakeLists.txt | 14 ++++++++++++-- cmake/cmake_uninstall.cmake.in | 21 +++++++++++++++++++++ cmake/hueplusplus-config.cmake.in | 7 +++++++ cmake_uninstall.cmake.in | 21 --------------------- extern | 0 hueplusplus/BaseHttpHandler.cpp | 117 --------------------------------------------------------------------------------------------------------------------- hueplusplus/CMakeLists.txt | 78 ------------------------------------------------------------------------------ hueplusplus/ExtendedColorHueStrategy.cpp | 275 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- hueplusplus/ExtendedColorTemperatureStrategy.cpp | 151 ------------------------------------------------------------------------------------------------------------------------------------------------------- hueplusplus/Hue.cpp | 457 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- hueplusplus/HueCommandAPI.cpp | 135 --------------------------------------------------------------------------------------------------------------------------------------- hueplusplus/HueException.cpp | 103 ------------------------------------------------------------------------------------------------------- hueplusplus/HueLight.cpp | 252 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ hueplusplus/LinHttpHandler.cpp | 223 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- hueplusplus/SimpleBrightnessStrategy.cpp | 88 ---------------------------------------------------------------------------------------- hueplusplus/SimpleColorHueStrategy.cpp | 428 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- hueplusplus/SimpleColorTemperatureStrategy.cpp | 113 ----------------------------------------------------------------------------------------------------------------- hueplusplus/UPnP.cpp | 57 --------------------------------------------------------- hueplusplus/Utils.cpp | 82 ---------------------------------------------------------------------------------- hueplusplus/WinHttpHandler.cpp | 298 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- hueplusplus/hueplusplus-config.cmake.in | 7 ------- hueplusplus/include/BaseHttpHandler.h | 175 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- hueplusplus/include/BrightnessStrategy.h | 58 ---------------------------------------------------------- hueplusplus/include/ColorHueStrategy.h | 155 ----------------------------------------------------------------------------------------------------------------------------------------------------------- hueplusplus/include/ColorTemperatureStrategy.h | 70 ---------------------------------------------------------------------- hueplusplus/include/ExtendedColorHueStrategy.h | 63 --------------------------------------------------------------- hueplusplus/include/ExtendedColorTemperatureStrategy.h | 52 ---------------------------------------------------- hueplusplus/include/Hue.h | 282 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ hueplusplus/include/HueCommandAPI.h | 123 --------------------------------------------------------------------------------------------------------------------------- hueplusplus/include/HueConfig.h | 29 ----------------------------- hueplusplus/include/HueException.h | 118 ---------------------------------------------------------------------------------------------------------------------- hueplusplus/include/HueExceptionMacro.h | 27 --------------------------- hueplusplus/include/HueLight.h | 790 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- hueplusplus/include/IHttpHandler.h | 196 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- hueplusplus/include/LinHttpHandler.h | 60 ------------------------------------------------------------ hueplusplus/include/SimpleBrightnessStrategy.h | 55 ------------------------------------------------------- hueplusplus/include/SimpleColorHueStrategy.h | 152 -------------------------------------------------------------------------------------------------------------------------------------------------------- hueplusplus/include/SimpleColorTemperatureStrategy.h | 66 ------------------------------------------------------------------ hueplusplus/include/UPnP.h | 46 ---------------------------------------------- hueplusplus/include/Units.h | 60 ------------------------------------------------------------ hueplusplus/include/Utils.h | 83 ----------------------------------------------------------------------------------- hueplusplus/include/WinHttpHandler.h | 69 --------------------------------------------------------------------- hueplusplus/include/json/json.hpp | 22875 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- hueplusplus/test/CMakeLists.txt | 109 ------------------------------------------------------------------------------------------------------------- hueplusplus/test/CMakeLists.txt.in | 15 --------------- hueplusplus/test/CodeCoverage.cmake | 234 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ hueplusplus/test/mocks/mock_BaseHttpHandler.h | 44 -------------------------------------------- hueplusplus/test/mocks/mock_HttpHandler.h | 78 ------------------------------------------------------------------------------ hueplusplus/test/mocks/mock_HueLight.h | 134 -------------------------------------------------------------------------------------------------------------------------------------- hueplusplus/test/test_BaseHttpHandler.cpp | 237 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- hueplusplus/test/test_ExtendedColorHueStrategy.cpp | 248 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- hueplusplus/test/test_ExtendedColorTemperatureStrategy.cpp | 148 ---------------------------------------------------------------------------------------------------------------------------------------------------- hueplusplus/test/test_Hue.cpp | 523 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- hueplusplus/test/test_HueCommandAPI.cpp | 240 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ hueplusplus/test/test_HueLight.cpp | 904 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- hueplusplus/test/test_Main.cpp | 29 ----------------------------- hueplusplus/test/test_SimpleBrightnessStrategy.cpp | 93 --------------------------------------------------------------------------------------------- hueplusplus/test/test_SimpleColorHueStrategy.cpp | 418 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- hueplusplus/test/test_SimpleColorTemperatureStrategy.cpp | 125 ----------------------------------------------------------------------------------------------------------------------------- hueplusplus/test/test_UPnP.cpp | 51 --------------------------------------------------- hueplusplus/test/testhelper.h | 283 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- include/hueplusplus/BaseHttpHandler.h | 175 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/hueplusplus/BrightnessStrategy.h | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/hueplusplus/ColorHueStrategy.h | 155 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/hueplusplus/ColorTemperatureStrategy.h | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/hueplusplus/ExtendedColorHueStrategy.h | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/hueplusplus/ExtendedColorTemperatureStrategy.h | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ include/hueplusplus/Hue.h | 282 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/hueplusplus/HueCommandAPI.h | 123 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/hueplusplus/HueConfig.h | 29 +++++++++++++++++++++++++++++ include/hueplusplus/HueException.h | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/hueplusplus/HueExceptionMacro.h | 27 +++++++++++++++++++++++++++ include/hueplusplus/HueLight.h | 790 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/hueplusplus/IHttpHandler.h | 196 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/hueplusplus/LinHttpHandler.h | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/hueplusplus/SimpleBrightnessStrategy.h | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/hueplusplus/SimpleColorHueStrategy.h | 152 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/hueplusplus/SimpleColorTemperatureStrategy.h | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/hueplusplus/UPnP.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++ include/hueplusplus/Units.h | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/hueplusplus/Utils.h | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/hueplusplus/WinHttpHandler.h | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/json/json.hpp | 22875 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/BaseHttpHandler.cpp | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/CMakeLists.txt | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/ExtendedColorHueStrategy.cpp | 275 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/ExtendedColorTemperatureStrategy.cpp | 151 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/Hue.cpp | 457 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/HueCommandAPI.cpp | 135 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/HueException.cpp | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/HueLight.cpp | 252 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/LinHttpHandler.cpp | 223 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/SimpleBrightnessStrategy.cpp | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/SimpleColorHueStrategy.cpp | 428 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/SimpleColorTemperatureStrategy.cpp | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/UPnP.cpp | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/Utils.cpp | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/WinHttpHandler.cpp | 298 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/test/CMakeLists.txt | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/test/CMakeLists.txt.in | 15 +++++++++++++++ src/test/CodeCoverage.cmake | 234 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/test/mocks/mock_BaseHttpHandler.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/test/mocks/mock_HttpHandler.h | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/test/mocks/mock_HueLight.h | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/test/test_BaseHttpHandler.cpp | 237 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/test/test_ExtendedColorHueStrategy.cpp | 248 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/test/test_ExtendedColorTemperatureStrategy.cpp | 148 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/test/test_Hue.cpp | 523 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/test/test_HueCommandAPI.cpp | 240 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/test/test_HueLight.cpp | 904 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/test/test_Main.cpp | 29 +++++++++++++++++++++++++++++ src/test/test_SimpleBrightnessStrategy.cpp | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/test/test_SimpleColorHueStrategy.cpp | 418 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/test/test_SimpleColorTemperatureStrategy.cpp | 125 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/test/test_UPnP.cpp | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/test/testhelper.h | 283 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 116 files changed, 32402 insertions(+), 32404 deletions(-) create mode 100644 cmake/cmake_uninstall.cmake.in create mode 100644 cmake/hueplusplus-config.cmake.in delete mode 100755 cmake_uninstall.cmake.in create mode 100644 extern delete mode 100644 hueplusplus/BaseHttpHandler.cpp delete mode 100755 hueplusplus/CMakeLists.txt delete mode 100755 hueplusplus/ExtendedColorHueStrategy.cpp delete mode 100644 hueplusplus/ExtendedColorTemperatureStrategy.cpp delete mode 100644 hueplusplus/Hue.cpp delete mode 100644 hueplusplus/HueCommandAPI.cpp delete mode 100644 hueplusplus/HueException.cpp delete mode 100644 hueplusplus/HueLight.cpp delete mode 100755 hueplusplus/LinHttpHandler.cpp delete mode 100644 hueplusplus/SimpleBrightnessStrategy.cpp delete mode 100644 hueplusplus/SimpleColorHueStrategy.cpp delete mode 100644 hueplusplus/SimpleColorTemperatureStrategy.cpp delete mode 100755 hueplusplus/UPnP.cpp delete mode 100644 hueplusplus/Utils.cpp delete mode 100755 hueplusplus/WinHttpHandler.cpp delete mode 100755 hueplusplus/hueplusplus-config.cmake.in delete mode 100644 hueplusplus/include/BaseHttpHandler.h delete mode 100755 hueplusplus/include/BrightnessStrategy.h delete mode 100755 hueplusplus/include/ColorHueStrategy.h delete mode 100755 hueplusplus/include/ColorTemperatureStrategy.h delete mode 100755 hueplusplus/include/ExtendedColorHueStrategy.h delete mode 100755 hueplusplus/include/ExtendedColorTemperatureStrategy.h delete mode 100644 hueplusplus/include/Hue.h delete mode 100644 hueplusplus/include/HueCommandAPI.h delete mode 100755 hueplusplus/include/HueConfig.h delete mode 100644 hueplusplus/include/HueException.h delete mode 100644 hueplusplus/include/HueExceptionMacro.h delete mode 100644 hueplusplus/include/HueLight.h delete mode 100755 hueplusplus/include/IHttpHandler.h delete mode 100755 hueplusplus/include/LinHttpHandler.h delete mode 100755 hueplusplus/include/SimpleBrightnessStrategy.h delete mode 100755 hueplusplus/include/SimpleColorHueStrategy.h delete mode 100755 hueplusplus/include/SimpleColorTemperatureStrategy.h delete mode 100755 hueplusplus/include/UPnP.h delete mode 100644 hueplusplus/include/Units.h delete mode 100644 hueplusplus/include/Utils.h delete mode 100644 hueplusplus/include/WinHttpHandler.h delete mode 100644 hueplusplus/include/json/json.hpp delete mode 100755 hueplusplus/test/CMakeLists.txt delete mode 100755 hueplusplus/test/CMakeLists.txt.in delete mode 100755 hueplusplus/test/CodeCoverage.cmake delete mode 100755 hueplusplus/test/mocks/mock_BaseHttpHandler.h delete mode 100755 hueplusplus/test/mocks/mock_HttpHandler.h delete mode 100644 hueplusplus/test/mocks/mock_HueLight.h delete mode 100755 hueplusplus/test/test_BaseHttpHandler.cpp delete mode 100755 hueplusplus/test/test_ExtendedColorHueStrategy.cpp delete mode 100755 hueplusplus/test/test_ExtendedColorTemperatureStrategy.cpp delete mode 100644 hueplusplus/test/test_Hue.cpp delete mode 100644 hueplusplus/test/test_HueCommandAPI.cpp delete mode 100644 hueplusplus/test/test_HueLight.cpp delete mode 100755 hueplusplus/test/test_Main.cpp delete mode 100755 hueplusplus/test/test_SimpleBrightnessStrategy.cpp delete mode 100755 hueplusplus/test/test_SimpleColorHueStrategy.cpp delete mode 100755 hueplusplus/test/test_SimpleColorTemperatureStrategy.cpp delete mode 100755 hueplusplus/test/test_UPnP.cpp delete mode 100644 hueplusplus/test/testhelper.h create mode 100644 include/hueplusplus/BaseHttpHandler.h create mode 100644 include/hueplusplus/BrightnessStrategy.h create mode 100644 include/hueplusplus/ColorHueStrategy.h create mode 100644 include/hueplusplus/ColorTemperatureStrategy.h create mode 100644 include/hueplusplus/ExtendedColorHueStrategy.h create mode 100644 include/hueplusplus/ExtendedColorTemperatureStrategy.h create mode 100644 include/hueplusplus/Hue.h create mode 100644 include/hueplusplus/HueCommandAPI.h create mode 100644 include/hueplusplus/HueConfig.h create mode 100644 include/hueplusplus/HueException.h create mode 100644 include/hueplusplus/HueExceptionMacro.h create mode 100644 include/hueplusplus/HueLight.h create mode 100644 include/hueplusplus/IHttpHandler.h create mode 100644 include/hueplusplus/LinHttpHandler.h create mode 100644 include/hueplusplus/SimpleBrightnessStrategy.h create mode 100644 include/hueplusplus/SimpleColorHueStrategy.h create mode 100644 include/hueplusplus/SimpleColorTemperatureStrategy.h create mode 100644 include/hueplusplus/UPnP.h create mode 100644 include/hueplusplus/Units.h create mode 100644 include/hueplusplus/Utils.h create mode 100644 include/hueplusplus/WinHttpHandler.h create mode 100644 include/json/json.hpp create mode 100644 src/BaseHttpHandler.cpp create mode 100644 src/CMakeLists.txt create mode 100644 src/ExtendedColorHueStrategy.cpp create mode 100644 src/ExtendedColorTemperatureStrategy.cpp create mode 100644 src/Hue.cpp create mode 100644 src/HueCommandAPI.cpp create mode 100644 src/HueException.cpp create mode 100644 src/HueLight.cpp create mode 100644 src/LinHttpHandler.cpp create mode 100644 src/SimpleBrightnessStrategy.cpp create mode 100644 src/SimpleColorHueStrategy.cpp create mode 100644 src/SimpleColorTemperatureStrategy.cpp create mode 100644 src/UPnP.cpp create mode 100644 src/Utils.cpp create mode 100644 src/WinHttpHandler.cpp create mode 100644 src/test/CMakeLists.txt create mode 100644 src/test/CMakeLists.txt.in create mode 100644 src/test/CodeCoverage.cmake create mode 100644 src/test/mocks/mock_BaseHttpHandler.h create mode 100644 src/test/mocks/mock_HttpHandler.h create mode 100644 src/test/mocks/mock_HueLight.h create mode 100644 src/test/test_BaseHttpHandler.cpp create mode 100644 src/test/test_ExtendedColorHueStrategy.cpp create mode 100644 src/test/test_ExtendedColorTemperatureStrategy.cpp create mode 100644 src/test/test_Hue.cpp create mode 100644 src/test/test_HueCommandAPI.cpp create mode 100644 src/test/test_HueLight.cpp create mode 100644 src/test/test_Main.cpp create mode 100644 src/test/test_SimpleBrightnessStrategy.cpp create mode 100644 src/test/test_SimpleColorHueStrategy.cpp create mode 100644 src/test/test_SimpleColorTemperatureStrategy.cpp create mode 100644 src/test/test_UPnP.cpp create mode 100644 src/test/testhelper.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 02789de..279cf3a 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,15 @@ -cmake_minimum_required(VERSION 2.8.3) -project(hueplusplus) +cmake_minimum_required(VERSION 3.2) + +if(${CMAKE_VERSION} VERSION_LESS 3.11) + cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) +else() + cmake_policy(VERSION 3.11) +endif() + +# Add cmake dir to module path, so Find*.cmake can be found +set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) + +project(hueplusplus LANGUAGES CXX) # options to set option(hueplusplus_TESTS "Build tests" OFF) diff --git a/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in new file mode 100644 index 0000000..4c07dc7 --- /dev/null +++ b/cmake/cmake_uninstall.cmake.in @@ -0,0 +1,21 @@ +if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") + message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt") +endif(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") + +file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files) +string(REGEX REPLACE "\n" ";" files "${files}") +foreach(file ${files}) + message(STATUS "Uninstalling $ENV{DESTDIR}${file}") + if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") + exec_program( + "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" + OUTPUT_VARIABLE rm_out + RETURN_VALUE rm_retval + ) + if(NOT "${rm_retval}" STREQUAL 0) + message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") + endif(NOT "${rm_retval}" STREQUAL 0) + else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") + message(STATUS "File $ENV{DESTDIR}${file} does not exist.") + endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") +endforeach(file) diff --git a/cmake/hueplusplus-config.cmake.in b/cmake/hueplusplus-config.cmake.in new file mode 100644 index 0000000..dc1490f --- /dev/null +++ b/cmake/hueplusplus-config.cmake.in @@ -0,0 +1,7 @@ +# -config file of the hueplusplus package +# It defines the following +# hueplusplus_FOUND - which indicates that the module was found +# hueplusplus_INCLUDE_DIR + +set(hueplusplus_FOUND TRUE) +set(hueplusplus_INCLUDE_DIR "@INSTALL_INCLUDE_DIR@") diff --git a/cmake_uninstall.cmake.in b/cmake_uninstall.cmake.in deleted file mode 100755 index 4c07dc7..0000000 --- a/cmake_uninstall.cmake.in +++ /dev/null @@ -1,21 +0,0 @@ -if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") - message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt") -endif(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") - -file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files) -string(REGEX REPLACE "\n" ";" files "${files}") -foreach(file ${files}) - message(STATUS "Uninstalling $ENV{DESTDIR}${file}") - if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") - exec_program( - "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" - OUTPUT_VARIABLE rm_out - RETURN_VALUE rm_retval - ) - if(NOT "${rm_retval}" STREQUAL 0) - message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") - endif(NOT "${rm_retval}" STREQUAL 0) - else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") - message(STATUS "File $ENV{DESTDIR}${file} does not exist.") - endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") -endforeach(file) diff --git a/extern b/extern new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/extern diff --git a/hueplusplus/BaseHttpHandler.cpp b/hueplusplus/BaseHttpHandler.cpp deleted file mode 100644 index f0cd07d..0000000 --- a/hueplusplus/BaseHttpHandler.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/** - \file BaseHttpHandler.cpp - Copyright Notice\n - Copyright (C) 2020 Jan Rogall - developer\n - Copyright (C) 2020 Moritz Wirger - developer\n - - This file is part of hueplusplus. - - hueplusplus is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - hueplusplus is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with hueplusplus. If not, see . -**/ - -#include "include/BaseHttpHandler.h" - -#include "include/HueExceptionMacro.h" - -std::string BaseHttpHandler::sendGetHTTPBody(const std::string& msg, const std::string& adr, int port) const -{ - std::string response = send(msg, adr, port); - size_t start = response.find("\r\n\r\n"); - if (start == std::string::npos) - { - std::cerr << "BaseHttpHandler: Failed to find body in response\n"; - std::cerr << "Request:\n"; - std::cerr << "\"" << msg << "\"\n"; - std::cerr << "Response:\n"; - std::cerr << "\"" << response << "\"\n"; - throw HueException(CURRENT_FILE_INFO, "Failed to find body in response"); - } - response.erase(0, start + 4); - return response; -} - -std::string BaseHttpHandler::sendHTTPRequest(const std::string& method, const std::string& uri, - const std::string& contentType, const std::string& body, const std::string& adr, int port) const -{ - std::string request; - // Protocol reference: - // https://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html Request-Line - request.append(method); // Method - request.append(" "); // Separation - request.append(uri); // Request-URI - request.append(" "); // Separation - request.append("HTTP/1.0"); // HTTP-Version - request.append("\r\n"); // Ending - // Entities - request.append("Content-Type:"); // entity-header - request.append(" "); // Separation - request.append(contentType); // media-type - request.append("\r\n"); // Entity ending - request.append("Content-Length:"); // entity-header - request.append(" "); // Separation - request.append(std::to_string(body.size())); // length - request.append("\r\n\r\n"); // Entity ending & Request-Line ending - request.append(body); // message-body - request.append("\r\n\r\n"); // Ending - - return sendGetHTTPBody(request.c_str(), adr, port); -} - -std::string BaseHttpHandler::GETString(const std::string& uri, const std::string& contentType, const std::string& body, - const std::string& adr, int port) const -{ - return sendHTTPRequest("GET", uri, contentType, body, adr, port); -} - -std::string BaseHttpHandler::POSTString(const std::string& uri, const std::string& contentType, const std::string& body, - const std::string& adr, int port) const -{ - return sendHTTPRequest("POST", uri, contentType, body, adr, port); -} - -std::string BaseHttpHandler::PUTString(const std::string& uri, const std::string& contentType, const std::string& body, - const std::string& adr, int port) const -{ - return sendHTTPRequest("PUT", uri, contentType, body, adr, port); -} - -std::string BaseHttpHandler::DELETEString(const std::string& uri, const std::string& contentType, - const std::string& body, const std::string& adr, int port) const -{ - return sendHTTPRequest("DELETE", uri, contentType, body, adr, port); -} - -nlohmann::json BaseHttpHandler::GETJson( - const std::string& uri, const nlohmann::json& body, const std::string& adr, int port) const -{ - return nlohmann::json::parse(GETString(uri, "application/json", body.dump(), adr, port)); -} - -nlohmann::json BaseHttpHandler::POSTJson( - const std::string& uri, const nlohmann::json& body, const std::string& adr, int port) const -{ - return nlohmann::json::parse(POSTString(uri, "application/json", body.dump(), adr, port)); -} - -nlohmann::json BaseHttpHandler::PUTJson( - const std::string& uri, const nlohmann::json& body, const std::string& adr, int port) const -{ - return nlohmann::json::parse(PUTString(uri, "application/json", body.dump(), adr, port)); -} - -nlohmann::json BaseHttpHandler::DELETEJson( - const std::string& uri, const nlohmann::json& body, const std::string& adr, int port) const -{ - return nlohmann::json::parse(DELETEString(uri, "application/json", body.dump(), adr, port)); -} diff --git a/hueplusplus/CMakeLists.txt b/hueplusplus/CMakeLists.txt deleted file mode 100755 index 608e2ad..0000000 --- a/hueplusplus/CMakeLists.txt +++ /dev/null @@ -1,78 +0,0 @@ -file(GLOB hueplusplus_HEADERS include/*.h include/*.hpp) -set(hueplusplus_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/BaseHttpHandler.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/ExtendedColorHueStrategy.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/ExtendedColorTemperatureStrategy.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Hue.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/HueCommandAPI.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/HueDeviceTypes.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/HueException.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/HueLight.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/SimpleBrightnessStrategy.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/SimpleColorHueStrategy.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/SimpleColorTemperatureStrategy.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/UPnP.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Utils.cpp -) - -# on windows we want to compile the WinHttpHandler -if(WIN32) - set(hueplusplus_SOURCES - ${hueplusplus_SOURCES} - ${CMAKE_CURRENT_SOURCE_DIR}/WinHttpHandler.cpp - ) -endif() -# whereas on linux we want the LinHttpHandler -if(UNIX) - set(hueplusplus_SOURCES - ${hueplusplus_SOURCES} - ${CMAKE_CURRENT_SOURCE_DIR}/LinHttpHandler.cpp - ) -endif() -if(ESP_PLATFORM) - set(hueplusplus_SOURCES - ${hueplusplus_SOURCES} - ${CMAKE_CURRENT_SOURCE_DIR}/LinHttpHandler.cpp - ) -endif() - - -# Set global includes BEFORE adding any targets for legacy CMake versions -if(CMAKE_VERSION VERSION_LESS 2.8.12) - include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include") - include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include/json") -endif() - - -# hueplusplus shared library -add_library(hueplusplusshared SHARED ${hueplusplus_SOURCES}) -set_property(TARGET hueplusplusshared PROPERTY CXX_STANDARD 14) -set_property(TARGET hueplusplusshared PROPERTY CXX_EXTENSIONS OFF) -if (NOT CMAKE_VERSION VERSION_LESS 2.8.12) - target_include_directories(hueplusplusshared PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include") -endif() -install(TARGETS hueplusplusshared DESTINATION lib) - -# hueplusplus static library -add_library(hueplusplusstatic STATIC ${hueplusplus_SOURCES}) -set_property(TARGET hueplusplusstatic PROPERTY CXX_STANDARD 14) -set_property(TARGET hueplusplusstatic PROPERTY CXX_EXTENSIONS OFF) -install(TARGETS hueplusplusstatic DESTINATION lib) -if (NOT CMAKE_VERSION VERSION_LESS 2.8.12) - target_include_directories(hueplusplusstatic PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include") -endif() -install(FILES ${hueplusplus_HEADERS} DESTINATION include/hueplusplus) - -# Export the package for use from the build-tree -# (this registers the build-tree with a global CMake-registry) -export(PACKAGE hueplusplus) -# Create the hueplusplus-config.cmake -configure_file (hueplusplus-config.cmake.in "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hueplusplus-config.cmake" @ONLY) -# Install hueplusplus-config.cmake -install(FILES "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hueplusplus-config.cmake" DESTINATION "${INSTALL_CMAKE_DIR}" COMPONENT dev) - -# if the user decided to use tests add the subdirectory -if(hueplusplus_TESTS) - set(HuePlusPlus_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) - add_subdirectory("test") -endif() diff --git a/hueplusplus/ExtendedColorHueStrategy.cpp b/hueplusplus/ExtendedColorHueStrategy.cpp deleted file mode 100755 index 6199855..0000000 --- a/hueplusplus/ExtendedColorHueStrategy.cpp +++ /dev/null @@ -1,275 +0,0 @@ -/** - \file ExtendedColorHueStrategy.cpp - Copyright Notice\n - Copyright (C) 2017 Jan Rogall - developer\n - Copyright (C) 2017 Moritz Wirger - developer\n - - This file is part of hueplusplus. - - hueplusplus is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - hueplusplus is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with hueplusplus. If not, see . -**/ - -#include "include/ExtendedColorHueStrategy.h" - -#include -#include -#include - -#include "include/HueConfig.h" - -bool ExtendedColorHueStrategy::alertHueSaturation(uint16_t hue, uint8_t sat, HueLight& light) const -{ - light.refreshState(); - std::string cType = light.state["state"]["colormode"].get(); - bool on = light.state["state"]["on"].get(); - if (cType == "hs") - { - uint16_t oldHue = light.state["state"]["hue"].get(); - uint8_t oldSat = light.state["state"]["sat"].get(); - if (!light.setColorHueSaturation(hue, sat, 1)) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY)); - if (!light.alert()) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY)); - if (!on) - { - light.setColorHueSaturation(oldHue, oldSat, 1); - return light.OffNoRefresh(1); - } - else - { - return light.setColorHueSaturation(oldHue, oldSat, 1); - } - } - else if (cType == "xy") - { - float oldX = light.state["state"]["xy"][0].get(); - float oldY = light.state["state"]["xy"][1].get(); - if (!light.setColorHueSaturation(hue, sat, 1)) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY)); - if (!light.alert()) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY)); - if (!on) - { - light.setColorXY(oldX, oldY, 1); - return light.OffNoRefresh(1); - } - else - { - return light.setColorXY(oldX, oldY, 1); - } - } - else if (cType == "ct") - { - uint16_t oldCT = light.state["state"]["ct"].get(); - if (!light.setColorHueSaturation(hue, sat, 1)) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY)); - if (!light.alert()) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY)); - if (!on) - { - light.setColorTemperature(oldCT, 1); - return light.OffNoRefresh(1); - } - else - { - return light.setColorTemperature(oldCT, 1); - } - } - else - { - return false; - } -} - -bool ExtendedColorHueStrategy::alertXY(float x, float y, HueLight& light) const -{ - light.refreshState(); - std::string cType = light.state["state"]["colormode"].get(); - bool on = light.state["state"]["on"].get(); - if (cType == "hs") - { - uint16_t oldHue = light.state["state"]["hue"].get(); - uint8_t oldSat = light.state["state"]["sat"].get(); - if (!light.setColorXY(x, y, 1)) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY)); - if (!light.alert()) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY)); - if (!on) - { - light.setColorHueSaturation(oldHue, oldSat, 1); - return light.OffNoRefresh(1); - } - else - { - return light.setColorHueSaturation(oldHue, oldSat, 1); - } - } - else if (cType == "xy") - { - float oldX = light.state["state"]["xy"][0].get(); - float oldY = light.state["state"]["xy"][1].get(); - if (!light.setColorXY(x, y, 1)) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY)); - if (!light.alert()) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY)); - if (!on) - { - light.setColorXY(oldX, oldY, 1); - return light.OffNoRefresh(1); - } - else - { - return light.setColorXY(oldX, oldY, 1); - } - } - else if (cType == "ct") - { - uint16_t oldCT = light.state["state"]["ct"].get(); - if (!light.setColorXY(x, y, 1)) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY)); - if (!light.alert()) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY)); - if (!on) - { - light.setColorTemperature(oldCT, 1); - return light.OffNoRefresh(1); - } - else - { - return light.setColorTemperature(oldCT, 1); - } - } - else - { - return false; - } -} - -bool ExtendedColorHueStrategy::alertRGB(uint8_t r, uint8_t g, uint8_t b, HueLight& light) const -{ - light.refreshState(); - std::string cType = light.state["state"]["colormode"].get(); - bool on = light.state["state"]["on"].get(); - if (cType == "hs") - { - uint16_t oldHue = light.state["state"]["hue"].get(); - uint8_t oldSat = light.state["state"]["sat"].get(); - if (!light.setColorRGB(r, g, b, 1)) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY)); - if (!light.alert()) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY)); - if (!on) - { - light.setColorHueSaturation(oldHue, oldSat, 1); - return light.OffNoRefresh(1); - } - else - { - return light.setColorHueSaturation(oldHue, oldSat, 1); - } - } - else if (cType == "xy") - { - float oldX = light.state["state"]["xy"][0].get(); - float oldY = light.state["state"]["xy"][1].get(); - if (!light.setColorRGB(r, g, b, 1)) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY)); - if (!light.alert()) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY)); - if (!on) - { - light.setColorXY(oldX, oldY, 1); - return light.OffNoRefresh(1); - } - else - { - return light.setColorXY(oldX, oldY, 1); - } - } - else if (cType == "ct") - { - uint16_t oldCT = light.state["state"]["ct"].get(); - if (!light.setColorRGB(r, g, b, 1)) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY)); - if (!light.alert()) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY)); - if (!on) - { - light.setColorTemperature(oldCT, 1); - return light.OffNoRefresh(1); - } - else - { - return light.setColorTemperature(oldCT, 1); - } - } - else - { - return false; - } -} diff --git a/hueplusplus/ExtendedColorTemperatureStrategy.cpp b/hueplusplus/ExtendedColorTemperatureStrategy.cpp deleted file mode 100644 index 202096a..0000000 --- a/hueplusplus/ExtendedColorTemperatureStrategy.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/** - \file ExtendedColorTemperatureStrategy.cpp - Copyright Notice\n - Copyright (C) 2017 Jan Rogall - developer\n - Copyright (C) 2017 Moritz Wirger - developer\n - - This file is part of hueplusplus. - - hueplusplus is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - hueplusplus is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with hueplusplus. If not, see . -**/ - -#include "include/ExtendedColorTemperatureStrategy.h" - -#include -#include -#include - -#include "include/HueConfig.h" -#include "include/HueExceptionMacro.h" -#include "include/Utils.h" - -bool ExtendedColorTemperatureStrategy::setColorTemperature( - unsigned int mired, uint8_t transition, HueLight& light) const -{ - light.refreshState(); - nlohmann::json request = nlohmann::json::object(); - if (transition != 4) - { - request["transitiontime"] = transition; - } - if (light.state["state"]["on"] != true) - { - request["on"] = true; - } - if (light.state["state"]["ct"] != mired || light.state["state"]["colormode"] != "ct") - { - if (mired > 500) - { - mired = 500; - } - if (mired < 153) - { - mired = 153; - } - request["ct"] = mired; - } - - if (!request.count("on") && !request.count("ct")) - { - // Nothing needs to be changed - return true; - } - - nlohmann::json reply = light.SendPutRequest(request, "/state", CURRENT_FILE_INFO); - - // Check whether request was successful - return utils::validateReplyForLight(request, reply, light.id); -} - -bool ExtendedColorTemperatureStrategy::alertTemperature(unsigned int mired, HueLight& light) const -{ - light.refreshState(); - std::string cType = light.state["state"]["colormode"].get(); - bool on = light.state["state"]["on"].get(); - if (cType == "hs") - { - uint16_t oldHue = light.state["state"]["hue"].get(); - uint8_t oldSat = light.state["state"]["sat"].get(); - if (!light.setColorTemperature(mired, 1)) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY)); - if (!light.alert()) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY)); - if (!on) - { - light.setColorHueSaturation(oldHue, oldSat, 1); - return light.OffNoRefresh(1); - } - else - { - return light.setColorHueSaturation(oldHue, oldSat, 1); - } - } - else if (cType == "xy") - { - float oldX = light.state["state"]["xy"][0].get(); - float oldY = light.state["state"]["xy"][1].get(); - if (!light.setColorTemperature(mired, 1)) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY)); - if (!light.alert()) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY)); - if (!on) - { - light.setColorXY(oldX, oldY, 1); - return light.OffNoRefresh(1); - } - else - { - return light.setColorXY(oldX, oldY, 1); - } - } - else if (cType == "ct") - { - uint16_t oldCT = light.state["state"]["ct"].get(); - if (!light.setColorTemperature(mired, 1)) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY)); - if (!light.alert()) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY)); - if (!on) - { - light.setColorTemperature(oldCT, 1); - return light.OffNoRefresh(1); - } - else - { - return light.setColorTemperature(oldCT, 1); - } - } - else - { - return false; - } -} diff --git a/hueplusplus/Hue.cpp b/hueplusplus/Hue.cpp deleted file mode 100644 index d088f4e..0000000 --- a/hueplusplus/Hue.cpp +++ /dev/null @@ -1,457 +0,0 @@ -/** - \file Hue.cpp - Copyright Notice\n - Copyright (C) 2017 Jan Rogall - developer\n - Copyright (C) 2017 Moritz Wirger - developer\n - - This file is part of hueplusplus. - - hueplusplus is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - hueplusplus is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with hueplusplus. If not, see . -**/ - -#include "include/Hue.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "include/HueDeviceTypes.h" -#include "include/ExtendedColorHueStrategy.h" -#include "include/ExtendedColorTemperatureStrategy.h" -#include "include/HueExceptionMacro.h" -#include "include/SimpleBrightnessStrategy.h" -#include "include/SimpleColorHueStrategy.h" -#include "include/SimpleColorTemperatureStrategy.h" -#include "include/UPnP.h" -#include "include/Utils.h" - -HueFinder::HueFinder(std::shared_ptr handler) : http_handler(std::move(handler)) {} - -std::vector HueFinder::FindBridges() const -{ - UPnP uplug; - std::vector> foundDevices = uplug.getDevices(http_handler); - - std::vector foundBridges; - for (const std::pair& p : foundDevices) - { - size_t found = p.second.find("IpBridge"); - if (found != std::string::npos) - { - HueIdentification bridge; - size_t start = p.first.find("//") + 2; - size_t length = p.first.find(":", start) - start; - bridge.ip = p.first.substr(start, length); - std::string desc - = http_handler->GETString("/description.xml", "application/xml", "", bridge.ip, bridge.port); - std::string mac = ParseDescription(desc); - if (!mac.empty()) - { - bridge.mac = NormalizeMac(mac); - foundBridges.push_back(std::move(bridge)); - } - } - } - return foundBridges; -} - -Hue HueFinder::GetBridge(const HueIdentification& identification) -{ - std::string normalizedMac = NormalizeMac(identification.mac); - auto pos = usernames.find(normalizedMac); - if (pos != usernames.end()) - { - return Hue(identification.ip, identification.port, pos->second, http_handler); - } - Hue bridge(identification.ip, identification.port, "", http_handler); - bridge.requestUsername(); - if (bridge.getUsername().empty()) - { - std::cerr << "Failed to request username for ip " << identification.ip << std::endl; - throw HueException(CURRENT_FILE_INFO, "Failed to request username!"); - } - AddUsername(normalizedMac, bridge.getUsername()); - - return bridge; -} - -void HueFinder::AddUsername(const std::string& mac, const std::string& username) -{ - usernames[NormalizeMac(mac)] = username; -} - -const std::map& HueFinder::GetAllUsernames() const -{ - return usernames; -} - -std::string HueFinder::NormalizeMac(std::string input) -{ - // Remove any non alphanumeric characters (e.g. ':' and whitespace) - input.erase(std::remove_if(input.begin(), input.end(), [](char c) { return !std::isalnum(c, std::locale()); }), - input.end()); - // Convert to lower case - std::transform(input.begin(), input.end(), input.begin(), [](char c) { return std::tolower(c, std::locale()); }); - return input; -} - -std::string HueFinder::ParseDescription(const std::string& description) -{ - const char* model = "Philips hue bridge"; - const char* serialBegin = ""; - const char* serialEnd = ""; - if (description.find(model) != std::string::npos) - { - std::size_t begin = description.find(serialBegin); - std::size_t end = description.find(serialEnd, begin); - if (begin != std::string::npos && end != std::string::npos) - { - begin += std::strlen(serialBegin); - if (begin < description.size()) - { - std::string result = description.substr(begin, end - begin); - return result; - } - } - } - return std::string(); -} - -Hue::Hue( - const std::string& ip, const int port, const std::string& username, std::shared_ptr handler) - : ip(ip), - port(port), - username(username), - simpleBrightnessStrategy(std::make_shared()), - simpleColorHueStrategy(std::make_shared()), - extendedColorHueStrategy(std::make_shared()), - simpleColorTemperatureStrategy(std::make_shared()), - extendedColorTemperatureStrategy(std::make_shared()), - http_handler(std::move(handler)), - commands(ip, port, username, http_handler) -{} - -std::string Hue::getBridgeIP() -{ - return ip; -} - -int Hue::getBridgePort() -{ - return port; -} - -std::string Hue::requestUsername() -{ - std::cout << "Please press the link Button! You've got 35 secs!\n"; // when the link - // button was - // pressed we - // got 30 - // seconds to - // get our - // username for - // control - - nlohmann::json request; - request["devicetype"] = "HuePlusPlus#User"; - - nlohmann::json answer; - std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now(); - std::chrono::steady_clock::time_point lastCheck; - while (std::chrono::steady_clock::now() - start < std::chrono::seconds(35)) - { - if (std::chrono::steady_clock::now() - lastCheck > std::chrono::seconds(1)) - { - lastCheck = std::chrono::steady_clock::now(); - answer = http_handler->POSTJson("/api", request, ip, port); - nlohmann::json jsonUser = utils::safeGetMember(answer, 0, "success", "username"); - if (jsonUser != nullptr) - { - // [{"success":{"username": ""}}] - username = jsonUser.get(); - // Update commands with new username and ip - commands = HueCommandAPI(ip, port, username, http_handler); - std::cout << "Success! Link button was pressed!\n"; - std::cout << "Username is \"" << username << "\"\n"; - break; - } - else if (answer.size() > 0 && answer[0].count("error")) - { - // All errors except 101: Link button not pressed - if (utils::safeGetMember(answer, 0, "error", "type") != 101) - { - throw HueAPIResponseException::Create(CURRENT_FILE_INFO, answer[0]); - } - } - - std::this_thread::sleep_until(lastCheck + std::chrono::seconds(1)); - } - } - return username; -} - -std::string Hue::getUsername() -{ - return username; -} - -void Hue::setIP(const std::string& ip) -{ - this->ip = ip; -} - -void Hue::setPort(const int port) -{ - this->port = port; -} - -HueLight& Hue::getLight(int id) -{ - auto pos = lights.find(id); - if (pos != lights.end()) - { - pos->second.refreshState(); - return pos->second; - } - refreshState(); - if (!state["lights"].count(std::to_string(id))) - { - std::cerr << "Error in Hue getLight(): light with id " << id << " is not valid\n"; - throw HueException(CURRENT_FILE_INFO, "Light id is not valid"); - } - // std::cout << state["lights"][std::to_string(id)] << std::endl; - std::string type = state["lights"][std::to_string(id)]["modelid"].get(); - // std::cout << type << std::endl; - auto light = MakeHueLight()(type, id, commands, simpleBrightnessStrategy, - extendedColorTemperatureStrategy, simpleColorTemperatureStrategy, extendedColorHueStrategy, - simpleColorHueStrategy); - lights.emplace(id, light); - return lights.find(id)->second; -} - -bool Hue::removeLight(int id) -{ - nlohmann::json result - = commands.DELETERequest("/lights/" + std::to_string(id), nlohmann::json::object(), CURRENT_FILE_INFO); - bool success = utils::safeGetMember(result, 0, "success") == "/lights/" + std::to_string(id) + " deleted"; - if (success && lights.count(id) != 0) - { - lights.erase(id); - } - return success; -} - -std::vector> Hue::getAllLights() -{ - refreshState(); - nlohmann::json lightsState = state["lights"]; - for (nlohmann::json::iterator it = lightsState.begin(); it != lightsState.end(); ++it) - { - getLight(std::stoi(it.key())); - } - std::vector> result; - for (auto& entry : lights) - { - result.emplace_back(entry.second); - } - return result; -} - -bool Hue::lightExists(int id) -{ - refreshState(); - auto pos = lights.find(id); - if (pos != lights.end()) - { - return true; - } - if (state["lights"].count(std::to_string(id))) - { - return true; - } - return false; -} - -bool Hue::lightExists(int id) const -{ - auto pos = lights.find(id); - if (pos != lights.end()) - { - return true; - } - if (state["lights"].count(std::to_string(id))) - { - return true; - } - return false; -} - -std::string Hue::getPictureOfLight(int id) const -{ - std::string ret = ""; - auto pos = lights.find(id); - if (pos != lights.end()) - { - ret = getPictureOfModel(pos->second.getModelId()); - } - return ret; -} - -std::string Hue::getPictureOfModel(const std::string& model_id) const -{ - std::string ret = ""; - if (model_id == "LCT001" || model_id == "LCT007" || model_id == "LCT010" || model_id == "LCT014" - || model_id == "LTW010" || model_id == "LTW001" || model_id == "LTW004" || model_id == "LTW015" - || model_id == "LWB004" || model_id == "LWB006") - { - ret.append("e27_waca"); - } - else if (model_id == "LWB010" || model_id == "LWB014") - { - ret.append("e27_white"); - } - else if (model_id == "LCT012" || model_id == "LTW012") - { - ret.append("e14"); - } - else if (model_id == "LCT002") - { - ret.append("br30"); - } - else if (model_id == "LCT011" || model_id == "LTW011") - { - ret.append("br30_slim"); - } - else if (model_id == "LCT003") - { - ret.append("gu10"); - } - else if (model_id == "LTW013") - { - ret.append("gu10_perfectfit"); - } - else if (model_id == "LST001" || model_id == "LST002") - { - ret.append("lightstrip"); - } - else if (model_id == "LLC006 " || model_id == "LLC010") - { - ret.append("iris"); - } - else if (model_id == "LLC005" || model_id == "LLC011" || model_id == "LLC012" || model_id == "LLC007") - { - ret.append("bloom"); - } - else if (model_id == "LLC014") - { - ret.append("aura"); - } - else if (model_id == "LLC013") - { - ret.append("storylight"); - } - else if (model_id == "LLC020") - { - ret.append("go"); - } - else if (model_id == "HBL001" || model_id == "HBL002" || model_id == "HBL003") - { - ret.append("beyond_ceiling_pendant_table"); - } - else if (model_id == "HIL001 " || model_id == "HIL002") - { - ret.append("impulse"); - } - else if (model_id == "HEL001 " || model_id == "HEL002") - { - ret.append("entity"); - } - else if (model_id == "HML001" || model_id == "HML002" || model_id == "HML003" || model_id == "HML004" - || model_id == "HML005") - { - ret.append("phoenix_ceiling_pendant_table_wall"); - } - else if (model_id == "HML006") - { - ret.append("phoenix_down"); - } - else if (model_id == "LTP001" || model_id == "LTP002" || model_id == "LTP003" || model_id == "LTP004" - || model_id == "LTP005" || model_id == "LTD003") - { - ret.append("pendant"); - } - else if (model_id == "LDF002" || model_id == "LTF001" || model_id == "LTF002" || model_id == "LTC001" - || model_id == "LTC002" || model_id == "LTC003" || model_id == "LTC004" || model_id == "LTD001" - || model_id == "LTD002" || model_id == "LDF001") - { - ret.append("ceiling"); - } - else if (model_id == "LDD002 " || model_id == "LFF001") - { - ret.append("floor"); - } - else if (model_id == "LDD001 " || model_id == "LTT001") - { - ret.append("table"); - } - else if (model_id == "LDT001 " || model_id == "MWM001") - { - ret.append("recessed"); - } - else if (model_id == "BSB001") - { - ret.append("bridge_v1"); - } - else if (model_id == "BSB002") - { - ret.append("bridge_v2"); - } - else if (model_id == "SWT001") - { - ret.append("tap"); - } - else if (model_id == "RWL021") - { - ret.append("hds"); - } - else if (model_id == "SML001") - { - ret.append("motion_sensor"); - } - return ret; -} - -void Hue::refreshState() -{ - if (username.empty()) - { - return; - } - nlohmann::json answer = commands.GETRequest("", nlohmann::json::object(), CURRENT_FILE_INFO); - if (answer.is_object() && answer.count("lights")) - { - state = answer; - } - else - { - std::cout << "Answer in Hue::refreshState of http_handler->GETJson(...) is " - "not expected!\nAnswer:\n\t" - << answer.dump() << std::endl; - } -} diff --git a/hueplusplus/HueCommandAPI.cpp b/hueplusplus/HueCommandAPI.cpp deleted file mode 100644 index b818d44..0000000 --- a/hueplusplus/HueCommandAPI.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/** - \file HueCommandAPI.h - Copyright Notice\n - Copyright (C) 2018 Jan Rogall - developer\n - Copyright (C) 2018 Moritz Wirger - developer\n - - This file is part of hueplusplus. - - hueplusplus is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - hueplusplus is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with hueplusplus. If not, see . -**/ - -#include "include/HueCommandAPI.h" - -#include - -#include "include/HueExceptionMacro.h" - -constexpr std::chrono::steady_clock::duration HueCommandAPI::minDelay; - -namespace -{ - // Runs functor with appropriate timeout and retries when timed out or connection reset - template - nlohmann::json RunWithTimeout( - std::shared_ptr timeout, std::chrono::steady_clock::duration minDelay, Fun fun) - { - auto now = std::chrono::steady_clock::now(); - std::lock_guard lock(timeout->mutex); - if (timeout->timeout > now) - { - std::this_thread::sleep_until(timeout->timeout); - } - try - { - nlohmann::json response = fun(); - timeout->timeout = now + minDelay; - return response; - } - catch (const std::system_error& e) - { - if (e.code() == std::errc::connection_reset || e.code() == std::errc::timed_out) - { - // Happens when hue is too busy, wait and try again (once) - std::this_thread::sleep_for(minDelay); - nlohmann::json v = fun(); - timeout->timeout = std::chrono::steady_clock::now() + minDelay; - return v; - } - // Cannot recover from other types of errors - throw; - } - } -} // namespace - -HueCommandAPI::HueCommandAPI( - const std::string& ip, const int port, const std::string& username, std::shared_ptr httpHandler) - : ip(ip), - port(port), - username(username), - httpHandler(std::move(httpHandler)), - timeout(new TimeoutData{std::chrono::steady_clock::now(), {}}) -{} - -nlohmann::json HueCommandAPI::PUTRequest(const std::string& path, const nlohmann::json& request) const -{ - return PUTRequest(path, request, CURRENT_FILE_INFO); -} - -nlohmann::json HueCommandAPI::PUTRequest( - const std::string& path, const nlohmann::json& request, FileInfo fileInfo) const -{ - return HandleError(fileInfo, - RunWithTimeout(timeout, minDelay, [&]() { return httpHandler->PUTJson(CombinedPath(path), request, ip); })); -} - -nlohmann::json HueCommandAPI::GETRequest(const std::string& path, const nlohmann::json& request) const -{ - return GETRequest(path, request, CURRENT_FILE_INFO); -} - -nlohmann::json HueCommandAPI::GETRequest( - const std::string& path, const nlohmann::json& request, FileInfo fileInfo) const -{ - return HandleError(fileInfo, - RunWithTimeout(timeout, minDelay, [&]() { return httpHandler->GETJson(CombinedPath(path), request, ip); })); -} - -nlohmann::json HueCommandAPI::DELETERequest(const std::string& path, const nlohmann::json& request) const -{ - return DELETERequest(path, request, CURRENT_FILE_INFO); -} - -nlohmann::json HueCommandAPI::DELETERequest( - const std::string& path, const nlohmann::json& request, FileInfo fileInfo) const -{ - return HandleError(fileInfo, - RunWithTimeout(timeout, minDelay, [&]() { return httpHandler->DELETEJson(CombinedPath(path), request, ip); })); -} - -nlohmann::json HueCommandAPI::HandleError(FileInfo fileInfo, const nlohmann::json& response) const -{ - if (response.count("error")) - { - throw HueAPIResponseException::Create(std::move(fileInfo), response); - } - else if (response.is_array() && response.size() > 0 && response[0].count("error")) - { - throw HueAPIResponseException::Create(std::move(fileInfo), response[0]); - } - return response; -} - -std::string HueCommandAPI::CombinedPath(const std::string& path) const -{ - std::string result = "/api/"; - result.append(username); - // If path does not begin with '/', insert it unless it is empty - if (!path.empty() && path.front() != '/') - { - result.append("/"); - } - result.append(path); - return result; -} diff --git a/hueplusplus/HueException.cpp b/hueplusplus/HueException.cpp deleted file mode 100644 index d54f6c7..0000000 --- a/hueplusplus/HueException.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/** - \file HueException.cpp - Copyright Notice\n - Copyright (C) 2020 Jan Rogall - developer\n - Copyright (C) 2020 Moritz Wirger - developer\n - - This file is part of hueplusplus. - - hueplusplus is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - hueplusplus is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with hueplusplus. If not, see . -**/ - -#include "include/HueException.h" - -HueException::HueException(FileInfo fileInfo, const std::string& message) - : HueException("HueException", std::move(fileInfo), message) -{} - -const char* HueException::what() const noexcept -{ - return whatMessage.c_str(); -} - -const FileInfo& HueException::GetFile() const noexcept -{ - return fileInfo; -} - -HueException::HueException(const char* exceptionName, FileInfo fileInfo, const std::string& message) - : fileInfo(std::move(fileInfo)) -{ - whatMessage = exceptionName; - whatMessage.append(" from "); - whatMessage.append(this->fileInfo.ToString()); - whatMessage.append(" "); - whatMessage.append(message); -} - -HueAPIResponseException::HueAPIResponseException( - FileInfo fileInfo, int error, std::string address, std::string description) - : HueException("HueApiResponseException", std::move(fileInfo), GetMessage(error, address, description)), - error(error), - address(std::move(address)), - description(std::move(description)) -{} - -int HueAPIResponseException::GetErrorNumber() const noexcept -{ - return error; -} - -const std::string& HueAPIResponseException::GetAddress() const noexcept -{ - return address; -} - -const std::string& HueAPIResponseException::GetDescription() const noexcept -{ - return description; -} - -HueAPIResponseException HueAPIResponseException::Create(FileInfo fileInfo, const nlohmann::json& response) -{ - const nlohmann::json error = response.at("error"); - int errorCode = error.value("type", -1); - std::string address = error.value("address", ""); - std::string description = error.value("description", ""); - return HueAPIResponseException(std::move(fileInfo), errorCode, std::move(address), std::move(description)); -} - -std::string HueAPIResponseException::GetMessage(int error, const std::string& addr, const std::string& description) -{ - std::string result = std::to_string(error); - result.append(" "); - result.append(addr); - result.append(" "); - result.append(description); - return result; -} - -std::string FileInfo::ToString() const -{ - if (filename.empty() || line < 0) - { - return "Unknown file"; - } - std::string result = func; - result.append(" in "); - result.append(filename); - result.append(":"); - result.append(std::to_string(line)); - return result; -} diff --git a/hueplusplus/HueLight.cpp b/hueplusplus/HueLight.cpp deleted file mode 100644 index dc705ff..0000000 --- a/hueplusplus/HueLight.cpp +++ /dev/null @@ -1,252 +0,0 @@ -/** - \file HueLight.cpp - Copyright Notice\n - Copyright (C) 2017 Jan Rogall - developer\n - Copyright (C) 2017 Moritz Wirger - developer\n - - This file is part of hueplusplus. - - hueplusplus is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - hueplusplus is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with hueplusplus. If not, see . -**/ - -#include "include/HueLight.h" - -#include -#include -#include - -#include "include/HueExceptionMacro.h" -#include "include/Utils.h" -#include "include/json/json.hpp" - -bool HueLight::On(uint8_t transition) -{ - refreshState(); - return OnNoRefresh(transition); -} - -bool HueLight::Off(uint8_t transition) -{ - refreshState(); - return OffNoRefresh(transition); -} - -bool HueLight::isOn() -{ - refreshState(); - return state["state"]["on"].get(); -} - -bool HueLight::isOn() const -{ - return state["state"]["on"].get(); -} - -int HueLight::getId() const -{ - return id; -} - -std::string HueLight::getType() const -{ - return state["type"].get(); -} - -std::string HueLight::getName() -{ - refreshState(); - return state["name"].get(); -} - -std::string HueLight::getName() const -{ - return state["name"].get(); -} - -std::string HueLight::getModelId() const -{ - return state["modelid"].get(); -} - -std::string HueLight::getUId() const -{ - if (state.count("uniqueid")) - { - return state["uniqueid"].get(); - } - return std::string(); -} - -std::string HueLight::getManufacturername() const -{ - if (state.count("manufacturername")) - { - return state["manufacturername"].get(); - } - return std::string(); -} - -std::string HueLight::getProductname() const -{ - if (state.count("productname")) - { - return state["productname"].get(); - } - return std::string(); -} - -std::string HueLight::getLuminaireUId() const -{ - if (state.count("luminaireuniqueid")) - { - return state["luminaireuniqueid"].get(); - } - return std::string(); -} - -std::string HueLight::getSwVersion() -{ - refreshState(); - return state["swversion"].get(); -} - -std::string HueLight::getSwVersion() const -{ - return state["swversion"].get(); -} - -bool HueLight::setName(const std::string& name) -{ - nlohmann::json request = nlohmann::json::object(); - request["name"] = name; - nlohmann::json reply = SendPutRequest(request, "/name", CURRENT_FILE_INFO); - - // Check whether request was successful - return utils::safeGetMember(reply, 0, "success", "/lights/" + std::to_string(id) + "/name") == name; -} - -ColorType HueLight::getColorType() const -{ - return colorType; -} - -unsigned int HueLight::KelvinToMired(unsigned int kelvin) const -{ - return int(0.5f + (1000000 / kelvin)); -} - -unsigned int HueLight::MiredToKelvin(unsigned int mired) const -{ - return int(0.5f + (1000000 / mired)); -} - -bool HueLight::alert() -{ - nlohmann::json request; - request["alert"] = "select"; - - nlohmann::json reply = SendPutRequest(request, "/state", CURRENT_FILE_INFO); - - return utils::validateReplyForLight(request, reply, id); -} - -HueLight::HueLight(int id, const HueCommandAPI& commands) : HueLight(id, commands, nullptr, nullptr, nullptr) {} - -HueLight::HueLight(int id, const HueCommandAPI& commands, std::shared_ptr brightnessStrategy, - std::shared_ptr colorTempStrategy, - std::shared_ptr colorHueStrategy) - : id(id), - brightnessStrategy(std::move(brightnessStrategy)), - colorTemperatureStrategy(std::move(colorTempStrategy)), - colorHueStrategy(std::move(colorHueStrategy)), - commands(commands) - -{ - refreshState(); -} - -bool HueLight::OnNoRefresh(uint8_t transition) -{ - nlohmann::json request = nlohmann::json::object(); - if (transition != 4) - { - request["transitiontime"] = transition; - } - if (state["state"]["on"] != true) - { - request["on"] = true; - } - - if (!request.count("on")) - { - // Nothing needs to be changed - return true; - } - - nlohmann::json reply = SendPutRequest(request, "/state", CURRENT_FILE_INFO); - - // Check whether request was successful - return utils::validateReplyForLight(request, reply, id); -} - -bool HueLight::OffNoRefresh(uint8_t transition) -{ - nlohmann::json request = nlohmann::json::object(); - if (transition != 4) - { - request["transitiontime"] = transition; - } - if (state["state"]["on"] != false) - { - request["on"] = false; - } - - if (!request.count("on")) - { - // Nothing needs to be changed - return true; - } - - nlohmann::json reply = SendPutRequest(request, "/state", CURRENT_FILE_INFO); - - // Check whether request was successful - return utils::validateReplyForLight(request, reply, id); -} - -nlohmann::json HueLight::SendPutRequest(const nlohmann::json& request, const std::string& subPath, FileInfo fileInfo) -{ - return commands.PUTRequest("/lights/" + std::to_string(id) + subPath, request, std::move(fileInfo)); -} - -void HueLight::refreshState() -{ - // std::chrono::steady_clock::time_point start = - // std::chrono::steady_clock::now(); std::cout << "\tRefreshing lampstate of - // lamp with id: " << id << ", ip: " << ip << "\n"; - nlohmann::json answer - = commands.GETRequest("/lights/" + std::to_string(id), nlohmann::json::object(), CURRENT_FILE_INFO); - if (answer.count("state")) - { - state = answer; - } - else - { - std::cout << "Answer in HueLight::refreshState of " - "http_handler->GETJson(...) is not expected!\nAnswer:\n\t" - << answer.dump() << std::endl; - } - // std::cout << "\tRefresh state took: " << - // std::chrono::duration_cast(std::chrono::steady_clock::now() - // - start).count() << "ms" << std::endl; -} diff --git a/hueplusplus/LinHttpHandler.cpp b/hueplusplus/LinHttpHandler.cpp deleted file mode 100755 index c8f7132..0000000 --- a/hueplusplus/LinHttpHandler.cpp +++ /dev/null @@ -1,223 +0,0 @@ -/** - \file LinHttpHandler.cpp - Copyright Notice\n - Copyright (C) 2017 Jan Rogall - developer\n - Copyright (C) 2017 Moritz Wirger - developer\n - - This file is part of hueplusplus. - - hueplusplus is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - hueplusplus is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with hueplusplus. If not, see . -**/ - -#include "include/LinHttpHandler.h" - -#include -#include -#include -#include -#include -#include - -#include -#include // struct hostent, gethostbyname -#include // struct sockaddr_in, struct sockaddr -#include // printf, sprintf -#include // exit -#include // functions for C style null-terminated strings -#include // socket, connect -#include // read, write, close - -class SocketCloser -{ -public: - explicit SocketCloser(int sockFd) : s(sockFd) {} - ~SocketCloser() { close(s); } - -private: - int s; -}; - -std::string LinHttpHandler::send(const std::string& msg, const std::string& adr, int port) const -{ - // create socket - int socketFD = socket(AF_INET, SOCK_STREAM, 0); - - SocketCloser closeMySocket(socketFD); - if (socketFD < 0) - { - int errCode = errno; - std::cerr << "LinHttpHandler: Failed to open socket: " << std::strerror(errCode) << "\n"; - throw(std::system_error(errCode, std::generic_category(), "LinHttpHandler: Failed to open socket")); - } - - // lookup ip address - hostent* server; - server = gethostbyname(adr.c_str()); - if (server == NULL) - { - int errCode = errno; - std::cerr << "LinHttpHandler: Failed to find host with address " << adr << ": " << std::strerror(errCode) - << "\n"; - throw(std::system_error(errCode, std::generic_category(), "LinHttpHandler: gethostbyname")); - } - - // fill in the structure - sockaddr_in server_addr; - memset(&server_addr, 0, sizeof(server_addr)); - server_addr.sin_family = AF_INET; - server_addr.sin_port = htons(port); - memcpy(&server_addr.sin_addr.s_addr, server->h_addr, server->h_length); - - // connect the socket - if (connect(socketFD, (struct sockaddr*)&server_addr, sizeof(server_addr)) < 0) - { - int errCode = errno; - std::cerr << "LinHttpHandler: Failed to connect socket: " << std::strerror(errCode) << "\n"; - throw(std::system_error(errCode, std::generic_category(), "LinHttpHandler: Failed to connect socket")); - } - - // send the request - size_t total = msg.length(); - size_t sent = 0; - do - { - ssize_t bytes = write(socketFD, msg.c_str() + sent, total - sent); - if (bytes < 0) - { - int errCode = errno; - std::cerr << "LinHttpHandler: Failed to write message to socket: " << std::strerror(errCode) << "\n"; - throw(std::system_error( - errCode, std::generic_category(), "LinHttpHandler: Failed to write message to socket")); - } - else if (bytes == 0) - { - break; - } - else - { - sent += bytes; - } - } while (sent < total); - - // receive the response - std::string response; - char buffer[128] = {}; - do - { - ssize_t bytes = read(socketFD, buffer, 127); - if (bytes < 0) - { - int errCode = errno; - std::cerr << "LinHttpHandler: Failed to read response from socket: " << std::strerror(errCode) << std::endl; - throw(std::system_error( - errCode, std::generic_category(), "LinHttpHandler: Failed to read response from socket")); - } - else if (bytes == 0) - { - break; - } - else - { - response.append(buffer, bytes); - } - } while (true); - - return response; -} - -std::vector LinHttpHandler::sendMulticast( - const std::string& msg, const std::string& adr, int port, int timeout) const -{ - hostent* server; // host information - sockaddr_in server_addr; // server address - - // fill in the server's address and data - memset((char*)&server_addr, 0, sizeof(server_addr)); - server_addr.sin_family = AF_INET; - server_addr.sin_port = htons(port); - - // look up the address of the server given its name - server = gethostbyname(adr.c_str()); - if (!server) - { - int errCode = errno; - std::cerr << "LinHttpHandler: sendMulticast: Failed to obtain address of " << msg << ": " - << std::strerror(errCode) << "\n"; - throw(std::system_error( - errCode, std::generic_category(), "LinHttpHandler: sendMulticast: Failed to obtain address of host")); - } - - // put the host's address into the server address structure - memcpy((void*)&server_addr.sin_addr, server->h_addr_list[0], server->h_length); - - // create the socket - int socketFD = socket(AF_INET, SOCK_DGRAM, 0); - SocketCloser closeMySendSocket(socketFD); - if (socketFD < 0) - { - int errCode = errno; - std::cerr << "LinHttpHandler: sendMulticast: Failed to open socket: " << std::strerror(errCode) << "\n"; - throw(std::system_error( - errCode, std::generic_category(), "LinHttpHandler: sendMulticast: Failed to open socket")); - } - - // send a message to the server - if (sendto(socketFD, msg.c_str(), strlen(msg.c_str()), 0, (struct sockaddr*)&server_addr, sizeof(server_addr)) < 0) - { - int errCode = errno; - std::cerr << "LinHttpHandler: sendMulticast: Failed to send message: " << std::strerror(errCode) << "\n"; - throw(std::system_error( - errCode, std::generic_category(), "LinHttpHandler: sendMulticast: Failed to send message")); - } - - std::string response; - char buffer[2048] = {}; // receive buffer - - std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now(); - while (std::chrono::steady_clock::now() - start < std::chrono::seconds(timeout)) - { - ssize_t bytesReceived = recv(socketFD, &buffer, 2048, MSG_DONTWAIT); - if (bytesReceived < 0) - { - int errCode = errno; - if (errCode != EAGAIN && errCode != EWOULDBLOCK) - { - std::cerr << "LinHttpHandler: sendMulticast: Failed to read response " - "from socket: " - << std::strerror(errCode) << "\n"; - throw(std::system_error(errCode, std::generic_category(), - "LinHttpHandler: sendMulticast: Failed to read " - "response from socket")); - } - continue; - } - if (bytesReceived) - { - response.append(buffer, bytesReceived); - } - } - - // construct return vector - std::vector returnString; - size_t pos = response.find("\r\n\r\n"); - size_t prevpos = 0; - while (pos != std::string::npos) - { - returnString.push_back(response.substr(prevpos, pos - prevpos)); - pos += 4; - prevpos = pos; - pos = response.find("\r\n\r\n", pos); - } - return returnString; -} diff --git a/hueplusplus/SimpleBrightnessStrategy.cpp b/hueplusplus/SimpleBrightnessStrategy.cpp deleted file mode 100644 index d0d00ac..0000000 --- a/hueplusplus/SimpleBrightnessStrategy.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/** - \file SimpleBrightnessStrategy.cpp - Copyright Notice\n - Copyright (C) 2017 Jan Rogall - developer\n - Copyright (C) 2017 Moritz Wirger - developer\n - - This file is part of hueplusplus. - - hueplusplus is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - hueplusplus is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with hueplusplus. If not, see . -**/ - -#include "include/SimpleBrightnessStrategy.h" - -#include -#include -#include - -#include "include/HueExceptionMacro.h" -#include "include/Utils.h" - -bool SimpleBrightnessStrategy::setBrightness(unsigned int bri, uint8_t transition, HueLight& light) const -{ - light.refreshState(); - if (bri == 0) - { - if (light.state["state"]["on"] == true) - { - return light.OffNoRefresh(transition); - } - else - { - return true; - } - } - else - { - nlohmann::json request = nlohmann::json::object(); - if (transition != 4) - { - request["transitiontime"] = transition; - } - if (light.state["state"]["on"] != true) - { - request["on"] = true; - } - if (light.state["state"]["bri"] != bri) - { - if (bri > 254) - { - bri = 254; - } - request["bri"] = bri; - } - - if (!request.count("on") && !request.count("bri")) - { - // Nothing needs to be changed - return true; - } - - nlohmann::json reply = light.SendPutRequest(request, "/state", CURRENT_FILE_INFO); - - // Check whether request was successful - return utils::validateReplyForLight(request, reply, light.id); - } -} - -unsigned int SimpleBrightnessStrategy::getBrightness(HueLight& light) const -{ - light.refreshState(); - return light.state["state"]["bri"].get(); -} - -unsigned int SimpleBrightnessStrategy::getBrightness(const HueLight& light) const -{ - return light.state["state"]["bri"].get(); -} diff --git a/hueplusplus/SimpleColorHueStrategy.cpp b/hueplusplus/SimpleColorHueStrategy.cpp deleted file mode 100644 index 86c5ee4..0000000 --- a/hueplusplus/SimpleColorHueStrategy.cpp +++ /dev/null @@ -1,428 +0,0 @@ -/** - \file SimpleColorHueStrategy.cpp - Copyright Notice\n - Copyright (C) 2017 Jan Rogall - developer\n - Copyright (C) 2017 Moritz Wirger - developer\n - - This file is part of hueplusplus. - - hueplusplus is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - hueplusplus is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with hueplusplus. If not, see . -**/ - -#include "include/SimpleColorHueStrategy.h" - -#include -#include -#include - -#include "include/HueConfig.h" -#include "include/HueExceptionMacro.h" -#include "include/Utils.h" - -bool SimpleColorHueStrategy::setColorHue(uint16_t hue, uint8_t transition, HueLight& light) const -{ - light.refreshState(); - nlohmann::json request = nlohmann::json::object(); - if (transition != 4) - { - request["transitiontime"] = transition; - } - if (light.state["state"]["on"] != true) - { - request["on"] = true; - } - if (light.state["state"]["hue"] != hue || light.state["state"]["colormode"] != "hs") - { - hue = hue % 65535; - request["hue"] = hue; - } - - if (!request.count("on") && !request.count("hue")) - { - // Nothing needs to be changed - return true; - } - - nlohmann::json reply = light.SendPutRequest(request, "/state", CURRENT_FILE_INFO); - - // Check whether request was successful - return utils::validateReplyForLight(request, reply, light.id); -} - -bool SimpleColorHueStrategy::setColorSaturation(uint8_t sat, uint8_t transition, HueLight& light) const -{ - light.refreshState(); - nlohmann::json request = nlohmann::json::object(); - if (transition != 4) - { - request["transitiontime"] = transition; - } - if (light.state["state"]["on"] != true) - { - request["on"] = true; - } - if (light.state["state"]["sat"] != sat) - { - if (sat > 254) - { - sat = 254; - } - request["sat"] = sat; - } - - if (!request.count("on") && !request.count("sat")) - { - // Nothing needs to be changed - return true; - } - - nlohmann::json reply = light.SendPutRequest(request, "/state", CURRENT_FILE_INFO); - - // Check whether request was successful - return utils::validateReplyForLight(request, reply, light.id); -} - -bool SimpleColorHueStrategy::setColorHueSaturation(uint16_t hue, uint8_t sat, uint8_t transition, HueLight& light) const -{ - light.refreshState(); - nlohmann::json request = nlohmann::json::object(); - - if (transition != 4) - { - request["transitiontime"] = transition; - } - if (light.state["state"]["on"] != true) - { - request["on"] = true; - } - if (light.state["state"]["hue"] != hue || light.state["state"]["colormode"] != "hs") - { - hue = hue % 65535; - request["hue"] = hue; - } - if (light.state["state"]["sat"] != sat || light.state["state"]["colormode"] != "hs") - { - if (sat > 254) - { - sat = 254; - } - request["sat"] = sat; - } - - if (!request.count("on") && !request.count("hue") && !request.count("sat")) - { - // Nothing needs to be changed - return true; - } - - nlohmann::json reply = light.SendPutRequest(request, "/state", CURRENT_FILE_INFO); - - // Check whether request was successful - return utils::validateReplyForLight(request, reply, light.id); -} - -bool SimpleColorHueStrategy::setColorXY(float x, float y, uint8_t transition, HueLight& light) const -{ - light.refreshState(); - nlohmann::json request = nlohmann::json::object(); - - if (transition != 4) - { - request["transitiontime"] = transition; - } - if (light.state["state"]["on"] != true) - { - request["on"] = true; - } - if (std::abs(light.state["state"]["xy"][0].get() - x) > 1E-4f - || std::abs(light.state["state"]["xy"][1].get() - y) > 1E-4f - || light.state["state"]["colormode"] != "xy") - { - request["xy"][0] = x; - request["xy"][1] = y; - } - - if (!request.count("on") && !request.count("xy")) - { - // Nothing needs to be changed - return true; - } - - nlohmann::json reply = light.SendPutRequest(request, "/state", CURRENT_FILE_INFO); - - // Check whether request was successful - return utils::validateReplyForLight(request, reply, light.id); -} - -bool SimpleColorHueStrategy::setColorRGB(uint8_t r, uint8_t g, uint8_t b, uint8_t transition, HueLight& light) const -{ - if ((r == 0) && (g == 0) && (b == 0)) - { - return light.OffNoRefresh(); - } - - const float red = float(r) / 255; - const float green = float(g) / 255; - const float blue = float(b) / 255; - - // gamma correction - const float redCorrected = (red > 0.04045f) ? pow((red + 0.055f) / (1.0f + 0.055f), 2.4f) : (red / 12.92f); - const float greenCorrected = (green > 0.04045f) ? pow((green + 0.055f) / (1.0f + 0.055f), 2.4f) : (green / 12.92f); - const float blueCorrected = (blue > 0.04045f) ? pow((blue + 0.055f) / (1.0f + 0.055f), 2.4f) : (blue / 12.92f); - - const float X = redCorrected * 0.664511f + greenCorrected * 0.154324f + blueCorrected * 0.162028f; - const float Y = redCorrected * 0.283881f + greenCorrected * 0.668433f + blueCorrected * 0.047685f; - const float Z = redCorrected * 0.000088f + greenCorrected * 0.072310f + blueCorrected * 0.986039f; - - const float x = X / (X + Y + Z); - const float y = Y / (X + Y + Z); - - return light.setColorXY(x, y, transition); -} - -bool SimpleColorHueStrategy::setColorLoop(bool on, HueLight& light) const -{ - // colorloop - light.refreshState(); - nlohmann::json request = nlohmann::json::object(); - - if (light.state["state"]["on"] != true) - { - request["on"] = true; - } - std::string effect; - if ((effect = on ? "colorloop" : "none") != light.state["state"]["effect"]) - { - request["effect"] = effect; - } - if (!request.count("on") && !request.count("effect")) - { - // Nothing needs to be changed - return true; - } - - nlohmann::json reply = light.SendPutRequest(request, "/state", CURRENT_FILE_INFO); - - // Check whether request was successful - return utils::validateReplyForLight(request, reply, light.id); -} - -bool SimpleColorHueStrategy::alertHueSaturation(uint16_t hue, uint8_t sat, HueLight& light) const -{ - light.refreshState(); - std::string cType = light.state["state"]["colormode"].get(); - bool on = light.state["state"]["on"].get(); - if (cType == "hs") - { - uint16_t oldHue = light.state["state"]["hue"].get(); - uint8_t oldSat = light.state["state"]["sat"].get(); - if (!light.setColorHueSaturation(hue, sat, 1)) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY)); - if (!light.alert()) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY)); - if (!on) - { - light.setColorHueSaturation(oldHue, oldSat, 1); - return light.OffNoRefresh(1); - } - else - { - return light.setColorHueSaturation(oldHue, oldSat, 1); - } - } - else if (cType == "xy") - { - float oldX = light.state["state"]["xy"][0].get(); - float oldY = light.state["state"]["xy"][1].get(); - if (!light.setColorHueSaturation(hue, sat, 1)) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY)); - if (!light.alert()) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY)); - if (!on) - { - light.setColorXY(oldX, oldY, 1); - return light.OffNoRefresh(1); - } - else - { - return light.setColorXY(oldX, oldY, 1); - } - } - else - { - return false; - } -} - -bool SimpleColorHueStrategy::alertXY(float x, float y, HueLight& light) const -{ - light.refreshState(); - std::string cType = light.state["state"]["colormode"].get(); - bool on = light.state["state"]["on"].get(); - if (cType == "hs") - { - uint16_t oldHue = light.state["state"]["hue"].get(); - uint8_t oldSat = light.state["state"]["sat"].get(); - if (!light.setColorXY(x, y, 1)) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY)); - if (!light.alert()) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY)); - if (!on) - { - light.setColorHueSaturation(oldHue, oldSat, 1); - return light.OffNoRefresh(1); - } - else - { - return light.setColorHueSaturation(oldHue, oldSat, 1); - } - } - else if (cType == "xy") - { - float oldX = light.state["state"]["xy"][0].get(); - float oldY = light.state["state"]["xy"][1].get(); - if (!light.setColorXY(x, y, 1)) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY)); - if (!light.alert()) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY)); - if (!on) - { - light.setColorXY(oldX, oldY, 1); - return light.OffNoRefresh(1); - } - else - { - return light.setColorXY(oldX, oldY, 1); - } - } - else - { - return false; - } -} - -bool SimpleColorHueStrategy::alertRGB(uint8_t r, uint8_t g, uint8_t b, HueLight& light) const -{ - light.refreshState(); - std::string cType = light.state["state"]["colormode"].get(); - bool on = light.state["state"]["on"].get(); - if (cType == "hs") - { - uint16_t oldHue = light.state["state"]["hue"].get(); - uint8_t oldSat = light.state["state"]["sat"].get(); - if (!light.setColorRGB(r, g, b, 1)) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY)); - if (!light.alert()) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY)); - if (!on) - { - light.setColorHueSaturation(oldHue, oldSat, 1); - return light.OffNoRefresh(1); - } - else - { - return light.setColorHueSaturation(oldHue, oldSat, 1); - } - } - else if (cType == "xy") - { - float oldX = light.state["state"]["xy"][0].get(); - float oldY = light.state["state"]["xy"][1].get(); - if (!light.setColorRGB(r, g, b, 1)) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY)); - if (!light.alert()) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY)); - if (!on) - { - light.setColorXY(oldX, oldY, 1); - return light.OffNoRefresh(1); - } - else - { - return light.setColorXY(oldX, oldY, 1); - } - } - else - { - return false; - } -} - -std::pair SimpleColorHueStrategy::getColorHueSaturation(HueLight& light) const -{ - light.refreshState(); - return std::make_pair(light.state["state"]["hue"].get(), light.state["state"]["sat"].get()); -} - -std::pair SimpleColorHueStrategy::getColorHueSaturation(const HueLight& light) const -{ - return std::make_pair(light.state["state"]["hue"].get(), light.state["state"]["sat"].get()); -} - -std::pair SimpleColorHueStrategy::getColorXY(HueLight& light) const -{ - light.refreshState(); - return std::make_pair(light.state["state"]["xy"][0].get(), light.state["state"]["xy"][1].get()); -} - -std::pair SimpleColorHueStrategy::getColorXY(const HueLight& light) const -{ - return std::make_pair(light.state["state"]["xy"][0].get(), light.state["state"]["xy"][1].get()); -} -/*bool SimpleColorHueStrategy::pointInTriangle(float pointx, float pointy, float -x0, float y0, float x1, float y1, float x2, float y2) -{ -float A = (-y1 * x2 + y0*(-x1 + x2) + x0*(y1 - y2) + x1 * y1); -int8_t sign = A < 0 ? -1 : 1; -float s = (y0 * x2 - x0 * y2 + (y2 - y0) * pointx + (x0 - x2) * pointy) * sign; -float t = (x0 * y1 - y0 * x1 + (y0 - y1) * pointx + (x1 - x0) * pointy) * sign; - -return s > 0 && t > 0 && (s + t) < A * sign; -}*/ diff --git a/hueplusplus/SimpleColorTemperatureStrategy.cpp b/hueplusplus/SimpleColorTemperatureStrategy.cpp deleted file mode 100644 index 8dac10f..0000000 --- a/hueplusplus/SimpleColorTemperatureStrategy.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/** - \file SimpleColorTemperatureStrategy.cpp - Copyright Notice\n - Copyright (C) 2017 Jan Rogall - developer\n - Copyright (C) 2017 Moritz Wirger - developer\n - - This file is part of hueplusplus. - - hueplusplus is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - hueplusplus is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with hueplusplus. If not, see . -**/ - -#include "include/SimpleColorTemperatureStrategy.h" - -#include -#include -#include - -#include "include/HueConfig.h" -#include "include/HueExceptionMacro.h" -#include "include/Utils.h" - -bool SimpleColorTemperatureStrategy::setColorTemperature(unsigned int mired, uint8_t transition, HueLight& light) const -{ - light.refreshState(); - nlohmann::json request = nlohmann::json::object(); - if (transition != 4) - { - request["transitiontime"] = transition; - } - if (light.state["state"]["on"] != true) - { - request["on"] = true; - } - if (light.state["state"]["ct"] != mired) - { - if (mired > 500) - { - mired = 500; - } - if (mired < 153) - { - mired = 153; - } - request["ct"] = mired; - } - - if (!request.count("on") && !request.count("ct")) - { - // Nothing needs to be changed - return true; - } - - nlohmann::json reply = light.SendPutRequest(request, "/state", CURRENT_FILE_INFO); - - // Check whether request was successful - return utils::validateReplyForLight(request, reply, light.id); -} - -bool SimpleColorTemperatureStrategy::alertTemperature(unsigned int mired, HueLight& light) const -{ - light.refreshState(); - std::string cType = light.state["state"]["colormode"].get(); - bool on = light.state["state"]["on"].get(); - if (cType == "ct") - { - uint16_t oldCT = light.state["state"]["ct"].get(); - if (!light.setColorTemperature(mired, 1)) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY)); - if (!light.alert()) - { - return false; - } - std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY)); - if (!on) - { - light.setColorTemperature(oldCT, 1); - return light.OffNoRefresh(1); - } - else - { - return light.setColorTemperature(oldCT, 1); - } - } - else - { - return false; - } -} - -unsigned int SimpleColorTemperatureStrategy::getColorTemperature(HueLight& light) const -{ - light.refreshState(); - return light.state["state"]["ct"].get(); -} - -unsigned int SimpleColorTemperatureStrategy::getColorTemperature(const HueLight& light) const -{ - return light.state["state"]["ct"].get(); -} diff --git a/hueplusplus/UPnP.cpp b/hueplusplus/UPnP.cpp deleted file mode 100755 index 1d5b349..0000000 --- a/hueplusplus/UPnP.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/** - \file UPnP.cpp - Copyright Notice\n - Copyright (C) 2017 Jan Rogall - developer\n - Copyright (C) 2017 Moritz Wirger - developer\n - - This file is part of hueplusplus. - - hueplusplus is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - hueplusplus is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with hueplusplus. If not, see . -**/ - -#include "include/UPnP.h" - -#include -#include - -std::vector> UPnP::getDevices(std::shared_ptr handler) -{ - // send UPnP M-Search request - std::vector foundDevices - = handler->sendMulticast("M-SEARCH * HTTP/1.1\r\nHOST: 239.255.255.250:1900\r\nMAN: " - "\"ssdp:discover\"\r\nMX: 5\r\nST: ssdp:all\r\n\r\n", - "239.255.255.250", 1900, 5); - - std::vector> devices; - - // filter out devices - for (const std::string& s : foundDevices) - { - std::pair device; - int start = s.find("LOCATION:") + 10; - device.first = s.substr(start, s.find("\r\n", start) - start); - start = s.find("SERVER:") + 8; - device.second = s.substr(start, s.find("\r\n", start) - start); - if (std::find_if(devices.begin(), devices.end(), - [&](const std::pair& item) { return item.first == device.first; }) - == devices.end()) - { - devices.push_back(device); - - // std::cout << "Device: \t" << device.first << std::endl; - // std::cout << " \t" << device.second << std::endl; - } - } - return devices; -} diff --git a/hueplusplus/Utils.cpp b/hueplusplus/Utils.cpp deleted file mode 100644 index 2b55488..0000000 --- a/hueplusplus/Utils.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/** - \file Utils.cpp - Copyright Notice\n - Copyright (C) 2020 Jan Rogall - developer\n - Copyright (C) 2020 Moritz Wirger - developer\n - - This file is part of hueplusplus. - - hueplusplus is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - hueplusplus is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with hueplusplus. If not, see . -**/ - -#include "include/Utils.h" - -#include - -namespace utils -{ - bool validateReplyForLight(const nlohmann::json& request, const nlohmann::json& reply, int lightId) - { - bool success = false; - std::string path = "/lights/" + std::to_string(lightId) + "/state/"; - for (auto it = reply.begin(); it != reply.end(); ++it) - { - success = it.value().count("success"); - if (success) - { - // Traverse through first object - nlohmann::json successObject = it.value()["success"]; - for (auto successIt = successObject.begin(); successIt != successObject.end(); ++successIt) - { - const std::string successPath = successIt.key(); - if (successPath.find(path) == 0) - { - const std::string valueKey = successPath.substr(path.size()); - auto requestIt = request.find(valueKey); - success = requestIt != request.end(); - if (success) - { - if (valueKey == "xy") - { - success - = std::abs(requestIt.value()[0].get() - successIt.value()[0].get()) - <= 1E-4f - && std::abs(requestIt.value()[1].get() - successIt.value()[1].get()) - <= 1E-4f; - } - else - { - success = requestIt.value() == successIt.value(); - } - if (!success) - { - std::cout << "Value " << requestIt.value() << " does not match reply " - << successIt.value() << std::endl; - } - } - } - else - { - success = false; - } - } - } - if (!success) // Fail fast - { - break; - } - } - return success; - } -} // namespace utils \ No newline at end of file diff --git a/hueplusplus/WinHttpHandler.cpp b/hueplusplus/WinHttpHandler.cpp deleted file mode 100755 index 23a53cf..0000000 --- a/hueplusplus/WinHttpHandler.cpp +++ /dev/null @@ -1,298 +0,0 @@ -/** - \file WinHttpHandler.cpp - Copyright Notice\n - Copyright (C) 2017 Jan Rogall - developer\n - Copyright (C) 2017 Moritz Wirger - developer\n - - This file is part of hueplusplus. - - hueplusplus is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - hueplusplus is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with hueplusplus. If not, see . -**/ - -#include "include/WinHttpHandler.h" - -#include -#include -#include -#include - -#include -#include - -#pragma comment(lib, "Ws2_32.lib") - -namespace -{ - class AddrInfoFreer - { - public: - explicit AddrInfoFreer(addrinfo* p) : p(p) {} - ~AddrInfoFreer() { freeaddrinfo(p); } - - private: - addrinfo* p; - }; - class SocketCloser - { - public: - explicit SocketCloser(SOCKET s) : s(s) {} - ~SocketCloser() { closesocket(s); } - - private: - SOCKET s; - }; -} // namespace - -WinHttpHandler::WinHttpHandler() -{ - // Initialize Winsock - int return_code = WSAStartup(MAKEWORD(2, 2), &wsaData); - if (return_code != 0) - { - std::cerr << "WinHttpHandler: Failed to open socket: " << return_code << std::endl; - throw(std::system_error(return_code, std::system_category(), "WinHttpHandler: Failed to open socket")); - } -} - -WinHttpHandler::~WinHttpHandler() -{ - WSACleanup(); -} - -std::string WinHttpHandler::send(const std::string& msg, const std::string& adr, int port) const -{ - struct addrinfo hints = {}; - hints.ai_family = AF_INET; - hints.ai_socktype = SOCK_STREAM; - hints.ai_protocol = IPPROTO_TCP; - - // Resolve the server address and port - struct addrinfo* result = nullptr; - if (getaddrinfo(adr.c_str(), std::to_string(port).c_str(), &hints, &result) != 0) - { - int err = WSAGetLastError(); - std::cerr << "WinHttpHandler: getaddrinfo failed: " << err << std::endl; - throw(std::system_error(err, std::system_category(), "WinHttpHandler: getaddrinfo failed")); - } - SOCKET connect_socket = INVALID_SOCKET; - int connectError = 0; - { - AddrInfoFreer freeResult(result); - - // Attempt to connect to the first address returned by - // the call to getaddrinfo - struct addrinfo* ptr = result; - - // Create a SOCKET for connecting to server - connect_socket = socket(ptr->ai_family, ptr->ai_socktype, ptr->ai_protocol); - - if (connect_socket == INVALID_SOCKET) - { - int err = WSAGetLastError(); - std::cerr << "WinHttpHandler: Error at socket(): " << err << std::endl; - throw(std::system_error(err, std::system_category(), "WinHttpHandler: Error at socket()")); - } - - // Connect to server. - if (connect(connect_socket, ptr->ai_addr, (int)ptr->ai_addrlen) == SOCKET_ERROR) - { - connectError = WSAGetLastError(); - closesocket(connect_socket); - connect_socket = INVALID_SOCKET; - } - - // Should really try the next address returned by getaddrinfo - // if the connect call failed - // But for this simple example we just free the resources - // returned by getaddrinfo and print an error message - } - - if (connect_socket == INVALID_SOCKET) - { - std::cerr << "WinHttpHandler: Unable to connect to server!" << std::endl; - throw std::system_error(connectError, std::system_category(), "WinHttpHandler: Unable to connect to server!"); - } - SocketCloser closeSocket(connect_socket); - - // Send an initial buffer - if (::send(connect_socket, msg.c_str(), msg.size(), 0) == SOCKET_ERROR) - { - int err = WSAGetLastError(); - std::cerr << "WinHttpHandler: send failed: " << err << std::endl; - throw(std::system_error(err, std::system_category(), "WinHttpHandler: send failed")); - } - - // shutdown the connection for sending since no more data will be sent - // the client can still use the ConnectSocket for receiving data - if (shutdown(connect_socket, SD_SEND) == SOCKET_ERROR) - { - int err = WSAGetLastError(); - std::cerr << "WinHttpHandler: shutdown failed: " << err << std::endl; - throw(std::system_error(err, std::system_category(), "WinHttpHandler: shutdown failed")); - } - - const int recvbuflen = 128; - char recvbuf[recvbuflen]; - - // Receive data until the server closes the connection - std::string response; - int res; - do - { - res = recv(connect_socket, recvbuf, recvbuflen, 0); - if (res > 0) - { - // std::cout << "WinHttpHandler: Bytes received: " << res << std::endl; - response.append(recvbuf, res); - } - else if (res == 0) - { - // std::cout << "WinHttpHandler: Connection closed " << std::endl; - } - else - { - int err = WSAGetLastError(); - std::cerr << "WinHttpHandler: recv failed: " << err << std::endl; - throw(std::system_error(err, std::system_category(), "WinHttpHandler: recv failed")); - } - } while (res > 0); - - return response; -} - -std::vector WinHttpHandler::sendMulticast( - const std::string& msg, const std::string& adr, int port, int timeout) const -{ - struct addrinfo hints = {}; - hints.ai_family = AF_INET; - hints.ai_socktype = SOCK_DGRAM; - hints.ai_protocol = IPPROTO_TCP; - - // Resolve the server address and port - struct addrinfo* result = nullptr; - if (getaddrinfo(adr.c_str(), std::to_string(port).c_str(), &hints, &result) != 0) - { - int err = WSAGetLastError(); - std::cerr << "WinHttpHandler: sendMulticast: getaddrinfo failed: " << err << std::endl; - throw(std::system_error(err, std::system_category(), "WinHttpHandler: sendMulticast: getaddrinfo failed")); - } - AddrInfoFreer freeResult(result); - - // Attempt to connect to the first address returned by - // the call to getaddrinfo - struct addrinfo* ptr = result; - - // Create a SOCKET for connecting to server - SOCKET connect_socket = socket(ptr->ai_family, ptr->ai_socktype, 0); - if (connect_socket == INVALID_SOCKET) - { - int err = WSAGetLastError(); - std::cerr << "WinHttpHandler: sendMulticast: Error at socket(): " << err << std::endl; - throw(std::system_error(err, std::system_category(), "WinHttpHandler: sendMulticast: Error at socket()")); - } - SocketCloser closeSocket(connect_socket); - - // Fill out source socket's address information. - SOCKADDR_IN source_sin; - source_sin.sin_family = AF_INET; - source_sin.sin_port = htons(0); - source_sin.sin_addr.s_addr = htonl(INADDR_ANY); - - // Associate the source socket's address with the socket, Sock. - if (bind(connect_socket, (struct sockaddr FAR*)&source_sin, sizeof(source_sin)) == SOCKET_ERROR) - { - int err = WSAGetLastError(); - std::cerr << "WinHttpHandler: sendMulticast: Binding socket failed: " << err << std::endl; - throw(std::system_error(err, std::system_category(), "WinHttpHandler: sendMulticast: Binding socket failed")); - } - - u_long sock_mode = 1; - ioctlsocket(connect_socket, FIONBIO, &sock_mode); - - BOOL bOptVal = TRUE; - setsockopt(connect_socket, SOL_SOCKET, SO_BROADCAST, (char*)&bOptVal, sizeof(bOptVal)); - - // Set the Time-to-Live of the multicast. - int iOptVal = 1; // for same subnet, but might be increased to 16 - if (setsockopt(connect_socket, IPPROTO_IP, IP_MULTICAST_TTL, (char FAR*)&iOptVal, sizeof(int)) == SOCKET_ERROR) - { - int err = WSAGetLastError(); - std::cerr << "WinHttpHandler: sendMulticast: setsockopt failed: " << err << std::endl; - throw(std::system_error(err, std::system_category(), "WinHttpHandler: sendMulticast: setsockopt failed")); - } - - // Fill out the desination socket's address information. - SOCKADDR_IN dest_sin; - dest_sin.sin_family = AF_INET; - dest_sin.sin_port = htons(port); - dest_sin.sin_addr.s_addr = inet_addr((const char*)ptr->ai_addr); - - // Send a message to the multicasting address. - if (sendto(connect_socket, msg.c_str(), msg.size(), 0, (struct sockaddr FAR*)&dest_sin, sizeof(dest_sin)) - == SOCKET_ERROR) - { - int err = WSAGetLastError(); - std::cerr << "WinHttpHandler: sendMulticast: sendto failed: " << WSAGetLastError() << std::endl; - throw(std::system_error(err, std::system_category(), "WinHttpHandler: sendMulticast: sendto failed")); - } - - // shutdown the connection for sending since no more data will be sent - // the client can still use the ConnectSocket for receiving data - if (shutdown(connect_socket, SD_SEND) == SOCKET_ERROR) - { - int err = WSAGetLastError(); - std::cerr << "WinHttpHandler: sendMulticast: shutdown failed: " << err << std::endl; - throw(std::system_error(err, std::system_category(), "WinHttpHandler: sendMulticast: shutdown failed")); - } - - std::string response; - const int recvbuflen = 2048; - char recvbuf[recvbuflen] = {}; - std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now(); - while (std::chrono::steady_clock::now() - start < std::chrono::seconds(timeout)) - { - int res = recv(connect_socket, recvbuf, recvbuflen, 0); - if (res > 0) - { - // std::cout << "WinHttpHandler: sendMulticast: Bytes received: " << res - // << std::endl; - response.append(recvbuf, res); - } - else if (res == 0) - { - // std::cout << "WinHttpHandler: sendMulticast: Connection closed " << - // std::endl; - } - else - { - // No exception here due to non blocking socket - // std::cerr << "sendMulticast: recv failed: " << WSAGetLastError() << - // std::endl; throw(std::runtime_error("recv failed")); - } - } - - // construct return vector - std::vector returnString; - size_t pos = response.find("\r\n\r\n"); - size_t prevpos = 0; - while (pos != std::string::npos) - { - returnString.push_back(response.substr(prevpos, pos - prevpos)); - pos += 4; - prevpos = pos; - pos = response.find("\r\n\r\n", pos); - } - - return returnString; -} diff --git a/hueplusplus/hueplusplus-config.cmake.in b/hueplusplus/hueplusplus-config.cmake.in deleted file mode 100755 index dc1490f..0000000 --- a/hueplusplus/hueplusplus-config.cmake.in +++ /dev/null @@ -1,7 +0,0 @@ -# -config file of the hueplusplus package -# It defines the following -# hueplusplus_FOUND - which indicates that the module was found -# hueplusplus_INCLUDE_DIR - -set(hueplusplus_FOUND TRUE) -set(hueplusplus_INCLUDE_DIR "@INSTALL_INCLUDE_DIR@") diff --git a/hueplusplus/include/BaseHttpHandler.h b/hueplusplus/include/BaseHttpHandler.h deleted file mode 100644 index 22d29c6..0000000 --- a/hueplusplus/include/BaseHttpHandler.h +++ /dev/null @@ -1,175 +0,0 @@ -/** - \file BaseHttpHandler.h - Copyright Notice\n - Copyright (C) 2020 Jan Rogall - developer\n - Copyright (C) 2020 Moritz Wirger - developer\n - - This file is part of hueplusplus. - - hueplusplus is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - hueplusplus is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with hueplusplus. If not, see . -**/ - -#ifndef _BASE_HTTPHANDLER_H -#define _BASE_HTTPHANDLER_H - -#include -#include -#include -#include - -#include "IHttpHandler.h" - -#include "json/json.hpp" - -//! Base class for classes that handle http requests and multicast requests -class BaseHttpHandler : public IHttpHandler -{ -public: - //! \brief Virtual dtor - virtual ~BaseHttpHandler() = default; - - //! \brief Send a message to a specified host and return the body of the response. - //! - //! \param msg The message that should sent to the specified address - //! \param adr Ip or hostname in dotted decimal notation like "192.168.2.1" - //! \param port Optional port the request is sent to, default is 80 - //! \return The body of the response of the host as a string - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - std::string sendGetHTTPBody(const std::string& msg, const std::string& adr, int port = 80) const override; - - //! \brief Send a HTTP request with the given method to the specified host and return the body of the response. - //! - //! \param method HTTP method type e.g. GET, HEAD, POST, PUT, DELETE, ... - //! \param uri Uniform Resource Identifier in the request - //! \param contentType MIME type of the body data e.g. "text/html", "application/json", ... - //! \param body Request body, may be empty - //! \param adr Ip or hostname in dotted decimal notation like "192.168.2.1" - //! \param port Optional port the request is sent to, default is 80 - //! \return Body of the response of the host - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - std::string sendHTTPRequest(const std::string& method, const std::string& uri, const std::string& contentType, - const std::string& body, const std::string& adr, int port = 80) const override; - - //! \brief Send a HTTP GET request to the specified host and return the body of the response. - //! - //! \param uri Uniform Resource Identifier in the request - //! \param contentType MIME type of the body data e.g. "text/html", "application/json", ... - //! \param body Request body, may be empty - //! \param adr Ip or hostname in dotted decimal notation like "192.168.2.1" - //! \param port Optional port the request is sent to, default is 80 - //! that specifies the port to which the request is sent to. Default is 80 - //! \return Body of the response of the host - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - std::string GETString(const std::string& uri, const std::string& contentType, const std::string& body, - const std::string& adr, int port = 80) const override; - - //! \brief Send a HTTP POST request to the specified host and return the body of the response. - //! - //! \param uri Uniform Resource Identifier in the request - //! \param contentType MIME type of the body data e.g. "text/html", "application/json", ... - //! \param body Request body, may be empty - //! \param adr Ip or hostname in dotted decimal notation like "192.168.2.1" - //! \param port Optional port the request is sent to, default is 80 - //! that specifies the port to which the request is sent to. Default is 80 - //! \return Body of the response of the host - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - std::string POSTString(const std::string& uri, const std::string& contentType, const std::string& body, - const std::string& adr, int port = 80) const override; - - //! \brief Send a HTTP PUT request to the specified host and return the body of the response. - //! - //! \param uri Uniform Resource Identifier in the request - //! \param contentType MIME type of the body data e.g. "text/html", "application/json", ... - //! \param body Request body, may be empty - //! \param adr Ip or hostname in dotted decimal notation like "192.168.2.1" - //! \param port Optional port the request is sent to, default is 80 - //! that specifies the port to which the request is sent to. Default is 80 - //! \return Body of the response of the host - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - std::string PUTString(const std::string& uri, const std::string& contentType, const std::string& body, - const std::string& adr, int port = 80) const override; - - //! \brief Send a HTTP DELETE request to the specified host and return the body of the response. - //! - //! \param uri Uniform Resource Identifier in the request - //! \param contentType MIME type of the body data e.g. "text/html", "application/json", ... - //! \param body Request body, may be empty - //! \param adr Ip or hostname in dotted decimal notation like "192.168.2.1" - //! \param port Optional port the request is sent to, default is 80 - //! that specifies the port to which the request is sent to. Default is 80 - //! \return Body of the response of the host - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - std::string DELETEString(const std::string& uri, const std::string& contentType, const std::string& body, - const std::string& adr, int port = 80) const override; - - //! \brief Send a HTTP GET request to the specified host and return the body of the response parsed as JSON. - //! - //! \param uri Uniform Resource Identifier in the request - //! \param body Request body, may be empty - //! \param adr Ip or hostname in dotted decimal notation like "192.168.2.1" - //! \param port Optional port the request is sent to, default is 80 - //! \return Parsed body of the response of the host - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws nlohmann::json::parse_error when the body could not be parsed - nlohmann::json GETJson( - const std::string& uri, const nlohmann::json& body, const std::string& adr, int port = 80) const override; - - //! \brief Send a HTTP POST request to the specified host and return the body of the response parsed as JSON. - //! - //! \param uri Uniform Resource Identifier in the request - //! \param body Request body, may be empty - //! \param adr Ip or hostname in dotted decimal notation like "192.168.2.1" - //! \param port Optional port the request is sent to, default is 80 - //! \return Parsed body of the response of the host - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws nlohmann::json::parse_error when the body could not be parsed - nlohmann::json POSTJson( - const std::string& uri, const nlohmann::json& body, const std::string& adr, int port = 80) const override; - - //! \brief Send a HTTP PUT request to the specified host and return the body of the response parsed as JSON. - //! - //! \param uri Uniform Resource Identifier in the request - //! \param body Request body, may be empty - //! \param adr Ip or hostname in dotted decimal notation like "192.168.2.1" - //! \param port Optional port the request is sent to, default is 80 - //! \return Parsed body of the response of the host - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws nlohmann::json::parse_error when the body could not be parsed - nlohmann::json PUTJson( - const std::string& uri, const nlohmann::json& body, const std::string& adr, int port = 80) const override; - - //! \brief Send a HTTP DELETE request to the specified host and return the body of the response parsed as JSON. - //! - //! \param uri Uniform Resource Identifier in the request - //! \param body Request body, may be empty - //! \param adr Ip or hostname in dotted decimal notation like "192.168.2.1" - //! \param port Optional port the request is sent to, default is 80 - //! \return Parsed body of the response of the host - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws nlohmann::json::parse_error when the body could not be parsed - nlohmann::json DELETEJson( - const std::string& uri, const nlohmann::json& body, const std::string& adr, int port = 80) const override; -}; - -#endif diff --git a/hueplusplus/include/BrightnessStrategy.h b/hueplusplus/include/BrightnessStrategy.h deleted file mode 100755 index 1c12704..0000000 --- a/hueplusplus/include/BrightnessStrategy.h +++ /dev/null @@ -1,58 +0,0 @@ -/** - \file BrightnessStrategy.h - Copyright Notice\n - Copyright (C) 2017 Jan Rogall - developer\n - Copyright (C) 2017 Moritz Wirger - developer\n - - This file is part of hueplusplus. - - hueplusplus is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - hueplusplus is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with hueplusplus. If not, see . -**/ - -#ifndef _BRIGHTNESS_STRATEGY_H -#define _BRIGHTNESS_STRATEGY_H - -#include - -class HueLight; - -//! Virtual base class for all BrightnessStrategies -class BrightnessStrategy -{ -public: - //! \brief Virtual function for changing a lights brightness with a specified - //! transition. - //! - //! \param bri The brightness raning from 0 = off to 255 = fully lit - //! \param transition The time it takes to fade to the new brightness in - //! multiples of 100ms, 4 = 400ms and should be seen as the default \param - //! light A reference of the light - virtual bool setBrightness(unsigned int bri, uint8_t transition, HueLight& light) const = 0; - //! \brief Virtual function that returns the current brightnessof the light - //! - //! Should update the lights state by calling refreshState() - //! \param light A reference of the light - //! \return Unsigned int representing the brightness - virtual unsigned int getBrightness(HueLight& light) const = 0; - //! \brief Virtual function that returns the current brightness of the light - //! - //! \note This should not update the lights state - //! \param light A const reference of the light - //! \return Unsigned int representing the brightness - virtual unsigned int getBrightness(const HueLight& light) const = 0; - //! \brief Virtual dtor - virtual ~BrightnessStrategy() = default; -}; - -#endif diff --git a/hueplusplus/include/ColorHueStrategy.h b/hueplusplus/include/ColorHueStrategy.h deleted file mode 100755 index 7d40d8a..0000000 --- a/hueplusplus/include/ColorHueStrategy.h +++ /dev/null @@ -1,155 +0,0 @@ -/** - \file ColorHueStrategy.h - Copyright Notice\n - Copyright (C) 2017 Jan Rogall - developer\n - Copyright (C) 2017 Moritz Wirger - developer\n - - This file is part of hueplusplus. - - hueplusplus is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - hueplusplus is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with hueplusplus. If not, see . -**/ - -#ifndef _COLOR_HUE_STRATEGY_H -#define _COLOR_HUE_STRATEGY_H - -#include - -#include - -class HueLight; - -//! Virtual base class for all ColorHueStrategies -class ColorHueStrategy -{ -public: - //! \brief Virtual function for changing a lights color in hue with a - //! specified transition. - //! - //! The hue ranges from 0 to 65535, whereas 65535 and 0 are red, 25500 is - //! green and 46920 is blue. \param hue The hue of the color \param transition - //! The time it takes to fade to the new color in multiples of 100ms, 4 = - //! 400ms and should be seen as the default \param light A reference of the - //! light - virtual bool setColorHue(uint16_t hue, uint8_t transition, HueLight& light) const = 0; - //! \brief Virtual function for changing a lights color in saturation with a - //! specified transition. - //! - //! The saturation ranges from 0 to 254, whereas 0 is least saturated (white) - //! and 254 is most saturated (vibrant). \param sat The saturation of the - //! color \param transition The time it takes to fade to the new color in - //! multiples of 100ms, 4 = 400ms and should be seen as the default \param - //! light A reference of the light - virtual bool setColorSaturation(uint8_t sat, uint8_t transition, HueLight& light) const = 0; - //! \brief Virtual function for changing a lights color in hue and saturation - //! format with a specified transition. - //! - //! The hue ranges from 0 to 65535, whereas 65535 and 0 are red, 25500 is - //! green and 46920 is blue. The saturation ranges from 0 to 254, whereas 0 is - //! least saturated (white) and 254 is most saturated (vibrant). \param hue - //! The hue of the color \param sat The saturation of the color \param - //! transition The time it takes to fade to the new color in multiples of - //! 100ms, 4 = 400ms and should be seen as the default \param light A - //! reference of the light - virtual bool setColorHueSaturation(uint16_t hue, uint8_t sat, uint8_t transition, HueLight& light) const = 0; - //! \brief Virtual function for changing a lights color in CIE format with a - //! specified transition. - //! - //! \param x The x coordinate in CIE, ranging from 0 to 1 - //! \param y The y coordinate in CIE, ranging from 0 to 1 - //! \param transition The time it takes to fade to the new color in multiples - //! of 100ms, 4 = 400ms and should be seen as the default \param light A - //! reference of the light - virtual bool setColorXY(float x, float y, uint8_t transition, HueLight& light) const = 0; - //! \brief Virtual function for changing a lights color in rgb format with a - //! specified transition. - //! - //! Red, green and blue are ranging from 0 to 255. - //! \param r The red portion of the color - //! \param g The green portion of the color - //! \param b The blue portion of the color - //! \param transition The time it takes to fade to the new color in multiples - //! of 100ms, 4 = 400ms and should be seen as the default \param light A - //! reference of the light - virtual bool setColorRGB(uint8_t r, uint8_t g, uint8_t b, uint8_t transition, HueLight& light) const = 0; - //! \brief Virtual function for turning on/off the color loop feature of a - //! light. - //! - //! Can be theoretically set for any light, but it only works for lights that - //! support this feature. When this feature is activated the light will fade - //! through every color on the current hue and saturation settings. Notice - //! that none of the setter functions check whether this feature is enabled - //! and the colorloop can only be disabled with this function or by simply - //! calling Off()/OffNoRefresh() and then On()/OnNoRefresh(), so you could - //! alternatively call Off() and then use any of the setter functions. \param - //! on Boolean to turn this feature on or off, true/1 for on and false/0 for - //! off \param light A reference of the light - virtual bool setColorLoop(bool on, HueLight& light) const = 0; - //! \brief Virtual function that lets the light perform one breath cycle in - //! the specified color. - //! - //! The hue ranges from 0 to 65535, whereas 65535 and 0 are red, 25500 is - //! green and 46920 is blue. The saturation ranges from 0 to 254, whereas 0 is - //! least saturated (white) and 254 is most saturated (vibrant). \param hue - //! The hue of the color \param sat The saturation of the color \param light A - //! reference of the light - virtual bool alertHueSaturation(uint16_t hue, uint8_t sat, HueLight& light) const = 0; - //! \brief Virtual function that lets the light perform one breath cycle in - //! the specified color. - //! - //! \param x The x coordinate in CIE, ranging from 0 to 1 - //! \param y The y coordinate in CIE, ranging from 0 to 1 - //! \param light A reference of the light - virtual bool alertXY(float x, float y, HueLight& light) const = 0; - //! \brief Virtual function that lets the light perform one breath cycle in - //! the specified color. - //! - //! Red, green and blue are ranging from 0 to 255. - //! \param r The red portion of the color - //! \param g The green portion of the color - //! \param b The blue portion of the color - //! \param light A reference of the light - virtual bool alertRGB(uint8_t r, uint8_t g, uint8_t b, HueLight& light) const = 0; - //! \brief Virtual function that returns the current color of the light as hue - //! and saturation - //! - //! Should update the lights state by calling refreshState() - //! \param light A reference of the light - //! \return Pair containing the hue as first value and saturation as second - //! value - virtual std::pair getColorHueSaturation(HueLight& light) const = 0; - //! \brief Virtual function that returns the current color of the light as hue - //! and saturation - //! - //! \note This should not update the lights state - //! \param light A const reference of the light - //! \return Pair containing the hue as first value and saturation as second - //! value - virtual std::pair getColorHueSaturation(const HueLight& light) const = 0; - //! \brief Virtual function that returns the current color of the light as xy - //! - //! Should update the lights state by calling refreshState() - //! \param light A reference of the light - //! \return Pair containing the x as first value and y as second value - virtual std::pair getColorXY(HueLight& light) const = 0; - //! \brief Virtual function that returns the current color of the light as xy - //! - //! \note This should not update the lights state - //! \param light A const reference of the light - //! \return Pair containing the x as first value and y as second value - virtual std::pair getColorXY(const HueLight& light) const = 0; - //! \brief Virtual dtor - virtual ~ColorHueStrategy() = default; -}; - -#endif diff --git a/hueplusplus/include/ColorTemperatureStrategy.h b/hueplusplus/include/ColorTemperatureStrategy.h deleted file mode 100755 index 37be4fe..0000000 --- a/hueplusplus/include/ColorTemperatureStrategy.h +++ /dev/null @@ -1,70 +0,0 @@ -/** - \file ColorTemperatureStrategy.h - Copyright Notice\n - Copyright (C) 2017 Jan Rogall - developer\n - Copyright (C) 2017 Moritz Wirger - developer\n - - This file is part of hueplusplus. - - hueplusplus is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - hueplusplus is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with hueplusplus. If not, see . -**/ - -#ifndef _COLOR_TEMPERATURE_STRATEGY_H -#define _COLOR_TEMPERATURE_STRATEGY_H - -#include - -class HueLight; - -//! Virtual base class for all ColorTemperatureStrategies -class ColorTemperatureStrategy -{ -public: - //! \brief Virtual function for changing a lights color temperature in mired - //! with a specified transition. - //! - //! The color temperature in mired ranges from 153 to 500 whereas 153 is cold - //! and 500 is warm. \param mired The color temperature in mired \param - //! transition The time it takes to fade to the new color in multiples of - //! 100ms, 4 = 400ms and should be seen as the default \param light A - //! reference of the light - virtual bool setColorTemperature(unsigned int mired, uint8_t transition, HueLight& light) const = 0; - //! \brief Virtual function that lets the light perform one breath cycle in - //! the specified color. - //! - //! The color temperature in mired ranges from 153 to 500 whereas 153 is cold - //! and 500 is warm. \param mired The color temperature in mired \param light - //! A reference of the light - virtual bool alertTemperature(unsigned int mired, HueLight& light) const = 0; - //! \brief Virtual function that returns the current color temperature of the - //! light - //! - //! Should update the lights state by calling refreshState() - //! The color temperature in mired ranges from 153 to 500 whereas 153 is cold - //! and 500 is warm. \param light A reference of the light \return Unsigned - //! int representing the color temperature in mired - virtual unsigned int getColorTemperature(HueLight& light) const = 0; - //! \brief Virtual function that returns the current color temperature of the - //! light - //! - //! The color temperature in mired ranges from 153 to 500 whereas 153 is cold - //! and 500 is warm. \note This should not update the lights state \param - //! light A const reference of the light \return Unsigned int representing the - //! color temperature in mired - virtual unsigned int getColorTemperature(const HueLight& light) const = 0; - //! \brief Virtual dtor - virtual ~ColorTemperatureStrategy() = default; -}; - -#endif diff --git a/hueplusplus/include/ExtendedColorHueStrategy.h b/hueplusplus/include/ExtendedColorHueStrategy.h deleted file mode 100755 index 000418f..0000000 --- a/hueplusplus/include/ExtendedColorHueStrategy.h +++ /dev/null @@ -1,63 +0,0 @@ -/** - \file ExtendedColorHueStrategy.h - Copyright Notice\n - Copyright (C) 2017 Jan Rogall - developer\n - Copyright (C) 2017 Moritz Wirger - developer\n - - This file is part of hueplusplus. - - hueplusplus is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - hueplusplus is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with hueplusplus. If not, see . -**/ - -#ifndef _EXTENDED_COLOR_HUE_STRATEGY_H -#define _EXTENDED_COLOR_HUE_STRATEGY_H - -#include "HueLight.h" -#include "SimpleColorHueStrategy.h" - -//! Class extending the implementation of SimpleColorHueStrategy -class ExtendedColorHueStrategy : public SimpleColorHueStrategy -{ -public: - //! \brief Function that lets the light perform one breath cycle in the - //! specified color. - //! - //! It uses this_thread::sleep_for to accomodate for the time an \ref - //! HueLight::alert() needs The hue ranges from 0 to 65535, whereas 65535 and - //! 0 are red, 25500 is green and 46920 is blue. The saturation ranges from 0 - //! to 254, whereas 0 is least saturated (white) and 254 is most saturated - //! (vibrant). \param hue The hue of the color \param sat The saturation of - //! the color \param light A reference of the light - bool alertHueSaturation(uint16_t hue, uint8_t sat, HueLight& light) const override; - //! \brief Function that lets the light perform one breath cycle in the - //! specified color. - //! - //! It uses this_thread::sleep_for to accomodate for the time an \ref - //! HueLight::alert() needs \param x The x coordinate in CIE, ranging from 0 - //! to 1 \param y The y coordinate in CIE, ranging from 0 to 1 \param light A - //! reference of the light - bool alertXY(float x, float y, HueLight& light) const override; - //! \brief Function that lets the light perform one breath cycle in the - //! specified color. - //! - //! It uses this_thread::sleep_for to accomodate for the time an \ref - //! HueLight::alert() needs Red, green and blue are ranging from 0 to 255. - //! \param r The red portion of the color - //! \param g The green portion of the color - //! \param b The blue portion of the color - //! \param light A reference of the light - bool alertRGB(uint8_t r, uint8_t g, uint8_t b, HueLight& light) const override; -}; - -#endif diff --git a/hueplusplus/include/ExtendedColorTemperatureStrategy.h b/hueplusplus/include/ExtendedColorTemperatureStrategy.h deleted file mode 100755 index e24137c..0000000 --- a/hueplusplus/include/ExtendedColorTemperatureStrategy.h +++ /dev/null @@ -1,52 +0,0 @@ -/** - \file ExtendedColorTemperatureStrategy.h - Copyright Notice\n - Copyright (C) 2017 Jan Rogall - developer\n - Copyright (C) 2017 Moritz Wirger - developer\n - - This file is part of hueplusplus. - - hueplusplus is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - hueplusplus is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with hueplusplus. If not, see . -**/ - -#ifndef _EXTENDED_COLOR_TEMPERATURE_STRATEGY_H -#define _EXTENDED_COLOR_TEMPERATURE_STRATEGY_H - -#include "HueLight.h" -#include "SimpleColorTemperatureStrategy.h" - -//! Class implementing the functions of ColorTemperatureStrategy -class ExtendedColorTemperatureStrategy : public SimpleColorTemperatureStrategy -{ -public: - //! \brief Function for changing a lights color temperature in mired with a - //! specified transition. - //! - //! The color temperature in mired ranges from 153 to 500 whereas 153 is cold - //! and 500 is warm. \param mired The color temperature in mired \param - //! transition The time it takes to fade to the new color in multiples of - //! 100ms, 4 = 400ms and should be seen as the default \param light A - //! reference of the light - bool setColorTemperature(unsigned int mired, uint8_t transition, HueLight& light) const override; - //! \brief Function that lets the light perform one breath cycle in the - //! specified color. - //! - //! It uses this_thread::sleep_for to accomodate for the time an \ref - //! HueLight::alert() needs The color temperature in mired ranges from 153 to - //! 500 whereas 153 is cold and 500 is warm. \param mired The color - //! temperature in mired \param light A reference of the light - bool alertTemperature(unsigned int mired, HueLight& light) const override; -}; - -#endif diff --git a/hueplusplus/include/Hue.h b/hueplusplus/include/Hue.h deleted file mode 100644 index 1aa8360..0000000 --- a/hueplusplus/include/Hue.h +++ /dev/null @@ -1,282 +0,0 @@ -/** - \file Hue.h - Copyright Notice\n - Copyright (C) 2017 Jan Rogall - developer\n - Copyright (C) 2017 Moritz Wirger - developer\n - - This file is part of hueplusplus. - - hueplusplus is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - hueplusplus is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with hueplusplus. If not, see . -**/ - -#ifndef _HUE_H -#define _HUE_H - -#include -#include -#include -#include -#include - -#include "BrightnessStrategy.h" -#include "ColorHueStrategy.h" -#include "ColorTemperatureStrategy.h" -#include "HueCommandAPI.h" -#include "HueLight.h" -#include "IHttpHandler.h" - -#include "json/json.hpp" - -// forward declarations -class Hue; - -//! -//! Class to find all Hue bridges on the network and create usernames for them. -//! -class HueFinder -{ -public: - struct HueIdentification - { - std::string ip; - int port = 80; - std::string mac; - }; - -public: - //! \brief Constructor of HueFinder class - //! - //! \param handler HttpHandler of type \ref IHttpHandler for communication with the bridge - HueFinder(std::shared_ptr handler); - - //! \brief Finds all bridges in the network and returns them. - //! - //! The user should be given the opportunity to select the correct one based on the mac address. - //! \return vector containing ip and mac of all found bridges - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - std::vector FindBridges() const; - - //! \brief Gets a \ref Hue bridge based on its identification - //! - //! \param identification \ref HueIdentification that specifies a bridge - //! \return \ref Hue class object - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body or username could not be requested - //! \throws HueAPIResponseException when response contains an error - //! \throws nlohmann::json::parse_error when response could not be parsed - Hue GetBridge(const HueIdentification& identification); - - //! \brief Function that adds a username to the usernames map - //! - //! \param mac MAC address of Hue bridge - //! \param username Username that is used to control the Hue bridge - void AddUsername(const std::string& mac, const std::string& username); - - //! \brief Function that returns a map of mac addresses and usernames. - //! - //! Note these should be saved at the end and re-loaded with \ref AddUsername - //! next time, so only one username is generated per bridge. \returns A map - //! mapping mac address to username for every bridge - const std::map& GetAllUsernames() const; - - //! \brief Normalizes mac address to plain hex number. - //! \returns \p input without separators and whitespace, in lower case. - static std::string NormalizeMac(std::string input); - -private: - //! \brief Parses mac address from description.xml - //! - //! \param description Content of description.xml file as returned by GET request. - //! \returns Content of xml element \c serialNumber if description matches a Hue bridge, otherwise an empty string. - static std::string ParseDescription(const std::string& description); - - std::map usernames; //!< Maps all macs to usernames added by \ref - //!< HueFinder::AddUsername - std::shared_ptr http_handler; -}; - -//! Hue class -class Hue -{ - friend class HueFinder; - -public: - //! \brief Constructor of Hue class - //! - //! \param ip IP address in dotted decimal notation like "192.168.2.1" - //! \param port Port of the hue bridge - //! \param username String that specifies the username that is used to control - //! the bridge. This needs to be acquired in \ref requestUsername - //! \param handler HttpHandler for communication with the bridge - Hue(const std::string& ip, const int port, const std::string& username, - std::shared_ptr handler); - - //! \brief Function to get the ip address of the hue bridge - //! - //! \return string containing ip - std::string getBridgeIP(); - - //! \brief Function to get the port of the hue bridge - //! - //! \return integer containing port - int getBridgePort(); - - //! \brief Send a username request to the Hue bridge. - //! - //! Blocks for about 30 seconds and 5 seconds to prepare. - //! It automatically sets the username variable according to the username received and returns the username - //! received. This function should only be called once to acquire a username to control the bridge and the username - //! should be saved for future use. - //! \return username for API usage - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws HueAPIResponseException when response contains an error except link button not pressed. - //! \throws nlohmann::json::parse_error when response could not be parsed - std::string requestUsername(); - - //! \brief Function that returns the username - //! - //! \return The username used for API access - std::string getUsername(); - - //! \brief Function to set the ip address of this class representing a bridge - //! - //! \param ip String that specifies the ip in dotted decimal notation like "192.168.2.1" - void setIP(const std::string& ip); - - //! \brief Function to set the port of this class representing a bridge - //! - //! \param port Integer that specifies the port of an address like - //! "192.168.2.1:8080" - void setPort(const int port); - - //! \brief Function that returns a \ref HueLight of specified id - //! - //! \param id Integer that specifies the ID of a Hue light - //! \return \ref HueLight that can be controlled - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when id does not exist or type is unknown - //! \throws HueAPIResponseException when response contains an error - //! \throws nlohmann::json::parse_error when response could not be parsed - HueLight& getLight(int id); - - //! \brief Function to remove a light from the bridge - //! - //! \attention Any use of the light after it was successfully removed results in undefined behavior - //! \param id Id of the light to remove - //! \return true on success - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contains no body - //! \throws HueAPIResponseException when response contains an error - //! \throws nlohmann::json::parse_error when response could not be parsed - bool removeLight(int id); - - //! \brief Function that returns all light types that are associated with this bridge - //! - //! \return A map mapping light id's to light types for every light - // const std::map& getAllLightTypes(); - - //! \brief Function that returns all lights that are associated with this - //! bridge - //! - //! \return A vector containing references to every HueLight - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contains no body - //! \throws HueAPIResponseException when response contains an error - //! \throws nlohmann::json::parse_error when response could not be parsed - std::vector> getAllLights(); - - //! \brief Function that tells whether a given light id represents an existing light - //! - //! Calls refreshState to update the local bridge state - //! \param id Id of a light to check for existance - //! \return Bool that is true when a light with the given id exists and false when not - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contains no body - //! \throws HueAPIResponseException when response contains an error - //! \throws nlohmann::json::parse_error when response could not be parsed - bool lightExists(int id); - - //! \brief Const function that tells whether a given light id represents an - //! existing light - //! - //! \note This will not update the local state of the bridge - //! \param id Id of a light to check for existance - //! \return Bool that is true when a light with the given id exists and false - //! when not - bool lightExists(int id) const; - - //! \brief Const function that returns the picture name of a given light id - //! - //! \note This will not update the local state of the bridge. - //! \note This function will only return the filename without extension, - //! because Philips provides different file types. \param id Id of a light to - //! get the picture of \return String that either contains the filename of the - //! picture of the light or if it was not found an empty string - std::string getPictureOfLight(int id) const; - - //! \brief Const function that returns the picture name of a given model id - //! - //! \note This will not update the local state of the bridge. - //! \note This function will only return the filename without extension, - //! because Philips provides different file types. \param model_id Model Id of - //! a device to get the picture of \return String that either contains the - //! filename of the picture of the device or if it was not found an empty - //! string - std::string getPictureOfModel(const std::string& model_id) const; - - //! \brief Function that sets the HttpHandler and updates the HueCommandAPI. - //! - //! The HttpHandler and HueCommandAPI are used for bridge communication - //! \param handler a HttpHandler of type \ref IHttpHandler - void setHttpHandler(std::shared_ptr handler) - { - http_handler = std::move(handler); - commands = HueCommandAPI(ip, port, username, http_handler); - } - -private: - //! \brief Function that refreshes the local \ref state of the Hue bridge - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws HueAPIResponseException when response contains an error - //! \throws nlohmann::json::parse_error when response could not be parsed - void refreshState(); - -private: - std::string ip; //!< IP-Address of the hue bridge in dotted decimal notation - //!< like "192.168.2.1" - std::string username; //!< Username that is ussed to access the hue bridge - int port; - nlohmann::json state; //!< The state of the hue bridge as it is returned from it - std::map lights; //!< Maps ids to HueLights that are controlled by this bridge - - std::shared_ptr simpleBrightnessStrategy; //!< Strategy that is used for controlling the - //!< brightness of lights - std::shared_ptr simpleColorHueStrategy; //!< Strategy that is used for controlling the - //!< color of lights - std::shared_ptr extendedColorHueStrategy; //!< Strategy that is used for controlling the - //!< color of lights - std::shared_ptr simpleColorTemperatureStrategy; //!< Strategy that is used for controlling - //!< the color temperature of lights - std::shared_ptr extendedColorTemperatureStrategy; //!< Strategy that is used for - //!< controlling the color temperature - //!< of lights - std::shared_ptr http_handler; //!< A IHttpHandler that is used to communicate with the - //!< bridge - HueCommandAPI commands; //!< A HueCommandAPI that is used to communicate with the bridge -}; - -#endif diff --git a/hueplusplus/include/HueCommandAPI.h b/hueplusplus/include/HueCommandAPI.h deleted file mode 100644 index 7bd9895..0000000 --- a/hueplusplus/include/HueCommandAPI.h +++ /dev/null @@ -1,123 +0,0 @@ -/** - \file HueCommandAPI.h - Copyright Notice\n - Copyright (C) 2018 Jan Rogall - developer\n - Copyright (C) 2018 Moritz Wirger - developer\n - - This file is part of hueplusplus. - - hueplusplus is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - hueplusplus is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with hueplusplus. If not, see . -**/ - -#ifndef _HUECOMMANDAPI_H -#define _HUECOMMANDAPI_H - -#include -#include -#include - -#include "HueException.h" -#include "IHttpHandler.h" - -//! Handles communication to the bridge via IHttpHandler and enforces a timeout -//! between each request -class HueCommandAPI -{ -public: - //! \brief Construct from ip, username and HttpHandler - //! - //! \param ip ip address of the Hue bridge in dotted decimal notation like "192.168.2.1" - //! \param port of the hue bridge - //! \param username username that is used to control the bridge - //! \param httpHandler HttpHandler for communication with the bridge - HueCommandAPI( - const std::string& ip, int port, const std::string& username, std::shared_ptr httpHandler); - - //! \brief Copy construct from other HueCommandAPI - //! \note All copies refer to the same timeout data, so even calls from different objects will be delayed - HueCommandAPI(const HueCommandAPI&) = default; - //! \brief Move construct from other HueCommandAPI - //! \note All copies refer to the same timeout data, so even calls from different objects will be delayed - HueCommandAPI(HueCommandAPI&&) = default; - - //! \brief Copy assign from other HueCommandAPI - //! \note All copies refer to the same timeout data, so even calls from different objects will be delayed - HueCommandAPI& operator=(const HueCommandAPI&) = default; - //! \brief Move assign from other HueCommandAPI - //! \note All copies refer to the same timeout data, so even calls from different objects will be delayed - HueCommandAPI& operator=(HueCommandAPI&&) = default; - - //! \brief Sends a HTTP PUT request to the bridge and returns the response - //! - //! This function will block until at least \ref minDelay has passed to any previous request - //! \param path API request path (appended after /api/{username}) - //! \param request Request to the api, may be empty - //! \returns The return value of the underlying \ref IHttpHandler::PUTJson call - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contains no body - //! \throws HueAPIResponseException when response contains an error - nlohmann::json PUTRequest(const std::string& path, const nlohmann::json& request) const; - nlohmann::json PUTRequest(const std::string& path, const nlohmann::json& request, FileInfo fileInfo) const; - - //! \brief Sends a HTTP GET request to the bridge and returns the response - //! - //! This function will block until at least \ref minDelay has passed to any previous request - //! \param path API request path (appended after /api/{username}) - //! \param request Request to the api, may be empty - //! \returns The return value of the underlying \ref IHttpHandler::GETJson call - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contains no body - //! \throws HueAPIResponseException when response contains an error - nlohmann::json GETRequest(const std::string& path, const nlohmann::json& request) const; - nlohmann::json GETRequest(const std::string& path, const nlohmann::json& request, FileInfo fileInfo) const; - - //! \brief Sends a HTTP DELETE request to the bridge and returns the response - //! - //! This function will block until at least \ref minDelay has passed to any previous request - //! \param path API request path (appended after /api/{username}) - //! \param request Request to the api, may be empty - //! \returns The return value of the underlying \ref IHttpHandler::DELETEJson call - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contains no body - //! \throws HueAPIResponseException when response contains an error - nlohmann::json DELETERequest(const std::string& path, const nlohmann::json& request) const; - nlohmann::json DELETERequest(const std::string& path, const nlohmann::json& request, FileInfo fileInfo) const; - -private: - struct TimeoutData - { - std::chrono::steady_clock::time_point timeout; - std::mutex mutex; - }; - - //! \brief Throws an exception if response contains an error, passes though value - //! \throws HueAPIResponseException when response contains an error - //! \returns \ref response if there is no error - nlohmann::json HandleError(FileInfo fileInfo, const nlohmann::json& response) const; - - //! \brief Combines path with api prefix and username - //! \returns "/api//" - std::string CombinedPath(const std::string& path) const; - -public: - static constexpr std::chrono::steady_clock::duration minDelay = std::chrono::milliseconds(100); -private: - std::string ip; - int port; - std::string username; - std::shared_ptr httpHandler; - std::shared_ptr timeout; -}; - -#endif \ No newline at end of file diff --git a/hueplusplus/include/HueConfig.h b/hueplusplus/include/HueConfig.h deleted file mode 100755 index de5c069..0000000 --- a/hueplusplus/include/HueConfig.h +++ /dev/null @@ -1,29 +0,0 @@ -/** - \file HueConfig.h - Copyright Notice\n - Copyright (C) 2017 Jan Rogall - developer\n - Copyright (C) 2017 Moritz Wirger - developer\n - - This file is part of hueplusplus. - - hueplusplus is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - hueplusplus is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with hueplusplus. If not, see . -**/ - -#ifndef _HUE_CONFIG_H -#define _HUE_CONFIG_H - -const uint16_t c_PRE_ALERT_DELAY = 120; //!< Delay for advanced alerts before the actual alert -const uint16_t c_POST_ALERT_DELAY = 1600; //!< Delay for advanced alerts after the actual alert - -#endif diff --git a/hueplusplus/include/HueException.h b/hueplusplus/include/HueException.h deleted file mode 100644 index fafb7cc..0000000 --- a/hueplusplus/include/HueException.h +++ /dev/null @@ -1,118 +0,0 @@ -/** - \file HueException.h - Copyright Notice\n - Copyright (C) 2020 Jan Rogall - developer\n - Copyright (C) 2020 Moritz Wirger - developer\n - - This file is part of hueplusplus. - - hueplusplus is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - hueplusplus is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with hueplusplus. If not, see . -**/ - -#ifndef _HUE_EXCEPTION_H -#define _HUE_EXCEPTION_H - -#include -#include - -#include "json/json.hpp" - -//! \brief Contains information about error location, use CURRENT_FILE_INFO to create -struct FileInfo -{ - //! \brief Current file name from __FILE__. Empty if unknown - std::string filename; - //! \brief Current line number from __LINE__. -1 if unknown - int line = -1; - //! \brief Current function from __func__. Empty if unknown - std::string func; - - //! \brief String representation of func, file and line. - //! \returns " in :" or "Unknown file" if unknown. - std::string ToString() const; -}; - -//! \brief Exception class with file information. Base class of all custom exception classes -class HueException : public std::exception -{ -public: - //! \brief Creates HueException with information about the error and source - //! \param fileInfo Source of the error. Must not always be the throw location, - //! can also be a calling function which matches the cause better. - //! \param message Human readable error message. - HueException(FileInfo fileInfo, const std::string& message); - - //! \brief What message of the exception - //! \returns exception name, file info and constructor message as char* into member string - const char* what() const noexcept override; - - //! \brief Filename and line where the exception was thrown or caused by - const FileInfo& GetFile() const noexcept; - -protected: - //! \brief Creates HueException with child class name - //! - //! Should be used by subclasses which can append additional information to the end of whatMessage. - //! \param exceptionName class name of the subclass - //! \param fileInfo Source of the error. Must not always be the throw location, - //! can also be a calling function which matches the cause better. - //! \param message Human readable error message - HueException(const char* exceptionName, FileInfo fileInfo, const std::string& message); - -private: - std::string whatMessage; - FileInfo fileInfo; -}; - -//! \brief Exception caused by a Hue API "error" response with additional information -//! -//! Refer to Hue developer documentation for more detail on specific error codes. -class HueAPIResponseException : public HueException -{ -public: - //! \brief Create exception with info from Hue API error - //! \param fileInfo Source of the error. Must not always be the throw location, - //! can also be a calling function which matches the cause better. - //! \param error Hue API error code from error response. - //! \param address URI the API call referred to from error response. - //! \param description Error description from response. - HueAPIResponseException(FileInfo fileInfo, int error, std::string address, std::string description); - - //! \brief Error number from Hue API error response. - //! - //! Refer to Hue developer documentation for meaning of error codes. - int GetErrorNumber() const noexcept; - //! \brief Address the API call tried to access. - const std::string& GetAddress() const noexcept; - //! \brief Error description - const std::string& GetDescription() const noexcept; - - //! \brief Creates exception from API response. - //! \param fileInfo Location of the cause - //! \param response Hue API response. Must contain a member "error" with "type", "address" and "description". - //! \returns HueAPIResponseException with info from the response. - //! If response does not contain the required members, they are defaulted to -1 or "". - static HueAPIResponseException Create(FileInfo fileInfo, const nlohmann::json& response); - -private: - //! \brief Creates exception message containing the given information - static std::string GetMessage(int error, const std::string& addr, const std::string& description); - -private: - int error; - std::string address; - std::string description; -}; - -#endif \ No newline at end of file diff --git a/hueplusplus/include/HueExceptionMacro.h b/hueplusplus/include/HueExceptionMacro.h deleted file mode 100644 index 80ffaeb..0000000 --- a/hueplusplus/include/HueExceptionMacro.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - \file HueException.h - Copyright Notice\n - Copyright (C) 2020 Jan Rogall - developer\n - Copyright (C) 2020 Moritz Wirger - developer\n - - This file is part of hueplusplus. - - hueplusplus is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - hueplusplus is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with hueplusplus. If not, see . -**/ - -#include "HueException.h" - -#ifndef CURRENT_FILE_INFO -#define CURRENT_FILE_INFO (FileInfo{__FILE__, __LINE__, __func__}) -#endif \ No newline at end of file diff --git a/hueplusplus/include/HueLight.h b/hueplusplus/include/HueLight.h deleted file mode 100644 index 0bd20ca..0000000 --- a/hueplusplus/include/HueLight.h +++ /dev/null @@ -1,790 +0,0 @@ -/** - \file HueLight.h - Copyright Notice\n - Copyright (C) 2017 Jan Rogall - developer\n - Copyright (C) 2017 Moritz Wirger - developer\n - - This file is part of hueplusplus. - - hueplusplus is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - hueplusplus is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with hueplusplus. If not, see . -**/ - -#ifndef _HUE_LIGHT_H -#define _HUE_LIGHT_H - -#include - -#include "BrightnessStrategy.h" -#include "ColorHueStrategy.h" -#include "ColorTemperatureStrategy.h" -#include "HueCommandAPI.h" - -#include "json/json.hpp" - -/*enum ModelType -{ -UNDEFINED, // undefined model -LCT001, // Hue bulb A19, Color Gamut B, ECL -LCT007, // Hue bulb A19, Color Gamut B, ECL -LCT010, // Hue bulb A19, Color Gamut C, ECL -LCT014, // Hue bulb A19, Color Gamut C, ECL - -LCT002, // Hue Spot BR30, Color Gamut B, ECL -LCT003, // Hue Spot GU10, Color Gamut B, ECL - -LCT011, // Hue BR30, Color Gamut C, ECL - -LST001, // Hue LightStrips, Color Gamut A, CL -LST002, // Hue LightStrips Plus, Color Gamut C, ECL - -LLC010, // Hue Living Colors Iris, Color Gamut A, CL -LLC011, // Hue Living Colors Bloom, Color Gamut A, CL -LLC012, // Hue Living Colors Bloom, Color Gamut A, CL -LLC006, // Living Colors Gen3 Iris, Color Gamut A, CL, NO HUE FRIEND -LLC007, // Living Colors Gen3 Bloom, Aura, Color Gamut A, CL, NO HUE FRIEND -LLC013, // Disney Living Colors, Color Gamut A, CL - -LWB004, // Hue A19 Lux, Color Gamut -, DL -LWB006, // Hue A19 Lux, Color Gamut -, DL -LWB007, // Hue A19 Lux, Color Gamut -, DL -LWB010, // Hue A19 Lux, Color Gamut -, DL -LWB014, // Hue A19 Lux, Color Gamut -, DL - -LLM001, // Color Light Module, Color Gamut B, ECL -LLM010, // Color Temperature Module, Color Gamut 2200K-6500K, CTL -LLM011, // Color Temperature Module, Color Gamut 2200K-6500K, CTL -LLM012, // Color Temperature Module, Color Gamut 2200K-6500K, CTL - -LTW001, // Hue Spot BR30, Color Gamut 2200K-6500K, CTL -LTW004, // Hue Spot BR30, Color Gamut 2200K-6500K, CTL -LTW013, // Hue Spot BR30, Color Gamut 2200K-6500K, CTL -LTW014, // Hue Spot BR30, Color Gamut 2200K-6500K, CTL - -LLC020 // Hue Go, Color Gamut C, ECL -};*/ - -//! enum that specifies the color type of all HueLights -enum ColorType -{ - UNDEFINED, //!< ColorType for this light is unknown or undefined - NONE, //!< light has no specific ColorType - GAMUT_A, - GAMUT_B, - GAMUT_C, - TEMPERATURE, - GAMUT_A_TEMPERATURE, - GAMUT_B_TEMPERATURE, - GAMUT_C_TEMPERATURE -}; - -//! -//! Class for Hue Light fixtures -//! -class HueLight -{ - friend class Hue; - friend struct MakeHueLight; - friend class SimpleBrightnessStrategy; - friend class SimpleColorHueStrategy; - friend class ExtendedColorHueStrategy; - friend class SimpleColorTemperatureStrategy; - friend class ExtendedColorTemperatureStrategy; - -public: - //! \brief std dtor - ~HueLight() = default; - - //! \brief Function that turns the light on. - //! - //! \param transition Optional parameter to set the transition from current state to new, standard is 4 = 400ms - //! \return true on success - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws HueAPIResponseException when response contains an error - //! \throws nlohmann::json::parse_error when response could not be parsed - virtual bool On(uint8_t transition = 4); - - //! \brief Function that turns the light off. - //! - //! \param transition Optional parameter to set the transition from current state to new, standard is 4 = 400ms - //! \return Bool that is true on success - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws HueAPIResponseException when response contains an error - //! \throws nlohmann::json::parse_error when response could not be parsed - virtual bool Off(uint8_t transition = 4); - - //! \brief Function to check whether a light is on or off - //! - //! \return Bool that is true, when the light is on and false, when off - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws HueAPIResponseException when response contains an error - //! \throws nlohmann::json::parse_error when response could not be parsed - virtual bool isOn(); - - //! \brief Const function to check whether a light is on or off - //! - //! \note This will not refresh the light state - //! \return Bool that is true, when the light is on and false, when off - virtual bool isOn() const; - - //! \brief Const function that returns the id of this light - //! - //! \return integer representing the light id - virtual int getId() const; - - //! \brief Const function that returns the light type - //! - //! \return String containing the type - virtual std::string getType() const; - - //! \brief Function that returns the name of the light. - //! - //! \return String containig the name of the light - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws HueAPIResponseException when response contains an error - //! \throws nlohmann::json::parse_error when response could not be parsed - virtual std::string getName(); - - //! \brief Const function that returns the name of the light. - //! - //! \note This will not refresh the light state - //! \return String containig the name of the light - virtual std::string getName() const; - - //! \brief Const function that returns the modelid of the light - //! - //! \return String conatining the modelid - virtual std::string getModelId() const; - - //! \brief Const function that returns the uniqueid of the light - //! - //! \note Only working on bridges with versions starting at 1.4 - //! \return String containing the uniqueid or an empty string when the function is not supported - virtual std::string getUId() const; - - //! \brief Const function that returns the manufacturername of the light - //! - //! \note Only working on bridges with versions starting at 1.7 - //! \return String containing the manufacturername or an empty string when the function is not supported - virtual std::string getManufacturername() const; - - //! \brief Const function that returns the productname of the light - //! - //! \note Only working on bridges with versions starting at 1.24 - //! \return String containing the productname or an empty string when the function is not supported - virtual std::string getProductname() const; - - //! \brief Const function that returns the luminaireuniqueid of the light - //! - //! \note Only working on bridges with versions starting at 1.9 - //! \return String containing the luminaireuniqueid or an empty string when the function is not supported - virtual std::string getLuminaireUId() const; - - //! \brief Function that returns the software version of the light - //! - //! \return String containing the software version - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws HueAPIResponseException when response contains an error - //! \throws nlohmann::json::parse_error when response could not be parsed - virtual std::string getSwVersion(); - - //! \brief Const function that returns the software version of the light - //! - //! \note This will not refresh the light state - //! \return String containing the software version - virtual std::string getSwVersion() const; - - //! \brief Function that sets the name of the light - //! - //! \return Bool that is true on success - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws HueAPIResponseException when response contains an error - //! \throws nlohmann::json::parse_error when response could not be parsed - virtual bool setName(const std::string& name); - - //! \brief Const function that returns the color type of the light. - //! - //! \return ColorType containig the color type of the light - virtual ColorType getColorType() const; - - //! \brief Const function to check whether this light has brightness control - //! - //! \return Bool that is true when the light has specified abilities and false - //! when not - virtual bool hasBrightnessControl() const { return brightnessStrategy != nullptr; }; - - //! \brief Const function to check whether this light has color temperature - //! control - //! - //! \return Bool that is true when the light has specified abilities and false - //! when not - virtual bool hasTemperatureControl() const { return colorTemperatureStrategy != nullptr; }; - - //! \brief Connst function to check whether this light has full color control - //! - //! \return Bool that is true when the light has specified abilities and false - //! when not - virtual bool hasColorControl() const { return colorHueStrategy != nullptr; }; - - //! \brief Const function that converts Kelvin to Mired. - //! - //! \param kelvin Unsigned integer value in Kelvin - //! \return Unsigned integer value in Mired - unsigned int KelvinToMired(unsigned int kelvin) const; - - //! \brief Const function that converts Mired to Kelvin. - //! - //! \param mired Unsigned integer value in Mired - //! \return Unsigned integer value in Kelvin - unsigned int MiredToKelvin(unsigned int mired) const; - - //! \brief Function that sets the brightness of this light. - //! - //! \note The brightness will only be set if the light has a reference to a - //! specific \ref BrightnessStrategy. The brightness can range from 0 = off to - //! 254 = fully lit. - //! \param bri Unsigned int that specifies the brightness - //! \param transition Optional parameter to set the transition from current state to new, standard is 4 = 400ms - //! \return Bool that is true on success - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws HueAPIResponseException when response contains an error - //! \throws nlohmann::json::parse_error when response could not be parsed - virtual bool setBrightness(unsigned int bri, uint8_t transition = 4) - { - if (brightnessStrategy) - { - return brightnessStrategy->setBrightness(bri, transition, *this); - } - return false; - }; - - //! \brief Const function that returns the brightness of this light. - //! - //! \note The brightness will only be returned if the light has a reference to - //! a specific \ref BrightnessStrategy. \note This will not refresh the light - //! state The brightness can range from 0 = off to 254 = fully lit. \return - //! Unsigned int that is 0 when function failed - virtual unsigned int getBrightness() const - { - if (brightnessStrategy) - { - return brightnessStrategy->getBrightness(*this); - } - return 0; - }; - - //! \brief Function that returns the brightness of this light. - //! - //! \note The brightness will only be returned if the light has a reference to - //! a specific \ref BrightnessStrategy. The brightness can range from 0 = off - //! to 254 = fully lit. - //! \return Unsigned int that is 0 when function failed - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws HueAPIResponseException when response contains an error - //! \throws nlohmann::json::parse_error when response could not be parsed - virtual unsigned int getBrightness() - { - if (brightnessStrategy) - { - return brightnessStrategy->getBrightness(*this); - } - return 0; - }; - - //! \brief Fucntion that sets the color temperature of this light in mired. - //! - //! \note The color temperature will only be set if the light has a reference - //! to a specific \ref ColorTemperatureStrategy. The color temperature can - //! range from 153 to 500. - //! \param mired Unsigned int that specifies the color temperature in Mired - //! \param transition Optional parameter to set the transition from current state to new, standard is 4 = 400ms - //! \return Bool that is true on success - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws HueAPIResponseException when response contains an error - //! \throws nlohmann::json::parse_error when response could not be parsed - virtual bool setColorTemperature(unsigned int mired, uint8_t transition = 4) - { - if (colorTemperatureStrategy) - { - return colorTemperatureStrategy->setColorTemperature(mired, transition, *this); - } - return false; - }; - - //! \brief Const function that returns the current color temperature of the - //! light - //! - //! \note The color temperature will only be returned when the light has a - //! reference to a specific \ref ColorTemperatureStrategy. - //! \note This will not refresh the light state - //! The color temperature in mired ranges from 153 to 500 whereas 153 is cold - //! and 500 is warm. - //! \return Unsigned int representing the color temperature in mired or 0 when failed - virtual unsigned int getColorTemperature() const - { - if (colorTemperatureStrategy) - { - return colorTemperatureStrategy->getColorTemperature(*this); - } - return 0; - }; - - //! \brief Function that returns the current color temperature of the light - //! - //! \note The color temperature will only be returned when the light has a - //! reference to a specific \ref ColorTemperatureStrategy. - //! Updates the lights state by calling refreshState() - //! The color temperature in mired ranges from 153 to 500 whereas 153 is cold - //! and 500 is warm. - //! \return Unsigned int representing the color temperature in mired or 0 when failed - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws HueAPIResponseException when response contains an error - //! \throws nlohmann::json::parse_error when response could not be parsed - virtual unsigned int getColorTemperature() - { - if (colorTemperatureStrategy) - { - return colorTemperatureStrategy->getColorTemperature(*this); - } - return 0; - }; - - //! \brief Function to set the color of this light with specified hue. - //! - //! \note The color will only be set if the light has a reference to a - //! specific \ref ColorHueStrategy. The hue can range from 0 to 65535, whereas - //! 65535 and 0 are red, 25500 is green and 46920 is blue. - //! \param hue uint16_t that specifies the hue - //! \param transition Optional parameter to set the transition from current state to new, standard is 4 = 400ms - //! \return Bool that is true on success - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws HueAPIResponseException when response contains an error - //! \throws nlohmann::json::parse_error when response could not be parsed - virtual bool setColorHue(uint16_t hue, uint8_t transition = 4) - { - if (colorHueStrategy) - { - return colorHueStrategy->setColorHue(hue, transition, *this); - } - return false; - }; - - //! \brief Function to set the color of this light with specified saturation. - //! - //! \note The color will only be set if the light has a reference to a - //! specific \ref ColorHueStrategy. The saturation can range from 0 to 254, - //! whereas 0 is least saturated (white) and 254 is most saturated. - //! \param sat uint8_t that specifies the saturation - //! \param transition Optional parameter to set the transition from current state to new, standard is 4 = 400ms - //! \return Bool that is true on success - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws HueAPIResponseException when response contains an error - //! \throws nlohmann::json::parse_error when response could not be parsed - virtual bool setColorSaturation(uint8_t sat, uint8_t transition = 4) - { - if (colorHueStrategy) - { - return colorHueStrategy->setColorSaturation(sat, transition, *this); - } - return false; - }; - - //! \brief Function to set the color of this light with specified hue and - //! saturation. - //! - //! \note The color will only be set if the light has a reference to a - //! specific \ref ColorHueStrategy. - //! \param hue uint16_t that specifies the hue - //! \param sat uint8_t that specifies the saturation - //! \param transition Optional parameter to set the transition from current state to new, standard is 4 = 400ms. - //! \return Bool that is true on success - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws HueAPIResponseException when response contains an error - //! \throws nlohmann::json::parse_error when response could not be parsed - virtual bool setColorHueSaturation(uint16_t hue, uint8_t sat, uint8_t transition = 4) - { - if (colorHueStrategy) - { - return colorHueStrategy->setColorHueSaturation(hue, sat, transition, *this); - } - return false; - }; - - //! \brief Const function that returns the current color of the light as hue - //! and saturation - //! - //! \note The color hue and saturation will only be returned when the light - //! has a reference to a specific \ref ColorHueStrategy. - //! \note This will not refresh the light state - //! \return Pair containing the hue as first value and saturation as second value or an empty one when failed - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws HueAPIResponseException when response contains an error - //! \throws nlohmann::json::parse_error when response could not be parsed - virtual std::pair getColorHueSaturation() const - { - if (colorHueStrategy) - { - return colorHueStrategy->getColorHueSaturation(*this); - } - return {}; - }; - - //! \brief Function that returns the current color of the light as hue and - //! saturation - //! - //! \note The color hue and saturation will only be returned when the light - //! has a reference to a specific \ref ColorHueStrategy. Updates the lights - //! state by calling refreshState() - //! \return Pair containing the hue as first value and saturation as second value or an empty one when failed - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws HueAPIResponseException when response contains an error - //! \throws nlohmann::json::parse_error when response could not be parsed - virtual std::pair getColorHueSaturation() - { - if (colorHueStrategy) - { - return colorHueStrategy->getColorHueSaturation(*this); - } - return {}; - }; - - //! \brief Function to set the color of this light in CIE with specified x y. - //! - //! \note The color will only be set if the light has a reference to a - //! specific \ref ColorHueStrategy. The values of x and y are ranging from 0 to 1. - //! \param x float that specifies the x coordinate in CIE - //! \param y float that specifies the y coordinate in CIE - //! \param transition Optional parameter to set the transition from current state to new, standard is 4 = 400ms - //! \return Bool that is true on success - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws HueAPIResponseException when response contains an error - //! \throws nlohmann::json::parse_error when response could not be parsed - virtual bool setColorXY(float x, float y, uint8_t transition = 4) - { - if (colorHueStrategy) - { - return colorHueStrategy->setColorXY(x, y, transition, *this); - } - return false; - }; - - //! \brief Const function that returns the current color of the light as xy - //! - //! \note The color x and y will only be returned when the light has a - //! reference to a specific \ref ColorHueStrategy. - //! \note This does not update the lights state - //! \return Pair containing the x as first value and y as second value or an - //! empty one when failed - virtual std::pair getColorXY() const - { - if (colorHueStrategy) - { - return colorHueStrategy->getColorXY(*this); - } - return {}; - }; - - //! \brief Function that returns the current color of the light as xy - //! - //! \note The color x and y will only be returned when the light has a - //! reference to a specific \ref ColorHueStrategy. - //! Updates the lights state by calling refreshState() - //! \return Pair containing the x as first value and y as second value or an empty one when failed - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws HueAPIResponseException when response contains an error - //! \throws nlohmann::json::parse_error when response could not be parsed - virtual std::pair getColorXY() - { - if (colorHueStrategy) - { - return colorHueStrategy->getColorXY(*this); - } - return {}; - }; - - //! \brief Function to set the color of this light with red green and blue - //! values. - //! - //! \note The color will only be set if the light has a reference to a - //! specific \ref ColorHueStrategy. The values of red, green and blue are - //! ranging from 0 to 255. - //! \param r uint8_t that specifies the red color value - //! \param g uint8_t that specifies the green color value - //! \param b uint8_t that specifies the blue color value - //! \param transition Optional parameter to set the transition from current state to new, standard is 4 = 400ms - //! \return Bool that is true on success - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws HueAPIResponseException when response contains an error - //! \throws nlohmann::json::parse_error when response could not be parsed - virtual bool setColorRGB(uint8_t r, uint8_t g, uint8_t b, uint8_t transition = 4) - { - if (colorHueStrategy) - { - return colorHueStrategy->setColorRGB(r, g, b, transition, *this); - } - return false; - }; - - //! \brief Function that lets the light perform one breath cycle. - //! - //! Can be used for locating a light. - //! \return bool that is true on success - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws HueAPIResponseException when response contains an error - //! \throws nlohmann::json::parse_error when response could not be parsed - virtual bool alert(); - - //! \brief Function that lets the light perform one breath cycle in specified - //! color temperature. - //! - //! \note The breath cylce will only be performed if the light has a reference - //! to a specific \ref ColorTemperatureStrategy. - //! \param mired Color temperature in mired - //! \return Bool that is true on success - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws HueAPIResponseException when response contains an error - //! \throws nlohmann::json::parse_error when response could not be parsed - virtual bool alertTemperature(unsigned int mired) - { - if (colorTemperatureStrategy) - { - return colorTemperatureStrategy->alertTemperature(mired, *this); - } - return false; - }; - - //! \brief Function that lets the light perform one breath cycle in specified - //! color. - //! - //! \note The breath cylce will only be performed if the light has a reference - //! to a specific \ref ColorHueStrategy. - //! \param hue uint16_t that specifies the hue - //! \param sat uint8_t that specifies the saturation - //! \return Bool that is true on success - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws HueAPIResponseException when response contains an error - //! \throws nlohmann::json::parse_error when response could not be parsed - virtual bool alertHueSaturation(uint16_t hue, uint8_t sat) - { - if (colorHueStrategy) - { - return colorHueStrategy->alertHueSaturation(hue, sat, *this); - } - return false; - }; - - //! \brief Function that lets the light perform one breath cycle in specified - //! color. - //! - //! \note The breath cylce will only be performed if the light has a reference - //! to a specific \ref ColorHueStrategy. The values of x and y are ranging - //! from 0 to 1. - //! \param x float that specifies the x coordinate in CIE - //! \param y float that specifies the y coordinate in CIE - //! \return Bool that is true on success - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws HueAPIResponseException when response contains an error - //! \throws nlohmann::json::parse_error when response could not be parsed - virtual bool alertXY(float x, float y) - { - if (colorHueStrategy) - { - return colorHueStrategy->alertXY(x, y, *this); - } - return false; - }; - - //! \brief Function that lets the light perform one breath cycle in specified - //! color. - //! - //! \note The breath cylce will only be performed if the light has a reference - //! to a specific \ref ColorHueStrategy. The values of red, green and blue are - //! ranging from 0 to 255. - //! \param r uint8_t that specifies the red color value - //! \param g uint8_t that specifies the green color value - //! \param b uint8_t that specifies the blue color value - //! \return Bool that is true on success - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws HueAPIResponseException when response contains an error - //! \throws nlohmann::json::parse_error when response could not be parsed - virtual bool alertRGB(uint8_t r, uint8_t g, uint8_t b) - { - if (colorHueStrategy) - { - return colorHueStrategy->alertRGB(r, g, b, *this); - } - return false; - }; - - //! \brief Function to turn colorloop effect on/off. - //! - //! Notice this function will only be performed light has a reference to a - //! specific \ref ColorHueStrategy. The colorloop effect will loop through all - //! colors on current hue and saturation levels. Notice that none of the - //! setter functions check whether this feature is enabled and the colorloop - //! can only be disabled with this function or by simply calling - //! Off()/OffNoRefresh() and then On()/OnNoRefresh(), so you could - //! alternatively call Off() and then use any of the setter functions. - //! \param on bool that enables this feature when true and disables it when false - //! \return Bool that is true on success - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws HueAPIResponseException when response contains an error - //! \throws nlohmann::json::parse_error when response could not be parsed - virtual bool setColorLoop(bool on) - { - if (colorHueStrategy) - { - return colorHueStrategy->setColorLoop(on, *this); - } - return false; - }; - -protected: - //! \brief Protected ctor that is used by \ref Hue class. - //! - //! \param id Integer that specifies the id of this light - //! \param commands HueCommandAPI for communication with the bridge - //! - //! leaves strategies unset - HueLight(int id, const HueCommandAPI& commands); - - //! \brief Protected ctor that is used by \ref Hue class, also sets - //! strategies. - //! - //! \param id Integer that specifies the id of this light - //! \param commands HueCommandAPI for communication with the bridge - //! \param brightnessStrategy Strategy for brightness. May be nullptr. - //! \param colorTempStrategy Strategy for color temperature. May be nullptr. - //! \param colorHueStrategy Strategy for color hue/saturation. May be nullptr. - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws HueAPIResponseException when response contains an error - //! \throws nlohmann::json::parse_error when response could not be parsed - HueLight(int id, const HueCommandAPI& commands, std::shared_ptr brightnessStrategy, - std::shared_ptr colorTempStrategy, - std::shared_ptr colorHueStrategy); - - //! \brief Protected function that sets the brightness strategy. - //! - //! The strategy defines how specific commands that deal with brightness - //! control are executed \param strat a strategy of type \ref - //! BrightnessStrategy - virtual void setBrightnessStrategy(std::shared_ptr strat) - { - brightnessStrategy = std::move(strat); - }; - - //! \brief Protected function that sets the colorTemperature strategy. - //! - //! The strategy defines how specific commands that deal with colortemperature - //! control are executed \param strat a strategy of type \ref - //! ColorTemperatureStrategy - virtual void setColorTemperatureStrategy(std::shared_ptr strat) - { - colorTemperatureStrategy = std::move(strat); - }; - - //! \brief Protected function that sets the colorHue strategy. - //! - //! The strategy defines how specific commands that deal with color control - //! are executed \param strat a strategy of type \ref ColorHueStrategy - virtual void setColorHueStrategy(std::shared_ptr strat) - { - colorHueStrategy = std::move(strat); - }; - - //! \brief Protected function that sets the HueCommandAPI. - //! - //! The HueCommandAPI is used for bridge communication - //! \param commandAPI the new HueCommandAPI - virtual void setCommandAPI(const HueCommandAPI& commandAPI) { commands = commandAPI; }; - - //! \brief Function that turns the light on without refreshing its state. - //! - //! \param transition Optional parameter to set the transition from current state to new standard is 4 = 400ms - //! \return Bool that is true on success - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws HueAPIResponseException when response contains an error - //! \throws nlohmann::json::parse_error when response could not be parsed - virtual bool OnNoRefresh(uint8_t transition = 4); - - //! \brief Function that turns the light off without refreshing its state. - //! - //! \param transition Optional parameter to set the transition from current state to new standard is 4 = 400ms - //! \return Bool that is true on success - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws HueAPIResponseException when response contains an error - //! \throws nlohmann::json::parse_error when response could not be parsed - virtual bool OffNoRefresh(uint8_t transition = 4); - - //! \brief Utility function to send a put request to the light. - //! - //! \throws nlohmann::json::parse_error if the reply could not be parsed - //! \param request A nlohmann::json aka the request to send - //! \param subPath A path that is appended to the uri, note it should always start with a slash ("/") - //! \param fileInfo FileInfo from calling function for exception details. - //! \return The parsed reply - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws HueAPIResponseException when response contains an error - //! \throws nlohmann::json::parse_error when response could not be parsed - virtual nlohmann::json SendPutRequest(const nlohmann::json& request, const std::string& subPath, FileInfo fileInfo); - - //! \brief Virtual function that refreshes the \ref state of the light. - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws HueAPIResponseException when response contains an error - //! \throws nlohmann::json::parse_error when response could not be parsed - virtual void refreshState(); - -protected: - int id; //!< holds the id of the light - nlohmann::json state; //!< holds the current state of the light updated by \ref refreshState - ColorType colorType; //!< holds the \ref ColorType of the light - - std::shared_ptr - brightnessStrategy; //!< holds a reference to the strategy that handles brightness commands - std::shared_ptr - colorTemperatureStrategy; //!< holds a reference to the strategy that handles colortemperature commands - std::shared_ptr - colorHueStrategy; //!< holds a reference to the strategy that handles all color commands - HueCommandAPI commands; //!< A IHttpHandler that is used to communicate with the bridge -}; - -#endif diff --git a/hueplusplus/include/IHttpHandler.h b/hueplusplus/include/IHttpHandler.h deleted file mode 100755 index edcb6be..0000000 --- a/hueplusplus/include/IHttpHandler.h +++ /dev/null @@ -1,196 +0,0 @@ -/** - \file IHttpHandler.h - Copyright Notice\n - Copyright (C) 2017 Jan Rogall - developer\n - Copyright (C) 2017 Moritz Wirger - developer\n - - This file is part of hueplusplus. - - hueplusplus is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - hueplusplus is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with hueplusplus. If not, see . -**/ - -#ifndef _IHTTPHANDLER_H -#define _IHTTPHANDLER_H - -#include -#include -#include -#include - -#include "json/json.hpp" - -//! Abstract class for classes that handle http requests and multicast requests -class IHttpHandler -{ -public: - //! \brief Virtual dtor - virtual ~IHttpHandler() = default; - - //! \brief Send a message to a specified host and return the response. - //! - //! \param msg The message that should be sent to the specified address - //! \param adr Ip or hostname in dotted decimal notation like "192.168.2.1" - //! \param port Optional port the request is sent to, default is 80 - //! \return The response of the host as a string - //! \throws std::system_error when system or socket operations fail - virtual std::string send(const std::string& msg, const std::string& adr, int port = 80) const = 0; - - //! \brief Send a message to a specified host and return the body of the response. - //! - //! \param msg The message that should sent to the specified address - //! \param adr Ip or hostname in dotted decimal notation like "192.168.2.1" - //! \param port Optional port the request is sent to, default is 80 - //! \return The body of the response of the host as a string - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - virtual std::string sendGetHTTPBody(const std::string& msg, const std::string& adr, int port = 80) const = 0; - - //! \brief Send a multicast request with a specified message. - //! - //! \param msg The message that should sent to the specified multicast address - //! \param adr Optional ip or hostname in dotted decimal notation, default is "239.255.255.250" - //! \param port Optional port the request is sent to, default is 1900 - //! \param timeout Optional time to wait for responses in seconds, default is 5 - //! - //! Blocks for the duration of the timeout. - //! - //! \return vector of strings containing each received answer - //! \throws std::system_error when system or socket operations fail - virtual std::vector sendMulticast( - const std::string& msg, const std::string& adr = "239.255.255.250", int port = 1900, int timeout = 5) const = 0; - - //! \brief Send a HTTP request with the given method to the specified host and return the body of the response. - //! - //! \param method HTTP method type e.g. GET, HEAD, POST, PUT, DELETE, ... - //! \param uri Uniform Resource Identifier in the request - //! \param contentType MIME type of the body data e.g. "text/html", "application/json", ... - //! \param body Request body, may be empty - //! \param adr Ip or hostname in dotted decimal notation like "192.168.2.1" - //! \param port Optional port the request is sent to, default is 80 - //! \return Body of the response of the host - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - virtual std::string sendHTTPRequest(const std::string& method, const std::string& uri, - const std::string& contentType, const std::string& body, const std::string& adr, int port = 80) const = 0; - - //! \brief Send a HTTP GET request to the specified host and return the body of the response. - //! - //! \param uri Uniform Resource Identifier in the request - //! \param contentType MIME type of the body data e.g. "text/html", "application/json", ... - //! \param body Request body, may be empty - //! \param adr Ip or hostname in dotted decimal notation like "192.168.2.1" - //! \param port Optional port the request is sent to, default is 80 - //! that specifies the port to which the request is sent to. Default is 80 - //! \return Body of the response of the host - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - virtual std::string GETString(const std::string& uri, const std::string& contentType, const std::string& body, - const std::string& adr, int port = 80) const = 0; - - //! \brief Send a HTTP POST request to the specified host and return the body of the response. - //! - //! \param uri Uniform Resource Identifier in the request - //! \param contentType MIME type of the body data e.g. "text/html", "application/json", ... - //! \param body Request body, may be empty - //! \param adr Ip or hostname in dotted decimal notation like "192.168.2.1" - //! \param port Optional port the request is sent to, default is 80 - //! that specifies the port to which the request is sent to. Default is 80 - //! \return Body of the response of the host - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - virtual std::string POSTString(const std::string& uri, const std::string& contentType, const std::string& body, - const std::string& adr, int port = 80) const = 0; - - //! \brief Send a HTTP PUT request to the specified host and return the body of the response. - //! - //! \param uri Uniform Resource Identifier in the request - //! \param contentType MIME type of the body data e.g. "text/html", "application/json", ... - //! \param body Request body, may be empty - //! \param adr Ip or hostname in dotted decimal notation like "192.168.2.1" - //! \param port Optional port the request is sent to, default is 80 - //! that specifies the port to which the request is sent to. Default is 80 - //! \return Body of the response of the host - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - virtual std::string PUTString(const std::string& uri, const std::string& contentType, const std::string& body, - const std::string& adr, int port = 80) const = 0; - - //! \brief Send a HTTP DELETE request to the specified host and return the body of the response. - //! - //! \param uri Uniform Resource Identifier in the request - //! \param contentType MIME type of the body data e.g. "text/html", "application/json", ... - //! \param body Request body, may be empty - //! \param adr Ip or hostname in dotted decimal notation like "192.168.2.1" - //! \param port Optional port the request is sent to, default is 80 - //! that specifies the port to which the request is sent to. Default is 80 - //! \return Body of the response of the host - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - virtual std::string DELETEString(const std::string& uri, const std::string& contentType, const std::string& body, - const std::string& adr, int port = 80) const = 0; - - //! \brief Send a HTTP GET request to the specified host and return the body of the response parsed as JSON. - //! - //! \param uri Uniform Resource Identifier in the request - //! \param body Request body, may be empty - //! \param adr Ip or hostname in dotted decimal notation like "192.168.2.1" - //! \param port Optional port the request is sent to, default is 80 - //! \return Parsed body of the response of the host - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws nlohmann::json::parse_error when the body could not be parsed - virtual nlohmann::json GETJson( - const std::string& uri, const nlohmann::json& body, const std::string& adr, int port = 80) const = 0; - - //! \brief Send a HTTP POST request to the specified host and return the body of the response parsed as JSON. - //! - //! \param uri Uniform Resource Identifier in the request - //! \param body Request body, may be empty - //! \param adr Ip or hostname in dotted decimal notation like "192.168.2.1" - //! \param port Optional port the request is sent to, default is 80 - //! \return Parsed body of the response of the host - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws nlohmann::json::parse_error when the body could not be parsed - virtual nlohmann::json POSTJson( - const std::string& uri, const nlohmann::json& body, const std::string& adr, int port = 80) const = 0; - - //! \brief Send a HTTP PUT request to the specified host and return the body of the response parsed as JSON. - //! - //! \param uri Uniform Resource Identifier in the request - //! \param body Request body, may be empty - //! \param adr Ip or hostname in dotted decimal notation like "192.168.2.1" - //! \param port Optional port the request is sent to, default is 80 - //! \return Parsed body of the response of the host - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws nlohmann::json::parse_error when the body could not be parsed - virtual nlohmann::json PUTJson( - const std::string& uri, const nlohmann::json& body, const std::string& adr, int port = 80) const = 0; - - //! \brief Send a HTTP DELETE request to the specified host and return the body of the response parsed as JSON. - //! - //! \param uri Uniform Resource Identifier in the request - //! \param body Request body, may be empty - //! \param adr Ip or hostname in dotted decimal notation like "192.168.2.1" - //! \param port Optional port the request is sent to, default is 80 - //! \return Parsed body of the response of the host - //! \throws std::system_error when system or socket operations fail - //! \throws HueException when response contained no body - //! \throws nlohmann::json::parse_error when the body could not be parsed - virtual nlohmann::json DELETEJson( - const std::string& uri, const nlohmann::json& body, const std::string& adr, int port = 80) const = 0; -}; - -#endif diff --git a/hueplusplus/include/LinHttpHandler.h b/hueplusplus/include/LinHttpHandler.h deleted file mode 100755 index 5717d4c..0000000 --- a/hueplusplus/include/LinHttpHandler.h +++ /dev/null @@ -1,60 +0,0 @@ -/** - \file LinHttpHandler.h - Copyright Notice\n - Copyright (C) 2017 Jan Rogall - developer\n - Copyright (C) 2017 Moritz Wirger - developer\n - - This file is part of hueplusplus. - - hueplusplus is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - hueplusplus is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with hueplusplus. If not, see . -**/ - -#ifndef _LINHTTPHANDLER_H -#define _LINHTTPHANDLER_H - -#include -#include - -#include "BaseHttpHandler.h" - -#include "json/json.hpp" - -//! Class to handle http requests and multicast requests on linux systems -class LinHttpHandler : public BaseHttpHandler -{ -public: - //! \brief Function that sends a given message to the specified host and - //! returns the response. - //! - //! \param msg String that contains the message that is sent to the specified - //! address \param adr String that contains an ip or hostname in dotted - //! decimal notation like "192.168.2.1" \param port Optional integer that - //! specifies the port to which the request is sent to. Default is 80 \return - //! String containing the response of the host - virtual std::string send(const std::string& msg, const std::string& adr, int port = 80) const; - - //! \brief Function that sends a multicast request with the specified message. - //! - //! \param msg String that contains the request that is sent to the specified - //! address \param adr Optional String that contains an ip or hostname in - //! dotted decimal notation, default is "239.255.255.250" \param port Optional - //! integer that specifies the port to which the request is sent. Default is - //! 1900 \param timeout Optional Integer that specifies the timeout of the - //! request in seconds. Default is 5 \return Vector containing strings of each - //! answer received - virtual std::vector sendMulticast( - const std::string& msg, const std::string& adr = "239.255.255.250", int port = 1900, int timeout = 5) const; -}; - -#endif diff --git a/hueplusplus/include/SimpleBrightnessStrategy.h b/hueplusplus/include/SimpleBrightnessStrategy.h deleted file mode 100755 index 59df71a..0000000 --- a/hueplusplus/include/SimpleBrightnessStrategy.h +++ /dev/null @@ -1,55 +0,0 @@ -/** - \file SimpleBrightnessStrategy.h - Copyright Notice\n - Copyright (C) 2017 Jan Rogall - developer\n - Copyright (C) 2017 Moritz Wirger - developer\n - - This file is part of hueplusplus. - - hueplusplus is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - hueplusplus is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with hueplusplus. If not, see . -**/ - -#ifndef _SIMPLE_BRIGHTNESS_STRATEGY_H -#define _SIMPLE_BRIGHTNESS_STRATEGY_H - -#include "BrightnessStrategy.h" -#include "HueLight.h" - -//! Class implementing the functions of BrightnessStrategy -class SimpleBrightnessStrategy : public BrightnessStrategy -{ -public: - //! \brief Function for changing a lights brightness with a specified - //! transition. - //! - //! \param bri The brightness raning from 0 = off to 255 = fully lit - //! \param transition The time it takes to fade to the new brightness in - //! multiples of 100ms, 4 = 400ms and should be seen as the default \param - //! light A reference of the light - bool setBrightness(unsigned int bri, uint8_t transition, HueLight& light) const override; - //! \brief Function that returns the current brightness of the light - //! - //! Updates the lights state by calling refreshState() - //! \param light A reference of the light - //! \return Unsigned int representing the brightness - unsigned int getBrightness(HueLight& light) const override; - //! \brief Function that returns the current brightness of the light - //! - //! \note This does not update the lights state - //! \param light A const reference of the light - //! \return Unsigned int representing the brightness - unsigned int getBrightness(const HueLight& light) const override; -}; - -#endif diff --git a/hueplusplus/include/SimpleColorHueStrategy.h b/hueplusplus/include/SimpleColorHueStrategy.h deleted file mode 100755 index c963ef2..0000000 --- a/hueplusplus/include/SimpleColorHueStrategy.h +++ /dev/null @@ -1,152 +0,0 @@ -/** - \file SimpleColorHueStrategy.h - Copyright Notice\n - Copyright (C) 2017 Jan Rogall - developer\n - Copyright (C) 2017 Moritz Wirger - developer\n - - This file is part of hueplusplus. - - hueplusplus is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - hueplusplus is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with hueplusplus. If not, see . -**/ - -#ifndef _SIMPLE_COLOR_HUE_STRATEGY_H -#define _SIMPLE_COLOR_HUE_STRATEGY_H - -#include "ColorHueStrategy.h" -#include "HueLight.h" - -//! Class implementing the functions of ColorHueStrategy -class SimpleColorHueStrategy : public ColorHueStrategy -{ -public: - //! \brief Function for changing a lights color in hue with a specified - //! transition. - //! - //! The hue ranges from 0 to 65535, whereas 65535 and 0 are red, 25500 is - //! green and 46920 is blue. \param hue The hue of the color \param transition - //! The time it takes to fade to the new color in multiples of 100ms, 4 = - //! 400ms and should be seen as the default \param light A reference of the - //! light - bool setColorHue(uint16_t hue, uint8_t transition, HueLight& light) const override; - //! \brief Function for changing a lights color in saturation with a specified - //! transition. - //! - //! The saturation ranges from 0 to 254, whereas 0 is least saturated (white) - //! and 254 is most saturated (vibrant). \param sat The saturation of the - //! color \param transition The time it takes to fade to the new color in - //! multiples of 100ms, 4 = 400ms and should be seen as the default \param - //! light A reference of the light - bool setColorSaturation(uint8_t sat, uint8_t transition, HueLight& light) const override; - //! \brief Function for changing a lights color in hue and saturation format - //! with a specified transition. - //! - //! The hue ranges from 0 to 65535, whereas 65535 and 0 are red, 25500 is - //! green and 46920 is blue. The saturation ranges from 0 to 254, whereas 0 is - //! least saturated (white) and 254 is most saturated (vibrant). \param hue - //! The hue of the color \param sat The saturation of the color \param - //! transition The time it takes to fade to the new color in multiples of - //! 100ms, 4 = 400ms and should be seen as the default \param light A - //! reference of the light - bool setColorHueSaturation(uint16_t hue, uint8_t sat, uint8_t transition, HueLight& light) const override; - //! \brief Function for changing a lights color in CIE format with a specified - //! transition. - //! - //! \param x The x coordinate in CIE, ranging from 0 to 1 - //! \param y The y coordinate in CIE, ranging from 0 to 1 - //! \param transition The time it takes to fade to the new color in multiples - //! of 100ms, 4 = 400ms and should be seen as the default \param light A - //! reference of the light - bool setColorXY(float x, float y, uint8_t transition, HueLight& light) const override; - //! \brief Function for changing a lights color in rgb format with a specified - //! transition. - //! - //! Red, green and blue are ranging from 0 to 255. - //! \param r The red portion of the color - //! \param g The green portion of the color - //! \param b The blue portion of the color - //! \param transition The time it takes to fade to the new color in multiples - //! of 100ms, 4 = 400ms and should be seen as the default \param light A - //! reference of the light - bool setColorRGB(uint8_t r, uint8_t g, uint8_t b, uint8_t transition, HueLight& light) const override; - //! \brief Function for turning on/off the color loop feature of a light. - //! - //! Can be theoretically set for any light, but it only works for lights that - //! support this feature. When this feature is activated the light will fade - //! through every color on the current hue and saturation settings. Notice - //! that none of the setter functions check whether this feature is enabled - //! and the colorloop can only be disabled with this function or by simply - //! calling Off()/OffNoRefresh() and then On()/OnNoRefresh(), so you could - //! alternatively call Off() and then use any of the setter functions. - //! \param on Boolean to turn this feature on or off, true/1 for on and - //! false/0 for off \param light A reference of the light - bool setColorLoop(bool on, HueLight& light) const override; - //! \brief Function that lets the light perform one breath cycle in the - //! specified color. - //! - //! \note It uses this_thread::sleep_for to accomodate for the time an \ref - //! HueLight::alert() needs The hue ranges from 0 to 65535, whereas 65535 and - //! 0 are red, 25500 is green and 46920 is blue. The saturation ranges from 0 - //! to 254, whereas 0 is least saturated (white) and 254 is most saturated - //! (vibrant). \param hue The hue of the color \param sat The saturation of - //! the color \param light A reference of the light - bool alertHueSaturation(uint16_t hue, uint8_t sat, HueLight& light) const override; - //! \brief Function that lets the light perform one breath cycle in the - //! specified color. - //! - //! \note It uses this_thread::sleep_for to accomodate for the time an \ref - //! HueLight::alert() needs \param x The x coordinate in CIE, ranging from 0 - //! to 1 \param y The y coordinate in CIE, ranging from 0 to 1 \param light A - //! reference of the light - bool alertXY(float x, float y, HueLight& light) const override; - //! \brief Function that lets the light perform one breath cycle in the - //! specified color. - //! - //! \note It uses this_thread::sleep_for to accomodate for the time an \ref - //! HueLight::alert() needs Red, green and blue are ranging from 0 to 255. - //! \param r The red portion of the color - //! \param g The green portion of the color - //! \param b The blue portion of the color - //! \param light A reference of the light - bool alertRGB(uint8_t r, uint8_t g, uint8_t b, HueLight& light) const override; - //! \brief Function that returns the current color of the light as hue and - //! saturation - //! - //! Updates the lights state by calling refreshState() - //! \param light A reference of the light - //! \return Pair containing the hue as first value and saturation as second - //! value - std::pair getColorHueSaturation(HueLight& light) const override; - //! \brief Function that returns the current color of the light as hue and - //! saturation - //! - //! \note This does not update the lights state - //! \param light A const reference of the light - //! \return Pair containing the hue as first value and saturation as second - //! value - std::pair getColorHueSaturation(const HueLight& light) const override; - //! \brief Function that returns the current color of the light as xy - //! - //! Updates the lights state by calling refreshState() - //! \param light A reference of the light - //! \return Pair containing the x as first value and y as second value - std::pair getColorXY(HueLight& light) const override; - //! \brief Function that returns the current color of the light as xy - //! - //! \note This does not update the lights state - //! \param light A const reference of the light - //! \return Pair containing the x as first value and y as second value - std::pair getColorXY(const HueLight& light) const override; -}; - -#endif diff --git a/hueplusplus/include/SimpleColorTemperatureStrategy.h b/hueplusplus/include/SimpleColorTemperatureStrategy.h deleted file mode 100755 index 484c081..0000000 --- a/hueplusplus/include/SimpleColorTemperatureStrategy.h +++ /dev/null @@ -1,66 +0,0 @@ -/** - \file SimpleColorTemperatureStrategy.h - Copyright Notice\n - Copyright (C) 2017 Jan Rogall - developer\n - Copyright (C) 2017 Moritz Wirger - developer\n - - This file is part of hueplusplus. - - hueplusplus is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - hueplusplus is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with hueplusplus. If not, see . -**/ - -#ifndef _SIMPLE_COLOR_TEMPERATURE_STRATEGY_H -#define _SIMPLE_COLOR_TEMPERATURE_STRATEGY_H - -#include "ColorTemperatureStrategy.h" -#include "HueLight.h" - -//! Class implementing the functions of ColorTemperatureStrategy -class SimpleColorTemperatureStrategy : public ColorTemperatureStrategy -{ -public: - //! \brief Function for changing a lights color temperature in mired with a - //! specified transition. - //! - //! The color temperature in mired ranges from 153 to 500 whereas 153 is cold - //! and 500 is warm. \param mired The color temperature in mired \param - //! transition The time it takes to fade to the new color in multiples of - //! 100ms, 4 = 400ms and should be seen as the default \param light A - //! reference of the light - bool setColorTemperature(unsigned int mired, uint8_t transition, HueLight& light) const override; - //! \brief Function that lets the light perform one breath cycle in the - //! specified color. - //! - //! It uses this_thread::sleep_for to accomodate for the time an \ref - //! HueLight::alert() needs The color temperature in mired ranges from 153 to - //! 500 whereas 153 is cold and 500 is warm. \param mired The color - //! temperature in mired \param light A reference of the light - bool alertTemperature(unsigned int mired, HueLight& light) const override; - //! \brief Function that returns the current color temperature of the light - //! - //! Updates the lights state by calling refreshState() - //! The color temperature in mired ranges from 153 to 500 whereas 153 is cold - //! and 500 is warm. \param light A reference of the light \return Unsigned - //! int representing the color temperature in mired - unsigned int getColorTemperature(HueLight& light) const override; - //! \brief Function that returns the current color temperature of the light - //! - //! The color temperature in mired ranges from 153 to 500 whereas 153 is cold - //! and 500 is warm. \note This does not update the lights state \param light - //! A const reference of the light \return Unsigned int representing the color - //! temperature in mired - unsigned int getColorTemperature(const HueLight& light) const override; -}; - -#endif diff --git a/hueplusplus/include/UPnP.h b/hueplusplus/include/UPnP.h deleted file mode 100755 index 01e75a9..0000000 --- a/hueplusplus/include/UPnP.h +++ /dev/null @@ -1,46 +0,0 @@ -/** - \file UPnP.h - Copyright Notice\n - Copyright (C) 2017 Jan Rogall - developer\n - Copyright (C) 2017 Moritz Wirger - developer\n - - This file is part of hueplusplus. - - hueplusplus is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - hueplusplus is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with hueplusplus. If not, see . -**/ - -#ifndef _UPNP_H -#define _UPNP_H - -#include -#include -#include - -#include "IHttpHandler.h" - -//! Class that looks for UPnP devices using an m-search package -class UPnP -{ -public: - //! \brief Searches for UPnP devices and returns all found ones. - //! - //! It does it by sending an m-search packet and waits for all responses. - //! Since responses can be received multiple times this function conveniently removes all duplicates. - //! \param handler HttpHandler for communication - //! \return A vector containing pairs of address and name of all found devices - //! \throws std::system_error when system or socket operations fail - std::vector> getDevices(std::shared_ptr handler); -}; - -#endif diff --git a/hueplusplus/include/Units.h b/hueplusplus/include/Units.h deleted file mode 100644 index ff24330..0000000 --- a/hueplusplus/include/Units.h +++ /dev/null @@ -1,60 +0,0 @@ -/** - \file Units.h - Copyright Notice\n - Copyright (C) 2017 Jan Rogall - developer\n - Copyright (C) 2017 Moritz Wirger - developer\n - - This file is part of hueplusplus. - - hueplusplus is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - hueplusplus is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with hueplusplus. If not, see . -**/ - -#ifndef _UNITS_H -#define _UNITS_H - -struct Kelvin -{ - int value; -}; - -struct Mired -{ - int value; -}; - -struct Brightness -{ - int value; -}; - -struct HueSaturation -{ - int hue; - int saturation; -}; - -struct XY -{ - float x; - float y; -}; - -struct RGB -{ - uint8_t r; - uint8_t g; - uint8_t b; -}; - -#endif diff --git a/hueplusplus/include/Utils.h b/hueplusplus/include/Utils.h deleted file mode 100644 index 96cff7c..0000000 --- a/hueplusplus/include/Utils.h +++ /dev/null @@ -1,83 +0,0 @@ -/** - \file Utils.h - Copyright Notice\n - Copyright (C) 2020 Jan Rogall - developer\n - Copyright (C) 2020 Moritz Wirger - developer\n - - This file is part of hueplusplus. - - hueplusplus is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - hueplusplus is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with hueplusplus. If not, see . -**/ - -#ifndef _UTILS_H -#define _UTILS_H - -#include "json/json.hpp" - -namespace utils -{ - namespace detail - { - // Forward declaration - template - nlohmann::json safeGetMemberHelper(const nlohmann::json& json, std::size_t index, Paths&&... otherPaths); - - inline nlohmann::json safeGetMemberHelper(const nlohmann::json& json) { return json; } - - template >::value>* = nullptr> - nlohmann::json safeGetMemberHelper(const nlohmann::json& json, KeyT&& key, Paths&&... otherPaths) - { - auto memberIt = json.find(std::forward(key)); - if (memberIt == json.end()) - { - return nullptr; - } - return safeGetMemberHelper(*memberIt, std::forward(otherPaths)...); - } - - // Needs to be after the other safeGetMemberHelper, otherwise another forward declaration is needed - template - nlohmann::json safeGetMemberHelper(const nlohmann::json& json, std::size_t index, Paths&&... otherPaths) - { - if (!json.is_array() || json.size() <= index) - { - return nullptr; - } - return safeGetMemberHelper(json[index], std::forward(otherPaths)...); - } - } // namespace detail - - //! \brief Function for validating that a request was executed correctly - //! - //! \param request The request that was sent initially - //! \param reply The reply that was received - //! \param lightId The identifier of the light - //! \return True if request was executed correctly - bool validateReplyForLight(const nlohmann::json& request, const nlohmann::json& reply, int lightId); - - //! \brief Returns the object/array member or null if it does not exist - //! - //! \param json The base json value - //! \param paths Any number of child accesses (e.g. 0, "key" would access json[0]["key"]) - //! \returns The specified member or null if any intermediate object does not contain the specified child. - template - nlohmann::json safeGetMember(const nlohmann::json& json, Paths&&... paths) - { - return detail::safeGetMemberHelper(json, std::forward(paths)...); - } - -} // namespace utils - -#endif \ No newline at end of file diff --git a/hueplusplus/include/WinHttpHandler.h b/hueplusplus/include/WinHttpHandler.h deleted file mode 100644 index e5c92dc..0000000 --- a/hueplusplus/include/WinHttpHandler.h +++ /dev/null @@ -1,69 +0,0 @@ -/** - \file WinHttpHandler.h - Copyright Notice\n - Copyright (C) 2017 Jan Rogall - developer\n - Copyright (C) 2017 Moritz Wirger - developer\n - - This file is part of hueplusplus. - - hueplusplus is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - hueplusplus is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with hueplusplus. If not, see . -**/ - -#ifndef _WINHTTPHANDLER_H -#define _WINHTTPHANDLER_H - -#include -#include - -#include - -#include "BaseHttpHandler.h" - -//! Class to handle http requests and multicast requests on windows systems -class WinHttpHandler : public BaseHttpHandler -{ -public: - //! \brief Ctor needed for initializing wsaData - WinHttpHandler(); - - //! \brief Dtor needed for wsaData cleanup - ~WinHttpHandler(); - - //! \brief Function that sends a given message to the specified host and - //! returns the response. - //! - //! \param msg String that contains the message that is sent to the specified - //! address \param adr String that contains an ip or hostname in dotted - //! decimal notation like "192.168.2.1" \param port Optional integer that - //! specifies the port to which the request is sent to. Default is 80 \return - //! String containing the response of the host - std::string send(const std::string& msg, const std::string& adr, int port = 80) const override; - - //! \brief Function that sends a multicast request with the specified message. - //! - //! \param msg String that contains the request that is sent to the specified - //! address \param adr Optional String that contains an ip or hostname in - //! dotted decimal notation, default is "239.255.255.250" \param port Optional - //! integer that specifies the port to which the request is sent. Default is - //! 1900 \param timeout Optional Integer that specifies the timeout of the - //! request in seconds. Default is 5 \return Vector containing strings of each - //! answer received - std::vector sendMulticast(const std::string& msg, const std::string& adr = "239.255.255.250", - int port = 1900, int timeout = 5) const override; - -private: - WSADATA wsaData; -}; - -#endif diff --git a/hueplusplus/include/json/json.hpp b/hueplusplus/include/json/json.hpp deleted file mode 100644 index 06da815..0000000 --- a/hueplusplus/include/json/json.hpp +++ /dev/null @@ -1,22875 +0,0 @@ -/* - __ _____ _____ _____ - __| | __| | | | JSON for Modern C++ -| | |__ | | | | | | version 3.7.3 -|_____|_____|_____|_|___| https://github.com/nlohmann/json - -Licensed under the MIT License . -SPDX-License-Identifier: MIT -Copyright (c) 2013-2019 Niels Lohmann . - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#ifndef INCLUDE_NLOHMANN_JSON_HPP_ -#define INCLUDE_NLOHMANN_JSON_HPP_ - -#define NLOHMANN_JSON_VERSION_MAJOR 3 -#define NLOHMANN_JSON_VERSION_MINOR 7 -#define NLOHMANN_JSON_VERSION_PATCH 3 - -#include // all_of, find, for_each -#include // assert -#include // and, not, or -#include // nullptr_t, ptrdiff_t, size_t -#include // hash, less -#include // initializer_list -#include // istream, ostream -#include // random_access_iterator_tag -#include // unique_ptr -#include // accumulate -#include // string, stoi, to_string -#include // declval, forward, move, pair, swap -#include // vector - -// #include - - -#include - -// #include - - -#include // transform -#include // array -#include // and, not -#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 - - -#include // exception -#include // runtime_error -#include // to_string - -// #include - - -#include // size_t - -namespace nlohmann -{ -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 -} // namespace nlohmann - -// #include - - -#include // pair -// #include -/* Hedley - https://nemequ.github.io/hedley - * Created by Evan Nemerson - * - * To the extent possible under law, the author(s) have dedicated all - * copyright and related and neighboring rights to this software to - * the public domain worldwide. This software is distributed without - * any warranty. - * - * For details, see . - * SPDX-License-Identifier: CC0-1.0 - */ - -#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 11) -#if defined(JSON_HEDLEY_VERSION) - #undef JSON_HEDLEY_VERSION -#endif -#define JSON_HEDLEY_VERSION 11 - -#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_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) - #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) - #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) - #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(_MSC_VER) - #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) - #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE) -#elif defined(__INTEL_COMPILER) - #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_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__) - #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#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_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_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_TI_VERSION) && \ - !defined(__COMPCERT__) - #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) - #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) __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) __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_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 - -/* 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) && JSON_HEDLEY_HAS_WARNING("-Wc++98-compat") -# 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 -#else -# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x -#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(6,0,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) - #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(8,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 - -#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_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_TI_VERSION_CHECK(8,0,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_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(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") -#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_MSVC_VERSION_CHECK(19,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030)) -#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(8,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173") -#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_DEPRECATED) - #undef JSON_HEDLEY_DEPRECATED -#endif -#if defined(JSON_HEDLEY_DEPRECATED_FOR) - #undef JSON_HEDLEY_DEPRECATED_FOR -#endif -#if 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_EXTENSION(attribute_deprecated_with_message) || \ - 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(8,3,0) - #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since))) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__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(8,0,0) || \ - (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) - #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__)) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__)) -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,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_MSVC_VERSION_CHECK(13,10,0) || \ - JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,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) - #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(__cplusplus) && (__cplusplus >= 201703L) - #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) -#elif \ - 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(8,0,0) || \ - (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) -#elif defined(_Check_return_) /* SAL */ - #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_ -#else - #define JSON_HEDLEY_WARN_UNUSED_RESULT -#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) - #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) - #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(18,0,0) || \ - (JSON_HEDLEY_TI_VERSION_CHECK(17,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) - #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) - #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) -#elif JSON_HEDLEY_TI_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 \ - (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) - #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable() -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) - #define JSON_HEDLEY_UNREACHABLE() __assume(0) -#elif JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) - #if defined(__cplusplus) - #define JSON_HEDLEY_UNREACHABLE() std::_nassert(0) - #else - #define JSON_HEDLEY_UNREACHABLE() _nassert(0) - #endif - #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return value -#elif defined(EXIT_FAILURE) - #define JSON_HEDLEY_UNREACHABLE() abort() -#else - #define JSON_HEDLEY_UNREACHABLE() - #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return value -#endif -#if !defined(JSON_HEDLEY_UNREACHABLE_RETURN) - #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE() -#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) - #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_VERSION_CHECK(6,0,0) - #if defined(__cplusplus) - #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr) - #else - #define JSON_HEDLEY_ASSUME(expr) _nassert(expr) - #endif -#elif \ - (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && !defined(JSON_HEDLEY_ARM_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) - #define JSON_HEDLEY_ASSUME(expr) ((void) ((expr) ? 1 : (__builtin_unreachable(), 1))) -#else - #define JSON_HEDLEY_ASSUME(expr) ((void) (expr)) -#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(8,0,0) || \ - (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) - #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) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) -# 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) -#if !defined(JSON_HEDLEY_BUILTIN_UNPREDICTABLE) - #define JSON_HEDLEY_BUILTIN_UNPREDICTABLE(expr) __builtin_expect_with_probability(!!(expr), 1, 0.5) -#endif -#elif \ - JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) || \ - 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(6,1,0) || \ - JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) -# define JSON_HEDLEY_PREDICT(expr, expected, probability) \ - (((probability) >= 0.9) ? __builtin_expect(!!(expr), (expected)) : (((void) (expected)), !!(expr))) -# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \ - (__extension__ ({ \ - JSON_HEDLEY_CONSTEXPR 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__ ({ \ - JSON_HEDLEY_CONSTEXPR 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) (((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(8,0,0) || \ - (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) - #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) - #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(8,0,0) || \ - (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) - #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 JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) - #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(8,0,0) || \ - (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) - #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_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_VERSION_CHECK(8,0,0) || \ - (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ - defined(__clang__) - #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_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) - #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(8,0,0) || \ - (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) - #define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) - #define JSON_HEDLEY_ALWAYS_INLINE __forceinline -#elif JSON_HEDLEY_TI_VERSION_CHECK(7,0,0) && defined(__cplusplus) - #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(8,0,0) || \ - (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) - #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__)) -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,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_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) || \ - JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_EABI__) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) - #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) - #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__)) -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(13,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_GNUC_HAS_ATTRIBUTE(fallthrough,7,0,0) && !defined(JSON_HEDLEY_PGI_VERSION) - #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) - #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_VERSION_CHECK(6,1,0) || \ - (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) - #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)) || \ - JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) || \ - 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_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) || \ - 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) || \ - (defined(__cplusplus) && JSON_HEDLEY_TI_VERSION_CHECK(8,3,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_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) - #define JSON_HEDLEY_CPP_CAST(T, expr) static_cast(expr) -#else - #define JSON_HEDLEY_CPP_CAST(T, expr) (expr) -#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) -# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg) -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,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) - #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__)) -#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) - #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 -// You MUST include macro_unscope.hpp at the end of json.hpp to undef all of them - -// 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 (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 - -// disable float-equal warnings on GCC/clang -#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wfloat-equal" -#endif - -// disable documentation warnings on clang -#if defined(__clang__) - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdocumentation" -#endif - -// allow to disable 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 - -/*! -@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> - -#define NLOHMANN_BASIC_JSON_TPL \ - basic_json - - -namespace nlohmann -{ -namespace detail -{ -//////////////// -// exceptions // -//////////////// - -/*! -@brief general exception of the @ref basic_json class - -This class is an extension of `std::exception` objects with a member @a id for -exception ids. It is used as the base class for all exceptions thrown by the -@ref basic_json class. This class can hence be used as "wildcard" to catch -exceptions. - -Subclasses: -- @ref parse_error for exceptions indicating a parse error -- @ref invalid_iterator for exceptions indicating errors with iterators -- @ref type_error for exceptions indicating executing a member function with - a wrong type -- @ref out_of_range for exceptions indicating access out of the defined range -- @ref other_error for exceptions indicating other library errors - -@internal -@note To have nothrow-copy-constructible exceptions, we internally use - `std::runtime_error` which can cope with arbitrary-length error messages. - Intermediate strings are built with static functions and then passed to - the actual constructor. -@endinternal - -@liveexample{The following code shows how arbitrary library exceptions can be -caught.,exception} - -@since version 3.0.0 -*/ -class exception : public std::exception -{ - public: - /// returns the explanatory string - JSON_HEDLEY_RETURNS_NON_NULL - const char* what() const noexcept override - { - return m.what(); - } - - /// the id of the exception - const int id; - - protected: - JSON_HEDLEY_NON_NULL(3) - exception(int id_, const char* what_arg) : id(id_), m(what_arg) {} - - static std::string name(const std::string& ename, int id_) - { - return "[json.exception." + ename + "." + std::to_string(id_) + "] "; - } - - private: - /// an exception object as storage for error messages - std::runtime_error m; -}; - -/*! -@brief exception indicating a parse error - -This exception is thrown by the library when a parse error occurs. Parse errors -can occur during the deserialization of JSON text, CBOR, MessagePack, as well -as when using JSON Patch. - -Member @a byte holds the byte index of the last read character in the input -file. - -Exceptions have ids 1xx. - -name / id | example message | description ------------------------------- | --------------- | ------------------------- -json.exception.parse_error.101 | parse error at 2: unexpected end of input; expected string literal | This error indicates a syntax error while deserializing a JSON text. The error message describes that an unexpected token (character) was encountered, and the member @a byte indicates the error position. -json.exception.parse_error.102 | parse error at 14: missing or wrong low surrogate | JSON uses the `\uxxxx` format to describe Unicode characters. Code points above above 0xFFFF are split into two `\uxxxx` entries ("surrogate pairs"). This error indicates that the surrogate pair is incomplete or contains an invalid code point. -json.exception.parse_error.103 | parse error: code points above 0x10FFFF are invalid | Unicode supports code points up to 0x10FFFF. Code points above 0x10FFFF are invalid. -json.exception.parse_error.104 | parse error: JSON patch must be an array of objects | [RFC 6902](https://tools.ietf.org/html/rfc6902) requires a JSON Patch document to be a JSON document that represents an array of objects. -json.exception.parse_error.105 | parse error: operation must have string member 'op' | An operation of a JSON Patch document must contain exactly one "op" member, whose value indicates the operation to perform. Its value must be one of "add", "remove", "replace", "move", "copy", or "test"; other values are errors. -json.exception.parse_error.106 | parse error: array index '01' must not begin with '0' | An array index in a JSON Pointer ([RFC 6901](https://tools.ietf.org/html/rfc6901)) may be `0` or any number without a leading `0`. -json.exception.parse_error.107 | parse error: JSON pointer must be empty or begin with '/' - was: 'foo' | A JSON Pointer must be a Unicode string containing a sequence of zero or more reference tokens, each prefixed by a `/` character. -json.exception.parse_error.108 | parse error: escape character '~' must be followed with '0' or '1' | In a JSON Pointer, only `~0` and `~1` are valid escape sequences. -json.exception.parse_error.109 | parse error: array index 'one' is not a number | A JSON Pointer array index must be a number. -json.exception.parse_error.110 | parse error at 1: cannot read 2 bytes from vector | When parsing CBOR or MessagePack, the byte vector ends before the complete value has been read. -json.exception.parse_error.112 | parse error at 1: error reading CBOR; last byte: 0xF8 | Not all types of CBOR or MessagePack are supported. This exception occurs if an unsupported byte was read. -json.exception.parse_error.113 | parse error at 2: expected a CBOR string; last byte: 0x98 | While parsing a map key, a value that is not a string has been read. -json.exception.parse_error.114 | parse error: Unsupported BSON record type 0x0F | The parsing of the corresponding BSON record type is not implemented (yet). - -@note For an input with n bytes, 1 is the index of the first character and n+1 - is the index of the terminating null byte or the end of file. This also - holds true when reading a byte vector (CBOR or MessagePack). - -@liveexample{The following code shows how a `parse_error` exception can be -caught.,parse_error} - -@sa - @ref exception for the base class of the library exceptions -@sa - @ref invalid_iterator for exceptions indicating errors with iterators -@sa - @ref type_error for exceptions indicating executing a member function with - a wrong type -@sa - @ref out_of_range for exceptions indicating access out of the defined range -@sa - @ref other_error for exceptions indicating other library errors - -@since version 3.0.0 -*/ -class parse_error : public exception -{ - public: - /*! - @brief create a parse error exception - @param[in] id_ the id of the exception - @param[in] pos the position where the error occurred (or with - chars_read_total=0 if the position cannot be - determined) - @param[in] what_arg the explanatory string - @return parse_error object - */ - static parse_error create(int id_, const position_t& pos, const std::string& what_arg) - { - std::string w = exception::name("parse_error", id_) + "parse error" + - position_string(pos) + ": " + what_arg; - return parse_error(id_, pos.chars_read_total, w.c_str()); - } - - static parse_error create(int id_, std::size_t byte_, const std::string& what_arg) - { - std::string w = exception::name("parse_error", id_) + "parse error" + - (byte_ != 0 ? (" at byte " + std::to_string(byte_)) : "") + - ": " + what_arg; - return parse_error(id_, byte_, w.c_str()); - } - - /*! - @brief byte index of the parse error - - The byte index of the last read character in the input file. - - @note For an input with n bytes, 1 is the index of the first character and - n+1 is the index of the terminating null byte or the end of file. - This also holds true when reading a byte vector (CBOR or MessagePack). - */ - const std::size_t byte; - - private: - parse_error(int id_, std::size_t byte_, const char* what_arg) - : exception(id_, what_arg), byte(byte_) {} - - static std::string position_string(const position_t& pos) - { - return " at line " + std::to_string(pos.lines_read + 1) + - ", column " + std::to_string(pos.chars_read_current_line); - } -}; - -/*! -@brief exception indicating errors with iterators - -This exception is thrown if iterators passed to a library function do not match -the expected semantics. - -Exceptions have ids 2xx. - -name / id | example message | description ------------------------------------ | --------------- | ------------------------- -json.exception.invalid_iterator.201 | iterators are not compatible | The iterators passed to constructor @ref basic_json(InputIT first, InputIT last) are not compatible, meaning they do not belong to the same container. Therefore, the range (@a first, @a last) is invalid. -json.exception.invalid_iterator.202 | iterator does not fit current value | In an erase or insert function, the passed iterator @a pos does not belong to the JSON value for which the function was called. It hence does not define a valid position for the deletion/insertion. -json.exception.invalid_iterator.203 | iterators do not fit current value | Either iterator passed to function @ref erase(IteratorType first, IteratorType last) does not belong to the JSON value from which values shall be erased. It hence does not define a valid range to delete values from. -json.exception.invalid_iterator.204 | iterators out of range | When an iterator range for a primitive type (number, boolean, or string) is passed to a constructor or an erase function, this range has to be exactly (@ref begin(), @ref end()), because this is the only way the single stored value is expressed. All other ranges are invalid. -json.exception.invalid_iterator.205 | iterator out of range | When an iterator for a primitive type (number, boolean, or string) is passed to an erase function, the iterator has to be the @ref begin() iterator, because it is the only way to address the stored value. All other iterators are invalid. -json.exception.invalid_iterator.206 | cannot construct with iterators from null | The iterators passed to constructor @ref basic_json(InputIT first, InputIT last) belong to a JSON null value and hence to not define a valid range. -json.exception.invalid_iterator.207 | cannot use key() for non-object iterators | The key() member function can only be used on iterators belonging to a JSON object, because other types do not have a concept of a key. -json.exception.invalid_iterator.208 | cannot use operator[] for object iterators | The operator[] to specify a concrete offset cannot be used on iterators belonging to a JSON object, because JSON objects are unordered. -json.exception.invalid_iterator.209 | cannot use offsets with object iterators | The offset operators (+, -, +=, -=) cannot be used on iterators belonging to a JSON object, because JSON objects are unordered. -json.exception.invalid_iterator.210 | iterators do not fit | The iterator range passed to the insert function are not compatible, meaning they do not belong to the same container. Therefore, the range (@a first, @a last) is invalid. -json.exception.invalid_iterator.211 | passed iterators may not belong to container | The iterator range passed to the insert function must not be a subrange of the container to insert to. -json.exception.invalid_iterator.212 | cannot compare iterators of different containers | When two iterators are compared, they must belong to the same container. -json.exception.invalid_iterator.213 | cannot compare order of object iterators | The order of object iterators cannot be compared, because JSON objects are unordered. -json.exception.invalid_iterator.214 | cannot get value | Cannot get value for iterator: Either the iterator belongs to a null value or it is an iterator to a primitive type (number, boolean, or string), but the iterator is different to @ref begin(). - -@liveexample{The following code shows how an `invalid_iterator` exception can be -caught.,invalid_iterator} - -@sa - @ref exception for the base class of the library exceptions -@sa - @ref parse_error for exceptions indicating a parse error -@sa - @ref type_error for exceptions indicating executing a member function with - a wrong type -@sa - @ref out_of_range for exceptions indicating access out of the defined range -@sa - @ref other_error for exceptions indicating other library errors - -@since version 3.0.0 -*/ -class invalid_iterator : public exception -{ - public: - static invalid_iterator create(int id_, const std::string& what_arg) - { - std::string w = exception::name("invalid_iterator", id_) + what_arg; - return invalid_iterator(id_, w.c_str()); - } - - private: - JSON_HEDLEY_NON_NULL(3) - invalid_iterator(int id_, const char* what_arg) - : exception(id_, what_arg) {} -}; - -/*! -@brief exception indicating executing a member function with a wrong type - -This exception is thrown in case of a type error; that is, a library function is -executed on a JSON value whose type does not match the expected semantics. - -Exceptions have ids 3xx. - -name / id | example message | description ------------------------------ | --------------- | ------------------------- -json.exception.type_error.301 | cannot create object from initializer list | To create an object from an initializer list, the initializer list must consist only of a list of pairs whose first element is a string. When this constraint is violated, an array is created instead. -json.exception.type_error.302 | type must be object, but is array | During implicit or explicit value conversion, the JSON type must be compatible to the target type. For instance, a JSON string can only be converted into string types, but not into numbers or boolean types. -json.exception.type_error.303 | incompatible ReferenceType for get_ref, actual type is object | To retrieve a reference to a value stored in a @ref basic_json object with @ref get_ref, the type of the reference must match the value type. For instance, for a JSON array, the @a ReferenceType must be @ref array_t &. -json.exception.type_error.304 | cannot use at() with string | The @ref at() member functions can only be executed for certain JSON types. -json.exception.type_error.305 | cannot use operator[] with string | The @ref operator[] member functions can only be executed for certain JSON types. -json.exception.type_error.306 | cannot use value() with string | The @ref value() member functions can only be executed for certain JSON types. -json.exception.type_error.307 | cannot use erase() with string | The @ref erase() member functions can only be executed for certain JSON types. -json.exception.type_error.308 | cannot use push_back() with string | The @ref push_back() and @ref operator+= member functions can only be executed for certain JSON types. -json.exception.type_error.309 | cannot use insert() with | The @ref insert() member functions can only be executed for certain JSON types. -json.exception.type_error.310 | cannot use swap() with number | The @ref swap() member functions can only be executed for certain JSON types. -json.exception.type_error.311 | cannot use emplace_back() with string | The @ref emplace_back() member function can only be executed for certain JSON types. -json.exception.type_error.312 | cannot use update() with string | The @ref update() member functions can only be executed for certain JSON types. -json.exception.type_error.313 | invalid value to unflatten | The @ref unflatten function converts an object whose keys are JSON Pointers back into an arbitrary nested JSON value. The JSON Pointers must not overlap, because then the resulting value would not be well defined. -json.exception.type_error.314 | only objects can be unflattened | The @ref unflatten function only works for an object whose keys are JSON Pointers. -json.exception.type_error.315 | values in object must be primitive | The @ref unflatten function only works for an object whose keys are JSON Pointers and whose values are primitive. -json.exception.type_error.316 | invalid UTF-8 byte at index 10: 0x7E | The @ref dump function only works with UTF-8 encoded strings; that is, if you assign a `std::string` to a JSON value, make sure it is UTF-8 encoded. | -json.exception.type_error.317 | JSON value cannot be serialized to requested format | The dynamic type of the object cannot be represented in the requested serialization format (e.g. a raw `true` or `null` JSON object cannot be serialized to BSON) | - -@liveexample{The following code shows how a `type_error` exception can be -caught.,type_error} - -@sa - @ref exception for the base class of the library exceptions -@sa - @ref parse_error for exceptions indicating a parse error -@sa - @ref invalid_iterator for exceptions indicating errors with iterators -@sa - @ref out_of_range for exceptions indicating access out of the defined range -@sa - @ref other_error for exceptions indicating other library errors - -@since version 3.0.0 -*/ -class type_error : public exception -{ - public: - static type_error create(int id_, const std::string& what_arg) - { - std::string w = exception::name("type_error", id_) + what_arg; - return type_error(id_, w.c_str()); - } - - private: - JSON_HEDLEY_NON_NULL(3) - type_error(int id_, const char* what_arg) : exception(id_, what_arg) {} -}; - -/*! -@brief exception indicating access out of the defined range - -This exception is thrown in case a library function is called on an input -parameter that exceeds the expected range, for instance in case of array -indices or nonexisting object keys. - -Exceptions have ids 4xx. - -name / id | example message | description -------------------------------- | --------------- | ------------------------- -json.exception.out_of_range.401 | array index 3 is out of range | The provided array index @a i is larger than @a size-1. -json.exception.out_of_range.402 | array index '-' (3) is out of range | The special array index `-` in a JSON Pointer never describes a valid element of the array, but the index past the end. That is, it can only be used to add elements at this position, but not to read it. -json.exception.out_of_range.403 | key 'foo' not found | The provided key was not found in the JSON object. -json.exception.out_of_range.404 | unresolved reference token 'foo' | A reference token in a JSON Pointer could not be resolved. -json.exception.out_of_range.405 | JSON pointer has no parent | The JSON Patch operations 'remove' and 'add' can not be applied to the root element of the JSON value. -json.exception.out_of_range.406 | number overflow parsing '10E1000' | A parsed number could not be stored as without changing it to NaN or INF. -json.exception.out_of_range.407 | number overflow serializing '9223372036854775808' | UBJSON and BSON only support integer numbers up to 9223372036854775807. | -json.exception.out_of_range.408 | excessive array size: 8658170730974374167 | The size (following `#`) of an UBJSON array or object exceeds the maximal capacity. | -json.exception.out_of_range.409 | BSON key cannot contain code point U+0000 (at byte 2) | Key identifiers to be serialized to BSON cannot contain code point U+0000, since the key is stored as zero-terminated c-string | - -@liveexample{The following code shows how an `out_of_range` exception can be -caught.,out_of_range} - -@sa - @ref exception for the base class of the library exceptions -@sa - @ref parse_error for exceptions indicating a parse error -@sa - @ref invalid_iterator for exceptions indicating errors with iterators -@sa - @ref type_error for exceptions indicating executing a member function with - a wrong type -@sa - @ref other_error for exceptions indicating other library errors - -@since version 3.0.0 -*/ -class out_of_range : public exception -{ - public: - static out_of_range create(int id_, const std::string& what_arg) - { - std::string w = exception::name("out_of_range", id_) + what_arg; - return out_of_range(id_, w.c_str()); - } - - private: - JSON_HEDLEY_NON_NULL(3) - out_of_range(int id_, const char* what_arg) : exception(id_, what_arg) {} -}; - -/*! -@brief exception indicating other library errors - -This exception is thrown in case of errors that cannot be classified with the -other exception types. - -Exceptions have ids 5xx. - -name / id | example message | description ------------------------------- | --------------- | ------------------------- -json.exception.other_error.501 | unsuccessful: {"op":"test","path":"/baz", "value":"bar"} | A JSON Patch operation 'test' failed. The unsuccessful operation is also printed. - -@sa - @ref exception for the base class of the library exceptions -@sa - @ref parse_error for exceptions indicating a parse error -@sa - @ref invalid_iterator for exceptions indicating errors with iterators -@sa - @ref type_error for exceptions indicating executing a member function with - a wrong type -@sa - @ref out_of_range for exceptions indicating access out of the defined range - -@liveexample{The following code shows how an `other_error` exception can be -caught.,other_error} - -@since version 3.0.0 -*/ -class other_error : public exception -{ - public: - static other_error create(int id_, const std::string& what_arg) - { - std::string w = exception::name("other_error", id_) + what_arg; - return other_error(id_, w.c_str()); - } - - private: - JSON_HEDLEY_NON_NULL(3) - other_error(int id_, const char* what_arg) : exception(id_, what_arg) {} -}; -} // namespace detail -} // namespace nlohmann - -// #include - -// #include - - -#include // not -#include // size_t -#include // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type - -namespace nlohmann -{ -namespace detail -{ -// alias templates to reduce boilerplate -template -using enable_if_t = typename std::enable_if::type; - -template -using uncvref_t = typename std::remove_cv::type>::type; - -// implementation of C++14 index_sequence and affiliates -// source: https://stackoverflow.com/a/32223343 -template -struct index_sequence -{ - using type = index_sequence; - using value_type = std::size_t; - static constexpr std::size_t size() noexcept - { - return sizeof...(Ints); - } -}; - -template -struct merge_and_renumber; - -template -struct merge_and_renumber, index_sequence> - : index_sequence < I1..., (sizeof...(I1) + I2)... > {}; - -template -struct make_index_sequence - : merge_and_renumber < typename make_index_sequence < N / 2 >::type, - typename make_index_sequence < N - N / 2 >::type > {}; - -template<> struct make_index_sequence<0> : index_sequence<> {}; -template<> struct make_index_sequence<1> : index_sequence<0> {}; - -template -using index_sequence_for = make_index_sequence; - -// 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 constexpr T value{}; -}; - -template -constexpr T static_const::value; -} // namespace detail -} // namespace nlohmann - -// #include - - -#include // not -#include // numeric_limits -#include // false_type, is_constructible, is_integral, is_same, true_type -#include // declval - -// #include - - -#include // random_access_iterator_tag - -// #include - - -namespace nlohmann -{ -namespace detail -{ -template struct make_void -{ - using type = void; -}; -template using void_t = typename make_void::type; -} // namespace detail -} // namespace nlohmann - -// #include - - -namespace nlohmann -{ -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 -} // namespace nlohmann - -// #include - -// #include - -// #include - - -#include - -// #include - - -// http://en.cppreference.com/w/cpp/experimental/is_detected -namespace nlohmann -{ -namespace detail -{ -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