Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom base class as node customization point #3110

Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
143f868
Allow to add a custom base class as an extension point to json nodes
barcode Oct 30, 2021
a131ecc
Fix code for msvc
barcode Oct 30, 2021
51d8c28
Fix test
barcode Oct 30, 2021
8f4d8a6
Re run make amalgamate
barcode Oct 31, 2021
09f42fd
Suppress fals positive of cppcheck
barcode Oct 31, 2021
e5534f1
Fix clang-tidy errors
barcode Oct 31, 2021
0046348
Try fixing code for clang-tidy
barcode Oct 31, 2021
ef54887
Remove make_unique to make the test c++11 compliant
barcode Nov 1, 2021
e41e315
Add NOLINT since clang-tidy requests make_unique, but C++11 jobs don'…
barcode Nov 1, 2021
f43c6b4
Document what the include of type_traits is used for
barcode Nov 1, 2021
5204ebb
Add documentation
barcode Nov 1, 2021
2e7e67d
Fix typo
barcode Nov 1, 2021
500fc0a
Remove accidentally duplicated doc text
barcode Nov 1, 2021
79a7056
Update / add documentation for custom base class
Jun 28, 2022
c427a52
Fix clang-tidy-15 warning about use after move
Jun 28, 2022
050a831
Update docs/mkdocs/docs/api/basic_json/json_base_class_t.md
barcode Jul 5, 2022
21d0d38
Update docs/mkdocs/docs/api/basic_json/json_base_class_t.md
barcode Jul 5, 2022
5539e6f
Update docs/mkdocs/docs/api/basic_json/json_base_class_t.md
barcode Jul 5, 2022
0a8e16d
Adapt code to review
Jul 5, 2022
962fca2
readd suppress for cppcheck
Jul 12, 2022
7cd3033
run amalgamate
Aug 8, 2022
afb108a
Update include/nlohmann/detail/json_custom_base_class.hpp
barcode Aug 19, 2022
f516209
Update single_include/nlohmann/json.hpp
barcode Aug 19, 2022
0bcc12c
Update include/nlohmann/detail/json_custom_base_class.hpp
barcode Aug 19, 2022
b1001c6
Update single_include/nlohmann/json.hpp
barcode Aug 19, 2022
763c59d
Update docs/mkdocs/docs/api/basic_json/json_base_class_t.md
barcode Aug 27, 2022
0ce9ded
Update docs/mkdocs/docs/api/basic_json/json_base_class_t.md
barcode Aug 27, 2022
49ab721
Update docs/mkdocs/docs/api/basic_json/json_base_class_t.md
barcode Aug 27, 2022
b0f5baf
Update docs/mkdocs/docs/api/basic_json/json_base_class_t.md
barcode Aug 27, 2022
e9f5e0c
Update docs/mkdocs/docs/api/basic_json/json_base_class_t.md
barcode Aug 27, 2022
b3816f1
Update include/nlohmann/detail/json_custom_base_class.hpp
barcode Aug 27, 2022
7d476a0
make amalgamate
Aug 27, 2022
c5ede1a
Update include/nlohmann/detail/json_custom_base_class.hpp
barcode Aug 27, 2022
19423a7
make amalgamate
Aug 27, 2022
46597f0
Add include for nlohmann/detail/abi_macros.hpp
Aug 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add documentation
barcode authored and barcode committed Aug 18, 2022
commit 5204ebb0d0672bfbb27594754eadc32e317f5d26
17 changes: 17 additions & 0 deletions include/nlohmann/detail/json_custom_base_class.hpp
Original file line number Diff line number Diff line change
@@ -7,6 +7,23 @@ namespace nlohmann
namespace detail
{

/*!
@brief Default base class of the @ref basic_json class.

So that the correct implementation of the copy / move ctors / assign operators
of @ref basic_json does not require complex case distinctions
(no base class / custom base class), @ref basic_json always a base class.
By default this class is used, since empty and thus has no effect on the
behaviour of @ref basic_json.


So that the correct implementation of the copy / move ctors / assign operators
of @ref basic_json does not require complex case distinctions
(no base class / custom base class used as customization point),
@ref basic_json always has a base class.
By default, this class is used because it is empty and thus has no effect
on the behavior of @ref basic_json.
*/
struct json_default_base {};

template<class T>
4 changes: 4 additions & 0 deletions tests/src/unit-custom-base-class.cpp
Original file line number Diff line number Diff line change
@@ -35,6 +35,8 @@ SOFTWARE.

#include <nlohmann/json.hpp>

// Test extending nlohmann::json by using a custom base class.
// Add some metadata to each node ant test the behaviour of copy / move
template<class MetaDataType>
class json_metadata
{
@@ -201,6 +203,8 @@ TEST_CASE("JSON Node Metadata")
}
}

// Test extending nlohmann::json by using a custom base class.
// Add a custom member function template iterating over the whole json tree.
class visitor_adaptor
{
public: