├── .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