├── .gitignore ├── .ycm_extra_conf.py ├── LICENSE.md ├── README.md ├── VERSION ├── assets └── Data │ └── SKSE │ └── Plugins │ └── sse-gui │ └── settings.json ├── include └── sse-gui │ ├── platform.h │ └── sse-gui.h ├── logo.jpg ├── share ├── gsl │ ├── LICENSE │ ├── gsl │ ├── gsl_algorithm │ ├── gsl_assert │ ├── gsl_byte │ ├── gsl_util │ ├── multi_span │ ├── pointers │ ├── span │ └── string_span ├── nlohmann │ ├── LICENSE.MIT │ ├── adl_serializer.hpp │ ├── detail │ │ ├── conversions │ │ │ ├── from_json.hpp │ │ │ ├── to_chars.hpp │ │ │ └── to_json.hpp │ │ ├── exceptions.hpp │ │ ├── input │ │ │ ├── binary_reader.hpp │ │ │ ├── input_adapters.hpp │ │ │ ├── json_sax.hpp │ │ │ ├── lexer.hpp │ │ │ ├── parser.hpp │ │ │ └── position_t.hpp │ │ ├── iterators │ │ │ ├── internal_iterator.hpp │ │ │ ├── iter_impl.hpp │ │ │ ├── iteration_proxy.hpp │ │ │ ├── iterator_traits.hpp │ │ │ ├── json_reverse_iterator.hpp │ │ │ └── primitive_iterator.hpp │ │ ├── json_pointer.hpp │ │ ├── json_ref.hpp │ │ ├── macro_scope.hpp │ │ ├── macro_unscope.hpp │ │ ├── meta │ │ │ ├── cpp_future.hpp │ │ │ ├── detected.hpp │ │ │ ├── is_sax.hpp │ │ │ ├── type_traits.hpp │ │ │ └── void_t.hpp │ │ ├── output │ │ │ ├── binary_writer.hpp │ │ │ ├── output_adapters.hpp │ │ │ └── serializer.hpp │ │ └── value_t.hpp │ ├── json.hpp │ └── json_fwd.hpp ├── skse │ ├── PluginAPI.h │ └── skse64_license.txt ├── sse-hooks │ ├── LICENSE.md │ ├── platform.h │ └── sse-hooks.h └── utils │ ├── winutils.cpp │ └── winutils.hpp ├── src ├── input.cpp ├── render.cpp ├── skse.cpp ├── sse-gui.cpp └── test_all.cpp ├── waf └── wscript /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | .lock-waf* 3 | .waf3-* 4 | *.7z 5 | 6 | out/ 7 | -------------------------------------------------------------------------------- /.ycm_extra_conf.py: -------------------------------------------------------------------------------- 1 | # This file is NOT licensed under the GPLv3, which is the license for the rest 2 | # of YouCompleteMe. 3 | # 4 | # Here's the license text for this file: 5 | # 6 | # This is free and unencumbered software released into the public domain. 7 | # 8 | # Anyone is free to copy, modify, publish, use, compile, sell, or 9 | # distribute this software, either in source code form or as a compiled 10 | # binary, for any purpose, commercial or non-commercial, and by any 11 | # means. 12 | # 13 | # In jurisdictions that recognize copyright laws, the author or authors 14 | # of this software dedicate any and all copyright interest in the 15 | # software to the public domain. We make this dedication for the benefit 16 | # of the public at large and to the detriment of our heirs and 17 | # successors. We intend this dedication to be an overt act of 18 | # relinquishment in perpetuity of all present and future rights to this 19 | # software under copyright law. 20 | # 21 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 24 | # IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 25 | # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 26 | # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | # OTHER DEALINGS IN THE SOFTWARE. 28 | # 29 | # For more information, please refer to 30 | 31 | import os 32 | import ycm_core 33 | 34 | # CHANGE THIS LIST OF FLAGS. YES, THIS IS THE DROID YOU HAVE BEEN LOOKING FOR. 35 | flags = [ 36 | # You 100% do NOT need -DUSE_CLANG_COMPLETER in your flags; only the YCM 37 | # source code needs it. 38 | '-DUSE_CLANG_COMPLETER', 39 | # ...and the same thing goes for the magic -x option which specifies the 40 | # language that the files to be compiled are written in. This is mostly 41 | # relevant for c++ headers. 42 | # For a C project, you would set this to 'c' instead of 'c++'. 43 | '-x', 44 | 'c++', 45 | # THIS IS IMPORTANT! Without a "-std=" flag, clang won't know which 46 | # language to use when compiling headers. So it will guess. Badly. So C++ 47 | # headers will be compiled as C headers. You don't want that so ALWAYS specify 48 | # a "-std=". 49 | # For a C project, you would set this to something like 'c99' instead of 50 | # 'c++11'. 51 | '-std=c++14', 52 | '-I', './src', '-I', '/share', 53 | '-Wall', 54 | #'-Wextra', 55 | '-Wno-missing-braces', 56 | ] 57 | 58 | def DirectoryOfThisScript(): 59 | return os.path.dirname( os.path.abspath( __file__ ) ) 60 | 61 | def MakeRelativePathsInFlagsAbsolute( flags, working_directory ): 62 | if not working_directory: 63 | return list( flags ) 64 | new_flags = [] 65 | make_next_absolute = False 66 | path_flags = [ '-isystem', '-I' ] 67 | for flag in flags: 68 | new_flag = flag 69 | 70 | if make_next_absolute: 71 | make_next_absolute = False 72 | if not flag.startswith ('/'): 73 | new_flag = os.path.join (working_directory, flag) 74 | 75 | for path_flag in path_flags: 76 | if flag == path_flag: 77 | make_next_absolute = True 78 | break 79 | 80 | if flag.startswith (path_flag): 81 | path = flag[ len (path_flag): ] 82 | new_flag = path_flag + os.path.join (working_directory, path) 83 | break 84 | 85 | if new_flag: 86 | new_flags.append (new_flag) 87 | return new_flags 88 | 89 | def FlagsForFile (filename, **kwargs): 90 | relative_to = DirectoryOfThisScript () 91 | final_flags = MakeRelativePathsInFlagsAbsolute (flags, relative_to) 92 | return { 'flags': final_flags } 93 | 94 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SSE GUI 2 | 3 | Skyrim SE, SKSE plugin providing basic framework for GUI overlays by hooking upon the rendering 4 | and input pipelines. 5 | 6 | Flow goes on as: 7 | 1. During SKSE's Post-Post Load message the render and input factories are wrapped 8 | 2. During SKSE's Input loaded message, the game window and rendering swaps are prepended 9 | 3. SSE GUI interface is broadcasted to willing subscribers 10 | 4. Each subscriber chooses to register a callback to the rendering and/or input pipelines 11 | 12 | Refer to `include/sse-gui/sse-gui.h` file for API specification. 13 | 14 | # Development 15 | 16 | * All incoming or outgoing strings are UTF-8 compatible. Internally, SSEH converts these to the 17 | Windows Unicode when needed. 18 | 19 | ## Required tools 20 | 21 | * Python 3.x for the build system (2.x may work too) 22 | * C++14 compatible compiler available on the PATH 23 | * Uses at run-time https://github.com/ryobg/sse-hooks 24 | 25 | Under Windows10/WSL with MinGW, it can be configure & build as: 26 | ``` 27 | CXX=x86_64-w64-mingw32-g++-posix AR=x86_64-w64-mingw32-ar ./waf configure 28 | ./waf 29 | ``` 30 | 31 | ## License 32 | 33 | LGPLv3, see the LICENSE.md file. Modules in `share/` have their own license. 34 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 1,2,2 2 | -------------------------------------------------------------------------------- /assets/Data/SKSE/Plugins/sse-gui/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "dinput": { 3 | "disable key": 210 4 | }, 5 | "version": { 6 | "major": 1, 7 | "minor": 2, 8 | "patch": 2, 9 | "timestamp": "2020-09-20T00:00:00.000000+00:00" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /include/sse-gui/platform.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file platform.h 3 | * @brief Detect the current operating environment 4 | * @internal 5 | * 6 | * This file is part of SSE Hooks project (aka SSEGUI). 7 | * 8 | * SSEGUI is free software: you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published 10 | * by the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * SSEGUI is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with SSEGUI. If not, see . 20 | * 21 | * @endinternal 22 | * 23 | * @ingroup Public API 24 | * 25 | * @details 26 | * This file contains conditional macro definitions determining compile time 27 | * attributes according to the operating environment. As of now it detects 28 | * the intended operating system where the exectuable will run under, which 29 | * compiler is used for the build and API build helpers. 30 | */ 31 | 32 | #ifndef SSEGUI_PLATFORM_H 33 | #define SSEGUI_PLATFORM_H 34 | 35 | /*----------------------------------------------------------------------------*/ 36 | /* Select operating system: */ 37 | 38 | #undef SSEGUI_WINDOWS 39 | #undef SSEGUI_POSIX 40 | 41 | #if defined(_WIN32) \ 42 | || defined(_WIN64) \ 43 | || defined(__WIN32__) \ 44 | || defined(__WINDOWS__) \ 45 | || defined(__MINGW32__) \ 46 | || defined(__MINGW64__) 47 | 48 | /** Defined when targeting Microsoft Windows operating system */ 49 | #define SSEGUI_WINDOWS 50 | 51 | #else 52 | 53 | /** Defined when NOT targeting Windows but POSIX compatible system */ 54 | #define SSEGUI_POSIX 55 | 56 | #endif 57 | 58 | /*----------------------------------------------------------------------------*/ 59 | /* Select compiler: */ 60 | 61 | #undef SSEGUI_GNUC 62 | #undef SSEGUI_MSVC 63 | #undef SSEGUI_MINGW 64 | 65 | #if defined(__GNUC__) 66 | 67 | /** Any GNU GCC C++ compiler */ 68 | #define SSEGUI_GNUC \ 69 | (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) 70 | 71 | #if defined(__MINGW32__) || defined(__MINGW64__) 72 | /** GNU GCC as cross compiler or native under Windows. */ 73 | #define SSEGUI_MINGW SSEGUI_GNUC 74 | #endif 75 | 76 | #elif defined(_MSC_VER) /* Last as other vendors also define this. */ 77 | 78 | /** Any Microsoft Visual Studio C++ compiler. */ 79 | #define SSEGUI_MSVC (_MSC_VER) 80 | 81 | #endif 82 | 83 | /*----------------------------------------------------------------------------*/ 84 | /* Select the C calling convention: */ 85 | 86 | #undef SSEGUI_CCONV 87 | 88 | #if defined(SSEGUI_WINDOWS) && !defined(SSEGUI_MINGW) 89 | #if defined(SSEGUI_GNUC) 90 | /** GCC on Windows understands stdcall */ 91 | #define SSEGUI_CCONV __attribute__((stdcall)) 92 | 93 | #elif defined(SSEGUI_MSVC) 94 | /** Visual C++ on Windows uses stdcall */ 95 | #define SSEGUI_CCONV __stdcall 96 | #endif 97 | 98 | #elif defined(SSEGUI_POSIX) || defined(SSEGUI_MINGW) 99 | /** Linux/Unix/Cross and etc. use only one type of convention */ 100 | #define SSEGUI_CCONV 101 | 102 | #endif 103 | 104 | /*----------------------------------------------------------------------------*/ 105 | /* Select the shared library interface */ 106 | 107 | #undef SSEGUI_API 108 | 109 | #if defined(SSEGUI_WINDOWS) 110 | 111 | /* In practice this is defined as paramater to the build. */ 112 | #if defined(SSEGUI_BUILD_API) 113 | /** The current build exposes DLL functions */ 114 | #define SSEGUI_API __declspec(dllexport) 115 | 116 | #else 117 | /** The current build imports, previously exported DLL functions */ 118 | #define SSEGUI_API __declspec(dllimport) 119 | #endif 120 | 121 | #elif defined(SSEGUI_POSIX) 122 | /** The current build does not use any specific storage information */ 123 | #define SSEGUI_API 124 | 125 | #endif 126 | 127 | /*----------------------------------------------------------------------------*/ 128 | 129 | #endif 130 | 131 | -------------------------------------------------------------------------------- /include/sse-gui/sse-gui.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file sse-hooks.h 3 | * @brief Public C API for users of SSE Hooks 4 | * @internal 5 | * 6 | * This file is part of SSE Hooks project (aka SSEGUI). 7 | * 8 | * SSEGUI is free software: you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published 10 | * by the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * SSEGUI is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with SSEGUI. If not, see . 20 | * 21 | * @endinternal 22 | * 23 | * @ingroup Public API 24 | * 25 | * @note This API is not thread-safe. 26 | * @note Unless mentioned, all strings are null-terminated and in UTF-8. 27 | * 28 | * @details 29 | * This file encompass all the functions which are presented to the users of 30 | * SSEGUI. The interface targets to be maximum compatible and portable 31 | * across the expected build and usage scenarios. This file uses generic C, but 32 | * is compatible with C++. As the methods are to be exported in the DLL, this 33 | * lib interface can be also accessed from other languages too. 34 | */ 35 | 36 | #ifndef SSEGUI_SSEGUI_H 37 | #define SSEGUI_SSEGUI_H 38 | 39 | #include 40 | #include 41 | 42 | /// To match a compiled in API against one loaded at run-time. 43 | #define SSEGUI_API_VERSION (1) 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | /******************************************************************************/ 50 | 51 | /** 52 | * Run-time version of this API and its implementation details. 53 | * 54 | * This function can be used to detect in run-time what kind of feature & fixes 55 | * on the API, the loaded SSEGUI is compiled with. This function is the only 56 | * one, which is guaranteed to preseve through the whole lifecycle of this 57 | * product. 58 | * 59 | * The @param api tells what version is the current API. Any version different 60 | * than the one expected guarantees a broken interface. Most likely it will 61 | * mean that a function is missing or its prototype is different. 62 | * 63 | * The @param maj describes major, but compatible changes within the API. Maybe 64 | * a new function is added or the behaviour of an old one was extended in 65 | * compatible way i.e. it won't break the callee. 66 | * 67 | * The @param imp is an implementation detail, in most cases may not be of 68 | * interest. It is reserved for patches, bug fixes, maybe documentation updates 69 | * re-release of something and etc. 70 | * 71 | * It is advised to check @param api against #SSEGUI_API_VERSION. 72 | * 73 | * @param[out] api (optional) non-portable 74 | * @param[out] maj (optional) new features and enhancements 75 | * @param[out] imp (optional) patches 76 | * @param[out] timestamp (optional) in ISO format 77 | */ 78 | 79 | SSEGUI_API void SSEGUI_CCONV 80 | ssegui_version (int* api, int* maj, int* imp, const char** timestamp); 81 | 82 | /** @see #ssegui_version() */ 83 | 84 | typedef void (SSEGUI_CCONV* ssegui_version_t) (int*, int*, int*, const char**); 85 | 86 | /******************************************************************************/ 87 | 88 | /** 89 | * Report the last message in more human-readable form. 90 | * 91 | * @param[in,out] size in bytes of @param message, on exit how many bytes were 92 | * actually written (excluding the terminating null) or how many bytes are 93 | * needed in order to get the full message. Can be zero, if there is no error. 94 | * 95 | * @param[out] message in human readable form, can be nullptr if @param size is 96 | * needed to pre-allocate a buffer. 97 | */ 98 | 99 | SSEGUI_API void SSEGUI_CCONV 100 | ssegui_last_error (size_t* size, char* message); 101 | 102 | /** @see #ssegui_last_error() */ 103 | 104 | typedef void (SSEGUI_CCONV* ssegui_last_error_t) (size_t*, char*); 105 | 106 | /******************************************************************************/ 107 | 108 | /** 109 | * Enable (default) the DInput for the hooked application. 110 | * 111 | * By default the control key, toggles the keyboard and mouse state, but this 112 | * function can be used for explicit requests (though the key will overwride 113 | * them if pressed). 114 | * 115 | * When the input is enabled, the hooked appliation will receive data, if 116 | * disabled - the keyboard and/or the mouse will freeze for the game. The 117 | * Windows message loop though will continue receive messages, so SSE GUI 118 | * plugins can continue reacting. 119 | * 120 | * @param[in,out] keyboard to enable (positive), disable (zero) or only report 121 | * state for (negative). On exit it will contain the old value (positive/zero) 122 | * or the current (negative) value. 123 | * @param[in,out] mouse see @param keyboard 124 | */ 125 | 126 | SSEGUI_API void SSEGUI_CCONV 127 | ssegui_enable_input (int* keyboard, int* mouse); 128 | 129 | /** @see #ssegui_enable_input() */ 130 | 131 | typedef void (SSEGUI_CCONV* ssegui_enable_input_t) (int*, int*); 132 | 133 | /** 134 | * Change the SSE GUI input control key. 135 | * 136 | * The control key is one of the DInput DIK_* constants (scan code) used to 137 | * toggle the input device on or off for the game. These codes are the same used 138 | * by SKSE and the KeyPressed(...) and etc. functions available for Papyrus. 139 | * 140 | * @see https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ee418641(v=vs.85) 141 | * @see #ssegui_control_listener() 142 | * @param[in,out] dik constant to be used from now on, if the param is negative 143 | * or out of bounds (>255) it won't change the constant. On exit it will 144 | * contain the previous, or the current (if not changed) key used. 145 | */ 146 | 147 | SSEGUI_API void SSEGUI_CCONV 148 | ssegui_control_key (int* dik); 149 | 150 | /** @see #ssegui_control_key() */ 151 | 152 | typedef void (SSEGUI_CCONV* ssegui_control_key_t) (int*); 153 | 154 | /******************************************************************************/ 155 | 156 | /** Zero indicates that the corresponding device has been just disabled for the game. */ 157 | 158 | typedef void (SSEGUI_CCONV* ssegui_control_callback) 159 | (int keyboard, int mouse); 160 | 161 | /** 162 | * Register or remove a DInput enabled/disabled listener 163 | * 164 | * The callback is called on each switch between enabling or disabling the 165 | * keyboard and mouse devices. Initially, they are enabled, but pressing the 166 | * control key (#ssegui_control_key()), zeroes the data received from them. 167 | * This means they are effectively disabled and the game cannot see them. 168 | * 169 | * @see #ssegui_control_key() 170 | * @param[in] callback to call or @param remove 171 | * @param[in] remove if positive, append if zero. 172 | */ 173 | 174 | SSEGUI_API void SSEGUI_CCONV 175 | ssegui_control_listener (ssegui_control_callback callback, int remove); 176 | 177 | /** @see #ssegui_control_listener() */ 178 | 179 | typedef void (SSEGUI_CCONV* ssegui_control_listener_t) 180 | (ssegui_control_callback, int); 181 | 182 | /******************************************************************************/ 183 | 184 | /// @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgi/nf-dxgi-idxgiswapchain-present 185 | 186 | typedef void (SSEGUI_CCONV* ssegui_render_callback) 187 | (void* pSwapChain, unsigned SyncInterval, unsigned Flags); 188 | 189 | /** 190 | * Register or remove a render listener 191 | * 192 | * These functions are invoked on each frame rendering, so plug ins can render 193 | * elements above or something. Note that, less and faster is better, or the 194 | * FPS can suffer. 195 | * 196 | * @param[in] callback to call or @param remove 197 | * @param[in] remove if positive, append if zero. 198 | */ 199 | 200 | SSEGUI_API void SSEGUI_CCONV 201 | ssegui_render_listener (ssegui_render_callback callback, int remove); 202 | 203 | /** @see #ssegui_render_listener() */ 204 | 205 | typedef void (SSEGUI_CCONV* ssegui_render_listener_t) 206 | (ssegui_render_callback, int); 207 | 208 | /******************************************************************************/ 209 | 210 | /** @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms633573(v=vs.85).aspx */ 211 | 212 | typedef intptr_t (SSEGUI_CCONV* ssegui_message_callback) 213 | (void* hWnd, unsigned msg, uintptr_t wParam, intptr_t lParam); 214 | 215 | /** 216 | * Register or remove a windows message listener 217 | * 218 | * The callback is called on each received window message, before forwarding to 219 | * the rest of the subclass chain. It is somehow easy to install such hook 220 | * through ::FindWindow() and ::SetWindowLongPtr(), but this is exposed as 221 | * complement to the rendering. 222 | * 223 | * @param[in] callback to call or @param remove 224 | * @param[in] remove if positive, append if zero. 225 | */ 226 | 227 | SSEGUI_API void SSEGUI_CCONV 228 | ssegui_message_listener (ssegui_message_callback callback, int remove); 229 | 230 | /** @see #ssegui_message_listener() */ 231 | 232 | typedef void (SSEGUI_CCONV* ssegui_message_listener_t) 233 | (ssegui_message_callback, int); 234 | 235 | /******************************************************************************/ 236 | 237 | /** 238 | * Read a parameter value 239 | * 240 | * This function is useful to retrieve some of the stored values which may be 241 | * of an interest, like the D11 chain pointer or the render window address. 242 | * 243 | * Current supported parameters (@param name, @param value type): 244 | * * "ID3D11Device", ID3D11Device** 245 | * * "ID3D11DeviceContext", ID3D11Device** 246 | * * "IDXGISwapChain", ID3D11Device** 247 | * * "window", HWND* 248 | * 249 | * @param[in] name of the parameter to obtain value for 250 | * @param[out] value to store in 251 | * @return non-zero if found, zero if no such parameter can be obtained 252 | */ 253 | 254 | SSEGUI_API int SSEGUI_CCONV 255 | ssegui_parameter (const char* name, void* value); 256 | 257 | /** @see #ssegui_parameter() */ 258 | 259 | typedef int (SSEGUI_CCONV* ssegui_parameter_t) (const char*, void*); 260 | 261 | /******************************************************************************/ 262 | 263 | /** 264 | * Confine the cursor within the fullscreen window. 265 | * 266 | * On multi-monitor setup, in fullscreen mode, the cursor can get out of the 267 | * window bounds and any click will cause minimization. This method, clips the 268 | * cursor to stay within the window. 269 | * 270 | * @param[in] enable clipping, if non-zero, or disable it, if zero. 271 | * @returns non-zero on success, otherwise see #ssegui_last_error () 272 | */ 273 | 274 | SSEGUI_API int SSEGUI_CCONV 275 | ssegui_clip_cursor (int enable); 276 | 277 | /** @see #ssegui_clip_cursor() */ 278 | 279 | typedef int (SSEGUI_CCONV* ssegui_clip_cursor_t) (int); 280 | 281 | /******************************************************************************/ 282 | 283 | /** 284 | * Execute custom command. 285 | * 286 | * This is highly implementation specific and may change any moment. It is like 287 | * patch hole for development use. 288 | * 289 | * @param[in] command identifier 290 | * @param[in,out] arg to pass in or out data 291 | * @returns non-zero on success, otherwise see #ssegui_last_error () 292 | */ 293 | 294 | SSEGUI_API int SSEGUI_CCONV 295 | ssegui_execute (const char* command, void* arg); 296 | 297 | /** @see #ssegui_execute() */ 298 | 299 | typedef int (SSEGUI_CCONV* ssegui_execute_t) (const char*, void*); 300 | 301 | /******************************************************************************/ 302 | 303 | /** 304 | * Set of function pointers as found in this file. 305 | * 306 | * Compatible changes are function pointers appened to the end of this 307 | * structure. 308 | */ 309 | 310 | struct ssegui_api_v1 311 | { 312 | /** @see #ssegui_version() */ 313 | ssegui_version_t version; 314 | /** @see #ssegui_last_error() */ 315 | ssegui_last_error_t last_error; 316 | /** @see #ssegui_enable_input() */ 317 | ssegui_enable_input_t enable_input; 318 | /** @see #ssegui_control_key() */ 319 | ssegui_control_key_t control_key; 320 | /** @see #ssegui_render_listener() */ 321 | ssegui_render_listener_t render_listener; 322 | /** @see #ssegui_message_listener() */ 323 | ssegui_message_listener_t message_listener; 324 | /** @see #ssegui_parameter() */ 325 | ssegui_parameter_t parameter; 326 | /** @see #ssegui_execute() */ 327 | ssegui_execute_t execute; 328 | /** @see #ssegui_clip_cursor() */ 329 | ssegui_clip_cursor_t clip_cursor; 330 | /** @see #ssegui_control_listener() */ 331 | ssegui_control_listener_t control_listener; 332 | }; 333 | 334 | /** Points to the current API version in use. */ 335 | typedef struct ssegui_api_v1 ssegui_api; 336 | 337 | /******************************************************************************/ 338 | 339 | /** 340 | * Create an instance of #ssegui_api, ready for use. 341 | * 342 | * @returns an API 343 | */ 344 | 345 | SSEGUI_API ssegui_api SSEGUI_CCONV 346 | ssegui_make_api (); 347 | 348 | /** @see #ssegui_make_api() */ 349 | 350 | typedef ssegui_api (SSEGUI_CCONV* ssegui_make_api_t) (); 351 | 352 | /******************************************************************************/ 353 | 354 | #ifdef __cplusplus 355 | } 356 | #endif 357 | 358 | #endif /* SSEGUI_SSEGUI_H */ 359 | 360 | /* EOF */ 361 | 362 | -------------------------------------------------------------------------------- /logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryobg/sse-gui/b0682f7f08ad013aa440a9239df74fd3023d73b5/logo.jpg -------------------------------------------------------------------------------- /share/gsl/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Microsoft Corporation. All rights reserved. 2 | 3 | This code is licensed under the MIT License (MIT). 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 9 | of the Software, and to permit persons to whom the Software is furnished to do 10 | so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /share/gsl/gsl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (c) 2015 Microsoft Corporation. All rights reserved. 4 | // 5 | // This code is licensed under the MIT License (MIT). 6 | // 7 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 8 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 9 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 10 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 11 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 12 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 13 | // THE SOFTWARE. 14 | // 15 | /////////////////////////////////////////////////////////////////////////////// 16 | 17 | #ifndef GSL_GSL_H 18 | #define GSL_GSL_H 19 | 20 | #include // copy 21 | #include // Ensures/Expects 22 | #include // byte 23 | #include // finally()/narrow()/narrow_cast()... 24 | #include // multi_span, strided_span... 25 | #include // owner, not_null 26 | #include // span 27 | #include // zstring, string_span, zstring_builder... 28 | 29 | #endif // GSL_GSL_H 30 | -------------------------------------------------------------------------------- /share/gsl/gsl_algorithm: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (c) 2015 Microsoft Corporation. All rights reserved. 4 | // 5 | // This code is licensed under the MIT License (MIT). 6 | // 7 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 8 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 9 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 10 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 11 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 12 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 13 | // THE SOFTWARE. 14 | // 15 | /////////////////////////////////////////////////////////////////////////////// 16 | 17 | #ifndef GSL_ALGORITHM_H 18 | #define GSL_ALGORITHM_H 19 | 20 | #include // for Expects 21 | #include // for dynamic_extent, span 22 | 23 | #include // for copy_n 24 | #include // for ptrdiff_t 25 | #include // for is_assignable 26 | 27 | #ifdef _MSC_VER 28 | #pragma warning(push) 29 | 30 | // turn off some warnings that are noisy about our Expects statements 31 | #pragma warning(disable : 4127) // conditional expression is constant 32 | #pragma warning(disable : 4996) // unsafe use of std::copy_n 33 | 34 | #endif // _MSC_VER 35 | 36 | namespace gsl 37 | { 38 | // Note: this will generate faster code than std::copy using span iterator in older msvc+stl 39 | // not necessary for msvc since VS2017 15.8 (_MSC_VER >= 1915) 40 | template 42 | void copy(span src, span dest) 43 | { 44 | static_assert(std::is_assignable::value, 45 | "Elements of source span can not be assigned to elements of destination span"); 46 | static_assert(SrcExtent == dynamic_extent || DestExtent == dynamic_extent || 47 | (SrcExtent <= DestExtent), 48 | "Source range is longer than target range"); 49 | 50 | Expects(dest.size() >= src.size()); 51 | GSL_SUPPRESS(stl.1) // NO-FORMAT: attribute 52 | std::copy_n(src.data(), src.size(), dest.data()); 53 | } 54 | 55 | } // namespace gsl 56 | 57 | #ifdef _MSC_VER 58 | #pragma warning(pop) 59 | #endif // _MSC_VER 60 | 61 | #endif // GSL_ALGORITHM_H 62 | -------------------------------------------------------------------------------- /share/gsl/gsl_assert: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (c) 2015 Microsoft Corporation. All rights reserved. 4 | // 5 | // This code is licensed under the MIT License (MIT). 6 | // 7 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 8 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 9 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 10 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 11 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 12 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 13 | // THE SOFTWARE. 14 | // 15 | /////////////////////////////////////////////////////////////////////////////// 16 | 17 | #ifndef GSL_CONTRACTS_H 18 | #define GSL_CONTRACTS_H 19 | 20 | #include 21 | #include // for logic_error 22 | 23 | // 24 | // make suppress attributes parse for some compilers 25 | // Hopefully temporary until suppression standardization occurs 26 | // 27 | #if defined(__clang__) 28 | #define GSL_SUPPRESS(x) [[gsl::suppress("x")]] 29 | #else 30 | #if defined(_MSC_VER) 31 | #define GSL_SUPPRESS(x) [[gsl::suppress(x)]] 32 | #else 33 | #define GSL_SUPPRESS(x) 34 | #endif // _MSC_VER 35 | #endif // __clang__ 36 | 37 | // 38 | // Temporary until MSVC STL supports no-exceptions mode. 39 | // Currently terminate is a no-op in this mode, so we add termination behavior back 40 | // 41 | #if defined(_MSC_VER) && defined(_HAS_EXCEPTIONS) && !_HAS_EXCEPTIONS 42 | #define GSL_MSVC_USE_STL_NOEXCEPTION_WORKAROUND 43 | #include 44 | #define RANGE_CHECKS_FAILURE 0 45 | 46 | #if defined(__clang__) 47 | #pragma clang diagnostic push 48 | #pragma clang diagnostic ignored "-Winvalid-noreturn" 49 | #endif 50 | 51 | #endif 52 | 53 | // 54 | // There are three configuration options for this GSL implementation's behavior 55 | // when pre/post conditions on the GSL types are violated: 56 | // 57 | // 1. GSL_TERMINATE_ON_CONTRACT_VIOLATION: std::terminate will be called (default) 58 | // 2. GSL_THROW_ON_CONTRACT_VIOLATION: a gsl::fail_fast exception will be thrown 59 | // 3. GSL_UNENFORCED_ON_CONTRACT_VIOLATION: nothing happens 60 | // 61 | #if !(defined(GSL_THROW_ON_CONTRACT_VIOLATION) || defined(GSL_TERMINATE_ON_CONTRACT_VIOLATION) || \ 62 | defined(GSL_UNENFORCED_ON_CONTRACT_VIOLATION)) 63 | #define GSL_TERMINATE_ON_CONTRACT_VIOLATION 64 | #endif 65 | 66 | #define GSL_STRINGIFY_DETAIL(x) #x 67 | #define GSL_STRINGIFY(x) GSL_STRINGIFY_DETAIL(x) 68 | 69 | #if defined(__clang__) || defined(__GNUC__) 70 | #define GSL_LIKELY(x) __builtin_expect(!!(x), 1) 71 | #define GSL_UNLIKELY(x) __builtin_expect(!!(x), 0) 72 | #else 73 | #define GSL_LIKELY(x) (!!(x)) 74 | #define GSL_UNLIKELY(x) (!!(x)) 75 | #endif 76 | 77 | // 78 | // GSL_ASSUME(cond) 79 | // 80 | // Tell the optimizer that the predicate cond must hold. It is unspecified 81 | // whether or not cond is actually evaluated. 82 | // 83 | #ifdef _MSC_VER 84 | #define GSL_ASSUME(cond) __assume(cond) 85 | #elif defined(__GNUC__) 86 | #define GSL_ASSUME(cond) ((cond) ? static_cast(0) : __builtin_unreachable()) 87 | #else 88 | #define GSL_ASSUME(cond) static_cast((cond) ? 0 : 0) 89 | #endif 90 | 91 | // 92 | // GSL.assert: assertions 93 | // 94 | 95 | namespace gsl 96 | { 97 | struct fail_fast : public std::logic_error 98 | { 99 | explicit fail_fast(char const* const message) : std::logic_error(message) {} 100 | }; 101 | 102 | namespace details 103 | { 104 | #if defined(GSL_MSVC_USE_STL_NOEXCEPTION_WORKAROUND) 105 | 106 | typedef void (__cdecl *terminate_handler)(); 107 | 108 | GSL_SUPPRESS(f.6) // NO-FORMAT: attribute 109 | [[noreturn]] inline void __cdecl default_terminate_handler() 110 | { 111 | __fastfail(RANGE_CHECKS_FAILURE); 112 | } 113 | 114 | inline gsl::details::terminate_handler& get_terminate_handler() noexcept 115 | { 116 | static terminate_handler handler = &default_terminate_handler; 117 | return handler; 118 | } 119 | 120 | #endif 121 | 122 | [[noreturn]] inline void terminate() noexcept 123 | { 124 | #if defined(GSL_MSVC_USE_STL_NOEXCEPTION_WORKAROUND) 125 | (*gsl::details::get_terminate_handler())(); 126 | #else 127 | std::terminate(); 128 | #endif 129 | } 130 | 131 | #if defined(GSL_TERMINATE_ON_CONTRACT_VIOLATION) 132 | 133 | template 134 | [[noreturn]] void throw_exception(Exception&&) noexcept 135 | { 136 | gsl::details::terminate(); 137 | } 138 | 139 | #else 140 | 141 | template 142 | [[noreturn]] void throw_exception(Exception&& exception) 143 | { 144 | throw std::forward(exception); 145 | } 146 | 147 | #endif // GSL_TERMINATE_ON_CONTRACT_VIOLATION 148 | 149 | } // namespace details 150 | } // namespace gsl 151 | 152 | #if defined(GSL_THROW_ON_CONTRACT_VIOLATION) 153 | 154 | #define GSL_CONTRACT_CHECK(type, cond) \ 155 | (GSL_LIKELY(cond) ? static_cast(0) \ 156 | : gsl::details::throw_exception(gsl::fail_fast( \ 157 | "GSL: " type " failure at " __FILE__ ": " GSL_STRINGIFY(__LINE__)))) 158 | 159 | #elif defined(GSL_TERMINATE_ON_CONTRACT_VIOLATION) 160 | 161 | #define GSL_CONTRACT_CHECK(type, cond) \ 162 | (GSL_LIKELY(cond) ? static_cast(0) : gsl::details::terminate()) 163 | 164 | #elif defined(GSL_UNENFORCED_ON_CONTRACT_VIOLATION) 165 | 166 | #define GSL_CONTRACT_CHECK(type, cond) GSL_ASSUME(cond) 167 | 168 | #endif // GSL_THROW_ON_CONTRACT_VIOLATION 169 | 170 | #define Expects(cond) GSL_CONTRACT_CHECK("Precondition", cond) 171 | #define Ensures(cond) GSL_CONTRACT_CHECK("Postcondition", cond) 172 | 173 | #if defined(GSL_MSVC_USE_STL_NOEXCEPTION_WORKAROUND) && defined(__clang__) 174 | #pragma clang diagnostic pop 175 | #endif 176 | 177 | #endif // GSL_CONTRACTS_H 178 | -------------------------------------------------------------------------------- /share/gsl/gsl_byte: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (c) 2015 Microsoft Corporation. All rights reserved. 4 | // 5 | // This code is licensed under the MIT License (MIT). 6 | // 7 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 8 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 9 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 10 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 11 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 12 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 13 | // THE SOFTWARE. 14 | // 15 | /////////////////////////////////////////////////////////////////////////////// 16 | 17 | #ifndef GSL_BYTE_H 18 | #define GSL_BYTE_H 19 | 20 | // 21 | // make suppress attributes work for some compilers 22 | // Hopefully temporary until suppression standardization occurs 23 | // 24 | #if defined(__clang__) 25 | #define GSL_SUPPRESS(x) [[gsl::suppress("x")]] 26 | #else 27 | #if defined(_MSC_VER) 28 | #define GSL_SUPPRESS(x) [[gsl::suppress(x)]] 29 | #else 30 | #define GSL_SUPPRESS(x) 31 | #endif // _MSC_VER 32 | #endif // __clang__ 33 | 34 | #include 35 | 36 | #ifdef _MSC_VER 37 | 38 | #pragma warning(push) 39 | 40 | // Turn MSVC /analyze rules that generate too much noise. TODO: fix in the tool. 41 | #pragma warning(disable : 26493) // don't use c-style casts // TODO: MSVC suppression in templates does not always work 42 | 43 | #ifndef GSL_USE_STD_BYTE 44 | // this tests if we are under MSVC and the standard lib has std::byte and it is enabled 45 | #if defined(_HAS_STD_BYTE) && _HAS_STD_BYTE 46 | 47 | #define GSL_USE_STD_BYTE 1 48 | 49 | #else // defined(_HAS_STD_BYTE) && _HAS_STD_BYTE 50 | 51 | #define GSL_USE_STD_BYTE 0 52 | 53 | #endif // defined(_HAS_STD_BYTE) && _HAS_STD_BYTE 54 | #endif // GSL_USE_STD_BYTE 55 | 56 | #else // _MSC_VER 57 | 58 | #ifndef GSL_USE_STD_BYTE 59 | // this tests if we are under GCC or Clang with enough -std:c++1z power to get us std::byte 60 | // also check if libc++ version is sufficient (> 5.0) or libstc++ actually contains std::byte 61 | #if defined(__cplusplus) && (__cplusplus >= 201703L) && \ 62 | (defined(__cpp_lib_byte) && (__cpp_lib_byte >= 201603) || \ 63 | defined(_LIBCPP_VERSION) && (_LIBCPP_VERSION >= 5000)) 64 | 65 | #define GSL_USE_STD_BYTE 1 66 | #include 67 | 68 | #else // defined(__cplusplus) && (__cplusplus >= 201703L) && 69 | // (defined(__cpp_lib_byte) && (__cpp_lib_byte >= 201603) || 70 | // defined(_LIBCPP_VERSION) && (_LIBCPP_VERSION >= 5000)) 71 | 72 | #define GSL_USE_STD_BYTE 0 73 | 74 | #endif //defined(__cplusplus) && (__cplusplus >= 201703L) && 75 | // (defined(__cpp_lib_byte) && (__cpp_lib_byte >= 201603) || 76 | // defined(_LIBCPP_VERSION) && (_LIBCPP_VERSION >= 5000)) 77 | #endif // GSL_USE_STD_BYTE 78 | 79 | #endif // _MSC_VER 80 | 81 | // Use __may_alias__ attribute on gcc and clang 82 | #if defined __clang__ || (defined(__GNUC__) && __GNUC__ > 5) 83 | #define byte_may_alias __attribute__((__may_alias__)) 84 | #else // defined __clang__ || defined __GNUC__ 85 | #define byte_may_alias 86 | #endif // defined __clang__ || defined __GNUC__ 87 | 88 | namespace gsl 89 | { 90 | #if GSL_USE_STD_BYTE 91 | 92 | using std::byte; 93 | using std::to_integer; 94 | 95 | #else // GSL_USE_STD_BYTE 96 | 97 | // This is a simple definition for now that allows 98 | // use of byte within span<> to be standards-compliant 99 | enum class byte_may_alias byte : unsigned char 100 | { 101 | }; 102 | 103 | template ::value>> 104 | constexpr byte& operator<<=(byte& b, IntegerType shift) noexcept 105 | { 106 | return b = byte(static_cast(b) << shift); 107 | } 108 | 109 | template ::value>> 110 | constexpr byte operator<<(byte b, IntegerType shift) noexcept 111 | { 112 | return byte(static_cast(b) << shift); 113 | } 114 | 115 | template ::value>> 116 | constexpr byte& operator>>=(byte& b, IntegerType shift) noexcept 117 | { 118 | return b = byte(static_cast(b) >> shift); 119 | } 120 | 121 | template ::value>> 122 | constexpr byte operator>>(byte b, IntegerType shift) noexcept 123 | { 124 | return byte(static_cast(b) >> shift); 125 | } 126 | 127 | constexpr byte& operator|=(byte& l, byte r) noexcept 128 | { 129 | return l = byte(static_cast(l) | static_cast(r)); 130 | } 131 | 132 | constexpr byte operator|(byte l, byte r) noexcept 133 | { 134 | return byte(static_cast(l) | static_cast(r)); 135 | } 136 | 137 | constexpr byte& operator&=(byte& l, byte r) noexcept 138 | { 139 | return l = byte(static_cast(l) & static_cast(r)); 140 | } 141 | 142 | constexpr byte operator&(byte l, byte r) noexcept 143 | { 144 | return byte(static_cast(l) & static_cast(r)); 145 | } 146 | 147 | constexpr byte& operator^=(byte& l, byte r) noexcept 148 | { 149 | return l = byte(static_cast(l) ^ static_cast(r)); 150 | } 151 | 152 | constexpr byte operator^(byte l, byte r) noexcept 153 | { 154 | return byte(static_cast(l) ^ static_cast(r)); 155 | } 156 | 157 | constexpr byte operator~(byte b) noexcept { return byte(~static_cast(b)); } 158 | 159 | template ::value>> 160 | constexpr IntegerType to_integer(byte b) noexcept 161 | { 162 | return static_cast(b); 163 | } 164 | 165 | #endif // GSL_USE_STD_BYTE 166 | 167 | template 168 | constexpr byte to_byte_impl(T t) noexcept 169 | { 170 | static_assert( 171 | E, "gsl::to_byte(t) must be provided an unsigned char, otherwise data loss may occur. " 172 | "If you are calling to_byte with an integer contant use: gsl::to_byte() version."); 173 | return static_cast(t); 174 | } 175 | template <> 176 | // NOTE: need suppression since c++14 does not allow "return {t}" 177 | // GSL_SUPPRESS(type.4) // NO-FORMAT: attribute // TODO: suppression does not work 178 | constexpr byte to_byte_impl(unsigned char t) noexcept 179 | { 180 | return byte(t); 181 | } 182 | 183 | template 184 | constexpr byte to_byte(T t) noexcept 185 | { 186 | return to_byte_impl::value, T>(t); 187 | } 188 | 189 | template 190 | constexpr byte to_byte() noexcept 191 | { 192 | static_assert(I >= 0 && I <= 255, 193 | "gsl::byte only has 8 bits of storage, values must be in range 0-255"); 194 | return static_cast(I); 195 | } 196 | 197 | } // namespace gsl 198 | 199 | #ifdef _MSC_VER 200 | #pragma warning(pop) 201 | #endif // _MSC_VER 202 | 203 | #endif // GSL_BYTE_H 204 | -------------------------------------------------------------------------------- /share/gsl/gsl_util: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (c) 2015 Microsoft Corporation. All rights reserved. 4 | // 5 | // This code is licensed under the MIT License (MIT). 6 | // 7 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 8 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 9 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 10 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 11 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 12 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 13 | // THE SOFTWARE. 14 | // 15 | /////////////////////////////////////////////////////////////////////////////// 16 | 17 | #ifndef GSL_UTIL_H 18 | #define GSL_UTIL_H 19 | 20 | #include // for Expects 21 | 22 | #include 23 | #include // for ptrdiff_t, size_t 24 | #include // for exception 25 | #include // for initializer_list 26 | #include // for is_signed, integral_constant 27 | #include // for forward 28 | 29 | #if defined(_MSC_VER) && !defined(__clang__) 30 | 31 | #pragma warning(push) 32 | #pragma warning(disable : 4127) // conditional expression is constant 33 | 34 | #if _MSC_VER < 1910 35 | #pragma push_macro("constexpr") 36 | #define constexpr /*constexpr*/ 37 | #endif // _MSC_VER < 1910 38 | #endif // _MSC_VER 39 | 40 | #if (defined(_MSC_VER) && _MSC_VER < 1910) || (!defined(__clang__) && defined(__GNUC__) && __GUNC__ < 6) 41 | #define GSL_CONSTEXPR_NARROW 0 42 | #else 43 | #define GSL_CONSTEXPR_NARROW 1 44 | #endif 45 | 46 | namespace gsl 47 | { 48 | // 49 | // GSL.util: utilities 50 | // 51 | 52 | // index type for all container indexes/subscripts/sizes 53 | using index = std::ptrdiff_t; 54 | 55 | // final_action allows you to ensure something gets run at the end of a scope 56 | template 57 | class final_action 58 | { 59 | public: 60 | explicit final_action(F f) noexcept : f_(std::move(f)) {} 61 | 62 | final_action(final_action&& other) noexcept : f_(std::move(other.f_)), invoke_(other.invoke_) 63 | { 64 | other.invoke_ = false; 65 | } 66 | 67 | final_action(const final_action&) = delete; 68 | final_action& operator=(const final_action&) = delete; 69 | final_action& operator=(final_action&&) = delete; 70 | 71 | GSL_SUPPRESS(f.6) // NO-FORMAT: attribute // terminate if throws 72 | ~final_action() noexcept 73 | { 74 | if (invoke_) f_(); 75 | } 76 | 77 | private: 78 | F f_; 79 | bool invoke_{true}; 80 | }; 81 | 82 | // finally() - convenience function to generate a final_action 83 | template 84 | final_action finally(const F& f) noexcept 85 | { 86 | return final_action(f); 87 | } 88 | 89 | template 90 | final_action finally(F&& f) noexcept 91 | { 92 | return final_action(std::forward(f)); 93 | } 94 | 95 | // narrow_cast(): a searchable way to do narrowing casts of values 96 | template 97 | GSL_SUPPRESS(type.1) // NO-FORMAT: attribute 98 | constexpr T narrow_cast(U&& u) noexcept 99 | { 100 | return static_cast(std::forward(u)); 101 | } 102 | 103 | struct narrowing_error : public std::exception 104 | { 105 | }; 106 | 107 | namespace details 108 | { 109 | template 110 | struct is_same_signedness 111 | : public std::integral_constant::value == std::is_signed::value> 112 | { 113 | }; 114 | } // namespace details 115 | 116 | // narrow() : a checked version of narrow_cast() that throws if the cast changed the value 117 | template 118 | GSL_SUPPRESS(type.1) // NO-FORMAT: attribute 119 | GSL_SUPPRESS(f.6) // NO-FORMAT: attribute // TODO: MSVC /analyze does not recognise noexcept(false) 120 | #if GSL_CONSTEXPR_NARROW 121 | constexpr 122 | #endif 123 | T narrow(U u) noexcept(false) 124 | { 125 | T t = narrow_cast(u); 126 | if (static_cast(t) != u) gsl::details::throw_exception(narrowing_error()); 127 | if (!details::is_same_signedness::value && ((t < T{}) != (u < U{}))) 128 | gsl::details::throw_exception(narrowing_error()); 129 | return t; 130 | } 131 | 132 | // 133 | // at() - Bounds-checked way of accessing builtin arrays, std::array, std::vector 134 | // 135 | template 136 | GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute 137 | GSL_SUPPRESS(bounds.2) // NO-FORMAT: attribute 138 | constexpr T& at(T (&arr)[N], const index i) 139 | { 140 | Expects(i >= 0 && i < narrow_cast(N)); 141 | return arr[narrow_cast(i)]; 142 | } 143 | 144 | template 145 | GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute 146 | GSL_SUPPRESS(bounds.2) // NO-FORMAT: attribute 147 | constexpr auto at(Cont& cont, const index i) -> decltype(cont[cont.size()]) 148 | { 149 | Expects(i >= 0 && i < narrow_cast(cont.size())); 150 | using size_type = decltype(cont.size()); 151 | return cont[narrow_cast(i)]; 152 | } 153 | 154 | template 155 | GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute 156 | constexpr T at(const std::initializer_list cont, const index i) 157 | { 158 | Expects(i >= 0 && i < narrow_cast(cont.size())); 159 | return *(cont.begin() + i); 160 | } 161 | 162 | } // namespace gsl 163 | 164 | #if defined(_MSC_VER) && !defined(__clang__) 165 | #if _MSC_VER < 1910 166 | #undef constexpr 167 | #pragma pop_macro("constexpr") 168 | 169 | #endif // _MSC_VER < 1910 170 | 171 | #pragma warning(pop) 172 | 173 | #endif // _MSC_VER 174 | 175 | #endif // GSL_UTIL_H 176 | -------------------------------------------------------------------------------- /share/gsl/pointers: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (c) 2015 Microsoft Corporation. All rights reserved. 4 | // 5 | // This code is licensed under the MIT License (MIT). 6 | // 7 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 8 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 9 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 10 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 11 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 12 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 13 | // THE SOFTWARE. 14 | // 15 | /////////////////////////////////////////////////////////////////////////////// 16 | 17 | #ifndef GSL_POINTERS_H 18 | #define GSL_POINTERS_H 19 | 20 | #include // for Ensures, Expects 21 | 22 | #include // for forward 23 | #include // for ptrdiff_t, nullptr_t, ostream, size_t 24 | #include // for shared_ptr, unique_ptr 25 | #include // for hash 26 | #include // for enable_if_t, is_convertible, is_assignable 27 | 28 | #if defined(_MSC_VER) && _MSC_VER < 1910 && !defined(__clang__) 29 | #pragma push_macro("constexpr") 30 | #define constexpr /*constexpr*/ 31 | 32 | #endif // defined(_MSC_VER) && _MSC_VER < 1910 33 | 34 | namespace gsl 35 | { 36 | 37 | // 38 | // GSL.owner: ownership pointers 39 | // 40 | using std::unique_ptr; 41 | using std::shared_ptr; 42 | 43 | // 44 | // owner 45 | // 46 | // owner is designed as a bridge for code that must deal directly with owning pointers for some reason 47 | // 48 | // T must be a pointer type 49 | // - disallow construction from any type other than pointer type 50 | // 51 | template ::value>> 52 | using owner = T; 53 | 54 | // 55 | // not_null 56 | // 57 | // Restricts a pointer or smart pointer to only hold non-null values. 58 | // 59 | // Has zero size overhead over T. 60 | // 61 | // If T is a pointer (i.e. T == U*) then 62 | // - allow construction from U* 63 | // - disallow construction from nullptr_t 64 | // - disallow default construction 65 | // - ensure construction from null U* fails 66 | // - allow implicit conversion to U* 67 | // 68 | template 69 | class not_null 70 | { 71 | public: 72 | static_assert(std::is_assignable::value, "T cannot be assigned nullptr."); 73 | 74 | template ::value>> 75 | constexpr not_null(U&& u) : ptr_(std::forward(u)) 76 | { 77 | Expects(ptr_ != nullptr); 78 | } 79 | 80 | template ::value>> 81 | constexpr not_null(T u) : ptr_(u) 82 | { 83 | Expects(ptr_ != nullptr); 84 | } 85 | 86 | template ::value>> 87 | constexpr not_null(const not_null& other) : not_null(other.get()) 88 | { 89 | } 90 | 91 | not_null(not_null&& other) = default; 92 | not_null(const not_null& other) = default; 93 | not_null& operator=(const not_null& other) = default; 94 | 95 | constexpr T get() const 96 | { 97 | Ensures(ptr_ != nullptr); 98 | return ptr_; 99 | } 100 | 101 | constexpr operator T() const { return get(); } 102 | constexpr T operator->() const { return get(); } 103 | constexpr decltype(auto) operator*() const { return *get(); } 104 | 105 | // prevents compilation when someone attempts to assign a null pointer constant 106 | not_null(std::nullptr_t) = delete; 107 | not_null& operator=(std::nullptr_t) = delete; 108 | 109 | // unwanted operators...pointers only point to single objects! 110 | not_null& operator++() = delete; 111 | not_null& operator--() = delete; 112 | not_null operator++(int) = delete; 113 | not_null operator--(int) = delete; 114 | not_null& operator+=(std::ptrdiff_t) = delete; 115 | not_null& operator-=(std::ptrdiff_t) = delete; 116 | void operator[](std::ptrdiff_t) const = delete; 117 | 118 | private: 119 | T ptr_; 120 | }; 121 | 122 | template 123 | auto make_not_null(T&& t) { 124 | return not_null>>{std::forward(t)}; 125 | } 126 | 127 | template 128 | std::ostream& operator<<(std::ostream& os, const not_null& val) 129 | { 130 | os << val.get(); 131 | return os; 132 | } 133 | 134 | template 135 | auto operator==(const not_null& lhs, const not_null& rhs) -> decltype(lhs.get() == rhs.get()) 136 | { 137 | return lhs.get() == rhs.get(); 138 | } 139 | 140 | template 141 | auto operator!=(const not_null& lhs, const not_null& rhs) -> decltype(lhs.get() != rhs.get()) 142 | { 143 | return lhs.get() != rhs.get(); 144 | } 145 | 146 | template 147 | auto operator<(const not_null& lhs, const not_null& rhs) -> decltype(lhs.get() < rhs.get()) 148 | { 149 | return lhs.get() < rhs.get(); 150 | } 151 | 152 | template 153 | auto operator<=(const not_null& lhs, const not_null& rhs) -> decltype(lhs.get() <= rhs.get()) 154 | { 155 | return lhs.get() <= rhs.get(); 156 | } 157 | 158 | template 159 | auto operator>(const not_null& lhs, const not_null& rhs) -> decltype(lhs.get() > rhs.get()) 160 | { 161 | return lhs.get() > rhs.get(); 162 | } 163 | 164 | template 165 | auto operator>=(const not_null& lhs, const not_null& rhs) -> decltype(lhs.get() >= rhs.get()) 166 | { 167 | return lhs.get() >= rhs.get(); 168 | } 169 | 170 | // more unwanted operators 171 | template 172 | std::ptrdiff_t operator-(const not_null&, const not_null&) = delete; 173 | template 174 | not_null operator-(const not_null&, std::ptrdiff_t) = delete; 175 | template 176 | not_null operator+(const not_null&, std::ptrdiff_t) = delete; 177 | template 178 | not_null operator+(std::ptrdiff_t, const not_null&) = delete; 179 | 180 | } // namespace gsl 181 | 182 | namespace std 183 | { 184 | template 185 | struct hash> 186 | { 187 | std::size_t operator()(const gsl::not_null& value) const { return hash{}(value); } 188 | }; 189 | 190 | } // namespace std 191 | 192 | namespace gsl 193 | { 194 | 195 | // 196 | // strict_not_null 197 | // 198 | // Restricts a pointer or smart pointer to only hold non-null values, 199 | // 200 | // - provides a strict (i.e. explicit contructor from T) wrapper of not_null 201 | // - to be used for new code that wishes the design to be cleaner and make not_null 202 | // checks intentional, or in old code that would like to make the transition. 203 | // 204 | // To make the transition from not_null, incrementally replace not_null 205 | // by strict_not_null and fix compilation errors 206 | // 207 | // Expect to 208 | // - remove all unneded conversions from raw pointer to not_null and back 209 | // - make API clear by specifyning not_null in parameters where needed 210 | // - remove unnesessary asserts 211 | // 212 | template 213 | class strict_not_null: public not_null 214 | { 215 | public: 216 | 217 | template ::value>> 218 | constexpr explicit strict_not_null(U&& u) : 219 | not_null(std::forward(u)) 220 | {} 221 | 222 | template ::value>> 223 | constexpr explicit strict_not_null(T u) : 224 | not_null(u) 225 | {} 226 | 227 | template ::value>> 228 | constexpr strict_not_null(const not_null& other) : 229 | not_null(other) 230 | {} 231 | 232 | template ::value>> 233 | constexpr strict_not_null(const strict_not_null& other) : 234 | not_null(other) 235 | {} 236 | 237 | strict_not_null(strict_not_null&& other) = default; 238 | strict_not_null(const strict_not_null& other) = default; 239 | strict_not_null& operator=(const strict_not_null& other) = default; 240 | strict_not_null& operator=(const not_null& other) 241 | { 242 | not_null::operator=(other); 243 | return *this; 244 | } 245 | 246 | // prevents compilation when someone attempts to assign a null pointer constant 247 | strict_not_null(std::nullptr_t) = delete; 248 | strict_not_null& operator=(std::nullptr_t) = delete; 249 | 250 | // unwanted operators...pointers only point to single objects! 251 | strict_not_null& operator++() = delete; 252 | strict_not_null& operator--() = delete; 253 | strict_not_null operator++(int) = delete; 254 | strict_not_null operator--(int) = delete; 255 | strict_not_null& operator+=(std::ptrdiff_t) = delete; 256 | strict_not_null& operator-=(std::ptrdiff_t) = delete; 257 | void operator[](std::ptrdiff_t) const = delete; 258 | }; 259 | 260 | // more unwanted operators 261 | template 262 | std::ptrdiff_t operator-(const strict_not_null&, const strict_not_null&) = delete; 263 | template 264 | strict_not_null operator-(const strict_not_null&, std::ptrdiff_t) = delete; 265 | template 266 | strict_not_null operator+(const strict_not_null&, std::ptrdiff_t) = delete; 267 | template 268 | strict_not_null operator+(std::ptrdiff_t, const strict_not_null&) = delete; 269 | 270 | template 271 | auto make_strict_not_null(T&& t) { 272 | return strict_not_null>>{std::forward(t)}; 273 | } 274 | 275 | } // namespace gsl 276 | 277 | namespace std 278 | { 279 | template 280 | struct hash> 281 | { 282 | std::size_t operator()(const gsl::strict_not_null& value) const { return hash{}(value); } 283 | }; 284 | 285 | } // namespace std 286 | 287 | #if defined(_MSC_VER) && _MSC_VER < 1910 && !defined(__clang__) 288 | 289 | #undef constexpr 290 | #pragma pop_macro("constexpr") 291 | 292 | #endif // defined(_MSC_VER) && _MSC_VER < 1910 && !defined(__clang__) 293 | 294 | #endif // GSL_POINTERS_H 295 | -------------------------------------------------------------------------------- /share/nlohmann/LICENSE.MIT: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2013-2019 Niels Lohmann 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /share/nlohmann/adl_serializer.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | namespace nlohmann 9 | { 10 | 11 | template 12 | struct adl_serializer 13 | { 14 | /*! 15 | @brief convert a JSON value to any value type 16 | 17 | This function is usually called by the `get()` function of the 18 | @ref basic_json class (either explicit or via conversion operators). 19 | 20 | @param[in] j JSON value to read from 21 | @param[in,out] val value to write to 22 | */ 23 | template 24 | static auto from_json(BasicJsonType&& j, ValueType& val) noexcept( 25 | noexcept(::nlohmann::from_json(std::forward(j), val))) 26 | -> decltype(::nlohmann::from_json(std::forward(j), val), void()) 27 | { 28 | ::nlohmann::from_json(std::forward(j), val); 29 | } 30 | 31 | /*! 32 | @brief convert any value type to a JSON value 33 | 34 | This function is usually called by the constructors of the @ref basic_json 35 | class. 36 | 37 | @param[in,out] j JSON value to write to 38 | @param[in] val value to read from 39 | */ 40 | template 41 | static auto to_json(BasicJsonType& j, ValueType&& val) noexcept( 42 | noexcept(::nlohmann::to_json(j, std::forward(val)))) 43 | -> decltype(::nlohmann::to_json(j, std::forward(val)), void()) 44 | { 45 | ::nlohmann::to_json(j, std::forward(val)); 46 | } 47 | }; 48 | 49 | } // namespace nlohmann 50 | -------------------------------------------------------------------------------- /share/nlohmann/detail/conversions/to_json.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include // copy 4 | #include // or, and, not 5 | #include // begin, end 6 | #include // string 7 | #include // tuple, get 8 | #include // is_same, is_constructible, is_floating_point, is_enum, underlying_type 9 | #include // move, forward, declval, pair 10 | #include // valarray 11 | #include // vector 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | namespace nlohmann 19 | { 20 | namespace detail 21 | { 22 | ////////////////// 23 | // constructors // 24 | ////////////////// 25 | 26 | template struct external_constructor; 27 | 28 | template<> 29 | struct external_constructor 30 | { 31 | template 32 | static void construct(BasicJsonType& j, typename BasicJsonType::boolean_t b) noexcept 33 | { 34 | j.m_type = value_t::boolean; 35 | j.m_value = b; 36 | j.assert_invariant(); 37 | } 38 | }; 39 | 40 | template<> 41 | struct external_constructor 42 | { 43 | template 44 | static void construct(BasicJsonType& j, const typename BasicJsonType::string_t& s) 45 | { 46 | j.m_type = value_t::string; 47 | j.m_value = s; 48 | j.assert_invariant(); 49 | } 50 | 51 | template 52 | static void construct(BasicJsonType& j, typename BasicJsonType::string_t&& s) 53 | { 54 | j.m_type = value_t::string; 55 | j.m_value = std::move(s); 56 | j.assert_invariant(); 57 | } 58 | 59 | template::value, 61 | int> = 0> 62 | static void construct(BasicJsonType& j, const CompatibleStringType& str) 63 | { 64 | j.m_type = value_t::string; 65 | j.m_value.string = j.template create(str); 66 | j.assert_invariant(); 67 | } 68 | }; 69 | 70 | template<> 71 | struct external_constructor 72 | { 73 | template 74 | static void construct(BasicJsonType& j, typename BasicJsonType::number_float_t val) noexcept 75 | { 76 | j.m_type = value_t::number_float; 77 | j.m_value = val; 78 | j.assert_invariant(); 79 | } 80 | }; 81 | 82 | template<> 83 | struct external_constructor 84 | { 85 | template 86 | static void construct(BasicJsonType& j, typename BasicJsonType::number_unsigned_t val) noexcept 87 | { 88 | j.m_type = value_t::number_unsigned; 89 | j.m_value = val; 90 | j.assert_invariant(); 91 | } 92 | }; 93 | 94 | template<> 95 | struct external_constructor 96 | { 97 | template 98 | static void construct(BasicJsonType& j, typename BasicJsonType::number_integer_t val) noexcept 99 | { 100 | j.m_type = value_t::number_integer; 101 | j.m_value = val; 102 | j.assert_invariant(); 103 | } 104 | }; 105 | 106 | template<> 107 | struct external_constructor 108 | { 109 | template 110 | static void construct(BasicJsonType& j, const typename BasicJsonType::array_t& arr) 111 | { 112 | j.m_type = value_t::array; 113 | j.m_value = arr; 114 | j.assert_invariant(); 115 | } 116 | 117 | template 118 | static void construct(BasicJsonType& j, typename BasicJsonType::array_t&& arr) 119 | { 120 | j.m_type = value_t::array; 121 | j.m_value = std::move(arr); 122 | j.assert_invariant(); 123 | } 124 | 125 | template::value, 127 | int> = 0> 128 | static void construct(BasicJsonType& j, const CompatibleArrayType& arr) 129 | { 130 | using std::begin; 131 | using std::end; 132 | j.m_type = value_t::array; 133 | j.m_value.array = j.template create(begin(arr), end(arr)); 134 | j.assert_invariant(); 135 | } 136 | 137 | template 138 | static void construct(BasicJsonType& j, const std::vector& arr) 139 | { 140 | j.m_type = value_t::array; 141 | j.m_value = value_t::array; 142 | j.m_value.array->reserve(arr.size()); 143 | for (const bool x : arr) 144 | { 145 | j.m_value.array->push_back(x); 146 | } 147 | j.assert_invariant(); 148 | } 149 | 150 | template::value, int> = 0> 152 | static void construct(BasicJsonType& j, const std::valarray& arr) 153 | { 154 | j.m_type = value_t::array; 155 | j.m_value = value_t::array; 156 | j.m_value.array->resize(arr.size()); 157 | std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin()); 158 | j.assert_invariant(); 159 | } 160 | }; 161 | 162 | template<> 163 | struct external_constructor 164 | { 165 | template 166 | static void construct(BasicJsonType& j, const typename BasicJsonType::object_t& obj) 167 | { 168 | j.m_type = value_t::object; 169 | j.m_value = obj; 170 | j.assert_invariant(); 171 | } 172 | 173 | template 174 | static void construct(BasicJsonType& j, typename BasicJsonType::object_t&& obj) 175 | { 176 | j.m_type = value_t::object; 177 | j.m_value = std::move(obj); 178 | j.assert_invariant(); 179 | } 180 | 181 | template::value, int> = 0> 183 | static void construct(BasicJsonType& j, const CompatibleObjectType& obj) 184 | { 185 | using std::begin; 186 | using std::end; 187 | 188 | j.m_type = value_t::object; 189 | j.m_value.object = j.template create(begin(obj), end(obj)); 190 | j.assert_invariant(); 191 | } 192 | }; 193 | 194 | ///////////// 195 | // to_json // 196 | ///////////// 197 | 198 | template::value, int> = 0> 200 | void to_json(BasicJsonType& j, T b) noexcept 201 | { 202 | external_constructor::construct(j, b); 203 | } 204 | 205 | template::value, int> = 0> 207 | void to_json(BasicJsonType& j, const CompatibleString& s) 208 | { 209 | external_constructor::construct(j, s); 210 | } 211 | 212 | template 213 | void to_json(BasicJsonType& j, typename BasicJsonType::string_t&& s) 214 | { 215 | external_constructor::construct(j, std::move(s)); 216 | } 217 | 218 | template::value, int> = 0> 220 | void to_json(BasicJsonType& j, FloatType val) noexcept 221 | { 222 | external_constructor::construct(j, static_cast(val)); 223 | } 224 | 225 | template::value, int> = 0> 227 | void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val) noexcept 228 | { 229 | external_constructor::construct(j, static_cast(val)); 230 | } 231 | 232 | template::value, int> = 0> 234 | void to_json(BasicJsonType& j, CompatibleNumberIntegerType val) noexcept 235 | { 236 | external_constructor::construct(j, static_cast(val)); 237 | } 238 | 239 | template::value, int> = 0> 241 | void to_json(BasicJsonType& j, EnumType e) noexcept 242 | { 243 | using underlying_type = typename std::underlying_type::type; 244 | external_constructor::construct(j, static_cast(e)); 245 | } 246 | 247 | template 248 | void to_json(BasicJsonType& j, const std::vector& e) 249 | { 250 | external_constructor::construct(j, e); 251 | } 252 | 253 | template ::value and 256 | not is_compatible_object_type< 257 | BasicJsonType, CompatibleArrayType>::value and 258 | not is_compatible_string_type::value and 259 | not is_basic_json::value, 260 | int> = 0> 261 | void to_json(BasicJsonType& j, const CompatibleArrayType& arr) 262 | { 263 | external_constructor::construct(j, arr); 264 | } 265 | 266 | template::value, int> = 0> 268 | void to_json(BasicJsonType& j, const std::valarray& arr) 269 | { 270 | external_constructor::construct(j, std::move(arr)); 271 | } 272 | 273 | template 274 | void to_json(BasicJsonType& j, typename BasicJsonType::array_t&& arr) 275 | { 276 | external_constructor::construct(j, std::move(arr)); 277 | } 278 | 279 | template::value and not is_basic_json::value, int> = 0> 281 | void to_json(BasicJsonType& j, const CompatibleObjectType& obj) 282 | { 283 | external_constructor::construct(j, obj); 284 | } 285 | 286 | template 287 | void to_json(BasicJsonType& j, typename BasicJsonType::object_t&& obj) 288 | { 289 | external_constructor::construct(j, std::move(obj)); 290 | } 291 | 292 | template < 293 | typename BasicJsonType, typename T, std::size_t N, 294 | enable_if_t::value, 296 | int> = 0 > 297 | void to_json(BasicJsonType& j, const T(&arr)[N]) 298 | { 299 | external_constructor::construct(j, arr); 300 | } 301 | 302 | template 303 | void to_json(BasicJsonType& j, const std::pair& p) 304 | { 305 | j = { p.first, p.second }; 306 | } 307 | 308 | // for https://github.com/nlohmann/json/pull/1134 309 | template < typename BasicJsonType, typename T, 310 | enable_if_t>::value, int> = 0> 311 | void to_json(BasicJsonType& j, const T& b) 312 | { 313 | j = { {b.key(), b.value()} }; 314 | } 315 | 316 | template 317 | void to_json_tuple_impl(BasicJsonType& j, const Tuple& t, index_sequence /*unused*/) 318 | { 319 | j = { std::get(t)... }; 320 | } 321 | 322 | template 323 | void to_json(BasicJsonType& j, const std::tuple& t) 324 | { 325 | to_json_tuple_impl(j, t, index_sequence_for {}); 326 | } 327 | 328 | struct to_json_fn 329 | { 330 | template 331 | auto operator()(BasicJsonType& j, T&& val) const noexcept(noexcept(to_json(j, std::forward(val)))) 332 | -> decltype(to_json(j, std::forward(val)), void()) 333 | { 334 | return to_json(j, std::forward(val)); 335 | } 336 | }; 337 | } // namespace detail 338 | 339 | /// namespace to hold default `to_json` function 340 | namespace 341 | { 342 | constexpr const auto& to_json = detail::static_const::value; 343 | } // namespace 344 | } // namespace nlohmann 345 | -------------------------------------------------------------------------------- /share/nlohmann/detail/input/position_t.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include // size_t 4 | 5 | namespace nlohmann 6 | { 7 | namespace detail 8 | { 9 | /// struct to capture the start position of the current token 10 | struct position_t 11 | { 12 | /// the total number of characters read 13 | std::size_t chars_read_total = 0; 14 | /// the number of characters read in the current line 15 | std::size_t chars_read_current_line = 0; 16 | /// the number of lines read 17 | std::size_t lines_read = 0; 18 | 19 | /// conversion to size_t to preserve SAX interface 20 | constexpr operator size_t() const 21 | { 22 | return chars_read_total; 23 | } 24 | }; 25 | 26 | } // namespace detail 27 | } // namespace nlohmann 28 | -------------------------------------------------------------------------------- /share/nlohmann/detail/iterators/internal_iterator.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace nlohmann 6 | { 7 | namespace detail 8 | { 9 | /*! 10 | @brief an iterator value 11 | 12 | @note This structure could easily be a union, but MSVC currently does not allow 13 | unions members with complex constructors, see https://github.com/nlohmann/json/pull/105. 14 | */ 15 | template struct internal_iterator 16 | { 17 | /// iterator for JSON objects 18 | typename BasicJsonType::object_t::iterator object_iterator {}; 19 | /// iterator for JSON arrays 20 | typename BasicJsonType::array_t::iterator array_iterator {}; 21 | /// generic iterator for all other types 22 | primitive_iterator_t primitive_iterator {}; 23 | }; 24 | } // namespace detail 25 | } // namespace nlohmann 26 | -------------------------------------------------------------------------------- /share/nlohmann/detail/iterators/iteration_proxy.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include // size_t 4 | #include // input_iterator_tag 5 | #include // string, to_string 6 | #include // tuple_size, get, tuple_element 7 | 8 | #include 9 | #include 10 | 11 | namespace nlohmann 12 | { 13 | namespace detail 14 | { 15 | template class iteration_proxy_value 16 | { 17 | public: 18 | using difference_type = std::ptrdiff_t; 19 | using value_type = iteration_proxy_value; 20 | using pointer = value_type * ; 21 | using reference = value_type & ; 22 | using iterator_category = std::input_iterator_tag; 23 | 24 | private: 25 | /// the iterator 26 | IteratorType anchor; 27 | /// an index for arrays (used to create key names) 28 | std::size_t array_index = 0; 29 | /// last stringified array index 30 | mutable std::size_t array_index_last = 0; 31 | /// a string representation of the array index 32 | mutable std::string array_index_str = "0"; 33 | /// an empty string (to return a reference for primitive values) 34 | const std::string empty_str = ""; 35 | 36 | public: 37 | explicit iteration_proxy_value(IteratorType it) noexcept : anchor(it) {} 38 | 39 | /// dereference operator (needed for range-based for) 40 | iteration_proxy_value& operator*() 41 | { 42 | return *this; 43 | } 44 | 45 | /// increment operator (needed for range-based for) 46 | iteration_proxy_value& operator++() 47 | { 48 | ++anchor; 49 | ++array_index; 50 | 51 | return *this; 52 | } 53 | 54 | /// equality operator (needed for InputIterator) 55 | bool operator==(const iteration_proxy_value& o) const 56 | { 57 | return anchor == o.anchor; 58 | } 59 | 60 | /// inequality operator (needed for range-based for) 61 | bool operator!=(const iteration_proxy_value& o) const 62 | { 63 | return anchor != o.anchor; 64 | } 65 | 66 | /// return key of the iterator 67 | const std::string& key() const 68 | { 69 | assert(anchor.m_object != nullptr); 70 | 71 | switch (anchor.m_object->type()) 72 | { 73 | // use integer array index as key 74 | case value_t::array: 75 | { 76 | if (array_index != array_index_last) 77 | { 78 | array_index_str = std::to_string(array_index); 79 | array_index_last = array_index; 80 | } 81 | return array_index_str; 82 | } 83 | 84 | // use key from the object 85 | case value_t::object: 86 | return anchor.key(); 87 | 88 | // use an empty key for all primitive types 89 | default: 90 | return empty_str; 91 | } 92 | } 93 | 94 | /// return value of the iterator 95 | typename IteratorType::reference value() const 96 | { 97 | return anchor.value(); 98 | } 99 | }; 100 | 101 | /// proxy class for the items() function 102 | template class iteration_proxy 103 | { 104 | private: 105 | /// the container to iterate 106 | typename IteratorType::reference container; 107 | 108 | public: 109 | /// construct iteration proxy from a container 110 | explicit iteration_proxy(typename IteratorType::reference cont) noexcept 111 | : container(cont) {} 112 | 113 | /// return iterator begin (needed for range-based for) 114 | iteration_proxy_value begin() noexcept 115 | { 116 | return iteration_proxy_value(container.begin()); 117 | } 118 | 119 | /// return iterator end (needed for range-based for) 120 | iteration_proxy_value end() noexcept 121 | { 122 | return iteration_proxy_value(container.end()); 123 | } 124 | }; 125 | // Structured Bindings Support 126 | // For further reference see https://blog.tartanllama.xyz/structured-bindings/ 127 | // And see https://github.com/nlohmann/json/pull/1391 128 | template = 0> 129 | auto get(const nlohmann::detail::iteration_proxy_value& i) -> decltype(i.key()) 130 | { 131 | return i.key(); 132 | } 133 | // Structured Bindings Support 134 | // For further reference see https://blog.tartanllama.xyz/structured-bindings/ 135 | // And see https://github.com/nlohmann/json/pull/1391 136 | template = 0> 137 | auto get(const nlohmann::detail::iteration_proxy_value& i) -> decltype(i.value()) 138 | { 139 | return i.value(); 140 | } 141 | } // namespace detail 142 | } // namespace nlohmann 143 | 144 | // The Addition to the STD Namespace is required to add 145 | // Structured Bindings Support to the iteration_proxy_value class 146 | // For further reference see https://blog.tartanllama.xyz/structured-bindings/ 147 | // And see https://github.com/nlohmann/json/pull/1391 148 | namespace std 149 | { 150 | #if defined(__clang__) 151 | // Fix: https://github.com/nlohmann/json/issues/1401 152 | #pragma clang diagnostic push 153 | #pragma clang diagnostic ignored "-Wmismatched-tags" 154 | #endif 155 | template 156 | class tuple_size<::nlohmann::detail::iteration_proxy_value> 157 | : public std::integral_constant {}; 158 | 159 | template 160 | class tuple_element> 161 | { 162 | public: 163 | using type = decltype( 164 | get(std::declval < 165 | ::nlohmann::detail::iteration_proxy_value> ())); 166 | }; 167 | #if defined(__clang__) 168 | #pragma clang diagnostic pop 169 | #endif 170 | } // namespace std 171 | -------------------------------------------------------------------------------- /share/nlohmann/detail/iterators/iterator_traits.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include // random_access_iterator_tag 4 | 5 | #include 6 | #include 7 | 8 | namespace nlohmann 9 | { 10 | namespace detail 11 | { 12 | template 13 | struct iterator_types {}; 14 | 15 | template 16 | struct iterator_types < 17 | It, 18 | void_t> 20 | { 21 | using difference_type = typename It::difference_type; 22 | using value_type = typename It::value_type; 23 | using pointer = typename It::pointer; 24 | using reference = typename It::reference; 25 | using iterator_category = typename It::iterator_category; 26 | }; 27 | 28 | // This is required as some compilers implement std::iterator_traits in a way that 29 | // doesn't work with SFINAE. See https://github.com/nlohmann/json/issues/1341. 30 | template 31 | struct iterator_traits 32 | { 33 | }; 34 | 35 | template 36 | struct iterator_traits < T, enable_if_t < !std::is_pointer::value >> 37 | : iterator_types 38 | { 39 | }; 40 | 41 | template 42 | struct iterator_traits::value>> 43 | { 44 | using iterator_category = std::random_access_iterator_tag; 45 | using value_type = T; 46 | using difference_type = ptrdiff_t; 47 | using pointer = T*; 48 | using reference = T&; 49 | }; 50 | } // namespace detail 51 | } // namespace nlohmann 52 | -------------------------------------------------------------------------------- /share/nlohmann/detail/iterators/json_reverse_iterator.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include // ptrdiff_t 4 | #include // reverse_iterator 5 | #include // declval 6 | 7 | namespace nlohmann 8 | { 9 | namespace detail 10 | { 11 | ////////////////////// 12 | // reverse_iterator // 13 | ////////////////////// 14 | 15 | /*! 16 | @brief a template for a reverse iterator class 17 | 18 | @tparam Base the base iterator type to reverse. Valid types are @ref 19 | iterator (to create @ref reverse_iterator) and @ref const_iterator (to 20 | create @ref const_reverse_iterator). 21 | 22 | @requirement The class satisfies the following concept requirements: 23 | - 24 | [BidirectionalIterator](https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator): 25 | The iterator that can be moved can be moved in both directions (i.e. 26 | incremented and decremented). 27 | - [OutputIterator](https://en.cppreference.com/w/cpp/named_req/OutputIterator): 28 | It is possible to write to the pointed-to element (only if @a Base is 29 | @ref iterator). 30 | 31 | @since version 1.0.0 32 | */ 33 | template 34 | class json_reverse_iterator : public std::reverse_iterator 35 | { 36 | public: 37 | using difference_type = std::ptrdiff_t; 38 | /// shortcut to the reverse iterator adapter 39 | using base_iterator = std::reverse_iterator; 40 | /// the reference type for the pointed-to element 41 | using reference = typename Base::reference; 42 | 43 | /// create reverse iterator from iterator 44 | explicit json_reverse_iterator(const typename base_iterator::iterator_type& it) noexcept 45 | : base_iterator(it) {} 46 | 47 | /// create reverse iterator from base class 48 | explicit json_reverse_iterator(const base_iterator& it) noexcept : base_iterator(it) {} 49 | 50 | /// post-increment (it++) 51 | json_reverse_iterator const operator++(int) 52 | { 53 | return static_cast(base_iterator::operator++(1)); 54 | } 55 | 56 | /// pre-increment (++it) 57 | json_reverse_iterator& operator++() 58 | { 59 | return static_cast(base_iterator::operator++()); 60 | } 61 | 62 | /// post-decrement (it--) 63 | json_reverse_iterator const operator--(int) 64 | { 65 | return static_cast(base_iterator::operator--(1)); 66 | } 67 | 68 | /// pre-decrement (--it) 69 | json_reverse_iterator& operator--() 70 | { 71 | return static_cast(base_iterator::operator--()); 72 | } 73 | 74 | /// add to iterator 75 | json_reverse_iterator& operator+=(difference_type i) 76 | { 77 | return static_cast(base_iterator::operator+=(i)); 78 | } 79 | 80 | /// add to iterator 81 | json_reverse_iterator operator+(difference_type i) const 82 | { 83 | return static_cast(base_iterator::operator+(i)); 84 | } 85 | 86 | /// subtract from iterator 87 | json_reverse_iterator operator-(difference_type i) const 88 | { 89 | return static_cast(base_iterator::operator-(i)); 90 | } 91 | 92 | /// return difference 93 | difference_type operator-(const json_reverse_iterator& other) const 94 | { 95 | return base_iterator(*this) - base_iterator(other); 96 | } 97 | 98 | /// access to successor 99 | reference operator[](difference_type n) const 100 | { 101 | return *(this->operator+(n)); 102 | } 103 | 104 | /// return the key of an object iterator 105 | auto key() const -> decltype(std::declval().key()) 106 | { 107 | auto it = --this->base(); 108 | return it.key(); 109 | } 110 | 111 | /// return the value of an iterator 112 | reference value() const 113 | { 114 | auto it = --this->base(); 115 | return it.operator * (); 116 | } 117 | }; 118 | } // namespace detail 119 | } // namespace nlohmann 120 | -------------------------------------------------------------------------------- /share/nlohmann/detail/iterators/primitive_iterator.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include // ptrdiff_t 4 | #include // numeric_limits 5 | 6 | namespace nlohmann 7 | { 8 | namespace detail 9 | { 10 | /* 11 | @brief an iterator for primitive JSON types 12 | 13 | This class models an iterator for primitive JSON types (boolean, number, 14 | string). It's only purpose is to allow the iterator/const_iterator classes 15 | to "iterate" over primitive values. Internally, the iterator is modeled by 16 | a `difference_type` variable. Value begin_value (`0`) models the begin, 17 | end_value (`1`) models past the end. 18 | */ 19 | class primitive_iterator_t 20 | { 21 | private: 22 | using difference_type = std::ptrdiff_t; 23 | static constexpr difference_type begin_value = 0; 24 | static constexpr difference_type end_value = begin_value + 1; 25 | 26 | /// iterator as signed integer type 27 | difference_type m_it = (std::numeric_limits::min)(); 28 | 29 | public: 30 | constexpr difference_type get_value() const noexcept 31 | { 32 | return m_it; 33 | } 34 | 35 | /// set iterator to a defined beginning 36 | void set_begin() noexcept 37 | { 38 | m_it = begin_value; 39 | } 40 | 41 | /// set iterator to a defined past the end 42 | void set_end() noexcept 43 | { 44 | m_it = end_value; 45 | } 46 | 47 | /// return whether the iterator can be dereferenced 48 | constexpr bool is_begin() const noexcept 49 | { 50 | return m_it == begin_value; 51 | } 52 | 53 | /// return whether the iterator is at end 54 | constexpr bool is_end() const noexcept 55 | { 56 | return m_it == end_value; 57 | } 58 | 59 | friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept 60 | { 61 | return lhs.m_it == rhs.m_it; 62 | } 63 | 64 | friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept 65 | { 66 | return lhs.m_it < rhs.m_it; 67 | } 68 | 69 | primitive_iterator_t operator+(difference_type n) noexcept 70 | { 71 | auto result = *this; 72 | result += n; 73 | return result; 74 | } 75 | 76 | friend constexpr difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept 77 | { 78 | return lhs.m_it - rhs.m_it; 79 | } 80 | 81 | primitive_iterator_t& operator++() noexcept 82 | { 83 | ++m_it; 84 | return *this; 85 | } 86 | 87 | primitive_iterator_t const operator++(int) noexcept 88 | { 89 | auto result = *this; 90 | ++m_it; 91 | return result; 92 | } 93 | 94 | primitive_iterator_t& operator--() noexcept 95 | { 96 | --m_it; 97 | return *this; 98 | } 99 | 100 | primitive_iterator_t const operator--(int) noexcept 101 | { 102 | auto result = *this; 103 | --m_it; 104 | return result; 105 | } 106 | 107 | primitive_iterator_t& operator+=(difference_type n) noexcept 108 | { 109 | m_it += n; 110 | return *this; 111 | } 112 | 113 | primitive_iterator_t& operator-=(difference_type n) noexcept 114 | { 115 | m_it -= n; 116 | return *this; 117 | } 118 | }; 119 | } // namespace detail 120 | } // namespace nlohmann 121 | -------------------------------------------------------------------------------- /share/nlohmann/detail/json_ref.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | namespace nlohmann 9 | { 10 | namespace detail 11 | { 12 | template 13 | class json_ref 14 | { 15 | public: 16 | using value_type = BasicJsonType; 17 | 18 | json_ref(value_type&& value) 19 | : owned_value(std::move(value)), value_ref(&owned_value), is_rvalue(true) 20 | {} 21 | 22 | json_ref(const value_type& value) 23 | : value_ref(const_cast(&value)), is_rvalue(false) 24 | {} 25 | 26 | json_ref(std::initializer_list init) 27 | : owned_value(init), value_ref(&owned_value), is_rvalue(true) 28 | {} 29 | 30 | template < 31 | class... Args, 32 | enable_if_t::value, int> = 0 > 33 | json_ref(Args && ... args) 34 | : owned_value(std::forward(args)...), value_ref(&owned_value), 35 | is_rvalue(true) {} 36 | 37 | // class should be movable only 38 | json_ref(json_ref&&) = default; 39 | json_ref(const json_ref&) = delete; 40 | json_ref& operator=(const json_ref&) = delete; 41 | json_ref& operator=(json_ref&&) = delete; 42 | ~json_ref() = default; 43 | 44 | value_type moved_or_copied() const 45 | { 46 | if (is_rvalue) 47 | { 48 | return std::move(*value_ref); 49 | } 50 | return *value_ref; 51 | } 52 | 53 | value_type const& operator*() const 54 | { 55 | return *static_cast(value_ref); 56 | } 57 | 58 | value_type const* operator->() const 59 | { 60 | return static_cast(value_ref); 61 | } 62 | 63 | private: 64 | mutable value_type owned_value = nullptr; 65 | value_type* value_ref = nullptr; 66 | const bool is_rvalue; 67 | }; 68 | } // namespace detail 69 | } // namespace nlohmann 70 | -------------------------------------------------------------------------------- /share/nlohmann/detail/macro_scope.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include // pair 4 | 5 | // This file contains all internal macro definitions 6 | // You MUST include macro_unscope.hpp at the end of json.hpp to undef all of them 7 | 8 | // exclude unsupported compilers 9 | #if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK) 10 | #if defined(__clang__) 11 | #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400 12 | #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers" 13 | #endif 14 | #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER)) 15 | #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800 16 | #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers" 17 | #endif 18 | #endif 19 | #endif 20 | 21 | // C++ language standard detection 22 | #if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 23 | #define JSON_HAS_CPP_17 24 | #define JSON_HAS_CPP_14 25 | #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) 26 | #define JSON_HAS_CPP_14 27 | #endif 28 | 29 | // disable float-equal warnings on GCC/clang 30 | #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) 31 | #pragma GCC diagnostic push 32 | #pragma GCC diagnostic ignored "-Wfloat-equal" 33 | #endif 34 | 35 | // disable documentation warnings on clang 36 | #if defined(__clang__) 37 | #pragma GCC diagnostic push 38 | #pragma GCC diagnostic ignored "-Wdocumentation" 39 | #endif 40 | 41 | // allow for portable deprecation warnings 42 | #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) 43 | #define JSON_DEPRECATED __attribute__((deprecated)) 44 | #elif defined(_MSC_VER) 45 | #define JSON_DEPRECATED __declspec(deprecated) 46 | #else 47 | #define JSON_DEPRECATED 48 | #endif 49 | 50 | // allow for portable nodiscard warnings 51 | #if defined(__has_cpp_attribute) 52 | #if __has_cpp_attribute(nodiscard) 53 | #if defined(__clang__) && !defined(JSON_HAS_CPP_17) // issue #1535 54 | #define JSON_NODISCARD 55 | #else 56 | #define JSON_NODISCARD [[nodiscard]] 57 | #endif 58 | #elif __has_cpp_attribute(gnu::warn_unused_result) 59 | #define JSON_NODISCARD [[gnu::warn_unused_result]] 60 | #else 61 | #define JSON_NODISCARD 62 | #endif 63 | #else 64 | #define JSON_NODISCARD 65 | #endif 66 | 67 | // allow to disable exceptions 68 | #if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION) 69 | #define JSON_THROW(exception) throw exception 70 | #define JSON_TRY try 71 | #define JSON_CATCH(exception) catch(exception) 72 | #define JSON_INTERNAL_CATCH(exception) catch(exception) 73 | #else 74 | #include 75 | #define JSON_THROW(exception) std::abort() 76 | #define JSON_TRY if(true) 77 | #define JSON_CATCH(exception) if(false) 78 | #define JSON_INTERNAL_CATCH(exception) if(false) 79 | #endif 80 | 81 | // override exception macros 82 | #if defined(JSON_THROW_USER) 83 | #undef JSON_THROW 84 | #define JSON_THROW JSON_THROW_USER 85 | #endif 86 | #if defined(JSON_TRY_USER) 87 | #undef JSON_TRY 88 | #define JSON_TRY JSON_TRY_USER 89 | #endif 90 | #if defined(JSON_CATCH_USER) 91 | #undef JSON_CATCH 92 | #define JSON_CATCH JSON_CATCH_USER 93 | #undef JSON_INTERNAL_CATCH 94 | #define JSON_INTERNAL_CATCH JSON_CATCH_USER 95 | #endif 96 | #if defined(JSON_INTERNAL_CATCH_USER) 97 | #undef JSON_INTERNAL_CATCH 98 | #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER 99 | #endif 100 | 101 | // manual branch prediction 102 | #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) 103 | #define JSON_LIKELY(x) __builtin_expect(x, 1) 104 | #define JSON_UNLIKELY(x) __builtin_expect(x, 0) 105 | #else 106 | #define JSON_LIKELY(x) x 107 | #define JSON_UNLIKELY(x) x 108 | #endif 109 | 110 | /*! 111 | @brief macro to briefly define a mapping between an enum and JSON 112 | @def NLOHMANN_JSON_SERIALIZE_ENUM 113 | @since version 3.4.0 114 | */ 115 | #define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \ 116 | template \ 117 | inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \ 118 | { \ 119 | static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ 120 | static const std::pair m[] = __VA_ARGS__; \ 121 | auto it = std::find_if(std::begin(m), std::end(m), \ 122 | [e](const std::pair& ej_pair) -> bool \ 123 | { \ 124 | return ej_pair.first == e; \ 125 | }); \ 126 | j = ((it != std::end(m)) ? it : std::begin(m))->second; \ 127 | } \ 128 | template \ 129 | inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \ 130 | { \ 131 | static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ 132 | static const std::pair m[] = __VA_ARGS__; \ 133 | auto it = std::find_if(std::begin(m), std::end(m), \ 134 | [j](const std::pair& ej_pair) -> bool \ 135 | { \ 136 | return ej_pair.second == j; \ 137 | }); \ 138 | e = ((it != std::end(m)) ? it : std::begin(m))->first; \ 139 | } 140 | 141 | // Ugly macros to avoid uglier copy-paste when specializing basic_json. They 142 | // may be removed in the future once the class is split. 143 | 144 | #define NLOHMANN_BASIC_JSON_TPL_DECLARATION \ 145 | template class ObjectType, \ 146 | template class ArrayType, \ 147 | class StringType, class BooleanType, class NumberIntegerType, \ 148 | class NumberUnsignedType, class NumberFloatType, \ 149 | template class AllocatorType, \ 150 | template class JSONSerializer> 151 | 152 | #define NLOHMANN_BASIC_JSON_TPL \ 153 | basic_json 156 | -------------------------------------------------------------------------------- /share/nlohmann/detail/macro_unscope.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // restore GCC/clang diagnostic settings 4 | #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) 5 | #pragma GCC diagnostic pop 6 | #endif 7 | #if defined(__clang__) 8 | #pragma GCC diagnostic pop 9 | #endif 10 | 11 | // clean up 12 | #undef JSON_INTERNAL_CATCH 13 | #undef JSON_CATCH 14 | #undef JSON_THROW 15 | #undef JSON_TRY 16 | #undef JSON_LIKELY 17 | #undef JSON_UNLIKELY 18 | #undef JSON_DEPRECATED 19 | #undef JSON_NODISCARD 20 | #undef JSON_HAS_CPP_14 21 | #undef JSON_HAS_CPP_17 22 | #undef NLOHMANN_BASIC_JSON_TPL_DECLARATION 23 | #undef NLOHMANN_BASIC_JSON_TPL 24 | -------------------------------------------------------------------------------- /share/nlohmann/detail/meta/cpp_future.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include // not 4 | #include // size_t 5 | #include // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type 6 | 7 | namespace nlohmann 8 | { 9 | namespace detail 10 | { 11 | // alias templates to reduce boilerplate 12 | template 13 | using enable_if_t = typename std::enable_if::type; 14 | 15 | template 16 | using uncvref_t = typename std::remove_cv::type>::type; 17 | 18 | // implementation of C++14 index_sequence and affiliates 19 | // source: https://stackoverflow.com/a/32223343 20 | template 21 | struct index_sequence 22 | { 23 | using type = index_sequence; 24 | using value_type = std::size_t; 25 | static constexpr std::size_t size() noexcept 26 | { 27 | return sizeof...(Ints); 28 | } 29 | }; 30 | 31 | template 32 | struct merge_and_renumber; 33 | 34 | template 35 | struct merge_and_renumber, index_sequence> 36 | : index_sequence < I1..., (sizeof...(I1) + I2)... > {}; 37 | 38 | template 39 | struct make_index_sequence 40 | : merge_and_renumber < typename make_index_sequence < N / 2 >::type, 41 | typename make_index_sequence < N - N / 2 >::type > {}; 42 | 43 | template<> struct make_index_sequence<0> : index_sequence<> {}; 44 | template<> struct make_index_sequence<1> : index_sequence<0> {}; 45 | 46 | template 47 | using index_sequence_for = make_index_sequence; 48 | 49 | // dispatch utility (taken from ranges-v3) 50 | template struct priority_tag : priority_tag < N - 1 > {}; 51 | template<> struct priority_tag<0> {}; 52 | 53 | // taken from ranges-v3 54 | template 55 | struct static_const 56 | { 57 | static constexpr T value{}; 58 | }; 59 | 60 | template 61 | constexpr T static_const::value; 62 | } // namespace detail 63 | } // namespace nlohmann 64 | -------------------------------------------------------------------------------- /share/nlohmann/detail/meta/detected.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | // http://en.cppreference.com/w/cpp/experimental/is_detected 8 | namespace nlohmann 9 | { 10 | namespace detail 11 | { 12 | struct nonesuch 13 | { 14 | nonesuch() = delete; 15 | ~nonesuch() = delete; 16 | nonesuch(nonesuch const&) = delete; 17 | nonesuch(nonesuch const&&) = delete; 18 | void operator=(nonesuch const&) = delete; 19 | void operator=(nonesuch&&) = delete; 20 | }; 21 | 22 | template class Op, 25 | class... Args> 26 | struct detector 27 | { 28 | using value_t = std::false_type; 29 | using type = Default; 30 | }; 31 | 32 | template class Op, class... Args> 33 | struct detector>, Op, Args...> 34 | { 35 | using value_t = std::true_type; 36 | using type = Op; 37 | }; 38 | 39 | template