mirror of
https://github.com/MadeOfJelly/MushMachine.git
synced 2025-06-20 19:56:37 +02:00
update nlohmann::json to 3.10.4
This commit is contained in:
@ -2,12 +2,16 @@
|
||||
|
||||
#include <algorithm> // copy
|
||||
#include <cstddef> // size_t
|
||||
#include <ios> // streamsize
|
||||
#include <iterator> // back_inserter
|
||||
#include <memory> // shared_ptr, make_shared
|
||||
#include <ostream> // basic_ostream
|
||||
#include <string> // basic_string
|
||||
#include <vector> // vector
|
||||
|
||||
#ifndef JSON_NO_IO
|
||||
#include <ios> // streamsize
|
||||
#include <ostream> // basic_ostream
|
||||
#endif // JSON_NO_IO
|
||||
|
||||
#include <nlohmann/detail/macro_scope.hpp>
|
||||
|
||||
namespace nlohmann
|
||||
@ -20,6 +24,12 @@ template<typename CharType> struct output_adapter_protocol
|
||||
virtual void write_character(CharType c) = 0;
|
||||
virtual void write_characters(const CharType* s, std::size_t length) = 0;
|
||||
virtual ~output_adapter_protocol() = default;
|
||||
|
||||
output_adapter_protocol() = default;
|
||||
output_adapter_protocol(const output_adapter_protocol&) = default;
|
||||
output_adapter_protocol(output_adapter_protocol&&) noexcept = default;
|
||||
output_adapter_protocol& operator=(const output_adapter_protocol&) = default;
|
||||
output_adapter_protocol& operator=(output_adapter_protocol&&) noexcept = default;
|
||||
};
|
||||
|
||||
/// a type to simplify interfaces
|
||||
@ -27,11 +37,11 @@ template<typename CharType>
|
||||
using output_adapter_t = std::shared_ptr<output_adapter_protocol<CharType>>;
|
||||
|
||||
/// output adapter for byte vectors
|
||||
template<typename CharType>
|
||||
template<typename CharType, typename AllocatorType = std::allocator<CharType>>
|
||||
class output_vector_adapter : public output_adapter_protocol<CharType>
|
||||
{
|
||||
public:
|
||||
explicit output_vector_adapter(std::vector<CharType>& vec) noexcept
|
||||
explicit output_vector_adapter(std::vector<CharType, AllocatorType>& vec) noexcept
|
||||
: v(vec)
|
||||
{}
|
||||
|
||||
@ -47,9 +57,10 @@ class output_vector_adapter : public output_adapter_protocol<CharType>
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<CharType>& v;
|
||||
std::vector<CharType, AllocatorType>& v;
|
||||
};
|
||||
|
||||
#ifndef JSON_NO_IO
|
||||
/// output adapter for output streams
|
||||
template<typename CharType>
|
||||
class output_stream_adapter : public output_adapter_protocol<CharType>
|
||||
@ -73,6 +84,7 @@ class output_stream_adapter : public output_adapter_protocol<CharType>
|
||||
private:
|
||||
std::basic_ostream<CharType>& stream;
|
||||
};
|
||||
#endif // JSON_NO_IO
|
||||
|
||||
/// output adapter for basic_string
|
||||
template<typename CharType, typename StringType = std::basic_string<CharType>>
|
||||
@ -102,11 +114,14 @@ template<typename CharType, typename StringType = std::basic_string<CharType>>
|
||||
class output_adapter
|
||||
{
|
||||
public:
|
||||
output_adapter(std::vector<CharType>& vec)
|
||||
: oa(std::make_shared<output_vector_adapter<CharType>>(vec)) {}
|
||||
template<typename AllocatorType = std::allocator<CharType>>
|
||||
output_adapter(std::vector<CharType, AllocatorType>& vec)
|
||||
: oa(std::make_shared<output_vector_adapter<CharType, AllocatorType>>(vec)) {}
|
||||
|
||||
#ifndef JSON_NO_IO
|
||||
output_adapter(std::basic_ostream<CharType>& s)
|
||||
: oa(std::make_shared<output_stream_adapter<CharType>>(s)) {}
|
||||
#endif // JSON_NO_IO
|
||||
|
||||
output_adapter(StringType& s)
|
||||
: oa(std::make_shared<output_string_adapter<CharType, StringType>>(s)) {}
|
||||
|
Reference in New Issue
Block a user