mirror of
https://github.com/boostorg/json.git
synced 2026-01-19 04:12:14 +00:00
deprecate type aliases
This commit is contained in:
@@ -298,7 +298,7 @@ public:
|
||||
while(repeat--)
|
||||
{
|
||||
p.reset();
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
p.write(s.data(), s.size(), ec);
|
||||
if(! ec)
|
||||
p.finish(ec);
|
||||
@@ -320,7 +320,7 @@ public:
|
||||
|
||||
FILE* f = fopen(fi.name.data(), "rb");
|
||||
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
while( true )
|
||||
{
|
||||
std::size_t const sz = fread(s, 1, sizeof(s), f);
|
||||
@@ -412,7 +412,7 @@ public:
|
||||
{
|
||||
monotonic_resource mr;
|
||||
p.reset(&mr);
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
p.write(s.data(), s.size(), ec);
|
||||
if(! ec)
|
||||
p.finish(ec);
|
||||
@@ -435,7 +435,7 @@ public:
|
||||
|
||||
FILE* f = fopen(fi.name.data(), "rb");
|
||||
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
while( true )
|
||||
{
|
||||
std::size_t const sz = fread(s, 1, sizeof(s), f);
|
||||
@@ -509,24 +509,24 @@ class boost_null_impl : public any_impl
|
||||
constexpr static std::size_t max_key_size = std::size_t(-1);
|
||||
constexpr static std::size_t max_string_size = std::size_t(-1);
|
||||
|
||||
bool on_document_begin(error_code&) { return true; }
|
||||
bool on_document_end(error_code&) { return true; }
|
||||
bool on_object_begin(error_code&) { return true; }
|
||||
bool on_object_end(std::size_t, error_code&) { return true; }
|
||||
bool on_array_begin(error_code&) { return true; }
|
||||
bool on_array_end(std::size_t, error_code&) { return true; }
|
||||
bool on_key_part(string_view, std::size_t, error_code&) { return true; }
|
||||
bool on_key( string_view, std::size_t, error_code&) { return true; }
|
||||
bool on_string_part(string_view, std::size_t, error_code&) { return true; }
|
||||
bool on_string(string_view, std::size_t, error_code&) { return true; }
|
||||
bool on_number_part(string_view, error_code&) { return true; }
|
||||
bool on_int64(std::int64_t, string_view, error_code&) { return true; }
|
||||
bool on_uint64(std::uint64_t, string_view, error_code&) { return true; }
|
||||
bool on_double(double, string_view, error_code&) { return true; }
|
||||
bool on_bool(bool, error_code&) { return true; }
|
||||
bool on_null(error_code&) { return true; }
|
||||
bool on_comment_part(string_view, error_code&) { return true; }
|
||||
bool on_comment(string_view, error_code&) { return true; }
|
||||
bool on_document_begin(system::error_code&) { return true; }
|
||||
bool on_document_end(system::error_code&) { return true; }
|
||||
bool on_object_begin(system::error_code&) { return true; }
|
||||
bool on_object_end(std::size_t, system::error_code&) { return true; }
|
||||
bool on_array_begin(system::error_code&) { return true; }
|
||||
bool on_array_end(std::size_t, system::error_code&) { return true; }
|
||||
bool on_key_part(string_view, std::size_t, system::error_code&) { return true; }
|
||||
bool on_key( string_view, std::size_t, system::error_code&) { return true; }
|
||||
bool on_string_part(string_view, std::size_t, system::error_code&) { return true; }
|
||||
bool on_string(string_view, std::size_t, system::error_code&) { return true; }
|
||||
bool on_number_part(string_view, system::error_code&) { return true; }
|
||||
bool on_int64(std::int64_t, string_view, system::error_code&) { return true; }
|
||||
bool on_uint64(std::uint64_t, string_view, system::error_code&) { return true; }
|
||||
bool on_double(double, string_view, system::error_code&) { return true; }
|
||||
bool on_bool(bool, system::error_code&) { return true; }
|
||||
bool on_null(system::error_code&) { return true; }
|
||||
bool on_comment_part(string_view, system::error_code&) { return true; }
|
||||
bool on_comment(string_view, system::error_code&) { return true; }
|
||||
};
|
||||
|
||||
basic_parser<handler> p_;
|
||||
@@ -546,7 +546,7 @@ class boost_null_impl : public any_impl
|
||||
write(
|
||||
char const* data,
|
||||
std::size_t size,
|
||||
error_code& ec)
|
||||
system::error_code& ec)
|
||||
{
|
||||
auto const n = p_.write_some(
|
||||
false, data, size, ec);
|
||||
@@ -559,14 +559,14 @@ class boost_null_impl : public any_impl
|
||||
write_some(
|
||||
char const* data,
|
||||
std::size_t size,
|
||||
error_code& ec)
|
||||
system::error_code& ec)
|
||||
{
|
||||
return p_.write_some(
|
||||
true, data, size, ec);
|
||||
}
|
||||
|
||||
void
|
||||
finish(error_code& ec)
|
||||
finish(system::error_code& ec)
|
||||
{
|
||||
p_.write_some(false, nullptr, 0, ec);
|
||||
}
|
||||
@@ -599,7 +599,7 @@ public:
|
||||
while(repeat--)
|
||||
{
|
||||
p.reset();
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
p.write(s.data(), s.size(), ec);
|
||||
BOOST_ASSERT(! ec);
|
||||
}
|
||||
@@ -618,7 +618,7 @@ public:
|
||||
|
||||
FILE* f = fopen(fi.name.data(), "rb");
|
||||
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
while( true )
|
||||
{
|
||||
std::size_t const sz = fread(s, 1, sizeof(s), f);
|
||||
@@ -679,7 +679,7 @@ public:
|
||||
auto const start = clock_type::now();
|
||||
while(repeat--)
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
monotonic_resource mr;
|
||||
auto jv = json::parse(s, ec, &mr, popts);
|
||||
(void)jv;
|
||||
@@ -693,7 +693,7 @@ public:
|
||||
auto const start = clock_type::now();
|
||||
while(repeat--)
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
std::ifstream is( fi.name, std::ios::in | std::ios::binary );
|
||||
monotonic_resource mr;
|
||||
auto jv = json::parse(is, ec, &mr, popts);
|
||||
@@ -1188,7 +1188,7 @@ main(
|
||||
|
||||
dout << "\n" << strout.str();
|
||||
}
|
||||
catch(system_error const& se)
|
||||
catch(boost::system::system_error const& se)
|
||||
{
|
||||
dout << se.what() << std::endl;
|
||||
}
|
||||
|
||||
@@ -39,12 +39,12 @@ definitions must be visible at all call sites.
|
||||
[heading Polymorphic Allocators]
|
||||
|
||||
C++17 improves the allocator model by representing the low-level
|
||||
allocation operation with an abstract interface called __memory_resource__,
|
||||
allocation operation with an abstract interface called `memory_resource`,
|
||||
which is not parameterized on the element type, and has no traits:
|
||||
|
||||
[doc_background_3]
|
||||
|
||||
The class template __polymorphic_allocator__ wraps a __memory_resource__
|
||||
The class template `polymorphic_allocator` wraps a `memory_resource`
|
||||
pointer and meets the requirements of __Allocator__, allowing it to be
|
||||
used where an allocator is expected. The standard provides type aliases
|
||||
using the polymorphic allocator for standard containers:
|
||||
@@ -71,20 +71,20 @@ instance of the library's custom memory resource as shown below:
|
||||
|
||||
[doc_background_7]
|
||||
|
||||
This can be worked around by declaring the container to use a custom
|
||||
allocator (perhaps using a `std::shared_ptr< memory_resource >` as a
|
||||
data member). This hinders library composition; every library now
|
||||
exports unique, incompatible container types. A raw memory resource
|
||||
pointer is also easy to misuse:
|
||||
This can be worked around by declaring the container to use a custom allocator
|
||||
(perhaps using a `std::shared_ptr< std::pmr::memory_resource >` as
|
||||
a data member). This hinders library composition; every library now exports
|
||||
unique, incompatible container types. A raw memory resource pointer is also
|
||||
easy to misuse:
|
||||
|
||||
[doc_background_8]
|
||||
|
||||
Workarounds for this problem are worse than the problem itself. The library
|
||||
could return a pair with the vector and `unique_ptr<memory_resource>`
|
||||
which the caller must manage. Or the library could change its function
|
||||
signatures to accept a `memory_resource*` provided by the caller, where
|
||||
the library also makes public the desired memory resources
|
||||
(`my_resource` above).
|
||||
could return a pair with the vector and
|
||||
`std::unique_ptr<std::pmr::memory_resource>` which the caller must
|
||||
manage. Or the library could change its function signatures to accept a
|
||||
`memory_resource*` provided by the caller, where the library also makes public
|
||||
the desired memory resources (`my_resource` above).
|
||||
|
||||
[heading Problem Statement]
|
||||
|
||||
@@ -92,7 +92,7 @@ We would like an allocator model using a single type `T` with the
|
||||
following properties:
|
||||
|
||||
* `T` is not a class template
|
||||
* `T` references a __memory_resource__
|
||||
* `T` references a `memory_resource`
|
||||
* `T` supports both reference semantics or shared ownership
|
||||
* `T` interoperates with code already using `std::pmr`
|
||||
|
||||
|
||||
@@ -105,15 +105,15 @@
|
||||
<entry valign="top">
|
||||
<bridgehead renderas="sect3">Aliases</bridgehead>
|
||||
<simplelist type="vert" columns="1">
|
||||
<member><link linkend="json.ref.boost__json__error_category">error_category</link></member>
|
||||
<member><link linkend="json.ref.boost__json__error_code">error_code</link></member>
|
||||
<member><link linkend="json.ref.boost__json__error_condition">error_condition</link></member>
|
||||
<member><link linkend="json.ref.boost__json__memory_resource">memory_resource</link></member>
|
||||
<member><link linkend="json.ref.boost__json__error_category"><emphasis role="red">error_category</emphasis></link></member>
|
||||
<member><link linkend="json.ref.boost__json__error_code"><emphasis role="red">error_code</emphasis></link></member>
|
||||
<member><link linkend="json.ref.boost__json__error_condition"><emphasis role="red">error_condition</emphasis></link></member>
|
||||
<member><link linkend="json.ref.boost__json__memory_resource"><emphasis role="red">memory_resource</emphasis></link></member>
|
||||
<member><link linkend="json.ref.boost__json__parser_for">parser_for</link></member>
|
||||
<member><link linkend="json.ref.boost__json__polymorphic_allocator">polymorphic_allocator</link></member>
|
||||
<member><link linkend="json.ref.boost__json__result">result</link></member>
|
||||
<member><link linkend="json.ref.boost__json__polymorphic_allocator"><emphasis role="red">polymorphic_allocator</emphasis></link></member>
|
||||
<member><link linkend="json.ref.boost__json__result"><emphasis role="red">result</emphasis></link></member>
|
||||
<member><link linkend="json.ref.boost__json__string_view">string_view</link></member>
|
||||
<member><link linkend="json.ref.boost__json__system_error">system_error</link></member>
|
||||
<member><link linkend="json.ref.boost__json__system_error"><emphasis role="red">system_error</emphasis></link></member>
|
||||
</simplelist>
|
||||
<bridgehead renderas="sect3">P0308R0</bridgehead>
|
||||
<simplelist type="vert" columns="1">
|
||||
|
||||
@@ -20,7 +20,7 @@ class file
|
||||
long size_ = 0;
|
||||
|
||||
void
|
||||
fail(boost::json::error_code& ec)
|
||||
fail(boost::system::error_code& ec)
|
||||
{
|
||||
ec.assign( errno, boost::system::generic_category() );
|
||||
}
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
open(
|
||||
char const* path,
|
||||
char const* mode,
|
||||
boost::json::error_code& ec)
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
close();
|
||||
#if defined(_MSC_VER)
|
||||
@@ -99,10 +99,10 @@ public:
|
||||
char const* path,
|
||||
char const* mode)
|
||||
{
|
||||
boost::json::error_code ec;
|
||||
boost::system::error_code ec;
|
||||
open(path, mode, ec);
|
||||
if(ec)
|
||||
throw boost::json::system_error(ec);
|
||||
throw boost::system::system_error(ec);
|
||||
}
|
||||
|
||||
long
|
||||
@@ -118,7 +118,7 @@ public:
|
||||
}
|
||||
|
||||
std::size_t
|
||||
read( char* data, std::size_t size, boost::json::error_code& ec)
|
||||
read( char* data, std::size_t size, boost::system::error_code& ec)
|
||||
{
|
||||
auto const nread = std::fread( data, 1, size, f_ );
|
||||
if( std::ferror(f_) )
|
||||
@@ -129,17 +129,17 @@ public:
|
||||
std::size_t
|
||||
read( char* data, std::size_t size )
|
||||
{
|
||||
boost::json::error_code ec;
|
||||
boost::system::error_code ec;
|
||||
auto const nread = read( data, size, ec );
|
||||
if(ec)
|
||||
throw boost::json::system_error(ec);
|
||||
throw boost::system::system_error(ec);
|
||||
return nread;
|
||||
}
|
||||
};
|
||||
|
||||
inline
|
||||
std::string
|
||||
read_file( char const* path, boost::json::error_code& ec )
|
||||
read_file( char const* path, boost::system::error_code& ec )
|
||||
{
|
||||
file f;
|
||||
f.open( path, "r", ec );
|
||||
@@ -157,10 +157,10 @@ inline
|
||||
std::string
|
||||
read_file( char const* path )
|
||||
{
|
||||
boost::json::error_code ec;
|
||||
boost::system::error_code ec;
|
||||
auto s = read_file( path, ec);
|
||||
if(ec)
|
||||
throw boost::json::system_error(ec);
|
||||
throw boost::system::system_error(ec);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
@@ -176,7 +176,7 @@ int main()
|
||||
|
||||
coordinates1 w;
|
||||
|
||||
boost::json::error_code ec;
|
||||
boost::system::error_code ec;
|
||||
boost::json::parse_into( w, json, ec );
|
||||
|
||||
if( ec.failed() )
|
||||
@@ -212,7 +212,7 @@ int main()
|
||||
|
||||
coordinates2 w;
|
||||
|
||||
boost::json::error_code ec;
|
||||
boost::system::error_code ec;
|
||||
boost::json::parse_into( w, json, ec );
|
||||
|
||||
if( ec.failed() )
|
||||
|
||||
@@ -82,7 +82,7 @@ int main()
|
||||
|
||||
canada w;
|
||||
|
||||
boost::json::error_code ec;
|
||||
boost::system::error_code ec;
|
||||
boost::json::parse_into( w, json, ec );
|
||||
|
||||
if( ec.failed() )
|
||||
|
||||
@@ -129,7 +129,7 @@ int main()
|
||||
|
||||
citm_catalog w;
|
||||
|
||||
boost::json::error_code ec;
|
||||
boost::system::error_code ec;
|
||||
boost::json::parse_into( w, json, ec );
|
||||
|
||||
if( ec.failed() )
|
||||
|
||||
@@ -27,7 +27,7 @@ parse_file( char const* filename )
|
||||
{
|
||||
file f( filename, "r" );
|
||||
json::stream_parser p;
|
||||
json::error_code ec;
|
||||
boost::system::error_code ec;
|
||||
do
|
||||
{
|
||||
char buf[4096];
|
||||
|
||||
@@ -42,7 +42,7 @@ template<
|
||||
is_sequence_like<T>::value &&
|
||||
std::uses_allocator<T, Alloc>::value
|
||||
>::type >
|
||||
result<T>
|
||||
boost::system::result<T>
|
||||
tag_invoke( try_value_to_tag<T>, const value& jv, const use_allocator_t<Alloc>& ctx, const FullContext& full_ctx )
|
||||
{
|
||||
|
||||
|
||||
@@ -36,24 +36,24 @@ class null_parser
|
||||
constexpr static std::size_t max_key_size = std::size_t(-1);
|
||||
constexpr static std::size_t max_string_size = std::size_t(-1);
|
||||
|
||||
bool on_document_begin( error_code& ) { return true; }
|
||||
bool on_document_end( error_code& ) { return true; }
|
||||
bool on_object_begin( error_code& ) { return true; }
|
||||
bool on_object_end( std::size_t, error_code& ) { return true; }
|
||||
bool on_array_begin( error_code& ) { return true; }
|
||||
bool on_array_end( std::size_t, error_code& ) { return true; }
|
||||
bool on_key_part( string_view, std::size_t, error_code& ) { return true; }
|
||||
bool on_key( string_view, std::size_t, error_code& ) { return true; }
|
||||
bool on_string_part( string_view, std::size_t, error_code& ) { return true; }
|
||||
bool on_string( string_view, std::size_t, error_code& ) { return true; }
|
||||
bool on_number_part( string_view, error_code& ) { return true; }
|
||||
bool on_int64( std::int64_t, string_view, error_code& ) { return true; }
|
||||
bool on_uint64( std::uint64_t, string_view, error_code& ) { return true; }
|
||||
bool on_double( double, string_view, error_code& ) { return true; }
|
||||
bool on_bool( bool, error_code& ) { return true; }
|
||||
bool on_null( error_code& ) { return true; }
|
||||
bool on_comment_part(string_view, error_code&) { return true; }
|
||||
bool on_comment(string_view, error_code&) { return true; }
|
||||
bool on_document_begin( boost::system::error_code& ) { return true; }
|
||||
bool on_document_end( boost::system::error_code& ) { return true; }
|
||||
bool on_object_begin( boost::system::error_code& ) { return true; }
|
||||
bool on_object_end( std::size_t, boost::system::error_code& ) { return true; }
|
||||
bool on_array_begin( boost::system::error_code& ) { return true; }
|
||||
bool on_array_end( std::size_t, boost::system::error_code& ) { return true; }
|
||||
bool on_key_part( string_view, std::size_t, boost::system::error_code& ) { return true; }
|
||||
bool on_key( string_view, std::size_t, boost::system::error_code& ) { return true; }
|
||||
bool on_string_part( string_view, std::size_t, boost::system::error_code& ) { return true; }
|
||||
bool on_string( string_view, std::size_t, boost::system::error_code& ) { return true; }
|
||||
bool on_number_part( string_view, boost::system::error_code& ) { return true; }
|
||||
bool on_int64( std::int64_t, string_view, boost::system::error_code& ) { return true; }
|
||||
bool on_uint64( std::uint64_t, string_view, boost::system::error_code& ) { return true; }
|
||||
bool on_double( double, string_view, boost::system::error_code& ) { return true; }
|
||||
bool on_bool( bool, boost::system::error_code& ) { return true; }
|
||||
bool on_null( boost::system::error_code& ) { return true; }
|
||||
bool on_comment_part(string_view, boost::system::error_code&) { return true; }
|
||||
bool on_comment(string_view, boost::system::error_code&) { return true; }
|
||||
};
|
||||
|
||||
basic_parser<handler> p_;
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
write(
|
||||
char const* data,
|
||||
std::size_t size,
|
||||
error_code& ec)
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
auto const n = p_.write_some( false, data, size, ec );
|
||||
if(! ec && n < size)
|
||||
@@ -86,7 +86,7 @@ validate( string_view s )
|
||||
{
|
||||
// Parse with the null parser and return false on error
|
||||
null_parser p;
|
||||
error_code ec;
|
||||
boost::system::error_code ec;
|
||||
p.write( s.data(), s.size(), ec );
|
||||
if( ec )
|
||||
return false;
|
||||
|
||||
@@ -26,24 +26,24 @@ class null_parser
|
||||
constexpr static std::size_t max_key_size = std::size_t(-1);
|
||||
constexpr static std::size_t max_string_size = std::size_t(-1);
|
||||
|
||||
bool on_document_begin( error_code& ) { return true; }
|
||||
bool on_document_end( error_code& ) { return true; }
|
||||
bool on_object_begin( error_code& ) { return true; }
|
||||
bool on_object_end( std::size_t, error_code& ) { return true; }
|
||||
bool on_array_begin( error_code& ) { return true; }
|
||||
bool on_array_end( std::size_t, error_code& ) { return true; }
|
||||
bool on_key_part( string_view, std::size_t, error_code& ) { return true; }
|
||||
bool on_key( string_view, std::size_t, error_code& ) { return true; }
|
||||
bool on_string_part( string_view, std::size_t, error_code& ) { return true; }
|
||||
bool on_string( string_view, std::size_t, error_code& ) { return true; }
|
||||
bool on_number_part( string_view, error_code& ) { return true; }
|
||||
bool on_int64( std::int64_t, string_view, error_code& ) { return true; }
|
||||
bool on_uint64( std::uint64_t, string_view, error_code& ) { return true; }
|
||||
bool on_double( double, string_view, error_code& ) { return true; }
|
||||
bool on_bool( bool, error_code& ) { return true; }
|
||||
bool on_null( error_code& ) { return true; }
|
||||
bool on_comment_part(string_view, error_code&) { return true; }
|
||||
bool on_comment(string_view, error_code&) { return true; }
|
||||
bool on_document_begin( boost::system::error_code& ) { return true; }
|
||||
bool on_document_end( boost::system::error_code& ) { return true; }
|
||||
bool on_object_begin( boost::system::error_code& ) { return true; }
|
||||
bool on_object_end( std::size_t, boost::system::error_code& ) { return true; }
|
||||
bool on_array_begin( boost::system::error_code& ) { return true; }
|
||||
bool on_array_end( std::size_t, boost::system::error_code& ) { return true; }
|
||||
bool on_key_part( string_view, std::size_t, boost::system::error_code& ) { return true; }
|
||||
bool on_key( string_view, std::size_t, boost::system::error_code& ) { return true; }
|
||||
bool on_string_part( string_view, std::size_t, boost::system::error_code& ) { return true; }
|
||||
bool on_string( string_view, std::size_t, boost::system::error_code& ) { return true; }
|
||||
bool on_number_part( string_view, boost::system::error_code& ) { return true; }
|
||||
bool on_int64( std::int64_t, string_view, boost::system::error_code& ) { return true; }
|
||||
bool on_uint64( std::uint64_t, string_view, boost::system::error_code& ) { return true; }
|
||||
bool on_double( double, string_view, boost::system::error_code& ) { return true; }
|
||||
bool on_bool( bool, boost::system::error_code& ) { return true; }
|
||||
bool on_null( boost::system::error_code& ) { return true; }
|
||||
bool on_comment_part(string_view, boost::system::error_code&) { return true; }
|
||||
bool on_comment(string_view, boost::system::error_code&) { return true; }
|
||||
};
|
||||
|
||||
basic_parser<handler> p_;
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
write(
|
||||
char const* data,
|
||||
std::size_t size,
|
||||
error_code& ec)
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
auto const n = p_.write_some( false, data, size, ec );
|
||||
if(! ec && n < size)
|
||||
@@ -76,7 +76,7 @@ validate( string_view s )
|
||||
{
|
||||
// Parse with the null parser and return false on error
|
||||
null_parser p;
|
||||
error_code ec;
|
||||
boost::system::error_code ec;
|
||||
p.write( s.data(), s.size(), ec );
|
||||
if( ec )
|
||||
return false;
|
||||
|
||||
@@ -15,7 +15,7 @@ using namespace boost::json;
|
||||
bool
|
||||
fuzz_parse(string_view sv)
|
||||
{
|
||||
error_code ec;
|
||||
boost::system::error_code ec;
|
||||
value jv = parse( sv, ec );
|
||||
if(ec)
|
||||
return false;
|
||||
|
||||
@@ -24,7 +24,7 @@ struct FuzzHelper {
|
||||
std::size_t memlimit2;
|
||||
bool res;
|
||||
void run(stream_parser& p) {
|
||||
error_code ec;
|
||||
boost::system::error_code ec;
|
||||
|
||||
// Write the first part of the buffer
|
||||
p.write( jsontext, ec);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <boost/json/conversion.hpp>
|
||||
#include <boost/json/error.hpp>
|
||||
#include <boost/json/fwd.hpp>
|
||||
#include <boost/json/is_deallocate_trivial.hpp>
|
||||
#include <boost/json/kind.hpp>
|
||||
#include <boost/json/memory_resource.hpp>
|
||||
#include <boost/json/monotonic_resource.hpp>
|
||||
@@ -27,6 +28,7 @@
|
||||
#include <boost/json/parse_options.hpp>
|
||||
#include <boost/json/parser.hpp>
|
||||
#include <boost/json/pilfer.hpp>
|
||||
#include <boost/json/result_for.hpp>
|
||||
#include <boost/json/serialize.hpp>
|
||||
#include <boost/json/serializer.hpp>
|
||||
#include <boost/json/set_pointer_options.hpp>
|
||||
|
||||
@@ -117,15 +117,15 @@ class array
|
||||
array(detail::unchecked_array&& ua);
|
||||
|
||||
public:
|
||||
/** The type of <em>Allocator</em> returned by @ref get_allocator
|
||||
/** Associated [Allocator](https://en.cppreference.com/w/cpp/named_req/Allocator)
|
||||
|
||||
This type is a @ref polymorphic_allocator.
|
||||
*/
|
||||
This type is `boost::container::pmr::polymorphic_allocator<value>`.
|
||||
*/
|
||||
#ifdef BOOST_JSON_DOCS
|
||||
// VFALCO doc toolchain renders this incorrectly
|
||||
using allocator_type = __see_below__;
|
||||
#else
|
||||
using allocator_type = polymorphic_allocator<value>;
|
||||
// VFALCO doc toolchain renders this incorrectly
|
||||
using allocator_type = container::pmr::polymorphic_allocator<value>;
|
||||
#endif
|
||||
|
||||
/// The type used to represent unsigned integers
|
||||
@@ -169,7 +169,7 @@ public:
|
||||
|
||||
The destructor for each element is called if needed,
|
||||
any used memory is deallocated, and shared ownership
|
||||
of the @ref memory_resource is released.
|
||||
of the `boost::container::pmr::memory_resource` is released.
|
||||
|
||||
@par Complexity
|
||||
Constant, or linear in @ref size().
|
||||
@@ -211,7 +211,7 @@ public:
|
||||
@par Exception Safety
|
||||
No-throw guarantee.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource`
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
*/
|
||||
@@ -240,7 +240,7 @@ public:
|
||||
|
||||
@param v The value to be inserted.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource`
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
*/
|
||||
@@ -264,7 +264,7 @@ public:
|
||||
|
||||
@param count The number of nulls to insert.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource`
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
*/
|
||||
@@ -299,7 +299,7 @@ public:
|
||||
@param last An input iterator pointing to the end
|
||||
of the range.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource`
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
|
||||
@@ -350,7 +350,7 @@ public:
|
||||
|
||||
@param other The array to copy
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource`
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
*/
|
||||
@@ -442,7 +442,7 @@ public:
|
||||
|
||||
@param other The container to move
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource`
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
*/
|
||||
@@ -466,7 +466,7 @@ public:
|
||||
|
||||
@param init The initializer list to insert
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource`
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
*/
|
||||
@@ -547,10 +547,10 @@ public:
|
||||
|
||||
//------------------------------------------------------
|
||||
|
||||
/** Return the associated @ref memory_resource
|
||||
/** Return the associated memory resource.
|
||||
|
||||
This returns the @ref memory_resource used by
|
||||
the container.
|
||||
This function returns the `boost::container::pmr::memory_resource` used
|
||||
by the container.
|
||||
|
||||
@par Complexity
|
||||
Constant.
|
||||
@@ -564,11 +564,10 @@ public:
|
||||
return sp_;
|
||||
}
|
||||
|
||||
/** Return the associated @ref memory_resource
|
||||
/** Return the associated allocator.
|
||||
|
||||
This function returns an instance of
|
||||
@ref polymorphic_allocator constructed from the
|
||||
associated @ref memory_resource.
|
||||
This function returns an instance of @ref allocator_type constructed
|
||||
from the associated `boost::container::pmr::memory_resource`.
|
||||
|
||||
@par Complexity
|
||||
Constant.
|
||||
@@ -593,14 +592,14 @@ public:
|
||||
Returns a reference to the element specified at
|
||||
location `pos`, with bounds checking. If `pos` is
|
||||
not within the range of the container, an exception
|
||||
of type @ref system_error is thrown.
|
||||
of type `boost::system::system_error` is thrown.
|
||||
|
||||
@par Complexity
|
||||
Constant.
|
||||
|
||||
@param pos A zero-based index.
|
||||
|
||||
@throw system_error `pos >= size()`
|
||||
@throw `boost::system::system_error` `pos >= size()`.
|
||||
*/
|
||||
/* @{ */
|
||||
inline
|
||||
@@ -1070,7 +1069,7 @@ public:
|
||||
|
||||
@param new_capacity The new capacity of the array.
|
||||
|
||||
@throw system_error `new_capacity > max_size()`
|
||||
@throw `boost::system::system_error` `new_capacity > max_size()`.
|
||||
*/
|
||||
inline
|
||||
void
|
||||
@@ -1141,7 +1140,7 @@ public:
|
||||
be inserted. This may be the @ref end() iterator.
|
||||
|
||||
@param v The value to insert. A copy will be made
|
||||
using container's associated @ref memory_resource.
|
||||
using container's associated `boost::container::pmr::memory_resource`.
|
||||
|
||||
@return An iterator to the inserted value
|
||||
*/
|
||||
@@ -1173,7 +1172,8 @@ public:
|
||||
|
||||
@param v The value to insert. Ownership of the
|
||||
value will be transferred via move construction,
|
||||
using the container's associated @ref memory_resource.
|
||||
using the container's
|
||||
associated `boost::container::pmr::memory_resource`.
|
||||
|
||||
@return An iterator to the inserted value
|
||||
*/
|
||||
@@ -1206,7 +1206,8 @@ public:
|
||||
@param count The number of copies to insert.
|
||||
|
||||
@param v The value to insert. Copies will be made
|
||||
using container's associated @ref memory_resource.
|
||||
using the container's
|
||||
associated `boost::container::pmr::memory_resource`.
|
||||
|
||||
@return An iterator to the first inserted value,
|
||||
or `pos` if `count == 0`.
|
||||
@@ -1406,8 +1407,8 @@ public:
|
||||
Strong guarantee.
|
||||
Calls to `memory_resource::allocate` may throw.
|
||||
|
||||
@param v The value to insert. A copy will be made
|
||||
using container's associated @ref memory_resource.
|
||||
@param v The value to insert. A copy will be made using the container's
|
||||
associated `boost::container::pmr::memory_resource`.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
void
|
||||
@@ -1429,9 +1430,9 @@ public:
|
||||
Strong guarantee.
|
||||
Calls to `memory_resource::allocate` may throw.
|
||||
|
||||
@param v The value to insert. Ownership of the
|
||||
value will be transferred via move construction,
|
||||
using the container's associated @ref memory_resource.
|
||||
@param v The value to insert. Ownership of the value will be
|
||||
transferred via move construction, using the container's
|
||||
associated `boost::container::pmr::memory_resource`.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
void
|
||||
@@ -1543,8 +1544,8 @@ public:
|
||||
/** Swap the contents.
|
||||
|
||||
Exchanges the contents of this array with another
|
||||
array. Ownership of the respective @ref memory_resource
|
||||
objects is not transferred.
|
||||
array. Ownership of the respective
|
||||
`boost::container::pmr::memory_resource` objects is not transferred.
|
||||
|
||||
@li If `*other.storage() == *this->storage()`,
|
||||
ownership of the underlying memory is swapped in
|
||||
@@ -1572,9 +1573,9 @@ public:
|
||||
|
||||
/** Exchange the given values.
|
||||
|
||||
Exchanges the contents of the array `lhs` with
|
||||
another array `rhs`. Ownership of the respective
|
||||
@ref memory_resource objects is not transferred.
|
||||
Exchanges the contents of the array `lhs` with another array `rhs`.
|
||||
Ownership of the respective `boost::container::pmr::memory_resource`
|
||||
objects is not transferred.
|
||||
|
||||
@li If `*lhs.storage() == *rhs.storage()`,
|
||||
ownership of the underlying memory is swapped in
|
||||
|
||||
@@ -299,7 +299,7 @@ class basic_parser
|
||||
Handler h_;
|
||||
|
||||
number num_;
|
||||
error_code ec_;
|
||||
system::error_code ec_;
|
||||
detail::stack st_;
|
||||
detail::utf8_sequence seq_;
|
||||
unsigned u1_;
|
||||
@@ -571,7 +571,7 @@ public:
|
||||
@par Exception Safety
|
||||
No-throw guarantee.
|
||||
*/
|
||||
error_code
|
||||
system::error_code
|
||||
last_error() const noexcept
|
||||
{
|
||||
return ec_;
|
||||
@@ -640,7 +640,7 @@ public:
|
||||
instead.
|
||||
*/
|
||||
void
|
||||
fail(error_code ec) noexcept;
|
||||
fail(system::error_code ec) noexcept;
|
||||
|
||||
/** Parse some of an input string as JSON, incrementally.
|
||||
|
||||
@@ -698,7 +698,7 @@ public:
|
||||
bool more,
|
||||
char const* data,
|
||||
std::size_t size,
|
||||
error_code& ec);
|
||||
system::error_code& ec);
|
||||
|
||||
std::size_t
|
||||
write_some(
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
#include <boost/json/detail/buffer.hpp>
|
||||
#include <boost/json/detail/charconv/from_chars.hpp>
|
||||
#include <boost/json/detail/sse2.hpp>
|
||||
#include <boost/mp11/algorithm.hpp>
|
||||
#include <boost/mp11/integral.hpp>
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
#include <cstring>
|
||||
@@ -2818,7 +2820,7 @@ reset() noexcept
|
||||
template<class Handler>
|
||||
void
|
||||
basic_parser<Handler>::
|
||||
fail(error_code ec) noexcept
|
||||
fail(system::error_code ec) noexcept
|
||||
{
|
||||
if(! ec)
|
||||
{
|
||||
@@ -2842,7 +2844,7 @@ write_some(
|
||||
bool more,
|
||||
char const* data,
|
||||
std::size_t size,
|
||||
error_code& ec)
|
||||
system::error_code& ec)
|
||||
{
|
||||
// see if we exited via exception
|
||||
// on the last call to write_some
|
||||
@@ -2929,7 +2931,7 @@ write_some(
|
||||
std::size_t size,
|
||||
std::error_code& ec)
|
||||
{
|
||||
error_code jec;
|
||||
system::error_code jec;
|
||||
std::size_t const result = write_some(more, data, size, jec);
|
||||
ec = jec;
|
||||
return result;
|
||||
|
||||
@@ -28,7 +28,7 @@ class
|
||||
BOOST_SYMBOL_VISIBLE
|
||||
BOOST_JSON_DECL
|
||||
default_resource final
|
||||
: public memory_resource
|
||||
: public container::pmr::memory_resource
|
||||
{
|
||||
union holder;
|
||||
|
||||
@@ -43,7 +43,7 @@ default_resource final
|
||||
|
||||
public:
|
||||
static
|
||||
memory_resource*
|
||||
container::pmr::memory_resource*
|
||||
get() noexcept
|
||||
{
|
||||
#ifdef BOOST_JSON_WEAK_CONSTINIT
|
||||
|
||||
@@ -24,7 +24,7 @@ BOOST_JSON_DECL
|
||||
void
|
||||
BOOST_NORETURN
|
||||
throw_system_error(
|
||||
error_code const& ec,
|
||||
system::error_code const& ec,
|
||||
source_location const& loc = BOOST_CURRENT_LOCATION);
|
||||
|
||||
BOOST_JSON_DECL
|
||||
|
||||
@@ -41,24 +41,24 @@ struct handler
|
||||
explicit
|
||||
handler(Args&&... args);
|
||||
|
||||
inline bool on_document_begin(error_code& ec);
|
||||
inline bool on_document_end(error_code& ec);
|
||||
inline bool on_object_begin(error_code& ec);
|
||||
inline bool on_object_end(std::size_t n, error_code& ec);
|
||||
inline bool on_array_begin(error_code& ec);
|
||||
inline bool on_array_end(std::size_t n, error_code& ec);
|
||||
inline bool on_key_part(string_view s, std::size_t n, error_code& ec);
|
||||
inline bool on_key(string_view s, std::size_t n, error_code& ec);
|
||||
inline bool on_string_part(string_view s, std::size_t n, error_code& ec);
|
||||
inline bool on_string(string_view s, std::size_t n, error_code& ec);
|
||||
inline bool on_number_part(string_view, error_code&);
|
||||
inline bool on_int64(std::int64_t i, string_view, error_code& ec);
|
||||
inline bool on_uint64(std::uint64_t u, string_view, error_code& ec);
|
||||
inline bool on_double(double d, string_view, error_code& ec);
|
||||
inline bool on_bool(bool b, error_code& ec);
|
||||
inline bool on_null(error_code& ec);
|
||||
inline bool on_comment_part(string_view, error_code&);
|
||||
inline bool on_comment(string_view, error_code&);
|
||||
inline bool on_document_begin(system::error_code& ec);
|
||||
inline bool on_document_end(system::error_code& ec);
|
||||
inline bool on_object_begin(system::error_code& ec);
|
||||
inline bool on_object_end(std::size_t n, system::error_code& ec);
|
||||
inline bool on_array_begin(system::error_code& ec);
|
||||
inline bool on_array_end(std::size_t n, system::error_code& ec);
|
||||
inline bool on_key_part(string_view s, std::size_t n, system::error_code& ec);
|
||||
inline bool on_key(string_view s, std::size_t n, system::error_code& ec);
|
||||
inline bool on_string_part(string_view s, std::size_t n, system::error_code& ec);
|
||||
inline bool on_string(string_view s, std::size_t n, system::error_code& ec);
|
||||
inline bool on_number_part(string_view, system::error_code&);
|
||||
inline bool on_int64(std::int64_t i, string_view, system::error_code& ec);
|
||||
inline bool on_uint64(std::uint64_t u, string_view, system::error_code& ec);
|
||||
inline bool on_double(double d, string_view, system::error_code& ec);
|
||||
inline bool on_bool(bool b, system::error_code& ec);
|
||||
inline bool on_null(system::error_code& ec);
|
||||
inline bool on_comment_part(string_view, system::error_code&);
|
||||
inline bool on_comment(string_view, system::error_code&);
|
||||
};
|
||||
|
||||
} // detail
|
||||
|
||||
@@ -22,11 +22,11 @@ namespace detail {
|
||||
|
||||
void
|
||||
throw_system_error(
|
||||
error_code const& ec,
|
||||
system::error_code const& ec,
|
||||
source_location const& loc)
|
||||
{
|
||||
throw_exception(
|
||||
system_error(ec),
|
||||
system::system_error(ec),
|
||||
loc);
|
||||
}
|
||||
|
||||
@@ -35,11 +35,11 @@ throw_system_error(
|
||||
error e,
|
||||
source_location const* loc)
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
ec.assign(e, loc);
|
||||
|
||||
throw_exception(
|
||||
system_error(ec),
|
||||
system::system_error(ec),
|
||||
*loc);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ handler(Args&&... args)
|
||||
bool
|
||||
handler::
|
||||
on_document_begin(
|
||||
error_code&)
|
||||
system::error_code&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -35,7 +35,7 @@ on_document_begin(
|
||||
bool
|
||||
handler::
|
||||
on_document_end(
|
||||
error_code&)
|
||||
system::error_code&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -43,7 +43,7 @@ on_document_end(
|
||||
bool
|
||||
handler::
|
||||
on_object_begin(
|
||||
error_code&)
|
||||
system::error_code&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -52,7 +52,7 @@ bool
|
||||
handler::
|
||||
on_object_end(
|
||||
std::size_t n,
|
||||
error_code&)
|
||||
system::error_code&)
|
||||
{
|
||||
st.push_object(n);
|
||||
return true;
|
||||
@@ -61,7 +61,7 @@ on_object_end(
|
||||
bool
|
||||
handler::
|
||||
on_array_begin(
|
||||
error_code&)
|
||||
system::error_code&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -70,7 +70,7 @@ bool
|
||||
handler::
|
||||
on_array_end(
|
||||
std::size_t n,
|
||||
error_code&)
|
||||
system::error_code&)
|
||||
{
|
||||
st.push_array(n);
|
||||
return true;
|
||||
@@ -81,29 +81,29 @@ handler::
|
||||
on_key_part(
|
||||
string_view s,
|
||||
std::size_t,
|
||||
error_code&)
|
||||
system::error_code&)
|
||||
{
|
||||
st.push_chars(s);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
handler::
|
||||
on_key(
|
||||
string_view s,
|
||||
std::size_t,
|
||||
error_code&)
|
||||
system::error_code&)
|
||||
{
|
||||
st.push_key(s);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
handler::
|
||||
on_string_part(
|
||||
string_view s,
|
||||
std::size_t,
|
||||
error_code&)
|
||||
std::size_t,
|
||||
system::error_code&)
|
||||
{
|
||||
st.push_chars(s);
|
||||
return true;
|
||||
@@ -113,8 +113,8 @@ bool
|
||||
handler::
|
||||
on_string(
|
||||
string_view s,
|
||||
std::size_t,
|
||||
error_code&)
|
||||
std::size_t,
|
||||
system::error_code&)
|
||||
{
|
||||
st.push_string(s);
|
||||
return true;
|
||||
@@ -124,7 +124,7 @@ bool
|
||||
handler::
|
||||
on_number_part(
|
||||
string_view,
|
||||
error_code&)
|
||||
system::error_code&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -134,18 +134,18 @@ handler::
|
||||
on_int64(
|
||||
std::int64_t i,
|
||||
string_view,
|
||||
error_code&)
|
||||
system::error_code&)
|
||||
{
|
||||
st.push_int64(i);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
handler::
|
||||
on_uint64(
|
||||
std::uint64_t u,
|
||||
string_view,
|
||||
error_code&)
|
||||
system::error_code&)
|
||||
{
|
||||
st.push_uint64(u);
|
||||
return true;
|
||||
@@ -156,17 +156,17 @@ handler::
|
||||
on_double(
|
||||
double d,
|
||||
string_view,
|
||||
error_code&)
|
||||
system::error_code&)
|
||||
{
|
||||
st.push_double(d);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
handler::
|
||||
on_bool(
|
||||
bool b,
|
||||
error_code&)
|
||||
system::error_code&)
|
||||
{
|
||||
st.push_bool(b);
|
||||
return true;
|
||||
@@ -174,7 +174,7 @@ on_bool(
|
||||
|
||||
bool
|
||||
handler::
|
||||
on_null(error_code&)
|
||||
on_null(system::error_code&)
|
||||
{
|
||||
st.push_null();
|
||||
return true;
|
||||
@@ -184,15 +184,15 @@ bool
|
||||
handler::
|
||||
on_comment_part(
|
||||
string_view,
|
||||
error_code&)
|
||||
system::error_code&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
handler::
|
||||
on_comment(
|
||||
string_view, error_code&)
|
||||
string_view, system::error_code&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -92,23 +92,23 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
bool on_object_begin( error_code& ec ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
||||
bool on_array_begin( error_code& ec ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
||||
bool on_array_end( error_code& ec ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
||||
bool on_string_part( error_code& ec, string_view ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
||||
bool on_string( error_code& ec, string_view ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
||||
bool on_number_part( error_code& ec ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
||||
bool on_int64( error_code& ec, std::int64_t ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
||||
bool on_uint64( error_code& ec, std::uint64_t ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
||||
bool on_double( error_code& ec, double ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
||||
bool on_bool( error_code& ec, bool ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
||||
bool on_null( error_code& ec ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
||||
bool on_object_begin( system::error_code& ec ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
||||
bool on_array_begin( system::error_code& ec ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
||||
bool on_array_end( system::error_code& ec ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
||||
bool on_string_part( system::error_code& ec, string_view ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
||||
bool on_string( system::error_code& ec, string_view ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
||||
bool on_number_part( system::error_code& ec ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
||||
bool on_int64( system::error_code& ec, std::int64_t ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
||||
bool on_uint64( system::error_code& ec, std::uint64_t ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
||||
bool on_double( system::error_code& ec, double ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
||||
bool on_bool( system::error_code& ec, bool ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
||||
bool on_null( system::error_code& ec ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
||||
|
||||
// LCOV_EXCL_START
|
||||
// parses that can't handle this would fail at on_object_begin
|
||||
bool on_object_end( error_code& ) { BOOST_ASSERT( false ); return false; }
|
||||
bool on_key_part( error_code& ec, string_view ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
||||
bool on_key( error_code& ec, string_view ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
||||
bool on_object_end( system::error_code& ) { BOOST_ASSERT( false ); return false; }
|
||||
bool on_key_part( system::error_code& ec, string_view ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
||||
bool on_key( system::error_code& ec, string_view ) { BOOST_JSON_FAIL( ec, E ); return false; }
|
||||
// LCOV_EXCL_START
|
||||
};
|
||||
|
||||
@@ -126,7 +126,7 @@ public:
|
||||
scalar_handler(P* p): parent_( p )
|
||||
{}
|
||||
|
||||
bool on_array_end( error_code& ec )
|
||||
bool on_array_end( system::error_code& ec )
|
||||
{
|
||||
return parent_->signal_end(ec);
|
||||
}
|
||||
@@ -158,7 +158,7 @@ public:
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
bool signal_end(error_code&)
|
||||
bool signal_end(system::error_code&)
|
||||
{
|
||||
inner_active_ = false;
|
||||
parent_->signal_value();
|
||||
@@ -173,72 +173,72 @@ public:
|
||||
else \
|
||||
return inner_.f
|
||||
|
||||
bool on_object_begin( error_code& ec )
|
||||
bool on_object_begin( system::error_code& ec )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_object_begin(ec) );
|
||||
}
|
||||
|
||||
bool on_object_end( error_code& ec )
|
||||
bool on_object_end( system::error_code& ec )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_object_end(ec) );
|
||||
}
|
||||
|
||||
bool on_array_begin( error_code& ec )
|
||||
bool on_array_begin( system::error_code& ec )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_array_begin(ec) );
|
||||
}
|
||||
|
||||
bool on_array_end( error_code& ec )
|
||||
bool on_array_end( system::error_code& ec )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_array_end(ec) );
|
||||
}
|
||||
|
||||
bool on_key_part( error_code& ec, string_view sv )
|
||||
bool on_key_part( system::error_code& ec, string_view sv )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_key_part(ec, sv) );
|
||||
}
|
||||
|
||||
bool on_key( error_code& ec, string_view sv )
|
||||
bool on_key( system::error_code& ec, string_view sv )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_key(ec, sv) );
|
||||
}
|
||||
|
||||
bool on_string_part( error_code& ec, string_view sv )
|
||||
bool on_string_part( system::error_code& ec, string_view sv )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_string_part(ec, sv) );
|
||||
}
|
||||
|
||||
bool on_string( error_code& ec, string_view sv )
|
||||
bool on_string( system::error_code& ec, string_view sv )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_string(ec, sv) );
|
||||
}
|
||||
|
||||
bool on_number_part( error_code& ec )
|
||||
bool on_number_part( system::error_code& ec )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_number_part(ec) );
|
||||
}
|
||||
|
||||
bool on_int64( error_code& ec, std::int64_t v )
|
||||
bool on_int64( system::error_code& ec, std::int64_t v )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_int64(ec, v) );
|
||||
}
|
||||
|
||||
bool on_uint64( error_code& ec, std::uint64_t v )
|
||||
bool on_uint64( system::error_code& ec, std::uint64_t v )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_uint64(ec, v) );
|
||||
}
|
||||
|
||||
bool on_double( error_code& ec, double v )
|
||||
bool on_double( system::error_code& ec, double v )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_double(ec, v) );
|
||||
}
|
||||
|
||||
bool on_bool( error_code& ec, bool v )
|
||||
bool on_bool( system::error_code& ec, bool v )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_bool(ec, v) );
|
||||
}
|
||||
|
||||
bool on_null( error_code& ec )
|
||||
bool on_null( system::error_code& ec )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_null(ec) );
|
||||
}
|
||||
@@ -280,12 +280,12 @@ public:
|
||||
, value_(v)
|
||||
{}
|
||||
|
||||
bool on_number_part( error_code& )
|
||||
bool on_number_part( system::error_code& )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool on_int64( error_code& ec, std::int64_t v )
|
||||
bool on_int64( system::error_code& ec, std::int64_t v )
|
||||
{
|
||||
if( !integral_in_range<V>( v ) )
|
||||
{
|
||||
@@ -299,7 +299,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool on_uint64( error_code& ec, std::uint64_t v )
|
||||
bool on_uint64( system::error_code& ec, std::uint64_t v )
|
||||
{
|
||||
if( !integral_in_range<V>( v ) )
|
||||
{
|
||||
@@ -328,12 +328,12 @@ public:
|
||||
, value_(v)
|
||||
{}
|
||||
|
||||
bool on_number_part( error_code& )
|
||||
bool on_number_part( system::error_code& )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool on_int64( error_code&, std::int64_t v )
|
||||
bool on_int64( system::error_code&, std::int64_t v )
|
||||
{
|
||||
*value_ = static_cast<V>( v );
|
||||
|
||||
@@ -341,7 +341,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool on_uint64( error_code&, std::uint64_t v )
|
||||
bool on_uint64( system::error_code&, std::uint64_t v )
|
||||
{
|
||||
*value_ = static_cast<V>( v );
|
||||
|
||||
@@ -349,7 +349,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool on_double( error_code&, double v )
|
||||
bool on_double( system::error_code&, double v )
|
||||
{
|
||||
*value_ = static_cast<V>( v );
|
||||
|
||||
@@ -373,7 +373,7 @@ public:
|
||||
, value_(v)
|
||||
{}
|
||||
|
||||
bool on_string_part( error_code&, string_view sv )
|
||||
bool on_string_part( system::error_code&, string_view sv )
|
||||
{
|
||||
if( !cleared_ )
|
||||
{
|
||||
@@ -385,7 +385,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool on_string( error_code&, string_view sv )
|
||||
bool on_string( system::error_code&, string_view sv )
|
||||
{
|
||||
if( !cleared_ )
|
||||
value_->clear();
|
||||
@@ -413,7 +413,7 @@ public:
|
||||
, value_(v)
|
||||
{}
|
||||
|
||||
bool on_bool( error_code&, bool v )
|
||||
bool on_bool( system::error_code&, bool v )
|
||||
{
|
||||
*value_ = v;
|
||||
|
||||
@@ -436,7 +436,7 @@ public:
|
||||
, value_(v)
|
||||
{}
|
||||
|
||||
bool on_null( error_code& )
|
||||
bool on_null( system::error_code& )
|
||||
{
|
||||
*value_ = {};
|
||||
|
||||
@@ -467,13 +467,13 @@ public:
|
||||
, value_(v)
|
||||
{}
|
||||
|
||||
bool on_string_part( error_code&, string_view sv )
|
||||
bool on_string_part( system::error_code&, string_view sv )
|
||||
{
|
||||
name_.append( sv.begin(), sv.end() );
|
||||
return true;
|
||||
}
|
||||
|
||||
bool on_string( error_code& ec, string_view sv )
|
||||
bool on_string( system::error_code& ec, string_view sv )
|
||||
{
|
||||
string_view name = sv;
|
||||
if( !name_.empty() )
|
||||
@@ -575,7 +575,7 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
bool signal_end(error_code& ec)
|
||||
bool signal_end(system::error_code& ec)
|
||||
{
|
||||
if( !check_inserter( inserter, value_->end() ) )
|
||||
{
|
||||
@@ -588,7 +588,7 @@ public:
|
||||
return converting_handler::composite_handler::signal_end(ec);
|
||||
}
|
||||
|
||||
bool on_array_begin( error_code& ec )
|
||||
bool on_array_begin( system::error_code& ec )
|
||||
{
|
||||
if( this->inner_active_ )
|
||||
return this->inner_.on_array_begin( ec );
|
||||
@@ -598,7 +598,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool on_array_end( error_code& ec )
|
||||
bool on_array_end( system::error_code& ec )
|
||||
{
|
||||
if( this->inner_active_ )
|
||||
return this->inner_.on_array_end( ec );
|
||||
@@ -635,7 +635,7 @@ public:
|
||||
this->inner_active_ = false;
|
||||
}
|
||||
|
||||
bool on_object_begin( error_code& ec )
|
||||
bool on_object_begin( system::error_code& ec )
|
||||
{
|
||||
if( this->inner_active_ )
|
||||
return this->inner_.on_object_begin(ec);
|
||||
@@ -644,7 +644,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool on_object_end( error_code& ec )
|
||||
bool on_object_end( system::error_code& ec )
|
||||
{
|
||||
if( this->inner_active_ )
|
||||
return this->inner_.on_object_end(ec);
|
||||
@@ -653,7 +653,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool on_array_end( error_code& ec )
|
||||
bool on_array_end( system::error_code& ec )
|
||||
{
|
||||
if( this->inner_active_ )
|
||||
return this->inner_.on_array_end(ec);
|
||||
@@ -661,7 +661,7 @@ public:
|
||||
return this->parent_->signal_end(ec);
|
||||
}
|
||||
|
||||
bool on_key_part( error_code& ec, string_view sv )
|
||||
bool on_key_part( system::error_code& ec, string_view sv )
|
||||
{
|
||||
if( this->inner_active_ )
|
||||
return this->inner_.on_key_part(ec, sv);
|
||||
@@ -670,7 +670,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool on_key( error_code& ec, string_view sv )
|
||||
bool on_key( system::error_code& ec, string_view sv )
|
||||
{
|
||||
if( this->inner_active_ )
|
||||
return this->inner_.on_key(ec, sv);
|
||||
@@ -820,7 +820,7 @@ public:
|
||||
++inner_active_;
|
||||
}
|
||||
|
||||
bool signal_end(error_code& ec)
|
||||
bool signal_end(system::error_code& ec)
|
||||
{
|
||||
constexpr int N = std::tuple_size<T>::value;
|
||||
if( inner_active_ < N )
|
||||
@@ -845,7 +845,7 @@ public:
|
||||
}; \
|
||||
\
|
||||
template< class... Args > \
|
||||
bool fn( error_code& ec, Args&& ... args ) \
|
||||
bool fn( system::error_code& ec, Args&& ... args ) \
|
||||
{ \
|
||||
if( inner_active_ < 0 ) \
|
||||
{ \
|
||||
@@ -858,7 +858,7 @@ public:
|
||||
BOOST_JSON_FAIL( ec, error::size_mismatch ); \
|
||||
return false; \
|
||||
} \
|
||||
using F = handler_op_invoker< do_ ## fn, error_code, Args...>; \
|
||||
using F = handler_op_invoker< do_ ## fn, system::error_code, Args...>; \
|
||||
using H = decltype(handlers_); \
|
||||
return mp11::mp_with_index<N>( \
|
||||
inner_active_, \
|
||||
@@ -873,7 +873,7 @@ public:
|
||||
struct do_on_array_begin
|
||||
{
|
||||
handler_tuple< converting_handler, tuple_element_list<T> >& handlers;
|
||||
error_code& ec;
|
||||
system::error_code& ec;
|
||||
|
||||
template< class I >
|
||||
bool operator()( I ) const
|
||||
@@ -881,7 +881,7 @@ public:
|
||||
return get<I::value>(handlers).on_array_begin(ec);
|
||||
}
|
||||
};
|
||||
bool on_array_begin( error_code& ec )
|
||||
bool on_array_begin( system::error_code& ec )
|
||||
{
|
||||
if( inner_active_ < 0 )
|
||||
{
|
||||
@@ -904,7 +904,7 @@ public:
|
||||
struct do_on_array_end
|
||||
{
|
||||
handler_tuple< converting_handler, tuple_element_list<T> >& handlers;
|
||||
error_code& ec;
|
||||
system::error_code& ec;
|
||||
|
||||
template< class I >
|
||||
bool operator()( I ) const
|
||||
@@ -912,7 +912,7 @@ public:
|
||||
return get<I::value>(handlers).on_array_end(ec);
|
||||
}
|
||||
};
|
||||
bool on_array_end( error_code& ec )
|
||||
bool on_array_end( system::error_code& ec )
|
||||
{
|
||||
if( inner_active_ < 0 )
|
||||
return parent_->signal_end(ec);
|
||||
@@ -1045,7 +1045,7 @@ public:
|
||||
inner_active_ = -1;
|
||||
}
|
||||
|
||||
bool signal_end(error_code&)
|
||||
bool signal_end(system::error_code&)
|
||||
{
|
||||
key_ = {};
|
||||
inner_active_ = -1;
|
||||
@@ -1066,7 +1066,7 @@ public:
|
||||
inner_active_, \
|
||||
tuple_handler_op_invoker<H, F>{handlers_, f} );
|
||||
|
||||
bool on_object_begin( error_code& ec )
|
||||
bool on_object_begin( system::error_code& ec )
|
||||
{
|
||||
if( inner_active_ < 0 )
|
||||
return true;
|
||||
@@ -1074,7 +1074,7 @@ public:
|
||||
BOOST_JSON_INVOKE_INNER( on_object_begin(ec) );
|
||||
}
|
||||
|
||||
bool on_object_end( error_code& ec )
|
||||
bool on_object_end( system::error_code& ec )
|
||||
{
|
||||
if( inner_active_ < 0 )
|
||||
{
|
||||
@@ -1094,12 +1094,12 @@ public:
|
||||
BOOST_JSON_INVOKE_INNER( on_object_end(ec) );
|
||||
}
|
||||
|
||||
bool on_array_begin( error_code& ec )
|
||||
bool on_array_begin( system::error_code& ec )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_array_begin(ec) );
|
||||
}
|
||||
|
||||
bool on_array_end( error_code& ec )
|
||||
bool on_array_end( system::error_code& ec )
|
||||
{
|
||||
if( inner_active_ < 0 )
|
||||
return parent_->signal_end(ec);
|
||||
@@ -1107,7 +1107,7 @@ public:
|
||||
BOOST_JSON_INVOKE_INNER( on_array_end(ec) );
|
||||
}
|
||||
|
||||
bool on_key_part( error_code& ec, string_view sv )
|
||||
bool on_key_part( system::error_code& ec, string_view sv )
|
||||
{
|
||||
if( inner_active_ < 0 )
|
||||
{
|
||||
@@ -1118,7 +1118,7 @@ public:
|
||||
BOOST_JSON_INVOKE_INNER( on_key_part(ec, sv) );
|
||||
}
|
||||
|
||||
bool on_key( error_code& ec, string_view sv )
|
||||
bool on_key( system::error_code& ec, string_view sv )
|
||||
{
|
||||
if( inner_active_ >= 0 )
|
||||
{
|
||||
@@ -1153,42 +1153,42 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool on_string_part( error_code& ec, string_view sv )
|
||||
bool on_string_part( system::error_code& ec, string_view sv )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_string_part(ec, sv) );
|
||||
}
|
||||
|
||||
bool on_string( error_code& ec, string_view sv )
|
||||
bool on_string( system::error_code& ec, string_view sv )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_string(ec, sv) );
|
||||
}
|
||||
|
||||
bool on_number_part( error_code& ec )
|
||||
bool on_number_part( system::error_code& ec )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_number_part(ec) );
|
||||
}
|
||||
|
||||
bool on_int64( error_code& ec, std::int64_t v )
|
||||
bool on_int64( system::error_code& ec, std::int64_t v )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_int64(ec, v) );
|
||||
}
|
||||
|
||||
bool on_uint64( error_code& ec, std::uint64_t v )
|
||||
bool on_uint64( system::error_code& ec, std::uint64_t v )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_uint64(ec, v) );
|
||||
}
|
||||
|
||||
bool on_double( error_code& ec, double v )
|
||||
bool on_double( system::error_code& ec, double v )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_double(ec, v) );
|
||||
}
|
||||
|
||||
bool on_bool( error_code& ec, bool v )
|
||||
bool on_bool( system::error_code& ec, bool v )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_bool(ec, v) );
|
||||
}
|
||||
|
||||
bool on_null( error_code& ec )
|
||||
bool on_null( system::error_code& ec )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_null(ec) );
|
||||
}
|
||||
@@ -1261,7 +1261,7 @@ template< class H >
|
||||
struct event_visitor
|
||||
{
|
||||
H& handler;
|
||||
error_code& ec;
|
||||
system::error_code& ec;
|
||||
|
||||
bool
|
||||
operator()(object_begin_handler_event&) const
|
||||
@@ -1369,7 +1369,7 @@ public:
|
||||
parent_->signal_value();
|
||||
}
|
||||
|
||||
bool signal_end(error_code& ec)
|
||||
bool signal_end(system::error_code& ec)
|
||||
{
|
||||
return parent_->signal_end(ec);
|
||||
}
|
||||
@@ -1400,7 +1400,7 @@ public:
|
||||
struct event_processor
|
||||
{
|
||||
converting_handler* self;
|
||||
error_code& ec;
|
||||
system::error_code& ec;
|
||||
parse_event& event;
|
||||
|
||||
template< class I >
|
||||
@@ -1412,7 +1412,7 @@ public:
|
||||
event_visitor<Handler>{handler, ec}, event );
|
||||
}
|
||||
};
|
||||
bool process_events(error_code& ec)
|
||||
bool process_events(system::error_code& ec)
|
||||
{
|
||||
constexpr std::size_t N = variant_size::value;
|
||||
|
||||
@@ -1453,22 +1453,22 @@ public:
|
||||
events_.emplace_back( ev ); \
|
||||
return process_events(ec);
|
||||
|
||||
bool on_object_begin( error_code& ec )
|
||||
bool on_object_begin( system::error_code& ec )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( object_begin_handler_event{}, ec );
|
||||
}
|
||||
|
||||
bool on_object_end( error_code& ec )
|
||||
bool on_object_end( system::error_code& ec )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( object_end_handler_event{}, ec );
|
||||
}
|
||||
|
||||
bool on_array_begin( error_code& ec )
|
||||
bool on_array_begin( system::error_code& ec )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( array_begin_handler_event{}, ec );
|
||||
}
|
||||
|
||||
bool on_array_end( error_code& ec )
|
||||
bool on_array_end( system::error_code& ec )
|
||||
{
|
||||
if( !inner_active_ )
|
||||
return signal_end(ec);
|
||||
@@ -1476,57 +1476,57 @@ public:
|
||||
BOOST_JSON_INVOKE_INNER( array_end_handler_event{}, ec );
|
||||
}
|
||||
|
||||
bool on_key_part( error_code&, string_view sv )
|
||||
bool on_key_part( system::error_code&, string_view sv )
|
||||
{
|
||||
string_.append(sv);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool on_key( error_code& ec, string_view sv )
|
||||
bool on_key( system::error_code& ec, string_view sv )
|
||||
{
|
||||
string_.append(sv);
|
||||
BOOST_JSON_INVOKE_INNER( key_handler_event{ std::move(string_) }, ec );
|
||||
}
|
||||
|
||||
bool on_string_part( error_code&, string_view sv )
|
||||
bool on_string_part( system::error_code&, string_view sv )
|
||||
{
|
||||
string_.append(sv);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool on_string( error_code& ec, string_view sv )
|
||||
bool on_string( system::error_code& ec, string_view sv )
|
||||
{
|
||||
string_.append(sv);
|
||||
BOOST_JSON_INVOKE_INNER(
|
||||
string_handler_event{ std::move(string_) }, ec );
|
||||
}
|
||||
|
||||
bool on_number_part( error_code& )
|
||||
bool on_number_part( system::error_code& )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool on_int64( error_code& ec, std::int64_t v )
|
||||
bool on_int64( system::error_code& ec, std::int64_t v )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( int64_handler_event{v}, ec );
|
||||
}
|
||||
|
||||
bool on_uint64( error_code& ec, std::uint64_t v )
|
||||
bool on_uint64( system::error_code& ec, std::uint64_t v )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( uint64_handler_event{v}, ec );
|
||||
}
|
||||
|
||||
bool on_double( error_code& ec, double v )
|
||||
bool on_double( system::error_code& ec, double v )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( double_handler_event{v}, ec );
|
||||
}
|
||||
|
||||
bool on_bool( error_code& ec, bool v )
|
||||
bool on_bool( system::error_code& ec, bool v )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( bool_handler_event{v}, ec );
|
||||
}
|
||||
|
||||
bool on_null( error_code& ec )
|
||||
bool on_null( system::error_code& ec )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( null_handler_event{}, ec );
|
||||
}
|
||||
@@ -1565,7 +1565,7 @@ public:
|
||||
parent_->signal_value();
|
||||
}
|
||||
|
||||
bool signal_end(error_code& ec)
|
||||
bool signal_end(system::error_code& ec)
|
||||
{
|
||||
return parent_->signal_end(ec);
|
||||
}
|
||||
@@ -1575,22 +1575,22 @@ public:
|
||||
inner_active_ = true; \
|
||||
return inner_.fn;
|
||||
|
||||
bool on_object_begin( error_code& ec )
|
||||
bool on_object_begin( system::error_code& ec )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_object_begin(ec) );
|
||||
}
|
||||
|
||||
bool on_object_end( error_code& ec )
|
||||
bool on_object_end( system::error_code& ec )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_object_end(ec) );
|
||||
}
|
||||
|
||||
bool on_array_begin( error_code& ec )
|
||||
bool on_array_begin( system::error_code& ec )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_array_begin(ec) );
|
||||
}
|
||||
|
||||
bool on_array_end( error_code& ec )
|
||||
bool on_array_end( system::error_code& ec )
|
||||
{
|
||||
if( !inner_active_ )
|
||||
return signal_end(ec);
|
||||
@@ -1598,52 +1598,52 @@ public:
|
||||
BOOST_JSON_INVOKE_INNER( on_array_end(ec) );
|
||||
}
|
||||
|
||||
bool on_key_part( error_code& ec, string_view sv )
|
||||
bool on_key_part( system::error_code& ec, string_view sv )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_key_part(ec, sv) );
|
||||
}
|
||||
|
||||
bool on_key( error_code& ec, string_view sv )
|
||||
bool on_key( system::error_code& ec, string_view sv )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_key(ec, sv) );
|
||||
}
|
||||
|
||||
bool on_string_part( error_code& ec, string_view sv )
|
||||
bool on_string_part( system::error_code& ec, string_view sv )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_string_part(ec, sv) );
|
||||
}
|
||||
|
||||
bool on_string( error_code& ec, string_view sv )
|
||||
bool on_string( system::error_code& ec, string_view sv )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_string(ec, sv) );
|
||||
}
|
||||
|
||||
bool on_number_part( error_code& ec )
|
||||
bool on_number_part( system::error_code& ec )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_number_part(ec) );
|
||||
}
|
||||
|
||||
bool on_int64( error_code& ec, std::int64_t v )
|
||||
bool on_int64( system::error_code& ec, std::int64_t v )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_int64(ec, v) );
|
||||
}
|
||||
|
||||
bool on_uint64( error_code& ec, std::uint64_t v )
|
||||
bool on_uint64( system::error_code& ec, std::uint64_t v )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_uint64(ec, v) );
|
||||
}
|
||||
|
||||
bool on_double( error_code& ec, double v )
|
||||
bool on_double( system::error_code& ec, double v )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_double(ec, v) );
|
||||
}
|
||||
|
||||
bool on_bool( error_code& ec, bool v )
|
||||
bool on_bool( system::error_code& ec, bool v )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_bool(ec, v) );
|
||||
}
|
||||
|
||||
bool on_null( error_code& ec )
|
||||
bool on_null( system::error_code& ec )
|
||||
{
|
||||
if( !inner_active_ )
|
||||
{
|
||||
@@ -1676,7 +1676,7 @@ public:
|
||||
, value_(v)
|
||||
{}
|
||||
|
||||
bool on_string_part( error_code&, string_view sv )
|
||||
bool on_string_part( system::error_code&, string_view sv )
|
||||
{
|
||||
if( !cleared_ )
|
||||
{
|
||||
@@ -1688,7 +1688,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool on_string( error_code&, string_view sv )
|
||||
bool on_string( system::error_code&, string_view sv )
|
||||
{
|
||||
if( !cleared_ )
|
||||
value_->clear();
|
||||
@@ -1735,17 +1735,17 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
bool signal_end(error_code&)
|
||||
bool signal_end(system::error_code&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool on_document_begin( error_code& )
|
||||
bool on_document_begin( system::error_code& )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool on_document_end( error_code& )
|
||||
bool on_document_end( system::error_code& )
|
||||
{
|
||||
inner_active_ = false;
|
||||
return true;
|
||||
@@ -1760,82 +1760,82 @@ public:
|
||||
else \
|
||||
return inner_.f
|
||||
|
||||
bool on_object_begin( error_code& ec )
|
||||
bool on_object_begin( system::error_code& ec )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_object_begin(ec) );
|
||||
}
|
||||
|
||||
bool on_object_end( std::size_t, error_code& ec )
|
||||
bool on_object_end( std::size_t, system::error_code& ec )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_object_end(ec) );
|
||||
}
|
||||
|
||||
bool on_array_begin( error_code& ec )
|
||||
bool on_array_begin( system::error_code& ec )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_array_begin(ec) );
|
||||
}
|
||||
|
||||
bool on_array_end( std::size_t, error_code& ec )
|
||||
bool on_array_end( std::size_t, system::error_code& ec )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_array_end(ec) );
|
||||
}
|
||||
|
||||
bool on_key_part( string_view sv, std::size_t, error_code& ec )
|
||||
bool on_key_part( string_view sv, std::size_t, system::error_code& ec )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_key_part(ec, sv) );
|
||||
}
|
||||
|
||||
bool on_key( string_view sv, std::size_t, error_code& ec )
|
||||
bool on_key( string_view sv, std::size_t, system::error_code& ec )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_key(ec, sv) );
|
||||
}
|
||||
|
||||
bool on_string_part( string_view sv, std::size_t, error_code& ec )
|
||||
bool on_string_part( string_view sv, std::size_t, system::error_code& ec )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_string_part(ec, sv) );
|
||||
}
|
||||
|
||||
bool on_string( string_view sv, std::size_t, error_code& ec )
|
||||
bool on_string( string_view sv, std::size_t, system::error_code& ec )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_string(ec, sv) );
|
||||
}
|
||||
|
||||
bool on_number_part( string_view, error_code& ec )
|
||||
bool on_number_part( string_view, system::error_code& ec )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_number_part(ec) );
|
||||
}
|
||||
|
||||
bool on_int64( std::int64_t v, string_view, error_code& ec )
|
||||
bool on_int64( std::int64_t v, string_view, system::error_code& ec )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_int64(ec, v) );
|
||||
}
|
||||
|
||||
bool on_uint64( std::uint64_t v, string_view, error_code& ec )
|
||||
bool on_uint64( std::uint64_t v, string_view, system::error_code& ec )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_uint64(ec, v) );
|
||||
}
|
||||
|
||||
bool on_double( double v, string_view, error_code& ec )
|
||||
bool on_double( double v, string_view, system::error_code& ec )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_double(ec, v) );
|
||||
}
|
||||
|
||||
bool on_bool( bool v, error_code& ec )
|
||||
bool on_bool( bool v, system::error_code& ec )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_bool(ec, v) );
|
||||
}
|
||||
|
||||
bool on_null( error_code& ec )
|
||||
bool on_null( system::error_code& ec )
|
||||
{
|
||||
BOOST_JSON_INVOKE_INNER( on_null(ec) );
|
||||
}
|
||||
|
||||
bool on_comment_part(string_view, error_code&)
|
||||
bool on_comment_part(string_view, system::error_code&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool on_comment(string_view, error_code&)
|
||||
bool on_comment(string_view, system::error_code&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#ifndef BOOST_JSON_DETAIL_SHARED_RESOURCE_HPP
|
||||
#define BOOST_JSON_DETAIL_SHARED_RESOURCE_HPP
|
||||
|
||||
#include <boost/container/pmr/memory_resource.hpp>
|
||||
#include <boost/json/memory_resource.hpp>
|
||||
#include <atomic>
|
||||
#include <utility>
|
||||
@@ -25,7 +26,7 @@ namespace detail {
|
||||
|
||||
struct BOOST_SYMBOL_VISIBLE
|
||||
shared_resource
|
||||
: memory_resource
|
||||
: container::pmr::memory_resource
|
||||
{
|
||||
BOOST_JSON_DECL
|
||||
shared_resource();
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#ifndef BOOST_JSON_DETAIL_VALUE_HPP
|
||||
#define BOOST_JSON_DETAIL_VALUE_HPP
|
||||
|
||||
#include <boost/json/fwd.hpp>
|
||||
#include <boost/json/kind.hpp>
|
||||
#include <boost/json/storage_ptr.hpp>
|
||||
#include <cstdint>
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include <boost/json/value.hpp>
|
||||
#include <boost/json/conversion.hpp>
|
||||
#include <boost/json/result_for.hpp>
|
||||
#include <boost/describe/enum_from_string.hpp>
|
||||
|
||||
#ifndef BOOST_NO_CXX17_HDR_OPTIONAL
|
||||
@@ -72,7 +73,7 @@ try_reserve(
|
||||
|
||||
// identity conversion
|
||||
template< class Ctx >
|
||||
result<value>
|
||||
system::result<value>
|
||||
value_to_impl(
|
||||
value_conversion_tag,
|
||||
try_value_to_tag<value>,
|
||||
@@ -92,7 +93,7 @@ value_to_impl(
|
||||
|
||||
// object
|
||||
template< class Ctx >
|
||||
result<object>
|
||||
system::result<object>
|
||||
value_to_impl(
|
||||
object_conversion_tag,
|
||||
try_value_to_tag<object>,
|
||||
@@ -102,14 +103,14 @@ value_to_impl(
|
||||
object const* obj = jv.if_object();
|
||||
if( obj )
|
||||
return *obj;
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
BOOST_JSON_FAIL(ec, error::not_object);
|
||||
return ec;
|
||||
}
|
||||
|
||||
// array
|
||||
template< class Ctx >
|
||||
result<array>
|
||||
system::result<array>
|
||||
value_to_impl(
|
||||
array_conversion_tag,
|
||||
try_value_to_tag<array>,
|
||||
@@ -119,14 +120,14 @@ value_to_impl(
|
||||
array const* arr = jv.if_array();
|
||||
if( arr )
|
||||
return *arr;
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
BOOST_JSON_FAIL(ec, error::not_array);
|
||||
return ec;
|
||||
}
|
||||
|
||||
// string
|
||||
template< class Ctx >
|
||||
result<string>
|
||||
system::result<string>
|
||||
value_to_impl(
|
||||
string_conversion_tag,
|
||||
try_value_to_tag<string>,
|
||||
@@ -136,32 +137,32 @@ value_to_impl(
|
||||
string const* str = jv.if_string();
|
||||
if( str )
|
||||
return *str;
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
BOOST_JSON_FAIL(ec, error::not_string);
|
||||
return ec;
|
||||
}
|
||||
|
||||
// bool
|
||||
template< class Ctx >
|
||||
result<bool>
|
||||
system::result<bool>
|
||||
value_to_impl(
|
||||
bool_conversion_tag, try_value_to_tag<bool>, value const& jv, Ctx const& )
|
||||
{
|
||||
auto b = jv.if_bool();
|
||||
if( b )
|
||||
return *b;
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
BOOST_JSON_FAIL(ec, error::not_bool);
|
||||
return {boost::system::in_place_error, ec};
|
||||
}
|
||||
|
||||
// integral and floating point
|
||||
template< class T, class Ctx >
|
||||
result<T>
|
||||
system::result<T>
|
||||
value_to_impl(
|
||||
number_conversion_tag, try_value_to_tag<T>, value const& jv, Ctx const& )
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
auto const n = jv.to_number<T>(ec);
|
||||
if( ec.failed() )
|
||||
return {boost::system::in_place_error, ec};
|
||||
@@ -170,7 +171,7 @@ value_to_impl(
|
||||
|
||||
// null-like conversion
|
||||
template< class T, class Ctx >
|
||||
result<T>
|
||||
system::result<T>
|
||||
value_to_impl(
|
||||
null_like_conversion_tag,
|
||||
try_value_to_tag<T>,
|
||||
@@ -179,14 +180,14 @@ value_to_impl(
|
||||
{
|
||||
if( jv.is_null() )
|
||||
return {boost::system::in_place_value, T{}};
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
BOOST_JSON_FAIL(ec, error::not_null);
|
||||
return {boost::system::in_place_error, ec};
|
||||
}
|
||||
|
||||
// string-like types
|
||||
template< class T, class Ctx >
|
||||
result<T>
|
||||
system::result<T>
|
||||
value_to_impl(
|
||||
string_like_conversion_tag,
|
||||
try_value_to_tag<T>,
|
||||
@@ -196,14 +197,14 @@ value_to_impl(
|
||||
auto str = jv.if_string();
|
||||
if( str )
|
||||
return {boost::system::in_place_value, T(str->subview())};
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
BOOST_JSON_FAIL(ec, error::not_string);
|
||||
return {boost::system::in_place_error, ec};
|
||||
}
|
||||
|
||||
// map-like containers
|
||||
template< class T, class Ctx >
|
||||
result<T>
|
||||
system::result<T>
|
||||
value_to_impl(
|
||||
map_like_conversion_tag,
|
||||
try_value_to_tag<T>,
|
||||
@@ -213,7 +214,7 @@ value_to_impl(
|
||||
object const* obj = jv.if_object();
|
||||
if( !obj )
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
BOOST_JSON_FAIL(ec, error::not_object);
|
||||
return {boost::system::in_place_error, ec};
|
||||
}
|
||||
@@ -223,7 +224,7 @@ value_to_impl(
|
||||
res, obj->size(), reserve_implementation<T>());
|
||||
if( e != error() )
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
BOOST_JSON_FAIL( ec, e );
|
||||
return {boost::system::in_place_error, ec};
|
||||
}
|
||||
@@ -243,7 +244,7 @@ value_to_impl(
|
||||
|
||||
// all other containers
|
||||
template< class T, class Ctx >
|
||||
result<T>
|
||||
system::result<T>
|
||||
value_to_impl(
|
||||
sequence_conversion_tag,
|
||||
try_value_to_tag<T>,
|
||||
@@ -253,7 +254,7 @@ value_to_impl(
|
||||
array const* arr = jv.if_array();
|
||||
if( !arr )
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
BOOST_JSON_FAIL(ec, error::not_array);
|
||||
return {boost::system::in_place_error, ec};
|
||||
}
|
||||
@@ -263,7 +264,7 @@ value_to_impl(
|
||||
result, arr->size(), reserve_implementation<T>());
|
||||
if( e != error() )
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
BOOST_JSON_FAIL( ec, e );
|
||||
return {boost::system::in_place_error, ec};
|
||||
}
|
||||
@@ -281,8 +282,8 @@ value_to_impl(
|
||||
|
||||
// tuple-like types
|
||||
template< class T, class Ctx >
|
||||
result<T>
|
||||
try_make_tuple_elem(value const& jv, Ctx const& ctx, error_code& ec)
|
||||
system::result<T>
|
||||
try_make_tuple_elem(value const& jv, Ctx const& ctx, system::error_code& ec)
|
||||
{
|
||||
if( ec.failed() )
|
||||
return {boost::system::in_place_error, ec};
|
||||
@@ -293,11 +294,11 @@ try_make_tuple_elem(value const& jv, Ctx const& ctx, error_code& ec)
|
||||
}
|
||||
|
||||
template <class T, class Ctx, std::size_t... Is>
|
||||
result<T>
|
||||
system::result<T>
|
||||
try_make_tuple_like(
|
||||
array const& arr, Ctx const& ctx, boost::mp11::index_sequence<Is...>)
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
auto items = std::make_tuple(
|
||||
try_make_tuple_elem<
|
||||
typename std::decay<tuple_element_t<Is, T>>::type >(
|
||||
@@ -311,14 +312,14 @@ try_make_tuple_like(
|
||||
}
|
||||
|
||||
template< class T, class Ctx >
|
||||
result<T>
|
||||
system::result<T>
|
||||
value_to_impl(
|
||||
tuple_conversion_tag,
|
||||
try_value_to_tag<T>,
|
||||
value const& jv,
|
||||
Ctx const& ctx )
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
|
||||
array const* arr = jv.if_array();
|
||||
if( !arr )
|
||||
@@ -344,7 +345,8 @@ struct to_described_member
|
||||
using Ds = describe::describe_members<
|
||||
T, describe::mod_public | describe::mod_inherited>;
|
||||
|
||||
using result_type = mp11::mp_eval_if_c< !non_throwing, T, result, T >;
|
||||
using result_type = mp11::mp_eval_if_c<
|
||||
!non_throwing, T, system::result, T>;
|
||||
|
||||
result_type& res;
|
||||
object const& obj;
|
||||
@@ -366,7 +368,7 @@ struct to_described_member
|
||||
{
|
||||
BOOST_IF_CONSTEXPR( !is_optional_like<M>::value )
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
BOOST_JSON_FAIL(ec, error::unknown_name);
|
||||
res = {boost::system::in_place_error, ec};
|
||||
}
|
||||
@@ -394,7 +396,7 @@ struct to_described_member
|
||||
|
||||
// described classes
|
||||
template< class T, class Ctx >
|
||||
result<T>
|
||||
system::result<T>
|
||||
value_to_impl(
|
||||
described_class_conversion_tag,
|
||||
try_value_to_tag<T>,
|
||||
@@ -402,12 +404,12 @@ value_to_impl(
|
||||
Ctx const& ctx )
|
||||
{
|
||||
BOOST_STATIC_ASSERT( std::is_default_constructible<T>::value );
|
||||
result<T> res;
|
||||
system::result<T> res;
|
||||
|
||||
auto* obj = jv.if_object();
|
||||
if( !obj )
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
BOOST_JSON_FAIL(ec, error::not_object);
|
||||
res = {boost::system::in_place_error, ec};
|
||||
return res;
|
||||
@@ -424,7 +426,7 @@ value_to_impl(
|
||||
|
||||
if( member_converter.count != obj->size() )
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
BOOST_JSON_FAIL(ec, error::size_mismatch);
|
||||
res = {boost::system::in_place_error, ec};
|
||||
return res;
|
||||
@@ -435,7 +437,7 @@ value_to_impl(
|
||||
|
||||
// described enums
|
||||
template< class T, class Ctx >
|
||||
result<T>
|
||||
system::result<T>
|
||||
value_to_impl(
|
||||
described_enum_conversion_tag,
|
||||
try_value_to_tag<T>,
|
||||
@@ -445,7 +447,7 @@ value_to_impl(
|
||||
T val = {};
|
||||
(void)jv;
|
||||
#ifdef BOOST_DESCRIBE_CXX14
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
|
||||
auto str = jv.if_string();
|
||||
if( !str )
|
||||
@@ -466,7 +468,7 @@ value_to_impl(
|
||||
|
||||
// optionals
|
||||
template< class T, class Ctx >
|
||||
result<T>
|
||||
system::result<T>
|
||||
value_to_impl(
|
||||
optional_conversion_tag,
|
||||
try_value_to_tag<T>,
|
||||
@@ -520,7 +522,7 @@ initialize_variant( V&& v, mp11::mp_int<1> )
|
||||
template< class T, class Ctx >
|
||||
struct alternative_converter
|
||||
{
|
||||
result<T>& res;
|
||||
system::result<T>& res;
|
||||
value const& jv;
|
||||
Ctx const& ctx;
|
||||
|
||||
@@ -541,32 +543,32 @@ struct alternative_converter
|
||||
};
|
||||
|
||||
template< class T, class Ctx >
|
||||
result<T>
|
||||
system::result<T>
|
||||
value_to_impl(
|
||||
variant_conversion_tag,
|
||||
try_value_to_tag<T>,
|
||||
value const& jv,
|
||||
Ctx const& ctx)
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
BOOST_JSON_FAIL(ec, error::exhausted_variants);
|
||||
|
||||
using Is = mp11::mp_iota< mp11::mp_size<T> >;
|
||||
|
||||
result<T> res = {system::in_place_error, ec};
|
||||
system::result<T> res = {system::in_place_error, ec};
|
||||
mp11::mp_for_each<Is>( alternative_converter<T, Ctx>{res, jv, ctx} );
|
||||
return res;
|
||||
}
|
||||
|
||||
template< class T, class Ctx >
|
||||
result<T>
|
||||
system::result<T>
|
||||
value_to_impl(
|
||||
path_conversion_tag, try_value_to_tag<T>, value const& jv, Ctx const& )
|
||||
{
|
||||
auto str = jv.if_string();
|
||||
if( !str )
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
BOOST_JSON_FAIL(ec, error::not_string);
|
||||
return {boost::system::in_place_error, ec};
|
||||
}
|
||||
@@ -701,7 +703,8 @@ value_to_impl(
|
||||
// User-provided conversions; nonthrowing -> nonthrowing
|
||||
template< class T, class Ctx >
|
||||
mp11::mp_if<
|
||||
mp11::mp_valid<has_nonthrowing_user_conversion_to_impl, T>, result<T> >
|
||||
mp11::mp_valid<
|
||||
has_nonthrowing_user_conversion_to_impl, T>, system::result<T> >
|
||||
value_to_impl(
|
||||
user_conversion_tag, try_value_to_tag<T>, value const& jv, Ctx const& )
|
||||
{
|
||||
@@ -716,7 +719,7 @@ template<
|
||||
mp11::mp_if<
|
||||
mp11::mp_valid<
|
||||
has_nonthrowing_context_conversion_to_impl, typename Sup::type, T>,
|
||||
result<T> >
|
||||
system::result<T> >
|
||||
value_to_impl(
|
||||
context_conversion_tag,
|
||||
try_value_to_tag<T> tag,
|
||||
@@ -736,7 +739,7 @@ mp11::mp_if<
|
||||
has_nonthrowing_full_context_conversion_to_impl,
|
||||
typename Sup::type,
|
||||
T>,
|
||||
result<T> >
|
||||
system::result<T> >
|
||||
value_to_impl(
|
||||
full_context_conversion_tag,
|
||||
try_value_to_tag<T> tag,
|
||||
@@ -759,7 +762,7 @@ struct does_allow_exceptions< std::tuple<allow_exceptions, Ctxes...> >
|
||||
{ };
|
||||
|
||||
template< class T, class... Args >
|
||||
result<T>
|
||||
system::result<T>
|
||||
wrap_conversion_exceptions( std::true_type, value_to_tag<T>, Args&& ... args )
|
||||
{
|
||||
return {
|
||||
@@ -768,7 +771,7 @@ wrap_conversion_exceptions( std::true_type, value_to_tag<T>, Args&& ... args )
|
||||
}
|
||||
|
||||
template< class T, class... Args >
|
||||
result<T>
|
||||
system::result<T>
|
||||
wrap_conversion_exceptions( std::false_type, value_to_tag<T>, Args&& ... args )
|
||||
{
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
@@ -785,13 +788,13 @@ wrap_conversion_exceptions( std::false_type, value_to_tag<T>, Args&& ... args )
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch( system_error const& e)
|
||||
catch( system::system_error const& e)
|
||||
{
|
||||
return {boost::system::in_place_error, e.code()};
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
BOOST_JSON_FAIL(ec, error::exception);
|
||||
return {boost::system::in_place_error, ec};
|
||||
}
|
||||
@@ -801,7 +804,7 @@ wrap_conversion_exceptions( std::false_type, value_to_tag<T>, Args&& ... args )
|
||||
template< class T, class Ctx >
|
||||
mp11::mp_if_c<
|
||||
!mp11::mp_valid<has_nonthrowing_user_conversion_to_impl, T>::value,
|
||||
result<T> >
|
||||
system::result<T> >
|
||||
value_to_impl(
|
||||
user_conversion_tag, try_value_to_tag<T>, value const& jv, Ctx const& )
|
||||
{
|
||||
@@ -819,7 +822,7 @@ mp11::mp_if_c<
|
||||
has_nonthrowing_context_conversion_to_impl,
|
||||
typename Sup::type,
|
||||
T>::value,
|
||||
result<T> >
|
||||
system::result<T> >
|
||||
value_to_impl(
|
||||
context_conversion_tag,
|
||||
try_value_to_tag<T>,
|
||||
@@ -840,7 +843,7 @@ mp11::mp_if_c<
|
||||
has_nonthrowing_full_context_conversion_to_impl,
|
||||
typename Sup::type,
|
||||
T>::value,
|
||||
result<T> >
|
||||
system::result<T> >
|
||||
value_to_impl(
|
||||
full_context_conversion_tag,
|
||||
try_value_to_tag<T>,
|
||||
@@ -882,14 +885,14 @@ using value_to_category = conversion_category<
|
||||
|
||||
#ifndef BOOST_NO_CXX17_HDR_OPTIONAL
|
||||
inline
|
||||
result<std::nullopt_t>
|
||||
system::result<std::nullopt_t>
|
||||
tag_invoke(
|
||||
try_value_to_tag<std::nullopt_t>,
|
||||
value const& jv)
|
||||
{
|
||||
if( jv.is_null() )
|
||||
return std::nullopt;
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
BOOST_JSON_FAIL(ec, error::not_null);
|
||||
return ec;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <boost/describe/bases.hpp>
|
||||
#include <boost/mp11/algorithm.hpp>
|
||||
#include <boost/mp11/utility.hpp>
|
||||
#include <boost/system/result.hpp>
|
||||
|
||||
#include <iterator>
|
||||
#include <tuple>
|
||||
@@ -484,7 +485,7 @@ using has_valueless_by_exception =
|
||||
template <class T>
|
||||
struct result_for<T, value>
|
||||
{
|
||||
using type = result< detail::remove_cvref<T> >;
|
||||
using type = system::result< detail::remove_cvref<T> >;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#ifndef BOOST_JSON_IMPL_ERROR_HPP
|
||||
#define BOOST_JSON_IMPL_ERROR_HPP
|
||||
|
||||
#include <boost/system/error_category.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost {
|
||||
@@ -45,11 +46,11 @@ namespace json {
|
||||
namespace detail {
|
||||
|
||||
struct error_code_category_t
|
||||
: error_category
|
||||
: system::error_category
|
||||
{
|
||||
constexpr
|
||||
error_code_category_t()
|
||||
: error_category(0xB9A9B9922177C772)
|
||||
: system::error_category(0xB9A9B9922177C772)
|
||||
{}
|
||||
|
||||
BOOST_JSON_DECL
|
||||
@@ -65,7 +66,7 @@ struct error_code_category_t
|
||||
message( int ev ) const override;
|
||||
|
||||
BOOST_JSON_DECL
|
||||
error_condition
|
||||
system::error_condition
|
||||
default_error_condition( int ev ) const noexcept override;
|
||||
};
|
||||
|
||||
@@ -74,11 +75,11 @@ BOOST_JSON_DECL
|
||||
error_code_category_t error_code_category;
|
||||
|
||||
struct error_condition_category_t
|
||||
: error_category
|
||||
: system::error_category
|
||||
{
|
||||
constexpr
|
||||
error_condition_category_t()
|
||||
: error_category(0x37CEF5A036D24FD1)
|
||||
: system::error_category(0x37CEF5A036D24FD1)
|
||||
{}
|
||||
|
||||
BOOST_JSON_DECL
|
||||
@@ -102,21 +103,21 @@ error_condition_category_t error_condition_category;
|
||||
|
||||
inline
|
||||
BOOST_SYSTEM_CONSTEXPR
|
||||
error_code
|
||||
system::error_code
|
||||
make_error_code(error e) noexcept
|
||||
{
|
||||
|
||||
return error_code(
|
||||
return system::error_code(
|
||||
static_cast<std::underlying_type<error>::type>(e),
|
||||
detail::error_code_category );
|
||||
}
|
||||
|
||||
inline
|
||||
BOOST_SYSTEM_CONSTEXPR
|
||||
error_condition
|
||||
system::error_condition
|
||||
make_error_condition(condition c) noexcept
|
||||
{
|
||||
return error_condition(
|
||||
return system::error_condition(
|
||||
static_cast<std::underlying_type<condition>::type>(c),
|
||||
detail::error_condition_category );
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ error_code_category_t::message( int ev ) const
|
||||
return message( ev, nullptr, 0 );
|
||||
}
|
||||
|
||||
error_condition
|
||||
system::error_condition
|
||||
error_code_category_t::default_error_condition( int ev) const noexcept
|
||||
{
|
||||
switch(static_cast<error>(ev))
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace detail {
|
||||
`std::bad_alloc` in calls to `allocate`.
|
||||
*/
|
||||
class null_resource final
|
||||
: public memory_resource
|
||||
: public container::pmr::memory_resource
|
||||
{
|
||||
public:
|
||||
/// Copy constructor (deleted)
|
||||
@@ -77,7 +77,7 @@ protected:
|
||||
|
||||
} // detail
|
||||
|
||||
memory_resource*
|
||||
container::pmr::memory_resource*
|
||||
get_null_resource() noexcept
|
||||
{
|
||||
static detail::null_resource mr;
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace json {
|
||||
value
|
||||
parse(
|
||||
string_view s,
|
||||
error_code& ec,
|
||||
system::error_code& ec,
|
||||
storage_ptr sp,
|
||||
const parse_options& opt)
|
||||
{
|
||||
@@ -44,7 +44,7 @@ parse(
|
||||
storage_ptr sp,
|
||||
parse_options const& opt)
|
||||
{
|
||||
error_code jec;
|
||||
system::error_code jec;
|
||||
value result = parse(s, jec, std::move(sp), opt);
|
||||
ec = jec;
|
||||
return result;
|
||||
@@ -56,7 +56,7 @@ parse(
|
||||
storage_ptr sp,
|
||||
const parse_options& opt)
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
auto jv = parse(
|
||||
s, ec, std::move(sp), opt);
|
||||
if(ec)
|
||||
@@ -67,7 +67,7 @@ parse(
|
||||
value
|
||||
parse(
|
||||
std::istream& is,
|
||||
error_code& ec,
|
||||
system::error_code& ec,
|
||||
storage_ptr sp,
|
||||
parse_options const& opt)
|
||||
{
|
||||
@@ -110,7 +110,7 @@ parse(
|
||||
storage_ptr sp,
|
||||
parse_options const& opt)
|
||||
{
|
||||
error_code jec;
|
||||
system::error_code jec;
|
||||
value result = parse(is, jec, std::move(sp), opt);
|
||||
ec = jec;
|
||||
return result;
|
||||
@@ -122,7 +122,7 @@ parse(
|
||||
storage_ptr sp,
|
||||
parse_options const& opt)
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
auto jv = parse(
|
||||
is, ec, std::move(sp), opt);
|
||||
if(ec)
|
||||
|
||||
@@ -23,7 +23,7 @@ void
|
||||
parse_into(
|
||||
V& v,
|
||||
string_view sv,
|
||||
error_code& ec,
|
||||
system::error_code& ec,
|
||||
parse_options const& opt )
|
||||
{
|
||||
parser_for<V> p( opt, &v );
|
||||
@@ -44,7 +44,7 @@ parse_into(
|
||||
std::error_code& ec,
|
||||
parse_options const& opt )
|
||||
{
|
||||
error_code jec;
|
||||
system::error_code jec;
|
||||
parse_into(v, sv, jec, opt);
|
||||
ec = jec;
|
||||
}
|
||||
@@ -56,7 +56,7 @@ parse_into(
|
||||
string_view sv,
|
||||
parse_options const& opt )
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
parse_into(v, sv, ec, opt);
|
||||
if( ec.failed() )
|
||||
detail::throw_system_error( ec );
|
||||
@@ -67,7 +67,7 @@ void
|
||||
parse_into(
|
||||
V& v,
|
||||
std::istream& is,
|
||||
error_code& ec,
|
||||
system::error_code& ec,
|
||||
parse_options const& opt )
|
||||
{
|
||||
parser_for<V> p( opt, &v );
|
||||
@@ -107,7 +107,7 @@ parse_into(
|
||||
std::error_code& ec,
|
||||
parse_options const& opt )
|
||||
{
|
||||
error_code jec;
|
||||
system::error_code jec;
|
||||
parse_into(v, is, jec, opt);
|
||||
ec = jec;
|
||||
}
|
||||
@@ -119,7 +119,7 @@ parse_into(
|
||||
std::istream& is,
|
||||
parse_options const& opt )
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
parse_into(v, is, ec, opt);
|
||||
if( ec.failed() )
|
||||
detail::throw_system_error( ec );
|
||||
|
||||
@@ -61,7 +61,7 @@ parser::
|
||||
write_some(
|
||||
char const* data,
|
||||
std::size_t size,
|
||||
error_code& ec)
|
||||
system::error_code& ec)
|
||||
{
|
||||
auto const n = p_.write_some(
|
||||
false, data, size, ec);
|
||||
@@ -76,7 +76,7 @@ write_some(
|
||||
std::size_t size,
|
||||
std::error_code& ec)
|
||||
{
|
||||
error_code jec;
|
||||
system::error_code jec;
|
||||
std::size_t const result = write_some(data, size, jec);
|
||||
ec = jec;
|
||||
return result;
|
||||
@@ -88,7 +88,7 @@ write_some(
|
||||
char const* data,
|
||||
std::size_t size)
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
auto const n = write_some(
|
||||
data, size, ec);
|
||||
if(ec)
|
||||
@@ -101,7 +101,7 @@ parser::
|
||||
write(
|
||||
char const* data,
|
||||
std::size_t size,
|
||||
error_code& ec)
|
||||
system::error_code& ec)
|
||||
{
|
||||
auto const n = write_some(
|
||||
data, size, ec);
|
||||
@@ -120,7 +120,7 @@ write(
|
||||
std::size_t size,
|
||||
std::error_code& ec)
|
||||
{
|
||||
error_code jec;
|
||||
system::error_code jec;
|
||||
std::size_t const result = write(data, size, jec);
|
||||
ec = jec;
|
||||
return result;
|
||||
@@ -132,7 +132,7 @@ write(
|
||||
char const* data,
|
||||
std::size_t size)
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
auto const n = write(
|
||||
data, size, ec);
|
||||
if(ec)
|
||||
@@ -149,7 +149,7 @@ release()
|
||||
// prevent undefined behavior
|
||||
if(! p_.last_error())
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
BOOST_JSON_FAIL(ec, error::incomplete);
|
||||
p_.fail(ec);
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ bool is_past_the_end_token(
|
||||
std::size_t
|
||||
parse_number_token(
|
||||
string_view sv,
|
||||
error_code& ec) noexcept
|
||||
system::error_code& ec) noexcept
|
||||
{
|
||||
BOOST_ASSERT( !sv.empty() );
|
||||
|
||||
@@ -216,7 +216,7 @@ parse_number_token(
|
||||
string_view
|
||||
next_segment(
|
||||
string_view& sv,
|
||||
error_code& ec) noexcept
|
||||
system::error_code& ec) noexcept
|
||||
{
|
||||
if( sv.empty() )
|
||||
return sv;
|
||||
@@ -285,7 +285,7 @@ Value*
|
||||
walk_pointer(
|
||||
Value& jv,
|
||||
string_view sv,
|
||||
error_code& ec,
|
||||
system::error_code& ec,
|
||||
OnObject on_object,
|
||||
OnArray on_array,
|
||||
OnScalar on_scalar)
|
||||
@@ -344,7 +344,7 @@ walk_pointer(
|
||||
value const&
|
||||
value::at_pointer(string_view ptr) const&
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
auto const found = find_pointer(ptr, ec);
|
||||
if( !found )
|
||||
detail::throw_system_error( ec );
|
||||
@@ -352,7 +352,7 @@ value::at_pointer(string_view ptr) const&
|
||||
}
|
||||
|
||||
value const*
|
||||
value::find_pointer( string_view sv, error_code& ec ) const noexcept
|
||||
value::find_pointer( string_view sv, system::error_code& ec ) const noexcept
|
||||
{
|
||||
return detail::walk_pointer(
|
||||
*this,
|
||||
@@ -362,7 +362,7 @@ value::find_pointer( string_view sv, error_code& ec ) const noexcept
|
||||
{
|
||||
return detail::if_contains_token(obj, token);
|
||||
},
|
||||
[]( array const& arr, std::size_t index, error_code& ec )
|
||||
[]( array const& arr, std::size_t index, system::error_code& ec )
|
||||
-> value const*
|
||||
{
|
||||
if( ec )
|
||||
@@ -377,7 +377,7 @@ value::find_pointer( string_view sv, error_code& ec ) const noexcept
|
||||
}
|
||||
|
||||
value*
|
||||
value::find_pointer(string_view ptr, error_code& ec) noexcept
|
||||
value::find_pointer(string_view ptr, system::error_code& ec) noexcept
|
||||
{
|
||||
value const& self = *this;
|
||||
return const_cast<value*>(self.find_pointer(ptr, ec));
|
||||
@@ -386,7 +386,7 @@ value::find_pointer(string_view ptr, error_code& ec) noexcept
|
||||
value const*
|
||||
value::find_pointer(string_view ptr, std::error_code& ec) const noexcept
|
||||
{
|
||||
error_code jec;
|
||||
system::error_code jec;
|
||||
value const* result = find_pointer(ptr, jec);
|
||||
ec = jec;
|
||||
return result;
|
||||
@@ -403,7 +403,7 @@ value*
|
||||
value::set_at_pointer(
|
||||
string_view sv,
|
||||
value_ref ref,
|
||||
error_code& ec,
|
||||
system::error_code& ec,
|
||||
set_pointer_options const& opts )
|
||||
{
|
||||
value* result = detail::walk_pointer(
|
||||
@@ -422,7 +422,7 @@ value::set_at_pointer(
|
||||
string key( token.begin(), token.end(), obj.storage() );
|
||||
return &obj.emplace( std::move(key), nullptr ).first->value();
|
||||
},
|
||||
[ &opts ]( array& arr, std::size_t index, error_code& ec ) -> value*
|
||||
[ &opts ]( array& arr, std::size_t index, system::error_code& ec ) -> value*
|
||||
{
|
||||
if( ec == error::past_the_end )
|
||||
index = arr.size();
|
||||
@@ -447,7 +447,7 @@ value::set_at_pointer(
|
||||
{
|
||||
if( opts.create_arrays )
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
detail::parse_number_token( segment, ec );
|
||||
if( !ec.failed() || ec == error::past_the_end )
|
||||
{
|
||||
@@ -478,7 +478,7 @@ value::set_at_pointer(
|
||||
std::error_code& ec,
|
||||
set_pointer_options const& opts )
|
||||
{
|
||||
error_code jec;
|
||||
system::error_code jec;
|
||||
value* result = set_at_pointer( sv, ref, jec, opts );
|
||||
ec = jec;
|
||||
return result;
|
||||
@@ -488,7 +488,7 @@ value&
|
||||
value::set_at_pointer(
|
||||
string_view sv, value_ref ref, set_pointer_options const& opts )
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
value* result = set_at_pointer( sv, ref, ec, opts );
|
||||
if( !result )
|
||||
detail::throw_system_error( ec );
|
||||
|
||||
@@ -61,7 +61,7 @@ stream_parser::
|
||||
write_some(
|
||||
char const* data,
|
||||
std::size_t size,
|
||||
error_code& ec)
|
||||
system::error_code& ec)
|
||||
{
|
||||
return p_.write_some(
|
||||
true, data, size, ec);
|
||||
@@ -74,7 +74,7 @@ write_some(
|
||||
std::size_t size,
|
||||
std::error_code& ec)
|
||||
{
|
||||
error_code jec;
|
||||
system::error_code jec;
|
||||
std::size_t const result = write_some(data, size, jec);
|
||||
ec = jec;
|
||||
return result;
|
||||
@@ -86,7 +86,7 @@ write_some(
|
||||
char const* data,
|
||||
std::size_t size)
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
auto const n = write_some(
|
||||
data, size, ec);
|
||||
if(ec)
|
||||
@@ -99,7 +99,7 @@ stream_parser::
|
||||
write(
|
||||
char const* data,
|
||||
std::size_t size,
|
||||
error_code& ec)
|
||||
system::error_code& ec)
|
||||
{
|
||||
auto const n = write_some(
|
||||
data, size, ec);
|
||||
@@ -118,7 +118,7 @@ write(
|
||||
std::size_t size,
|
||||
std::error_code& ec)
|
||||
{
|
||||
error_code jec;
|
||||
system::error_code jec;
|
||||
std::size_t const result = write(data, size, jec);
|
||||
ec = jec;
|
||||
return result;
|
||||
@@ -130,7 +130,7 @@ write(
|
||||
char const* data,
|
||||
std::size_t size)
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
auto const n = write(
|
||||
data, size, ec);
|
||||
if(ec)
|
||||
@@ -140,7 +140,7 @@ write(
|
||||
|
||||
void
|
||||
stream_parser::
|
||||
finish(error_code& ec)
|
||||
finish(system::error_code& ec)
|
||||
{
|
||||
p_.write_some(false, nullptr, 0, ec);
|
||||
}
|
||||
@@ -149,7 +149,7 @@ void
|
||||
stream_parser::
|
||||
finish()
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
finish(ec);
|
||||
if(ec)
|
||||
detail::throw_system_error( ec );
|
||||
@@ -159,7 +159,7 @@ void
|
||||
stream_parser::
|
||||
finish(std::error_code& ec)
|
||||
{
|
||||
error_code jec;
|
||||
system::error_code jec;
|
||||
finish(jec);
|
||||
ec = jec;
|
||||
}
|
||||
|
||||
@@ -445,7 +445,7 @@ operator>>(
|
||||
{
|
||||
while( true )
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
|
||||
// we peek the buffer; this either makes sure that there's no
|
||||
// more input, or makes sure there's something in the internal
|
||||
|
||||
74
include/boost/json/is_deallocate_trivial.hpp
Normal file
74
include/boost/json/is_deallocate_trivial.hpp
Normal file
@@ -0,0 +1,74 @@
|
||||
//
|
||||
// Copyright (c) 2024 Dmitry Arkhipov (grisumbras@yandex.ru)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// Official repository: https://github.com/boostorg/json
|
||||
//
|
||||
|
||||
#ifndef BOOST_JSON_IS_DEALLOCATE_TRIVIAL_HPP
|
||||
#define BOOST_JSON_IS_DEALLOCATE_TRIVIAL_HPP
|
||||
|
||||
namespace boost {
|
||||
namespace json {
|
||||
|
||||
/** Return true if a memory resource's deallocate function has no effect.
|
||||
|
||||
This metafunction may be specialized to indicate to the library that calls
|
||||
to the `deallocate` function of a `boost::container::pmr::memory_resource`
|
||||
have no effect. The implementation will elide such calls when it is safe to
|
||||
do so. By default, the implementation assumes that all memory resources
|
||||
require a call to `deallocate` for each memory region obtained by
|
||||
calling `allocate`.
|
||||
|
||||
@par Example
|
||||
|
||||
This example specializes the metafuction for `my_resource`,
|
||||
to indicate that calls to deallocate have no effect:
|
||||
|
||||
@code
|
||||
|
||||
// Forward-declaration for a user-defined memory resource
|
||||
struct my_resource;
|
||||
|
||||
// It is necessary to specialize the template from
|
||||
// inside the namespace in which it is declared:
|
||||
|
||||
namespace boost {
|
||||
namespace json {
|
||||
|
||||
template<>
|
||||
struct is_deallocate_trivial< my_resource >
|
||||
{
|
||||
static constexpr bool value = true;
|
||||
};
|
||||
|
||||
} // namespace json
|
||||
} // namespace boost
|
||||
|
||||
@endcode
|
||||
|
||||
It is usually not necessary for users to check this trait.
|
||||
Instead, they can call @ref storage_ptr::is_deallocate_trivial
|
||||
to determine if the pointed-to memory resource has a trivial
|
||||
deallocate function.
|
||||
|
||||
@see
|
||||
@ref storage_ptr,
|
||||
[`boost::container::pmr::memory_resource`](https://www.boost.org/doc/libs/release/doc/html/boost/container/pmr/memory_resource.html).
|
||||
*/
|
||||
template<class T>
|
||||
struct is_deallocate_trivial
|
||||
{
|
||||
/** A bool equal to true if calls to `T::do_deallocate` have no effect.
|
||||
|
||||
The primary template sets `value` to false.
|
||||
*/
|
||||
static constexpr bool value = false;
|
||||
};
|
||||
|
||||
} // namespace json
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_JSON_IS_DEALLOCATE_TRIVIAL_HPP
|
||||
@@ -14,93 +14,36 @@
|
||||
|
||||
#include <boost/container/pmr/memory_resource.hpp>
|
||||
#include <boost/container/pmr/polymorphic_allocator.hpp>
|
||||
#include <boost/json/is_deallocate_trivial.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace json {
|
||||
|
||||
#ifdef BOOST_JSON_DOCS
|
||||
|
||||
/** The type of memory resource used by the library.
|
||||
|
||||
Alias for `boost::container::pmr::memory_resource`.
|
||||
@note This alias is deprecated in favor of
|
||||
`boost::container::pmr::memory_resource`. It is included for backwards
|
||||
compatibility and shouldn't be used in new code. It will be removed
|
||||
completely in version 1.87.0.
|
||||
*/
|
||||
class memory_resource
|
||||
{
|
||||
};
|
||||
typedef boost::container::pmr::memory_resource
|
||||
BOOST_DEPRECATED("Use boost::container::pmr::memory_resource instead")
|
||||
memory_resource;
|
||||
|
||||
/** The type of polymorphic allocator used by the library.
|
||||
|
||||
Alias template for `boost::container::pmr::polymorphic_allocator`.
|
||||
@note This alias is deprecated in favor of
|
||||
`boost::container::pmr::polymorphic_allocator`. It is included for
|
||||
backwards compatibility and shouldn't be used in new code. It will be
|
||||
removed completely in version 1.87.0.
|
||||
*/
|
||||
template<class T>
|
||||
class polymorphic_allocator;
|
||||
|
||||
// VFALCO Bug: doc toolchain won't make this a ref
|
||||
//using memory_resource = __see_below__;
|
||||
|
||||
#else
|
||||
using memory_resource = boost::container::pmr::memory_resource;
|
||||
|
||||
template<class T>
|
||||
using polymorphic_allocator =
|
||||
boost::container::pmr::polymorphic_allocator<T>;
|
||||
using
|
||||
polymorphic_allocator
|
||||
#ifndef BOOST_MSVC
|
||||
BOOST_DEPRECATED("Use boost::container::pmr::polymorphic_allocator instead")
|
||||
#endif
|
||||
|
||||
/** Return true if a memory resource's deallocate function has no effect.
|
||||
|
||||
This metafunction may be specialized to indicate to
|
||||
the library that calls to the `deallocate` function of
|
||||
a @ref memory_resource have no effect. The implementation
|
||||
will elide such calls when it is safe to do so. By default,
|
||||
the implementation assumes that all memory resources
|
||||
require a call to `deallocate` for each memory region
|
||||
obtained by calling `allocate`.
|
||||
|
||||
@par Example
|
||||
|
||||
This example specializes the metafuction for `my_resource`,
|
||||
to indicate that calls to deallocate have no effect:
|
||||
|
||||
@code
|
||||
|
||||
// Forward-declaration for a user-defined memory resource
|
||||
struct my_resource;
|
||||
|
||||
// It is necessary to specialize the template from
|
||||
// inside the namespace in which it is declared:
|
||||
|
||||
namespace boost {
|
||||
namespace json {
|
||||
|
||||
template<>
|
||||
struct is_deallocate_trivial< my_resource >
|
||||
{
|
||||
static constexpr bool value = true;
|
||||
};
|
||||
|
||||
} // namespace json
|
||||
} // namespace boost
|
||||
|
||||
@endcode
|
||||
|
||||
It is usually not necessary for users to check this trait.
|
||||
Instead, they can call @ref storage_ptr::is_deallocate_trivial
|
||||
to determine if the pointed-to memory resource has a trivial
|
||||
deallocate function.
|
||||
|
||||
@see
|
||||
@ref memory_resource,
|
||||
@ref storage_ptr
|
||||
*/
|
||||
template<class T>
|
||||
struct is_deallocate_trivial
|
||||
{
|
||||
/** A bool equal to true if calls to `T::do_deallocate` have no effect.
|
||||
|
||||
The primary template sets `value` to false.
|
||||
*/
|
||||
static constexpr bool value = false;
|
||||
};
|
||||
= boost::container::pmr::polymorphic_allocator<T>;
|
||||
|
||||
} // namespace json
|
||||
} // namespace boost
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#ifndef BOOST_JSON_MONOTONIC_RESOURCE_HPP
|
||||
#define BOOST_JSON_MONOTONIC_RESOURCE_HPP
|
||||
|
||||
#include <boost/container/pmr/memory_resource.hpp>
|
||||
#include <boost/json/detail/config.hpp>
|
||||
#include <boost/json/memory_resource.hpp>
|
||||
#include <boost/json/storage_ptr.hpp>
|
||||
@@ -87,7 +88,7 @@ class
|
||||
BOOST_JSON_DECL
|
||||
BOOST_SYMBOL_VISIBLE
|
||||
monotonic_resource final
|
||||
: public memory_resource
|
||||
: public container::pmr::memory_resource
|
||||
{
|
||||
struct block;
|
||||
struct block_base
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#ifndef BOOST_JSON_NULL_RESOURCE_HPP
|
||||
#define BOOST_JSON_NULL_RESOURCE_HPP
|
||||
|
||||
#include <boost/container/pmr/memory_resource.hpp>
|
||||
#include <boost/json/detail/config.hpp>
|
||||
#include <boost/json/memory_resource.hpp>
|
||||
|
||||
@@ -28,7 +29,7 @@ namespace json {
|
||||
No-throw guarantee.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
memory_resource*
|
||||
boost::container::pmr::memory_resource*
|
||||
get_null_resource() noexcept;
|
||||
|
||||
} // namespace json
|
||||
|
||||
@@ -94,15 +94,15 @@ class object
|
||||
object(detail::unchecked_object&& uo);
|
||||
|
||||
public:
|
||||
/** The type of _Allocator_ returned by @ref get_allocator
|
||||
/** Associated [Allocator](https://en.cppreference.com/w/cpp/named_req/Allocator)
|
||||
|
||||
This type is a @ref polymorphic_allocator.
|
||||
This type is a `boost::container::pmr::polymorphic_allocator`.
|
||||
*/
|
||||
#ifdef BOOST_JSON_DOCS
|
||||
// VFALCO doc toolchain renders this incorrectly
|
||||
using allocator_type = __see_below__;
|
||||
#else
|
||||
using allocator_type = polymorphic_allocator<value>;
|
||||
// VFALCO doc toolchain renders this incorrectly
|
||||
using allocator_type = container::pmr::polymorphic_allocator<value>;
|
||||
#endif
|
||||
|
||||
/** The type of keys.
|
||||
@@ -154,9 +154,9 @@ public:
|
||||
|
||||
/** Destructor.
|
||||
|
||||
The destructor for each element is called if needed,
|
||||
any used memory is deallocated, and shared ownership
|
||||
of the @ref memory_resource is released.
|
||||
The destructor for each element is called if needed, any used memory is
|
||||
deallocated, and shared ownership of the
|
||||
`boost::container::pmr::memory_resource` is released.
|
||||
|
||||
@par Complexity
|
||||
Constant, or linear in @ref size().
|
||||
@@ -198,9 +198,9 @@ public:
|
||||
@par Exception Safety
|
||||
No-throw guarantee.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
*/
|
||||
explicit
|
||||
object(storage_ptr sp) noexcept
|
||||
@@ -226,9 +226,9 @@ public:
|
||||
of elements for which capacity is guaranteed
|
||||
without a subsequent reallocation.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
object(
|
||||
@@ -272,9 +272,9 @@ public:
|
||||
Upon construction, @ref capacity() will be greater
|
||||
than or equal to this number.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
|
||||
@tparam InputIt a type satisfying the requirements
|
||||
of __InputIterator__.
|
||||
@@ -349,9 +349,9 @@ public:
|
||||
|
||||
@param other The object to move.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
object(
|
||||
@@ -421,9 +421,9 @@ public:
|
||||
|
||||
@param other The object to copy.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
object(
|
||||
@@ -449,9 +449,9 @@ public:
|
||||
|
||||
@param init The initializer list to insert.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
*/
|
||||
object(
|
||||
std::initializer_list<
|
||||
@@ -488,9 +488,9 @@ public:
|
||||
Upon construction, @ref capacity() will be greater
|
||||
than or equal to this number.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
object(
|
||||
@@ -576,10 +576,10 @@ public:
|
||||
|
||||
//------------------------------------------------------
|
||||
|
||||
/** Return the associated @ref memory_resource
|
||||
/** Return the associated memory resource.
|
||||
|
||||
This returns the @ref memory_resource used by
|
||||
the container.
|
||||
This function returns the `boost::container::pmr::memory_resource` used
|
||||
by the container.
|
||||
|
||||
@par Complexity
|
||||
Constant.
|
||||
@@ -593,11 +593,10 @@ public:
|
||||
return sp_;
|
||||
}
|
||||
|
||||
/** Return the associated @ref memory_resource
|
||||
/** Return the associated allocator.
|
||||
|
||||
This function returns an instance of
|
||||
@ref polymorphic_allocator constructed from the
|
||||
associated @ref memory_resource.
|
||||
This function returns an instance of @ref allocator_type constructed
|
||||
from the associated `boost::container::pmr::memory_resource`.
|
||||
|
||||
@par Complexity
|
||||
Constant.
|
||||
@@ -896,7 +895,7 @@ public:
|
||||
|
||||
@param new_capacity The new minimum capacity.
|
||||
|
||||
@throw system_error `new_capacity > max_size()`
|
||||
@throw `boost::system::system_error` `new_capacity > max_size()`.
|
||||
*/
|
||||
inline
|
||||
void
|
||||
@@ -952,9 +951,8 @@ public:
|
||||
|
||||
@param p The value to insert.
|
||||
|
||||
@throw system_error key is too long.
|
||||
|
||||
@throw system_error @ref size() >= max_size().
|
||||
@throw `boost::system::system_error` key is too long.
|
||||
@throw `boost::system::system_error` @ref size() >= max_size().
|
||||
|
||||
@return A pair where `first` is an iterator
|
||||
to the existing or inserted element, and `second`
|
||||
@@ -1077,7 +1075,7 @@ public:
|
||||
|
||||
@param m The value to insert or assign
|
||||
|
||||
@throw system_error if key is too long
|
||||
@throw `boost::system::system_error` if key is too long.
|
||||
*/
|
||||
template<class M>
|
||||
std::pair<iterator, bool>
|
||||
@@ -1112,7 +1110,7 @@ public:
|
||||
This will be passed as `std::forward<Arg>(arg)` to
|
||||
the @ref value constructor.
|
||||
|
||||
@throw system_error if key is too long
|
||||
@throw `boost::system::system_error` if key is too long.
|
||||
*/
|
||||
template<class Arg>
|
||||
std::pair<iterator, bool>
|
||||
@@ -1220,9 +1218,9 @@ public:
|
||||
|
||||
/** Swap two objects.
|
||||
|
||||
Exchanges the contents of this object with another
|
||||
object. Ownership of the respective @ref memory_resource
|
||||
objects is not transferred.
|
||||
Exchanges the contents of this object with another object. Ownership of
|
||||
the respective `boost::container::pmr::memory_resource` objects is not
|
||||
transferred.
|
||||
|
||||
@li If `*other.storage() == *this->storage()`,
|
||||
ownership of the underlying memory is swapped in
|
||||
@@ -1250,9 +1248,9 @@ public:
|
||||
|
||||
/** Swap two objects.
|
||||
|
||||
Exchanges the contents of the object `lhs` with
|
||||
another object `rhs`. Ownership of the respective
|
||||
@ref memory_resource objects is not transferred.
|
||||
Exchanges the contents of the object `lhs` with another object `rhs`.
|
||||
Ownership of the respective `boost::container::pmr::memory_resource`
|
||||
objects is not transferred.
|
||||
|
||||
@li If `*lhs.storage() == *rhs.storage()`,
|
||||
ownership of the underlying memory is swapped in
|
||||
@@ -1311,7 +1309,7 @@ public:
|
||||
|
||||
@param key The key of the element to find.
|
||||
|
||||
@throw system_error if no such element exists.
|
||||
@throw `boost::system::system_error` if no such element exists.
|
||||
*/
|
||||
/* @{ */
|
||||
inline
|
||||
|
||||
@@ -62,7 +62,7 @@ BOOST_JSON_DECL
|
||||
value
|
||||
parse(
|
||||
string_view s,
|
||||
error_code& ec,
|
||||
system::error_code& ec,
|
||||
storage_ptr sp = {},
|
||||
parse_options const& opt = {});
|
||||
|
||||
@@ -101,7 +101,7 @@ parse(
|
||||
@param opt The options for the parser. If this parameter
|
||||
is omitted, the parser will accept only standard JSON.
|
||||
|
||||
@throw system_error Thrown on failure.
|
||||
@throw boost::system::system_error Thrown on failure.
|
||||
|
||||
@see
|
||||
@ref parse_options,
|
||||
@@ -156,7 +156,7 @@ BOOST_JSON_DECL
|
||||
value
|
||||
parse(
|
||||
std::istream& is,
|
||||
error_code& ec,
|
||||
system::error_code& ec,
|
||||
storage_ptr sp = {},
|
||||
parse_options const& opt = {});
|
||||
|
||||
@@ -181,7 +181,7 @@ parse(
|
||||
|
||||
@par Exception Safety
|
||||
Basic guarantee.
|
||||
Throws @ref system_error on failed parse.
|
||||
Throws `boost::system::system_error` on failed parse.
|
||||
Calls to `memory_resource::allocate` may throw.
|
||||
The stream may throw as described by
|
||||
[`std::ios::exceptions`](https://en.cppreference.com/w/cpp/io/basic_ios/exceptions).
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <boost/json/string_view.hpp>
|
||||
#include <boost/json/system_error.hpp>
|
||||
#include <boost/json/detail/parse_into.hpp>
|
||||
#include <boost/system/result.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace json {
|
||||
@@ -75,7 +76,7 @@ void
|
||||
parse_into(
|
||||
V& v,
|
||||
string_view sv,
|
||||
error_code& ec,
|
||||
system::error_code& ec,
|
||||
parse_options const& opt = {} );
|
||||
|
||||
template<class V>
|
||||
@@ -105,7 +106,6 @@ parse_into(
|
||||
|
||||
@par Exception Safety
|
||||
Basic guarantee.
|
||||
Throws @ref system_error on failed parse.
|
||||
Calls to `memory_resource::allocate` may throw.
|
||||
|
||||
@param v The type to parse into.
|
||||
@@ -114,6 +114,8 @@ parse_into(
|
||||
|
||||
@param opt The options for the parser. If this parameter
|
||||
is omitted, the parser will accept only standard JSON.
|
||||
|
||||
@throw `boost::system::system_error` on failed parse.
|
||||
*/
|
||||
template<class V>
|
||||
void
|
||||
@@ -159,7 +161,7 @@ void
|
||||
parse_into(
|
||||
V& v,
|
||||
std::istream& is,
|
||||
error_code& ec,
|
||||
system::error_code& ec,
|
||||
parse_options const& opt = {} );
|
||||
|
||||
template<class V>
|
||||
@@ -189,7 +191,6 @@ parse_into(
|
||||
|
||||
@par Exception Safety
|
||||
Basic guarantee.
|
||||
Throws @ref system_error on failed parse.
|
||||
Calls to `memory_resource::allocate` may throw.
|
||||
The stream may throw as described by
|
||||
[`std::ios::exceptions`](https://en.cppreference.com/w/cpp/io/basic_ios/exceptions).
|
||||
@@ -200,6 +201,8 @@ parse_into(
|
||||
|
||||
@param opt The options for the parser. If this parameter
|
||||
is omitted, the parser will accept only standard JSON.
|
||||
|
||||
@throw `boost::system::system_error` on failed parse.
|
||||
*/
|
||||
template<class V>
|
||||
void
|
||||
|
||||
@@ -68,14 +68,14 @@ namespace json {
|
||||
first obtained from an optional, caller-owned
|
||||
buffer specified upon construction. When that
|
||||
is exhausted, the next allocation uses the
|
||||
@ref memory_resource passed to the constructor; if
|
||||
`boost::container::pmr::memory_resource` passed to the constructor; if
|
||||
no such argument is specified, the default memory
|
||||
resource is used. Temporary storage is freed only
|
||||
when the parser is destroyed; The performance of
|
||||
parsing multiple JSON texts may be improved by reusing
|
||||
the same parser instance.
|
||||
\n
|
||||
It is important to note that the @ref memory_resource
|
||||
It is important to note that the `boost::container::pmr::memory_resource`
|
||||
supplied upon construction is used for temporary
|
||||
storage only, and not for allocating the elements
|
||||
which make up the parsed value. That other memory
|
||||
@@ -410,9 +410,9 @@ public:
|
||||
@par Exception Safety
|
||||
No-throw guarantee.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use for the resulting @ref value. The parser
|
||||
will acquire shared ownership.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use for the resulting @ref value. The parser will acquire shared
|
||||
ownership.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
void
|
||||
@@ -463,7 +463,7 @@ public:
|
||||
write_some(
|
||||
char const* data,
|
||||
std::size_t size,
|
||||
error_code& ec);
|
||||
system::error_code& ec);
|
||||
|
||||
BOOST_JSON_DECL
|
||||
std::size_t
|
||||
@@ -510,7 +510,7 @@ public:
|
||||
@param size The number of characters pointed to
|
||||
by `data`.
|
||||
|
||||
@throw system_error Thrown on error.
|
||||
@throw `boost::system::system_error` Thrown on error.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
std::size_t
|
||||
@@ -557,7 +557,7 @@ public:
|
||||
std::size_t
|
||||
write_some(
|
||||
string_view s,
|
||||
error_code& ec)
|
||||
system::error_code& ec)
|
||||
{
|
||||
return write_some(
|
||||
s.data(), s.size(), ec);
|
||||
@@ -606,7 +606,7 @@ public:
|
||||
|
||||
@param s The character string to parse.
|
||||
|
||||
@throw system_error Thrown on error.
|
||||
@throw `boost::system::system_error` Thrown on error.
|
||||
*/
|
||||
std::size_t
|
||||
write_some(
|
||||
@@ -658,7 +658,7 @@ public:
|
||||
write(
|
||||
char const* data,
|
||||
std::size_t size,
|
||||
error_code& ec);
|
||||
system::error_code& ec);
|
||||
|
||||
BOOST_JSON_DECL
|
||||
std::size_t
|
||||
@@ -702,7 +702,7 @@ public:
|
||||
@param size The number of characters pointed to
|
||||
by `data`.
|
||||
|
||||
@throw system_error Thrown on error.
|
||||
@throw `boost::system::system_error` Thrown on error.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
std::size_t
|
||||
@@ -746,7 +746,7 @@ public:
|
||||
std::size_t
|
||||
write(
|
||||
string_view s,
|
||||
error_code& ec)
|
||||
system::error_code& ec)
|
||||
{
|
||||
return write(
|
||||
s.data(), s.size(), ec);
|
||||
@@ -792,7 +792,7 @@ public:
|
||||
|
||||
@param s The character string to parse.
|
||||
|
||||
@throw system_error Thrown on error.
|
||||
@throw `boost::system::system_error` Thrown on error.
|
||||
*/
|
||||
std::size_t
|
||||
write(
|
||||
@@ -816,7 +816,7 @@ public:
|
||||
@return The parsed value. Ownership of this
|
||||
value is transferred to the caller.
|
||||
|
||||
@throw system_error Thrown on failure.
|
||||
@throw `boost::system::system_error` Thrown on failure.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
value
|
||||
|
||||
146
include/boost/json/result_for.hpp
Normal file
146
include/boost/json/result_for.hpp
Normal file
@@ -0,0 +1,146 @@
|
||||
//
|
||||
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
|
||||
// Copyright (c) 2024 Dmitry Arkhipov (grisumbras@yandex.ru)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// Official repository: https://github.com/boostorg/json
|
||||
//
|
||||
|
||||
#ifndef BOOST_JSON_RESULT_FOR_HPP
|
||||
#define BOOST_JSON_RESULT_FOR_HPP
|
||||
|
||||
#include <boost/json/detail/config.hpp>
|
||||
#include <boost/json/fwd.hpp>
|
||||
#include <boost/assert/source_location.hpp>
|
||||
#include <boost/system/result.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace json {
|
||||
|
||||
/**
|
||||
Helper trait that returns @ref result
|
||||
|
||||
The primary template is an incomplete type. The library provides a partial
|
||||
specialisation `result_for<T1, value>`, that has nested type alias `type`
|
||||
that aliases the type `result<T1>`.
|
||||
|
||||
The purpose of this trait is to let users provide non-throwing conversions
|
||||
for their types without creating a physical dependency on Boost.Json. For
|
||||
example:
|
||||
|
||||
@code
|
||||
namespace boost
|
||||
{
|
||||
namespace json
|
||||
{
|
||||
|
||||
template<class T>
|
||||
struct value_to_tag;
|
||||
|
||||
template<class T1, class T2>
|
||||
struct result_for;
|
||||
}
|
||||
}
|
||||
|
||||
namespace mine
|
||||
{
|
||||
class my_class;
|
||||
...
|
||||
template<class JsonValue>
|
||||
boost::json::result_for<my_class, JsonValue>
|
||||
tag_invoke(boost::json::try_value_to_tag<my_class>, const JsonValue& jv)
|
||||
{ ... }
|
||||
}
|
||||
@endcode
|
||||
|
||||
@see @ref try_value_to, @ref try_value_to_tag
|
||||
*/
|
||||
template <class T1, class T2>
|
||||
struct result_for;
|
||||
|
||||
/** Create @ref result storing a portable error code
|
||||
|
||||
This function constructs a `boost::system::result<T>` that stores
|
||||
`boost::system::error_code` with `value()` equal to `e` and `category()`
|
||||
equal to `boost::system::generic_category()`. <br>
|
||||
|
||||
The main use for this function is in implementation of functions returning
|
||||
@ref result, without including `boost/json/system_error.hpp` or even
|
||||
`<system_error>`. In particular, it may be useful for customizations of
|
||||
@ref try_value_to without creating a physical dependency on Boost.JSON.
|
||||
For example:
|
||||
|
||||
@code
|
||||
#include <cerrno>
|
||||
#include <boost/assert/source_location.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace json
|
||||
{
|
||||
|
||||
class value;
|
||||
|
||||
template<class T>
|
||||
struct try_value_to_tag;
|
||||
|
||||
template<class T1, class T2>
|
||||
struct result_for;
|
||||
|
||||
template <class T>
|
||||
typename result_for<T, value>::type
|
||||
result_from_errno(int e, boost::source_location const* loc) noexcept
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
namespace mine
|
||||
{
|
||||
|
||||
class my_class;
|
||||
...
|
||||
template<class JsonValue>
|
||||
boost::json::result_for<my_class, JsonValue>
|
||||
tag_invoke(boost::json::try_value_to_tag<my_class>, const JsonValue& jv)
|
||||
{
|
||||
BOOST_STATIC_CONSTEXPR boost::source_location loc = BOOST_CURRENT_LOCATION;
|
||||
if( !jv.is_null() )
|
||||
return boost::json::result_from_errno<my_class>(EINVAL, &loc);
|
||||
return my_class();
|
||||
}
|
||||
|
||||
}
|
||||
@endcode
|
||||
|
||||
@par Exception Safety
|
||||
Does not throw exceptions.
|
||||
|
||||
@tparam T The value type of returned `result`.
|
||||
|
||||
@param e The error value.
|
||||
|
||||
@param loc The error location.
|
||||
|
||||
@returns `boost::system::error_code` with `value()` equal to `e` and
|
||||
`category()` equal to `boost::system::generic_category()`.
|
||||
|
||||
@see @ref try_value_to_tag, @ref try_value_to, @ref result_for,
|
||||
<a href="https://www.boost.org/doc/libs/develop/libs/system/doc/html/system.html#ref_generic_category">
|
||||
`boost::system::generic_category`</a>,
|
||||
<a href="https://www.boost.org/doc/libs/master/libs/assert/doc/html/assert.html#source_location_support">
|
||||
`boost::source_location`</a>.
|
||||
*/
|
||||
template <class T>
|
||||
typename result_for<T, value>::type
|
||||
result_from_errno(int e, boost::source_location const* loc) noexcept
|
||||
{
|
||||
system::error_code ec(e, system::generic_category(), loc);
|
||||
return {system::in_place_error, ec};
|
||||
}
|
||||
|
||||
} // namespace json
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_JSON_RESULT_FOR_HPP
|
||||
@@ -150,11 +150,9 @@ public:
|
||||
@par Exception Safety
|
||||
No-throw guarantee.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use when producing partial output.
|
||||
Shared ownership of the memory resource
|
||||
is retained until the serializer is
|
||||
destroyed.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use when producing partial output. Shared ownership of the memory
|
||||
resource is retained until the serializer is destroyed.
|
||||
|
||||
@param buf An optional static buffer to
|
||||
use for temporary storage when producing
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
#ifndef BOOST_JSON_STATIC_RESOURCE_HPP
|
||||
#define BOOST_JSON_STATIC_RESOURCE_HPP
|
||||
|
||||
#include <boost/container/pmr/memory_resource.hpp>
|
||||
#include <boost/json/detail/config.hpp>
|
||||
#include <boost/json/is_deallocate_trivial.hpp>
|
||||
#include <boost/json/memory_resource.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
@@ -67,7 +69,7 @@ class
|
||||
BOOST_JSON_DECL
|
||||
BOOST_SYMBOL_VISIBLE
|
||||
static_resource final
|
||||
: public memory_resource
|
||||
: public container::pmr::memory_resource
|
||||
{
|
||||
void* p_;
|
||||
std::size_t n_;
|
||||
|
||||
@@ -10,10 +10,12 @@
|
||||
#ifndef BOOST_JSON_STORAGE_PTR_HPP
|
||||
#define BOOST_JSON_STORAGE_PTR_HPP
|
||||
|
||||
#include <boost/container/pmr/polymorphic_allocator.hpp>
|
||||
#include <boost/json/detail/config.hpp>
|
||||
#include <boost/json/memory_resource.hpp>
|
||||
#include <boost/json/detail/shared_resource.hpp>
|
||||
#include <boost/json/detail/default_resource.hpp>
|
||||
#include <boost/json/is_deallocate_trivial.hpp>
|
||||
#include <cstddef>
|
||||
#include <new>
|
||||
#include <type_traits>
|
||||
@@ -22,19 +24,17 @@
|
||||
namespace boost {
|
||||
namespace json {
|
||||
|
||||
/** A smart pointer to a @ref memory_resource
|
||||
/** A smart pointer to a memory resource.
|
||||
|
||||
This container is used to hold a pointer to a memory resource. The
|
||||
pointed-to resource is always valid. Depending on the means of
|
||||
construction, the ownership will be either:
|
||||
|
||||
@li Non-owning, when constructing from a raw
|
||||
pointer to @ref memory_resource or from a
|
||||
@ref polymorphic_allocator. In this case the
|
||||
caller is responsible for ensuring that the
|
||||
lifetime of the memory resource extends until
|
||||
there are no more calls to allocate or
|
||||
deallocate.
|
||||
@li Non-owning, when constructing from a raw pointer to
|
||||
`boost::container::pmr::memory_resource` or from a
|
||||
`boost::container::pmr::polymorphic_allocator`. In this case the caller is
|
||||
responsible for ensuring that the lifetime of the memory resource extends
|
||||
until there are no more calls to allocate or deallocate.
|
||||
|
||||
@li Owning, when constructing using the function
|
||||
@ref make_shared_resource. In this case
|
||||
@@ -74,8 +74,9 @@ namespace json {
|
||||
|
||||
@see
|
||||
@ref make_shared_resource,
|
||||
@ref memory_resource,
|
||||
@ref polymorphic_allocator
|
||||
[`boost::container::pmr::polymorphic_allocator`](https://www.boost.org/doc/libs/release/doc/html/boost/container/pmr/polymorphic_allocator.html).
|
||||
[`boost::container::pmr::memory_resource`](https://www.boost.org/doc/libs/release/doc/html/boost/container/pmr/memory_resource.html).
|
||||
|
||||
*/
|
||||
class storage_ptr
|
||||
{
|
||||
@@ -95,7 +96,7 @@ class storage_ptr
|
||||
get_shared() const noexcept
|
||||
{
|
||||
return static_cast<shared_resource*>(
|
||||
reinterpret_cast<memory_resource*>(
|
||||
reinterpret_cast<container::pmr::memory_resource*>(
|
||||
i_ & ~3));
|
||||
}
|
||||
|
||||
@@ -123,7 +124,7 @@ class storage_ptr
|
||||
storage_ptr(
|
||||
detail::shared_resource_impl<T>* p) noexcept
|
||||
: i_(reinterpret_cast<std::uintptr_t>(
|
||||
static_cast<memory_resource*>(p)) + 1 +
|
||||
static_cast<container::pmr::memory_resource*>(p)) + 1 +
|
||||
(json::is_deallocate_trivial<T>::value ? 2 : 0))
|
||||
{
|
||||
BOOST_ASSERT(p);
|
||||
@@ -168,14 +169,13 @@ public:
|
||||
|
||||
/** Constructor
|
||||
|
||||
This constructs a non-owning pointer that
|
||||
points to the memory resource `r`.
|
||||
The caller is responsible for maintaining the
|
||||
lifetime of the pointed-to @ref memory_resource.
|
||||
This constructs a non-owning pointer that points to the memory resource
|
||||
`r`. The caller is responsible for maintaining the lifetime of the
|
||||
pointed-to `boost::container::pmr::memory_resource`.
|
||||
|
||||
@par Constraints
|
||||
@code
|
||||
std::is_convertible< T*, memory_resource* >::value == true
|
||||
std::is_convertible< T*, boost::container::pmr::memory_resource* >::value == true
|
||||
@endcode
|
||||
|
||||
@par Preconditions
|
||||
@@ -193,12 +193,12 @@ public:
|
||||
#ifndef BOOST_JSON_DOCS
|
||||
, class = typename std::enable_if<
|
||||
std::is_convertible<T*,
|
||||
memory_resource*>::value>::type
|
||||
container::pmr::memory_resource*>::value>::type
|
||||
#endif
|
||||
>
|
||||
storage_ptr(T* r) noexcept
|
||||
: i_(reinterpret_cast<std::uintptr_t>(
|
||||
static_cast<memory_resource *>(r)) +
|
||||
static_cast<container::pmr::memory_resource *>(r)) +
|
||||
(json::is_deallocate_trivial<T>::value ? 2 : 0))
|
||||
{
|
||||
BOOST_ASSERT(r);
|
||||
@@ -206,26 +206,25 @@ public:
|
||||
|
||||
/** Constructor
|
||||
|
||||
This constructs a non-owning pointer that
|
||||
points to the same memory resource as `alloc`,
|
||||
obtained by calling `alloc.resource()`.
|
||||
The caller is responsible for maintaining the
|
||||
lifetime of the pointed-to @ref memory_resource.
|
||||
This constructs a non-owning pointer that points to the same memory
|
||||
resource as `alloc`, obtained by calling `alloc.resource()`. The caller
|
||||
is responsible for maintaining the lifetime of the
|
||||
pointed-to `boost::container::pmr::memory_resource`.
|
||||
|
||||
@par Constraints
|
||||
@code
|
||||
std::is_convertible< T*, memory_resource* >::value == true
|
||||
std::is_convertible< T*, boost::container::pmr::memory_resource* >::value == true
|
||||
@endcode
|
||||
|
||||
@par Exception Safety
|
||||
No-throw guarantee.
|
||||
|
||||
@param alloc A @ref polymorphic_allocator to
|
||||
@param alloc A `boost::container::pmr::polymorphic_allocator` to
|
||||
construct from.
|
||||
*/
|
||||
template<class T>
|
||||
storage_ptr(
|
||||
polymorphic_allocator<T> const& alloc) noexcept
|
||||
container::pmr::polymorphic_allocator<T> const& alloc) noexcept
|
||||
: i_(reinterpret_cast<std::uintptr_t>(
|
||||
alloc.resource()))
|
||||
{
|
||||
@@ -400,7 +399,7 @@ public:
|
||||
/** Return a pointer to the memory resource.
|
||||
|
||||
This function returns a pointer to the
|
||||
referenced @ref memory_resource.
|
||||
referenced `boost::container::pmr::memory_resource`.
|
||||
|
||||
@par Complexity
|
||||
Constant.
|
||||
@@ -408,19 +407,19 @@ public:
|
||||
@par Exception Safety
|
||||
No-throw guarantee.
|
||||
*/
|
||||
memory_resource*
|
||||
container::pmr::memory_resource*
|
||||
get() const noexcept
|
||||
{
|
||||
if(i_ != 0)
|
||||
return reinterpret_cast<
|
||||
memory_resource*>(i_ & ~3);
|
||||
container::pmr::memory_resource*>(i_ & ~3);
|
||||
return default_resource::get();
|
||||
}
|
||||
|
||||
/** Return a pointer to the memory resource.
|
||||
|
||||
This function returns a pointer to the
|
||||
referenced @ref memory_resource.
|
||||
referenced `boost::container::pmr::memory_resource`.
|
||||
|
||||
@par Complexity
|
||||
Constant.
|
||||
@@ -428,7 +427,7 @@ public:
|
||||
@par Exception Safety
|
||||
No-throw guarantee.
|
||||
*/
|
||||
memory_resource*
|
||||
container::pmr::memory_resource*
|
||||
operator->() const noexcept
|
||||
{
|
||||
return get();
|
||||
@@ -437,7 +436,7 @@ public:
|
||||
/** Return a reference to the memory resource.
|
||||
|
||||
This function returns a reference to the
|
||||
pointed-to @ref memory_resource.
|
||||
pointed-to `boost::container::pmr::memory_resource`.
|
||||
|
||||
@par Complexity
|
||||
|
||||
@@ -447,7 +446,7 @@ public:
|
||||
|
||||
No-throw guarantee.
|
||||
*/
|
||||
memory_resource&
|
||||
container::pmr::memory_resource&
|
||||
operator*() const noexcept
|
||||
{
|
||||
return *get();
|
||||
@@ -474,7 +473,7 @@ public:
|
||||
|
||||
@par Mandates
|
||||
@code
|
||||
std::is_base_of< memory_resource, U >::value == true
|
||||
std::is_base_of< boost::container::pmr::memory_resource, U >::value == true
|
||||
@endcode
|
||||
|
||||
@par Complexity
|
||||
@@ -495,7 +494,7 @@ make_shared_resource(Args&&... args)
|
||||
// `T` is not a memory resource.
|
||||
BOOST_STATIC_ASSERT(
|
||||
std::is_base_of<
|
||||
memory_resource, U>::value);
|
||||
container::pmr::memory_resource, U>::value);
|
||||
return storage_ptr(new
|
||||
detail::shared_resource_impl<U>(
|
||||
std::forward<Args>(args)...));
|
||||
@@ -506,9 +505,9 @@ make_shared_resource(Args&&... args)
|
||||
|
||||
/** Return true if two storage pointers point to the same memory resource.
|
||||
|
||||
This function returns `true` if the @ref memory_resource
|
||||
objects pointed to by `lhs` and `rhs` have the
|
||||
same address.
|
||||
This function returns `true` if the
|
||||
`boost::container::pmr::memory_resource` objects pointed to by `lhs` and
|
||||
`rhs` have the same address.
|
||||
*/
|
||||
inline
|
||||
bool
|
||||
@@ -521,9 +520,9 @@ operator==(
|
||||
|
||||
/** Return true if two storage pointers point to different memory resources.
|
||||
|
||||
This function returns `true` if the @ref memory_resource
|
||||
objects pointed to by `lhs` and `rhs` have different
|
||||
addresses.
|
||||
This function returns `true` if the
|
||||
`boost::container::pmr::memory_resource` objects pointed to by `lhs` and
|
||||
`rhs` have different addresses.
|
||||
*/
|
||||
inline
|
||||
bool
|
||||
|
||||
@@ -89,19 +89,17 @@ namespace json {
|
||||
first obtained from an optional, caller-owned
|
||||
buffer specified upon construction. When that
|
||||
is exhausted, the next allocation uses the
|
||||
@ref memory_resource passed to the constructor; if
|
||||
`boost::container::pmr::memory_resource` passed to the constructor; if
|
||||
no such argument is specified, the default memory
|
||||
resource is used. Temporary storage is freed only
|
||||
when the parser is destroyed; The performance of
|
||||
parsing multiple JSON texts may be improved by reusing
|
||||
the same parser instance.
|
||||
\n
|
||||
It is important to note that the @ref memory_resource
|
||||
supplied upon construction is used for temporary
|
||||
storage only, and not for allocating the elements
|
||||
which make up the parsed value. That other memory
|
||||
resource is optionally supplied in each call
|
||||
to @ref reset.
|
||||
It is important to note that the `boost::container::pmr::memory_resource`
|
||||
supplied upon construction is used for temporary storage only, and not for
|
||||
allocating the elements which make up the parsed value. That other memory
|
||||
resource is optionally supplied in each call to @ref reset.
|
||||
|
||||
@par Duplicate Keys
|
||||
|
||||
@@ -431,9 +429,9 @@ public:
|
||||
@par Exception Safety
|
||||
No-throw guarantee.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use for the resulting @ref value. The parser
|
||||
will acquire shared ownership.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use for the resulting @ref value. The parser will acquire shared
|
||||
ownership.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
void
|
||||
@@ -517,7 +515,7 @@ public:
|
||||
write_some(
|
||||
char const* data,
|
||||
std::size_t size,
|
||||
error_code& ec);
|
||||
system::error_code& ec);
|
||||
|
||||
BOOST_JSON_DECL
|
||||
std::size_t
|
||||
@@ -573,7 +571,7 @@ public:
|
||||
@param size The number of characters pointed to
|
||||
by `data`.
|
||||
|
||||
@throw system_error Thrown on error.
|
||||
@throw `boost::system::system_error` Thrown on error.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
std::size_t
|
||||
@@ -629,7 +627,7 @@ public:
|
||||
std::size_t
|
||||
write_some(
|
||||
string_view s,
|
||||
error_code& ec)
|
||||
system::error_code& ec)
|
||||
{
|
||||
return write_some(
|
||||
s.data(), s.size(), ec);
|
||||
@@ -687,7 +685,7 @@ public:
|
||||
|
||||
@param s The character string to parse.
|
||||
|
||||
@throw system_error Thrown on error.
|
||||
@throw `boost::system::system_error` Thrown on error.
|
||||
*/
|
||||
std::size_t
|
||||
write_some(
|
||||
@@ -748,7 +746,7 @@ public:
|
||||
write(
|
||||
char const* data,
|
||||
std::size_t size,
|
||||
error_code& ec);
|
||||
system::error_code& ec);
|
||||
|
||||
BOOST_JSON_DECL
|
||||
std::size_t
|
||||
@@ -801,7 +799,7 @@ public:
|
||||
@param size The number of characters pointed to
|
||||
by `data`.
|
||||
|
||||
@throw system_error Thrown on error.
|
||||
@throw `boost::system::system_error` Thrown on error.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
std::size_t
|
||||
@@ -854,7 +852,7 @@ public:
|
||||
std::size_t
|
||||
write(
|
||||
string_view s,
|
||||
error_code& ec)
|
||||
system::error_code& ec)
|
||||
{
|
||||
return write(
|
||||
s.data(), s.size(), ec);
|
||||
@@ -909,7 +907,7 @@ public:
|
||||
|
||||
@param s The character string to parse.
|
||||
|
||||
@throw system_error Thrown on error.
|
||||
@throw `boost::system::system_error` Thrown on error.
|
||||
*/
|
||||
std::size_t
|
||||
write(
|
||||
@@ -955,7 +953,7 @@ public:
|
||||
/** @{ */
|
||||
BOOST_JSON_DECL
|
||||
void
|
||||
finish(error_code& ec);
|
||||
finish(system::error_code& ec);
|
||||
|
||||
BOOST_JSON_DECL
|
||||
void
|
||||
@@ -993,7 +991,7 @@ public:
|
||||
Upon error or exception, subsequent calls will
|
||||
fail until @ref reset is called to parse a new JSON text.
|
||||
|
||||
@throw system_error Thrown on error.
|
||||
@throw `boost::system::system_error` Thrown on error.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
void
|
||||
@@ -1020,7 +1018,7 @@ public:
|
||||
@return The parsed value. Ownership of this
|
||||
value is transferred to the caller.
|
||||
|
||||
@throw system_error Thrown on failure.
|
||||
@throw `boost::system::system_error` Thrown on failure.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
value
|
||||
|
||||
@@ -84,15 +84,15 @@ class string
|
||||
storage_ptr sp);
|
||||
|
||||
public:
|
||||
/** The type of _Allocator_ returned by @ref get_allocator
|
||||
/** Associated [Allocator](https://en.cppreference.com/w/cpp/named_req/Allocator)
|
||||
|
||||
This type is a @ref polymorphic_allocator.
|
||||
This type is a `boost::container::pmr::polymorphic_allocator<value>`.
|
||||
*/
|
||||
#ifdef BOOST_JSON_DOCS
|
||||
// VFALCO doc toolchain renders this incorrectly
|
||||
using allocator_type = __see_below__;
|
||||
#else
|
||||
using allocator_type = polymorphic_allocator<value>;
|
||||
// VFALCO doc toolchain renders this incorrectly
|
||||
using allocator_type = container::pmr::polymorphic_allocator<value>;
|
||||
#endif
|
||||
|
||||
/// The type of a character
|
||||
@@ -219,9 +219,9 @@ public:
|
||||
|
||||
Constant.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
*/
|
||||
explicit
|
||||
string(storage_ptr sp)
|
||||
@@ -248,12 +248,12 @@ public:
|
||||
@param ch The value to initialize characters
|
||||
of the string with.
|
||||
|
||||
@param sp An optional pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
The default argument for this parameter is `{}`.
|
||||
@param sp An optional pointer to the
|
||||
`boost::container::pmr::memory_resource` to use. The container will
|
||||
acquire shared ownership of the memory resource. The default argument
|
||||
for this parameter is `{}`.
|
||||
|
||||
@throw system_error `count > max_size()`.
|
||||
@throw `boost::system::system_error` `count > max_size()`.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
explicit
|
||||
@@ -281,12 +281,12 @@ public:
|
||||
@param s A pointer to a character string used to
|
||||
copy from.
|
||||
|
||||
@param sp An optional pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
The default argument for this parameter is `{}`.
|
||||
@param sp An optional pointer to the
|
||||
`boost::container::pmr::memory_resource` to use. The container will
|
||||
acquire shared ownership of the memory resource. The default argument
|
||||
for this parameter is `{}`.
|
||||
|
||||
@throw system_error `strlen(s) > max_size()`.
|
||||
@throw `boost::system::system_error` `strlen(s) > max_size()`.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
string(
|
||||
@@ -313,12 +313,12 @@ public:
|
||||
@param s A pointer to a character string used to
|
||||
copy from.
|
||||
|
||||
@param sp An optional pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
The default argument for this parameter is `{}`.
|
||||
@param sp An optional pointer to the
|
||||
`boost::container::pmr::memory_resource` to use. The container will
|
||||
acquire shared ownership of the memory resource. The default argument
|
||||
for this parameter is `{}`.
|
||||
|
||||
@throw system_error `count > max_size()`.
|
||||
@throw `boost::system::system_error` `count > max_size()`.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
explicit
|
||||
@@ -354,12 +354,12 @@ public:
|
||||
@param last An input iterator pointing to the end
|
||||
of the range.
|
||||
|
||||
@param sp An optional pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
The default argument for this parameter is `{}`.
|
||||
@param sp An optional pointer to the
|
||||
`boost::container::pmr::memory_resource` to use. The container will
|
||||
acquire shared ownership of the memory resource. The default argument
|
||||
for this parameter is `{}`.
|
||||
|
||||
@throw system_error `std::distance(first, last) > max_size()`.
|
||||
@throw `boost::system::system_error` `std::distance(first, last) > max_size()`.
|
||||
*/
|
||||
template<class InputIt
|
||||
#ifndef BOOST_JSON_DOCS
|
||||
@@ -407,10 +407,10 @@ public:
|
||||
@param other The string to use as a source
|
||||
to copy from.
|
||||
|
||||
@param sp An optional pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
The default argument for this parameter is `{}`.
|
||||
@param sp An optional pointer to the
|
||||
`boost::container::pmr::memory_resource` to use. The container will
|
||||
acquire shared ownership of the memory resource. The default argument
|
||||
for this parameter is `{}`.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
explicit
|
||||
@@ -420,13 +420,12 @@ public:
|
||||
|
||||
/** Move constructor.
|
||||
|
||||
Constructs the string with the contents of `other`
|
||||
using move semantics. Ownership of the underlying
|
||||
memory is transferred.
|
||||
The container acquires shared ownership of the
|
||||
@ref memory_resource used by `other`. After construction,
|
||||
the moved-from string behaves as if newly
|
||||
constructed with its current memory resource.
|
||||
Constructs the string with the contents of `other` using move
|
||||
semantics. Ownership of the underlying memory is transferred. The
|
||||
container acquires shared ownership of the
|
||||
`boost::container::pmr::memory_resource` used by `other`. After
|
||||
construction, the moved-from string behaves as if newly constructed
|
||||
with its current memory resource.
|
||||
|
||||
@par Complexity
|
||||
|
||||
@@ -446,12 +445,10 @@ public:
|
||||
Construct the contents with those of `other`
|
||||
using move semantics.
|
||||
|
||||
@li If `*other.storage() == *sp`,
|
||||
ownership of the underlying memory is transferred
|
||||
in constant time, with no possibility
|
||||
of exceptions. After construction, the moved-from
|
||||
string behaves as if newly constructed with
|
||||
its current @ref memory_resource. Otherwise,
|
||||
@li If `*other.storage() == *sp`, ownership of the underlying memory is
|
||||
transferred in constant time, with no possibility of exceptions. After
|
||||
construction, the moved-from string behaves as if newly constructed
|
||||
with its current `boost::container::pmr::memory_resource`. Otherwise,
|
||||
|
||||
@li If `*other.storage() != *sp`,
|
||||
a copy of the characters in `other` is made. In
|
||||
@@ -468,10 +465,10 @@ public:
|
||||
|
||||
@param other The string to assign from.
|
||||
|
||||
@param sp An optional pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
The default argument for this parameter is `{}`.
|
||||
@param sp An optional pointer to the
|
||||
`boost::container::pmr::memory_resource` to use. The container will
|
||||
acquire shared ownership of the memory resource. The default argument
|
||||
for this parameter is `{}`.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
explicit
|
||||
@@ -496,12 +493,12 @@ public:
|
||||
|
||||
@param s The string view to copy from.
|
||||
|
||||
@param sp An optional pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
The default argument for this parameter is `{}`.
|
||||
@param sp An optional pointer to the
|
||||
`boost::container::pmr::memory_resource` to use. The container will
|
||||
acquire shared ownership of the memory resource. The default argument
|
||||
for this parameter is `{}`.
|
||||
|
||||
@throw system_error `s.size() > max_size()`.
|
||||
@throw `boost::system::system_error` `std::distance(first, last) > max_size()`.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
string(
|
||||
@@ -543,12 +540,11 @@ public:
|
||||
|
||||
@li If `&other == this`, do nothing. Otherwise,
|
||||
|
||||
@li If `*other.storage() == *this->storage()`,
|
||||
ownership of the underlying memory is transferred
|
||||
in constant time, with no possibility
|
||||
of exceptions. After construction, the moved-from
|
||||
string behaves as if newly constructed with its
|
||||
current @ref memory_resource. Otherwise,
|
||||
@li If `*other.storage() == *this->storage()`, ownership of the
|
||||
underlying memory is transferred in constant time, with no possibility
|
||||
of exceptions. After construction, the moved-from string behaves as if
|
||||
newly constructed with its current
|
||||
`boost::container::pmr::memory_resource`. Otherwise,
|
||||
|
||||
@li a copy of the characters in `other` is made. In
|
||||
this case, the moved-from container is not changed.
|
||||
@@ -591,7 +587,7 @@ public:
|
||||
|
||||
@param s The null-terminated character string.
|
||||
|
||||
@throw system_error `std::strlen(s) > max_size()`.
|
||||
@throw `boost::system::system_error` `std::strlen(s) > max_size()`.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
string&
|
||||
@@ -616,7 +612,7 @@ public:
|
||||
|
||||
@param s The string view to copy from.
|
||||
|
||||
@throw system_error `s.size() > max_size()`.
|
||||
@throw `boost::system::system_error` `s.size() > max_size()`.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
string&
|
||||
@@ -645,7 +641,7 @@ public:
|
||||
@param ch The value to initialize characters
|
||||
of the string with.
|
||||
|
||||
@throw system_error `count > max_size()`.
|
||||
@throw `boost::system::system_error` `count > max_size()`.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
string&
|
||||
@@ -683,12 +679,11 @@ public:
|
||||
|
||||
@li If `&other == this`, do nothing. Otherwise,
|
||||
|
||||
@li If `*other.storage() == *this->storage()`,
|
||||
ownership of the underlying memory is transferred
|
||||
in constant time, with no possibility of
|
||||
exceptions. After construction, the moved-from
|
||||
string behaves as if newly constructed with
|
||||
its current @ref memory_resource, otherwise
|
||||
@li If `*other.storage() == *this->storage()`, ownership of the
|
||||
underlying memory is transferred in constant time, with no possibility
|
||||
of exceptions. After construction, the moved-from string behaves as if
|
||||
newly constructed with its current
|
||||
`boost::container::pmr::memory_resource`, otherwise
|
||||
|
||||
@li If `*other.storage() != *this->storage()`,
|
||||
a copy of the characters in `other` is made.
|
||||
@@ -734,7 +729,7 @@ public:
|
||||
@param s A pointer to a character string used to
|
||||
copy from.
|
||||
|
||||
@throw system_error `count > max_size()`.
|
||||
@throw `boost::system::system_error` `count > max_size()`.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
string&
|
||||
@@ -766,7 +761,7 @@ public:
|
||||
@param s A pointer to a character string used to
|
||||
copy from.
|
||||
|
||||
@throw system_error `strlen(s) > max_size()`.
|
||||
@throw `boost::system::system_error` `strlen(s) > max_size()`.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
string&
|
||||
@@ -802,7 +797,7 @@ public:
|
||||
@param last An input iterator pointing to the end
|
||||
of the range.
|
||||
|
||||
@throw system_error `std::distance(first, last) > max_size()`.
|
||||
@throw `boost::system::system_error` `std::distance(first, last) > max_size()`.
|
||||
*/
|
||||
template<class InputIt
|
||||
#ifndef BOOST_JSON_DOCS
|
||||
@@ -833,7 +828,7 @@ public:
|
||||
|
||||
@param s The string view to copy from.
|
||||
|
||||
@throw system_error `s.size() > max_size()`.
|
||||
@throw `boost::system::system_error` `s.size() > max_size()`.
|
||||
*/
|
||||
string&
|
||||
assign(string_view s)
|
||||
@@ -843,9 +838,9 @@ public:
|
||||
|
||||
//------------------------------------------------------
|
||||
|
||||
/** Return the associated @ref memory_resource
|
||||
/** Return the associated memory resource.
|
||||
|
||||
This returns the @ref memory_resource used by
|
||||
This returns the `boost::container::pmr::memory_resource` used by
|
||||
the container.
|
||||
|
||||
@par Complexity
|
||||
@@ -862,11 +857,10 @@ public:
|
||||
return sp_;
|
||||
}
|
||||
|
||||
/** Return the associated @ref memory_resource
|
||||
/** Return the associated allocator.
|
||||
|
||||
This function returns an instance of
|
||||
@ref polymorphic_allocator constructed from the
|
||||
associated @ref memory_resource.
|
||||
This function returns an instance of @ref allocator_type constructed
|
||||
from the associated `boost::container::pmr::memory_resource`.
|
||||
|
||||
@par Complexity
|
||||
|
||||
@@ -903,7 +897,7 @@ public:
|
||||
|
||||
@param pos A zero-based index to access.
|
||||
|
||||
@throw system_error `pos >= size()`
|
||||
@throw `boost::system::system_error` `pos >= size()`.
|
||||
*/
|
||||
/** @{ */
|
||||
char&
|
||||
@@ -1474,7 +1468,7 @@ public:
|
||||
|
||||
@param new_capacity The new capacity of the array.
|
||||
|
||||
@throw system_error `new_capacity > max_size()`
|
||||
@throw `boost::system::system_error` `new_capacity > max_size()`.
|
||||
*/
|
||||
void
|
||||
reserve(std::size_t new_capacity)
|
||||
@@ -1548,9 +1542,8 @@ public:
|
||||
|
||||
@param sv The `string_view` to insert.
|
||||
|
||||
@throw system_error `size() + s.size() > max_size()`
|
||||
|
||||
@throw system_error `pos > size()`
|
||||
@throw `boost::system::system_error` `size() + s.size() > max_size()`.
|
||||
@throw `boost::system::system_error` `pos > size()`.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
string&
|
||||
@@ -1578,9 +1571,8 @@ public:
|
||||
|
||||
@param ch The character to insert.
|
||||
|
||||
@throw system_error `size() + count > max_size()`
|
||||
|
||||
@throw system_error `pos > size()`
|
||||
@throw `boost::system::system_error` `size() + count > max_size()`.
|
||||
@throw `boost::system::system_error` `pos > size()`.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
string&
|
||||
@@ -1608,9 +1600,8 @@ public:
|
||||
|
||||
@param ch The character to insert.
|
||||
|
||||
@throw system_error `size() + 1 > max_size()`
|
||||
|
||||
@throw system_error `pos > size()`
|
||||
@throw `boost::system::system_error` `size() + 1 > max_size()`.
|
||||
@throw `boost::system::system_error` `pos > size()`.
|
||||
*/
|
||||
string&
|
||||
insert(
|
||||
@@ -1651,9 +1642,8 @@ public:
|
||||
|
||||
@param last The end of the character range.
|
||||
|
||||
@throw system_error `size() + insert_count > max_size()`
|
||||
|
||||
@throw system_error `pos > size()`
|
||||
@throw `boost::system::system_error` `size() + insert_count > max_size()`.
|
||||
@throw `boost::system::system_error` `pos > size()`.
|
||||
*/
|
||||
template<class InputIt
|
||||
#ifndef BOOST_JSON_DOCS
|
||||
@@ -1691,7 +1681,7 @@ public:
|
||||
The default argument for this parameter
|
||||
is @ref npos.
|
||||
|
||||
@throw system_error `pos > size()`
|
||||
@throw `boost::system::system_error` `pos > size()`.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
string&
|
||||
@@ -1775,7 +1765,7 @@ public:
|
||||
|
||||
@param ch The character to append.
|
||||
|
||||
@throw system_error `size() + 1 > max_size()`
|
||||
@throw `boost::system::system_error` `size() + 1 > max_size()`.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
void
|
||||
@@ -1812,7 +1802,7 @@ public:
|
||||
|
||||
@param ch The character to append.
|
||||
|
||||
@throw system_error `size() + count > max_size()`
|
||||
@throw `boost::system::system_error` `size() + count > max_size()`.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
string&
|
||||
@@ -1832,7 +1822,7 @@ public:
|
||||
|
||||
@param sv The `string_view` to append.
|
||||
|
||||
@throw system_error `size() + s.size() > max_size()`
|
||||
@throw `boost::system::system_error` `size() + s.size() > max_size()`.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
string&
|
||||
@@ -1865,7 +1855,7 @@ public:
|
||||
@param last An iterator one past the
|
||||
last character to append.
|
||||
|
||||
@throw system_error `size() + insert_count > max_size()`
|
||||
@throw `boost::system::system_error` `size() + insert_count > max_size()`.
|
||||
*/
|
||||
template<class InputIt
|
||||
#ifndef BOOST_JSON_DOCS
|
||||
@@ -1890,7 +1880,7 @@ public:
|
||||
|
||||
@param sv The `string_view` to append.
|
||||
|
||||
@throw system_error `size() + sv.size() > max_size()`
|
||||
@throw `boost::system::system_error` `size() + sv.size() > max_size()`.
|
||||
*/
|
||||
string&
|
||||
operator+=(string_view sv)
|
||||
@@ -1908,7 +1898,7 @@ public:
|
||||
|
||||
@param ch The character to append.
|
||||
|
||||
@throw system_error `size() + 1 > max_size()`
|
||||
@throw `boost::system::system_error` `size() + 1 > max_size()`.
|
||||
*/
|
||||
string&
|
||||
operator+=(char ch)
|
||||
@@ -2037,9 +2027,8 @@ public:
|
||||
|
||||
@param sv The `string_view` to replace with.
|
||||
|
||||
@throw system_error `size() + (sv.size() - rcount) > max_size()`
|
||||
|
||||
@throw system_error `pos > size()`
|
||||
@throw `boost::system::system_error` `size() + (sv.size() - rcount) > max_size()`.
|
||||
@throw `boost::system::system_error` `pos > size()`.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
string&
|
||||
@@ -2075,7 +2064,7 @@ public:
|
||||
|
||||
@param sv The `string_view` to replace with.
|
||||
|
||||
@throw system_error `size() + (sv.size() - std::distance(first, last)) > max_size()`
|
||||
@throw `boost::system::system_error` `size() + (sv.size() - std::distance(first, last)) > max_size()`.
|
||||
*/
|
||||
string&
|
||||
replace(
|
||||
@@ -2125,7 +2114,7 @@ public:
|
||||
@param last2 An iterator one past the end of
|
||||
the last character to replace with.
|
||||
|
||||
@throw system_error `size() + (inserted - std::distance(first, last)) > max_size()`
|
||||
@throw `boost::system::system_error` `size() + (inserted - std::distance(first, last)) > max_size()`.
|
||||
*/
|
||||
template<class InputIt
|
||||
#ifndef BOOST_JSON_DOCS
|
||||
@@ -2164,9 +2153,8 @@ public:
|
||||
|
||||
@param ch The character to replace with.
|
||||
|
||||
@throw system_error `size() + (count2 - rcount) > max_size()`
|
||||
|
||||
@throw system_error `pos > size()`
|
||||
@throw `boost::system::system_error` `size() + (count2 - rcount) > max_size()`.
|
||||
@throw `boost::system::system_error` `pos > size()`.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
string&
|
||||
@@ -2206,7 +2194,7 @@ public:
|
||||
|
||||
@param ch The character to replace with.
|
||||
|
||||
@throw system_error `size() + (count - std::distance(first, last)) > max_size()`
|
||||
@throw `boost::system::system_error` `size() + (count - std::distance(first, last)) > max_size()`.
|
||||
*/
|
||||
string&
|
||||
replace(
|
||||
@@ -2237,7 +2225,7 @@ public:
|
||||
The default argument for this parameter
|
||||
is @ref npos.
|
||||
|
||||
@throw system_error `pos > size()`
|
||||
@throw `boost::system::system_error` `pos > size()`.
|
||||
*/
|
||||
string_view
|
||||
subview(
|
||||
@@ -2282,7 +2270,7 @@ public:
|
||||
@param pos The index to begin copying from. The
|
||||
default argument for this parameter is `0`.
|
||||
|
||||
@throw system_error `pos > max_size()`
|
||||
@throw `boost::system::system_error` `pos > max_size()`.
|
||||
*/
|
||||
std::size_t
|
||||
copy(
|
||||
@@ -2304,7 +2292,7 @@ public:
|
||||
|
||||
@param count The size to resize the string to.
|
||||
|
||||
@throw system_error `count > max_size()`
|
||||
@throw `boost::system::system_error` `count > max_size()`.
|
||||
*/
|
||||
void
|
||||
resize(std::size_t count)
|
||||
@@ -2324,7 +2312,7 @@ public:
|
||||
@param ch The characters to append if the size
|
||||
increases.
|
||||
|
||||
@throw system_error `count > max_size()`
|
||||
@throw `boost::system::system_error` `count > max_size()`.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
void
|
||||
@@ -2360,9 +2348,9 @@ public:
|
||||
|
||||
/** Swap the contents.
|
||||
|
||||
Exchanges the contents of this string with another
|
||||
string. Ownership of the respective @ref memory_resource
|
||||
objects is not transferred.
|
||||
Exchanges the contents of this string with another string. Ownership of
|
||||
the respective `boost::container::pmr::memory_resource` objects is not
|
||||
transferred.
|
||||
|
||||
@li If `&other == this`, do nothing. Otherwise,
|
||||
|
||||
@@ -2391,9 +2379,9 @@ public:
|
||||
|
||||
/** Exchange the given values.
|
||||
|
||||
Exchanges the contents of the string `lhs` with
|
||||
another string `rhs`. Ownership of the respective
|
||||
@ref memory_resource objects is not transferred.
|
||||
Exchanges the contents of the string `lhs` with another string `rhs`.
|
||||
Ownership of the respective `boost::container::pmr::memory_resource`
|
||||
objects is not transferred.
|
||||
|
||||
@li If `&lhs == &rhs`, do nothing. Otherwise,
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <boost/json/detail/config.hpp>
|
||||
#include <boost/json/fwd.hpp>
|
||||
#include <boost/assert/source_location.hpp>
|
||||
#include <boost/json/result_for.hpp>
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/system/result.hpp>
|
||||
#include <boost/system/system_error.hpp>
|
||||
@@ -21,17 +22,46 @@
|
||||
namespace boost {
|
||||
namespace json {
|
||||
|
||||
/// The type of error code used by the library.
|
||||
using error_code = boost::system::error_code;
|
||||
/** The type of error code used by the library.
|
||||
|
||||
/// The type of error category used by the library.
|
||||
using error_category = boost::system::error_category;
|
||||
@note This alias is deprecated in favor of `boost::system::error_code`.
|
||||
It is included for backwards compatibility and shouldn't be used in new
|
||||
code. It will be removed completely in version 1.87.0.
|
||||
*/
|
||||
typedef boost::system::error_code
|
||||
BOOST_DEPRECATED("Use boost::system::error_code instead")
|
||||
error_code;
|
||||
|
||||
/// The type of error condition used by the library.
|
||||
using error_condition = boost::system::error_condition;
|
||||
/** The type of error category used by the library.
|
||||
|
||||
/// The type of system error thrown by the library.
|
||||
using system_error = boost::system::system_error;
|
||||
@note This alias is deprecated in favor of `boost::system::error_category`.
|
||||
It is included for backwards compatibility and shouldn't be used in new
|
||||
code. It will be removed completely in version 1.87.0.
|
||||
*/
|
||||
typedef boost::system::error_category
|
||||
BOOST_DEPRECATED("Use boost::system::error_category instead")
|
||||
error_category;
|
||||
|
||||
/** The type of error condition used by the library.
|
||||
|
||||
@note This alias is deprecated in favor of
|
||||
`boost::system::error_condition`. It is included for backwards
|
||||
compatibility and shouldn't be used in new code. It will be removed
|
||||
completely in version 1.87.0.
|
||||
*/
|
||||
typedef boost::system::error_condition
|
||||
BOOST_DEPRECATED("Use boost::system::error_condition instead")
|
||||
error_condition;
|
||||
|
||||
/** The type of system error thrown by the library.
|
||||
|
||||
@note This alias is deprecated in favor of `boost::system::system_error`.
|
||||
It is included for backwards compatibility and shouldn't be used in new
|
||||
code. It will be removed completely in version 1.87.0.
|
||||
*/
|
||||
typedef boost::system::system_error
|
||||
BOOST_DEPRECATED("Use boost::system::system_error instead")
|
||||
system_error;
|
||||
|
||||
/** The type of result returned by library functions
|
||||
|
||||
@@ -90,134 +120,19 @@ using system_error = boost::system::system_error;
|
||||
std::cout << r.error();
|
||||
@endcode
|
||||
|
||||
@note For a full synopsis of the type, please see the corresponding
|
||||
documentation in Boost.System.
|
||||
@note This alias is deprecated in favor of `boost::system::result`. It is
|
||||
included for backwards compatibility and shouldn't be used in new code. It
|
||||
will be removed completely in version 1.87.0.
|
||||
|
||||
@tparam T The type of value held by the result.
|
||||
*/
|
||||
template< class T >
|
||||
using result = boost::system::result<T>;
|
||||
|
||||
/**
|
||||
Helper trait that returns @ref result
|
||||
|
||||
The primary template is an incomplete type. The library provides a partial
|
||||
specialisation `result_for<T1, value>`, that has nested type alias `type`
|
||||
that aliases the type `result<T1>`.
|
||||
|
||||
The purpose of this trait is to let users provide non-throwing conversions
|
||||
for their types without creating a physical dependency on Boost.Json. For
|
||||
example:
|
||||
|
||||
@code
|
||||
namespace boost
|
||||
{
|
||||
namespace json
|
||||
{
|
||||
|
||||
template<class T>
|
||||
struct value_to_tag;
|
||||
|
||||
template<class T1, class T2>
|
||||
struct result_for;
|
||||
}
|
||||
}
|
||||
|
||||
namespace mine
|
||||
{
|
||||
class my_class;
|
||||
...
|
||||
template<class JsonValue>
|
||||
boost::json::result_for<my_class, JsonValue>
|
||||
tag_invoke(boost::json::try_value_to_tag<my_class>, const JsonValue& jv)
|
||||
{ ... }
|
||||
}
|
||||
@endcode
|
||||
|
||||
@see @ref try_value_to, @ref try_value_to_tag
|
||||
*/
|
||||
template <class T1, class T2>
|
||||
struct result_for;
|
||||
|
||||
/** Create @ref result storing a portable error code
|
||||
|
||||
This function constructs a `result<T>` that stores @ref error_code with
|
||||
`value()` equal to `e` and `category()` equal to
|
||||
`boost::system::generic_category()`. <br>
|
||||
|
||||
The main use for this function is in implementation of functions returning
|
||||
@ref result, without including `boost/json/system_error.hpp` or even
|
||||
`<system_error>`. In particular, it may be useful for customizations of
|
||||
@ref try_value_to without creating a physical dependency on Boost.JSON.
|
||||
For example:
|
||||
|
||||
@code
|
||||
#include <cerrno>
|
||||
#include <boost/assert/source_location.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace json
|
||||
{
|
||||
|
||||
class value;
|
||||
|
||||
template<class T>
|
||||
struct try_value_to_tag;
|
||||
|
||||
template<class T1, class T2>
|
||||
struct result_for;
|
||||
|
||||
template <class T>
|
||||
typename result_for<T, value>::type
|
||||
result_from_errno(int e, boost::source_location const* loc) noexcept
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
namespace mine
|
||||
{
|
||||
|
||||
class my_class;
|
||||
...
|
||||
template<class JsonValue>
|
||||
boost::json::result_for<my_class, JsonValue>
|
||||
tag_invoke(boost::json::try_value_to_tag<my_class>, const JsonValue& jv)
|
||||
{
|
||||
BOOST_STATIC_CONSTEXPR boost::source_location loc = BOOST_CURRENT_LOCATION;
|
||||
if( !jv.is_null() )
|
||||
return boost::json::result_from_errno<my_class>(EINVAL, &loc);
|
||||
return my_class();
|
||||
}
|
||||
|
||||
}
|
||||
@endcode
|
||||
|
||||
@par Exception Safety
|
||||
Does not throw exceptions.
|
||||
|
||||
@tparam T The value type of returned `result`.
|
||||
|
||||
@param e The error value.
|
||||
|
||||
@param loc The error location.
|
||||
|
||||
@returns @ref error_code with `value()` equal to `e` and `category()` equal
|
||||
to `boost::system::generic_category()`.
|
||||
|
||||
@see @ref try_value_to_tag, @ref try_value_to, @ref result_for,
|
||||
<a href="https://www.boost.org/doc/libs/develop/libs/system/doc/html/system.html#ref_generic_category">
|
||||
`boost::system::generic_category`</a>,
|
||||
<a href="https://www.boost.org/doc/libs/master/libs/assert/doc/html/assert.html#source_location_support">
|
||||
`boost::source_location`</a>.
|
||||
*/
|
||||
template <class T>
|
||||
typename result_for<T, value>::type
|
||||
result_from_errno(int e, boost::source_location const* loc) noexcept
|
||||
{
|
||||
error_code ec(e, system::generic_category(), loc);
|
||||
return {system::in_place_error, ec};
|
||||
}
|
||||
using
|
||||
result
|
||||
#ifndef BOOST_MSVC
|
||||
BOOST_DEPRECATED("Use boost::system::result instead")
|
||||
#endif
|
||||
= boost::system::result<T>;
|
||||
|
||||
} // namespace json
|
||||
} // namespace boost
|
||||
|
||||
@@ -111,15 +111,15 @@ class value
|
||||
}
|
||||
|
||||
public:
|
||||
/** The type of _Allocator_ returned by @ref get_allocator
|
||||
/** Associated [Allocator](https://en.cppreference.com/w/cpp/named_req/Allocator)
|
||||
|
||||
This type is a @ref polymorphic_allocator.
|
||||
This type is a `boost::container::pmr::polymorphic_allocator<value>`.
|
||||
*/
|
||||
#ifdef BOOST_JSON_DOCS
|
||||
// VFALCO doc toolchain renders this incorrectly
|
||||
using allocator_type = __see_below__;
|
||||
#else
|
||||
using allocator_type = polymorphic_allocator<value>;
|
||||
// VFALCO doc toolchain renders this incorrectly
|
||||
using allocator_type = container::pmr::polymorphic_allocator<value>;
|
||||
#endif
|
||||
|
||||
/** Destructor.
|
||||
@@ -157,8 +157,8 @@ public:
|
||||
|
||||
/** Constructor.
|
||||
|
||||
The constructed value is null,
|
||||
using the specified @ref memory_resource.
|
||||
The constructed value is null, using the
|
||||
specified `boost::container::pmr::memory_resource`.
|
||||
|
||||
@par Complexity
|
||||
Constant.
|
||||
@@ -166,9 +166,9 @@ public:
|
||||
@par Exception Safety
|
||||
No-throw guarantee.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
*/
|
||||
explicit
|
||||
value(storage_ptr sp) noexcept
|
||||
@@ -239,9 +239,9 @@ public:
|
||||
|
||||
@param other The value to copy.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
value(
|
||||
@@ -297,9 +297,9 @@ public:
|
||||
|
||||
@param other The value to move.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
value(
|
||||
@@ -322,9 +322,9 @@ public:
|
||||
@par Exception Safety
|
||||
No-throw guarantee.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
*/
|
||||
value(
|
||||
std::nullptr_t,
|
||||
@@ -346,9 +346,9 @@ public:
|
||||
|
||||
@param b The initial value.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
*/
|
||||
#ifdef BOOST_JSON_DOCS
|
||||
value(
|
||||
@@ -377,9 +377,9 @@ public:
|
||||
|
||||
@param i The initial value.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
*/
|
||||
value(
|
||||
signed char i,
|
||||
@@ -399,9 +399,9 @@ public:
|
||||
|
||||
@param i The initial value.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
*/
|
||||
value(
|
||||
short i,
|
||||
@@ -421,9 +421,9 @@ public:
|
||||
|
||||
@param i The initial value.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
*/
|
||||
value(
|
||||
int i,
|
||||
@@ -443,9 +443,9 @@ public:
|
||||
|
||||
@param i The initial value.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
*/
|
||||
value(
|
||||
long i,
|
||||
@@ -465,9 +465,9 @@ public:
|
||||
|
||||
@param i The initial value.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
*/
|
||||
value(
|
||||
long long i,
|
||||
@@ -487,9 +487,9 @@ public:
|
||||
|
||||
@param u The initial value.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
*/
|
||||
value(
|
||||
unsigned char u,
|
||||
@@ -509,9 +509,9 @@ public:
|
||||
|
||||
@param u The initial value.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
*/
|
||||
value(
|
||||
unsigned short u,
|
||||
@@ -531,9 +531,9 @@ public:
|
||||
|
||||
@param u The initial value.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
*/
|
||||
value(
|
||||
unsigned int u,
|
||||
@@ -553,9 +553,9 @@ public:
|
||||
|
||||
@param u The initial value.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
*/
|
||||
value(
|
||||
unsigned long u,
|
||||
@@ -575,9 +575,9 @@ public:
|
||||
|
||||
@param u The initial value.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
*/
|
||||
value(
|
||||
unsigned long long u,
|
||||
@@ -597,9 +597,9 @@ public:
|
||||
|
||||
@param d The initial value.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
*/
|
||||
value(
|
||||
double d,
|
||||
@@ -622,9 +622,9 @@ public:
|
||||
|
||||
@param s The string view to construct with.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
*/
|
||||
value(
|
||||
string_view s,
|
||||
@@ -649,9 +649,9 @@ public:
|
||||
@param s The null-terminated string to construct
|
||||
with.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
*/
|
||||
value(
|
||||
char const* s,
|
||||
@@ -704,9 +704,9 @@ public:
|
||||
|
||||
@param other The string to construct with.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
*/
|
||||
value(
|
||||
string const& other,
|
||||
@@ -731,9 +731,9 @@ public:
|
||||
|
||||
@param other The string to construct with.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
*/
|
||||
value(
|
||||
string&& other,
|
||||
@@ -765,9 +765,9 @@ public:
|
||||
@par Exception Safety
|
||||
No-throw guarantee.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
|
||||
@see @ref string_kind
|
||||
*/
|
||||
@@ -821,9 +821,9 @@ public:
|
||||
|
||||
@param other The array to construct with.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
*/
|
||||
value(
|
||||
array const& other,
|
||||
@@ -848,9 +848,9 @@ public:
|
||||
|
||||
@param other The array to construct with.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
*/
|
||||
value(
|
||||
array&& other,
|
||||
@@ -882,9 +882,9 @@ public:
|
||||
@par Exception Safety
|
||||
No-throw guarantee.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
|
||||
@see @ref array_kind
|
||||
*/
|
||||
@@ -938,9 +938,9 @@ public:
|
||||
|
||||
@param other The object to construct with.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
*/
|
||||
value(
|
||||
object const& other,
|
||||
@@ -965,9 +965,9 @@ public:
|
||||
|
||||
@param other The object to construct with.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
*/
|
||||
value(
|
||||
object&& other,
|
||||
@@ -999,9 +999,9 @@ public:
|
||||
@par Exception Safety
|
||||
No-throw guarantee.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
|
||||
@see @ref object_kind
|
||||
*/
|
||||
@@ -1034,9 +1034,9 @@ public:
|
||||
|
||||
@param init The initializer list to construct from.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The container will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The container will acquire shared ownership of the memory
|
||||
resource.
|
||||
|
||||
@par Note
|
||||
The previous behavior of this constructor was to always
|
||||
@@ -1592,10 +1592,9 @@ public:
|
||||
|
||||
/** Return a reference to an @ref object, changing the kind and replacing the contents.
|
||||
|
||||
The contents are replaced with an empty @ref object
|
||||
using the current @ref memory_resource. All
|
||||
previously obtained iterators and references
|
||||
obtained beforehand are invalidated.
|
||||
The contents are replaced with an empty @ref object using the current
|
||||
`boost::container::pmr::memory_resource`. All previously obtained
|
||||
iterators and references obtained beforehand are invalidated.
|
||||
|
||||
@par Complexity
|
||||
Linear in the size of `*this`.
|
||||
@@ -1609,9 +1608,9 @@ public:
|
||||
|
||||
/** Swap the given values.
|
||||
|
||||
Exchanges the contents of this value with another
|
||||
value. Ownership of the respective @ref memory_resource
|
||||
objects is not transferred:
|
||||
Exchanges the contents of this value with another value. Ownership of
|
||||
the respective `boost::container::pmr::memory_resource` objects is not
|
||||
transferred:
|
||||
|
||||
@li If `*other.storage() == *this->storage()`,
|
||||
ownership of the underlying memory is swapped in
|
||||
@@ -1640,9 +1639,9 @@ public:
|
||||
|
||||
/** Swap the given values.
|
||||
|
||||
Exchanges the contents of value `lhs` with
|
||||
another value `rhs`. Ownership of the respective
|
||||
@ref memory_resource objects is not transferred.
|
||||
Exchanges the contents of value `lhs` with another value `rhs`.
|
||||
Ownership of the respective `boost::container::pmr::memory_resource`
|
||||
objects is not transferred.
|
||||
|
||||
@li If `*lhs.storage() == *rhs.storage()`,
|
||||
ownership of the underlying memory is swapped in
|
||||
@@ -2386,7 +2385,7 @@ public:
|
||||
! std::is_same<T, bool>::value,
|
||||
T>::type
|
||||
#endif
|
||||
to_number(error_code& ec) const noexcept
|
||||
to_number(system::error_code& ec) const noexcept
|
||||
{
|
||||
error e;
|
||||
auto result = to_number<T>(e);
|
||||
@@ -2405,7 +2404,7 @@ public:
|
||||
#endif
|
||||
to_number(std::error_code& ec) const noexcept
|
||||
{
|
||||
error_code jec;
|
||||
system::error_code jec;
|
||||
auto result = to_number<T>(jec);
|
||||
ec = jec;
|
||||
return result;
|
||||
@@ -2446,7 +2445,7 @@ public:
|
||||
|
||||
@return The converted number.
|
||||
|
||||
@throw system_error on error.
|
||||
@throw `boost::system::system_error` Thrown on error.
|
||||
*/
|
||||
template<class T>
|
||||
#ifdef BOOST_JSON_DOCS
|
||||
@@ -2475,10 +2474,10 @@ public:
|
||||
//
|
||||
//------------------------------------------------------
|
||||
|
||||
/** Return the memory resource associated with the value.
|
||||
/** Return the associated memory resource.
|
||||
|
||||
This returns a pointer to the memory resource
|
||||
that was used to construct the value.
|
||||
This function returns the `boost::container::pmr::memory_resource` used
|
||||
by the container.
|
||||
|
||||
@par Complexity
|
||||
Constant.
|
||||
@@ -2492,11 +2491,10 @@ public:
|
||||
return sp_;
|
||||
}
|
||||
|
||||
/** Return the associated @ref memory_resource
|
||||
/** Return the associated allocator.
|
||||
|
||||
This function returns an instance of
|
||||
@ref polymorphic_allocator constructed from the
|
||||
associated @ref memory_resource.
|
||||
This function returns an instance of @ref allocator_type constructed
|
||||
from the associated `boost::container::pmr::memory_resource`.
|
||||
|
||||
@par Complexity
|
||||
Constant.
|
||||
@@ -2524,7 +2522,7 @@ public:
|
||||
@par Exception Safety
|
||||
Strong guarantee.
|
||||
|
||||
@throw system_error `! this->is_object()`
|
||||
@throw `boost::system::system_error` `! this->is_object()`.
|
||||
*/
|
||||
/* @{ */
|
||||
object&
|
||||
@@ -2562,7 +2560,7 @@ public:
|
||||
@par Exception Safety
|
||||
Strong guarantee.
|
||||
|
||||
@throw system_error `! this->is_array()`
|
||||
@throw `boost::system::system_error` `! this->is_array()`.
|
||||
*/
|
||||
/* @{ */
|
||||
array&
|
||||
@@ -2600,7 +2598,7 @@ public:
|
||||
@par Exception Safety
|
||||
Strong guarantee.
|
||||
|
||||
@throw system_error `! this->is_string()`
|
||||
@throw `boost::system::system_error` `! this->is_string()`.
|
||||
*/
|
||||
/* @{ */
|
||||
string&
|
||||
@@ -2638,7 +2636,7 @@ public:
|
||||
@par Exception Safety
|
||||
Strong guarantee.
|
||||
|
||||
@throw system_error `! this->is_int64()`
|
||||
@throw `boost::system::system_error` `! this->is_int64()`.
|
||||
|
||||
@par Note
|
||||
This function is intended for direct access to the underlying object,
|
||||
@@ -2669,7 +2667,7 @@ public:
|
||||
@par Exception Safety
|
||||
Strong guarantee.
|
||||
|
||||
@throw system_error `! this->is_int64()`
|
||||
@throw `boost::system::system_error` `! this->is_int64()`.
|
||||
|
||||
@par Note
|
||||
This function is the const-qualified overload of @ref as_int64, which
|
||||
@@ -2700,7 +2698,7 @@ public:
|
||||
@par Exception Safety
|
||||
Strong guarantee.
|
||||
|
||||
@throw system_error `! this->is_uint64()`
|
||||
@throw `boost::system::system_error` `! this->is_uint64()`.
|
||||
|
||||
@par Note
|
||||
This function is intended for direct access to the underlying object,
|
||||
@@ -2731,7 +2729,7 @@ public:
|
||||
@par Exception Safety
|
||||
Strong guarantee.
|
||||
|
||||
@throw system_error `! this->is_uint64()`
|
||||
@throw `boost::system::system_error` `! this->is_uint64()`.
|
||||
|
||||
@par Note
|
||||
This function is the const-qualified overload of @ref as_uint64, which
|
||||
@@ -2763,7 +2761,7 @@ public:
|
||||
@par Exception Safety
|
||||
Strong guarantee.
|
||||
|
||||
@throw system_error `! this->is_double()`
|
||||
@throw `boost::system::system_error` `! this->is_double()`.
|
||||
|
||||
@par Note
|
||||
This function is intended for direct access to the underlying object,
|
||||
@@ -2793,7 +2791,7 @@ public:
|
||||
@par Exception Safety
|
||||
Strong guarantee.
|
||||
|
||||
@throw system_error `! this->is_double()`
|
||||
@throw `boost::system::system_error` `! this->is_double()`.
|
||||
|
||||
@par Note
|
||||
This function is the const-qualified overload of @ref as_double, which
|
||||
@@ -2824,7 +2822,7 @@ public:
|
||||
@par Exception Safety
|
||||
Strong guarantee.
|
||||
|
||||
@throw system_error `! this->is_bool()`
|
||||
@throw `boost::system::system_error` `! this->is_bool()`.
|
||||
*/
|
||||
bool&
|
||||
as_bool()
|
||||
@@ -2847,7 +2845,7 @@ public:
|
||||
@par Exception Safety
|
||||
Strong guarantee.
|
||||
|
||||
@throw system_error `! this->is_bool()`
|
||||
@throw `boost::system::system_error` `! this->is_bool()`.
|
||||
*/
|
||||
bool
|
||||
as_bool() const
|
||||
@@ -3261,7 +3259,7 @@ public:
|
||||
|
||||
@return reference to the element identified by `ptr`.
|
||||
|
||||
@throw system_error if an error occurs.
|
||||
@throw `boost::system::system_error` if an error occurs.
|
||||
|
||||
@see
|
||||
<a href="https://datatracker.ietf.org/doc/html/rfc6901">
|
||||
@@ -3305,11 +3303,11 @@ public:
|
||||
/** @{ */
|
||||
BOOST_JSON_DECL
|
||||
value const*
|
||||
find_pointer(string_view ptr, error_code& ec) const noexcept;
|
||||
find_pointer(string_view ptr, system::error_code& ec) const noexcept;
|
||||
|
||||
BOOST_JSON_DECL
|
||||
value*
|
||||
find_pointer(string_view ptr, error_code& ec) noexcept;
|
||||
find_pointer(string_view ptr, system::error_code& ec) noexcept;
|
||||
|
||||
BOOST_JSON_DECL
|
||||
value const*
|
||||
@@ -3452,7 +3450,7 @@ public:
|
||||
set_at_pointer(
|
||||
string_view sv,
|
||||
value_ref ref,
|
||||
error_code& ec,
|
||||
system::error_code& ec,
|
||||
set_pointer_options const& opts = {} );
|
||||
|
||||
BOOST_JSON_DECL
|
||||
@@ -3840,9 +3838,8 @@ public:
|
||||
|
||||
@param other The key/value pair to copy.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The element will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The element will acquire shared ownership of the memory resource.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
key_value_pair(
|
||||
@@ -3959,9 +3956,8 @@ public:
|
||||
@param p A `std::pair` with the key
|
||||
string and @ref value to construct with.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The element will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The element will acquire shared ownership of the memory resource.
|
||||
*/
|
||||
explicit
|
||||
key_value_pair(
|
||||
@@ -3989,9 +3985,8 @@ public:
|
||||
@param p A `std::pair` with the key
|
||||
string and @ref value to construct with.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use. The element will acquire shared
|
||||
ownership of the memory resource.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use. The element will acquire shared ownership of the memory resource.
|
||||
*/
|
||||
explicit
|
||||
key_value_pair(
|
||||
|
||||
@@ -44,12 +44,11 @@ class string;
|
||||
@li `std::initializer_list< std::pair< string_view, value_ref > >`
|
||||
for constructing or assigning an @ref object.
|
||||
|
||||
A `value_ref` uses reference semantics. Creation
|
||||
of the actual container from the initializer
|
||||
list is lazily deferred until the list is used.
|
||||
This means that the @ref memory_resource used to
|
||||
construct a container can be specified after the
|
||||
point where the initializer list is specified.
|
||||
A `value_ref` uses reference semantics. Creation of the actual container
|
||||
from the initializer list is lazily deferred until the list is used. This
|
||||
means that the `boost::container::pmr::memory_resource` used to construct a
|
||||
container can be specified after the point where the initializer list is
|
||||
specified.
|
||||
|
||||
@par Example
|
||||
|
||||
|
||||
@@ -23,33 +23,27 @@ namespace json {
|
||||
|
||||
/** A stack of @ref value elements, for building a document.
|
||||
|
||||
This stack of @ref value allows iterative
|
||||
construction of a JSON document in memory.
|
||||
The implementation uses temporary internal
|
||||
storage to buffer elements so that arrays, objects,
|
||||
and strings in the document are constructed using a
|
||||
single memory allocation. This improves performance
|
||||
and makes efficient use of the @ref memory_resource
|
||||
This stack of @ref value allows iterative construction of a JSON document
|
||||
in memory. The implementation uses temporary internal storage to buffer
|
||||
elements so that arrays, objects, and strings in the document are
|
||||
constructed using a single memory allocation. This improves performance
|
||||
and makes efficient use of the `boost::container::pmr::memory_resource`
|
||||
used to create the resulting @ref value.
|
||||
|
||||
Temporary storage used by the implementation
|
||||
initially comes from an optional memory buffer
|
||||
owned by the caller. If that storage is exhausted,
|
||||
Temporary storage used by the implementation initially comes from an
|
||||
optional memory buffer owned by the caller. If that storage is exhausted,
|
||||
then memory is obtained dynamically from the
|
||||
@ref memory_resource provided on construction.
|
||||
`boost::container::pmr::memory_resource` provided on construction.
|
||||
|
||||
@par Usage
|
||||
|
||||
Construct the stack with an optional initial
|
||||
temporary buffer, and a @ref storage_ptr to use for
|
||||
more storage when the initial buffer is exhausted.
|
||||
Then to build a @ref value, first call @ref reset
|
||||
and optionally specify the @ref memory_resource
|
||||
which will be used for the value. Then push elements
|
||||
onto the stack by calling the corresponding functions.
|
||||
After the document has been fully created, call
|
||||
@ref release to acquire ownership of the top-level
|
||||
@ref value.
|
||||
Construct the stack with an optional initial temporary buffer, and a
|
||||
@ref storage_ptr to use for more storage when the initial buffer is
|
||||
exhausted. Then to build a @ref value, first call @ref reset and
|
||||
optionally specify the `boost::container::pmr::memory_resource` which will
|
||||
be used for the value. Then push elements onto the stack by calling the
|
||||
corresponding functions. After the document has been fully created, call
|
||||
@ref release to acquire ownership of the top-level @ref value.
|
||||
|
||||
@par Performance
|
||||
|
||||
@@ -190,10 +184,9 @@ public:
|
||||
intermediate storage; it will not be used
|
||||
for the @ref value returned by @ref release.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use for intermediate storage allocations. If
|
||||
this argument is omitted, the default memory
|
||||
resource is used.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use for intermediate storage allocations. If this argument is omitted,
|
||||
the default memory resource is used.
|
||||
|
||||
@param temp_buffer A pointer to a caller-owned
|
||||
buffer which will be used to store temporary
|
||||
@@ -222,12 +215,10 @@ public:
|
||||
|
||||
No-throw guarantee.
|
||||
|
||||
@param sp A pointer to the @ref memory_resource
|
||||
to use for top-level @ref value and all child
|
||||
values. The stack will acquire shared ownership
|
||||
of the memory resource until @ref release or
|
||||
@ref reset is called, or when the stack is
|
||||
destroyed.
|
||||
@param sp A pointer to the `boost::container::pmr::memory_resource` to
|
||||
use for top-level @ref value and all child values. The stack will
|
||||
acquire shared ownership of the memory resource until @ref release or
|
||||
@ref reset is called, or when the stack is destroyed.
|
||||
*/
|
||||
BOOST_JSON_DECL
|
||||
void
|
||||
|
||||
@@ -36,6 +36,7 @@ local SOURCES =
|
||||
parse_into.cpp
|
||||
pilfer.cpp
|
||||
pointer.cpp
|
||||
result_for.cpp
|
||||
serialize.cpp
|
||||
serializer.cpp
|
||||
snippets.cpp
|
||||
@@ -44,7 +45,6 @@ local SOURCES =
|
||||
stream_parser.cpp
|
||||
string.cpp
|
||||
string_view.cpp
|
||||
system_error.cpp
|
||||
value.cpp
|
||||
value_from.cpp
|
||||
value_stack.cpp
|
||||
|
||||
@@ -136,7 +136,7 @@ validate( string_view s )
|
||||
{
|
||||
// Parse with the null parser and return false on error
|
||||
null_parser p;
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
p.write( s.data(), s.size(), ec );
|
||||
if( ec )
|
||||
return false;
|
||||
@@ -199,7 +199,7 @@ public:
|
||||
#define TEST_GRIND_ONE(s, good, po) \
|
||||
do { \
|
||||
string_view _test_gr1_s = s; \
|
||||
error_code ec; \
|
||||
system::error_code ec; \
|
||||
fail_parser p((po)); \
|
||||
auto sz = p.write(false, _test_gr1_s.data(), _test_gr1_s.size(), ec); \
|
||||
if(good) \
|
||||
@@ -224,7 +224,7 @@ public:
|
||||
{ \
|
||||
for(std::size_t j = 1;;++j) \
|
||||
{ \
|
||||
error_code ec; \
|
||||
system::error_code ec; \
|
||||
fail_parser p(j, (po)); \
|
||||
auto sz = p.write(true, _test_gr_s.data(), i, ec); \
|
||||
if(ec == error::test_failure) \
|
||||
@@ -258,7 +258,7 @@ public:
|
||||
{ \
|
||||
for(std::size_t j = 1;;++j) \
|
||||
{ \
|
||||
error_code ec; \
|
||||
system::error_code ec; \
|
||||
throw_parser p(j, (po)); \
|
||||
try \
|
||||
{ \
|
||||
@@ -705,7 +705,7 @@ public:
|
||||
bool done)
|
||||
{
|
||||
fail_parser p;
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
p.write_some(
|
||||
true,
|
||||
s.data(), s.size(),
|
||||
@@ -788,7 +788,7 @@ public:
|
||||
|
||||
// no input
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
fail_parser p;
|
||||
p.write(false, nullptr, 0, ec);
|
||||
BOOST_TEST(ec);
|
||||
@@ -800,7 +800,7 @@ public:
|
||||
{
|
||||
fail_parser p;
|
||||
std::size_t n;
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
n = p.write_some(true, "null", 4, ec );
|
||||
if(BOOST_TEST(! ec))
|
||||
{
|
||||
@@ -840,7 +840,7 @@ public:
|
||||
{
|
||||
if(v.result == 'i')
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
fail_parser p(po);
|
||||
p.write(
|
||||
false,
|
||||
@@ -962,28 +962,28 @@ public:
|
||||
constexpr static std::size_t max_string_size = std::size_t(-1);
|
||||
|
||||
std::string captured = "";
|
||||
bool on_document_begin( error_code& ) { return true; }
|
||||
bool on_document_end( error_code& ) { return true; }
|
||||
bool on_object_begin( error_code& ) { return true; }
|
||||
bool on_object_end( std::size_t, error_code& ) { return true; }
|
||||
bool on_array_begin( error_code& ) { return true; }
|
||||
bool on_array_end( std::size_t, error_code& ) { return true; }
|
||||
bool on_key_part( string_view, std::size_t, error_code& ) { return true; }
|
||||
bool on_key( string_view, std::size_t, error_code& ) { return true; }
|
||||
bool on_string_part( string_view, std::size_t, error_code& ) { return true; }
|
||||
bool on_string( string_view, std::size_t, error_code& ) { return true; }
|
||||
bool on_number_part( string_view, error_code&) { return true; }
|
||||
bool on_int64( std::int64_t, string_view, error_code& ) { return true; }
|
||||
bool on_uint64( std::uint64_t, string_view, error_code& ) { return true; }
|
||||
bool on_double( double, string_view, error_code& ) { return true; }
|
||||
bool on_bool( bool, error_code& ) { return true; }
|
||||
bool on_null( error_code& ) { return true; }
|
||||
bool on_comment_part( string_view s, error_code& )
|
||||
bool on_document_begin( system::error_code& ) { return true; }
|
||||
bool on_document_end( system::error_code& ) { return true; }
|
||||
bool on_object_begin( system::error_code& ) { return true; }
|
||||
bool on_object_end( std::size_t, system::error_code& ) { return true; }
|
||||
bool on_array_begin( system::error_code& ) { return true; }
|
||||
bool on_array_end( std::size_t, system::error_code& ) { return true; }
|
||||
bool on_key_part( string_view, std::size_t, system::error_code& ) { return true; }
|
||||
bool on_key( string_view, std::size_t, system::error_code& ) { return true; }
|
||||
bool on_string_part( string_view, std::size_t, system::error_code& ) { return true; }
|
||||
bool on_string( string_view, std::size_t, system::error_code& ) { return true; }
|
||||
bool on_number_part( string_view, system::error_code&) { return true; }
|
||||
bool on_int64( std::int64_t, string_view, system::error_code& ) { return true; }
|
||||
bool on_uint64( std::uint64_t, string_view, system::error_code& ) { return true; }
|
||||
bool on_double( double, string_view, system::error_code& ) { return true; }
|
||||
bool on_bool( bool, system::error_code& ) { return true; }
|
||||
bool on_null( system::error_code& ) { return true; }
|
||||
bool on_comment_part( string_view s, system::error_code& )
|
||||
{
|
||||
captured.append(s.data(), s.size());
|
||||
return true;
|
||||
}
|
||||
bool on_comment( string_view s, error_code& )
|
||||
bool on_comment( string_view s, system::error_code& )
|
||||
{
|
||||
captured.append(s.data(), s.size());
|
||||
return true;
|
||||
@@ -1002,7 +1002,7 @@ public:
|
||||
write(
|
||||
char const* data,
|
||||
std::size_t size,
|
||||
error_code& ec)
|
||||
system::error_code& ec)
|
||||
{
|
||||
auto const n = p_.write_some(
|
||||
false, data, size, ec);
|
||||
@@ -1070,7 +1070,7 @@ public:
|
||||
{
|
||||
// test the handler
|
||||
comment_parser p;
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
p.write( formatted.data(), formatted.size(), ec );
|
||||
BOOST_TEST(! ec);
|
||||
BOOST_TEST(p.captured() == just_comments);
|
||||
@@ -1114,7 +1114,7 @@ public:
|
||||
parse_options po;
|
||||
po.allow_comments = true;
|
||||
fail_parser p(po);
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
p.write(true, "//", 2, ec); // suspend while inside comment
|
||||
BOOST_TEST( !ec.failed() );
|
||||
p.write(true, " \n1", 2, ec); // input ends comment,
|
||||
@@ -1177,32 +1177,32 @@ public:
|
||||
constexpr static std::size_t max_string_size = std::size_t(-1);
|
||||
|
||||
std::string captured = "";
|
||||
bool on_document_begin( error_code& ) { return true; }
|
||||
bool on_document_end( error_code& ) { return true; }
|
||||
bool on_object_begin( error_code& ) { return true; }
|
||||
bool on_object_end( std::size_t, error_code& ) { return true; }
|
||||
bool on_array_begin( error_code& ) { return true; }
|
||||
bool on_array_end( std::size_t, error_code& ) { return true; }
|
||||
bool on_key_part( string_view, std::size_t, error_code& ) { return true; }
|
||||
bool on_key( string_view, std::size_t, error_code& ) { return true; }
|
||||
bool on_string_part( string_view sv, std::size_t, error_code& )
|
||||
bool on_document_begin( system::error_code& ) { return true; }
|
||||
bool on_document_end( system::error_code& ) { return true; }
|
||||
bool on_object_begin( system::error_code& ) { return true; }
|
||||
bool on_object_end( std::size_t, system::error_code& ) { return true; }
|
||||
bool on_array_begin( system::error_code& ) { return true; }
|
||||
bool on_array_end( std::size_t, system::error_code& ) { return true; }
|
||||
bool on_key_part( string_view, std::size_t, system::error_code& ) { return true; }
|
||||
bool on_key( string_view, std::size_t, system::error_code& ) { return true; }
|
||||
bool on_string_part( string_view sv, std::size_t, system::error_code& )
|
||||
{
|
||||
captured.append(sv.data(), sv.size());
|
||||
return true;
|
||||
}
|
||||
bool on_string( string_view sv, std::size_t, error_code& )
|
||||
bool on_string( string_view sv, std::size_t, system::error_code& )
|
||||
{
|
||||
captured.append(sv.data(), sv.size());
|
||||
return true;
|
||||
}
|
||||
bool on_number_part( string_view, error_code&) { return true; }
|
||||
bool on_int64( std::int64_t, string_view, error_code& ) { return true; }
|
||||
bool on_uint64( std::uint64_t, string_view, error_code& ) { return true; }
|
||||
bool on_double( double, string_view, error_code& ) { return true; }
|
||||
bool on_bool( bool, error_code& ) { return true; }
|
||||
bool on_null( error_code& ) { return true; }
|
||||
bool on_comment_part( string_view, error_code& ) { return true; }
|
||||
bool on_comment( string_view, error_code& ) { return true; }
|
||||
bool on_number_part( string_view, system::error_code&) { return true; }
|
||||
bool on_int64( std::int64_t, string_view, system::error_code& ) { return true; }
|
||||
bool on_uint64( std::uint64_t, string_view, system::error_code& ) { return true; }
|
||||
bool on_double( double, string_view, system::error_code& ) { return true; }
|
||||
bool on_bool( bool, system::error_code& ) { return true; }
|
||||
bool on_null( system::error_code& ) { return true; }
|
||||
bool on_comment_part( string_view, system::error_code& ) { return true; }
|
||||
bool on_comment( string_view, system::error_code& ) { return true; }
|
||||
};
|
||||
|
||||
basic_parser<handler> p_;
|
||||
@@ -1218,7 +1218,7 @@ public:
|
||||
bool more,
|
||||
char const* data,
|
||||
std::size_t size,
|
||||
error_code& ec)
|
||||
system::error_code& ec)
|
||||
{
|
||||
auto const n = p_.write_some(
|
||||
more, data, size, ec);
|
||||
@@ -1407,7 +1407,7 @@ public:
|
||||
utf8_parser p;
|
||||
for(std::size_t i = 0; i < expected.size(); i += write_size)
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
write_size = (std::min)(write_size, expected.size() - i);
|
||||
auto more = (i < expected.size() - write_size);
|
||||
auto written = p.write(more,
|
||||
@@ -1433,7 +1433,7 @@ public:
|
||||
parse_options opt;
|
||||
opt.max_depth = 4;
|
||||
null_parser p(opt);
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
p.write(s.data(), s.size(), ec);
|
||||
BOOST_TEST(ec == error::too_deep);
|
||||
BOOST_TEST(ec.has_location());
|
||||
@@ -1443,7 +1443,7 @@ public:
|
||||
parse_options opt;
|
||||
opt.max_depth = 4;
|
||||
null_parser p(opt);
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
p.write(s.data(), s.size(), ec);
|
||||
BOOST_TEST(ec == error::too_deep);
|
||||
BOOST_TEST(ec.has_location());
|
||||
@@ -1454,7 +1454,7 @@ public:
|
||||
parse_options opt;
|
||||
opt.max_depth = 4;
|
||||
null_parser p(opt);
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
p.write(s.data(), s.size(), ec);
|
||||
BOOST_TEST(ec == error::too_deep);
|
||||
BOOST_TEST(ec.has_location());
|
||||
@@ -1465,7 +1465,7 @@ public:
|
||||
parse_options opt;
|
||||
opt.max_depth = 4;
|
||||
null_parser p(opt);
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
p.write(s.data(), s.size(), ec);
|
||||
BOOST_TEST(ec == error::too_deep);
|
||||
BOOST_TEST(ec.has_location());
|
||||
@@ -1482,43 +1482,43 @@ public:
|
||||
constexpr static std::size_t max_string_size = std::size_t(-1);
|
||||
|
||||
std::string captured = "";
|
||||
bool on_document_begin( error_code& ) { return true; }
|
||||
bool on_document_end( error_code& ) { return true; }
|
||||
bool on_object_begin( error_code& ) { return true; }
|
||||
bool on_object_end( std::size_t, error_code& ) { return true; }
|
||||
bool on_array_begin( error_code& ) { return true; }
|
||||
bool on_array_end( std::size_t, error_code& ) { return true; }
|
||||
bool on_key_part( string_view, std::size_t, error_code& ) { return true; }
|
||||
bool on_key( string_view, std::size_t, error_code& ) { return true; }
|
||||
bool on_string_part( string_view, std::size_t, error_code& ) { return true; }
|
||||
bool on_string( string_view, std::size_t, error_code& ) { return true; }
|
||||
bool on_number_part( string_view sv, error_code&)
|
||||
bool on_document_begin( system::error_code& ) { return true; }
|
||||
bool on_document_end( system::error_code& ) { return true; }
|
||||
bool on_object_begin( system::error_code& ) { return true; }
|
||||
bool on_object_end( std::size_t, system::error_code& ) { return true; }
|
||||
bool on_array_begin( system::error_code& ) { return true; }
|
||||
bool on_array_end( std::size_t, system::error_code& ) { return true; }
|
||||
bool on_key_part( string_view, std::size_t, system::error_code& ) { return true; }
|
||||
bool on_key( string_view, std::size_t, system::error_code& ) { return true; }
|
||||
bool on_string_part( string_view, std::size_t, system::error_code& ) { return true; }
|
||||
bool on_string( string_view, std::size_t, system::error_code& ) { return true; }
|
||||
bool on_number_part( string_view sv, system::error_code&)
|
||||
{
|
||||
captured.append(sv.data(), sv.size());
|
||||
return true;
|
||||
}
|
||||
bool on_int64( std::int64_t, string_view sv, error_code& )
|
||||
bool on_int64( std::int64_t, string_view sv, system::error_code& )
|
||||
{
|
||||
captured.append(sv.data(), sv.size());
|
||||
captured += 's';
|
||||
return true;
|
||||
}
|
||||
bool on_uint64( std::uint64_t, string_view sv, error_code& )
|
||||
bool on_uint64( std::uint64_t, string_view sv, system::error_code& )
|
||||
{
|
||||
captured.append(sv.data(), sv.size());
|
||||
captured += 'u';
|
||||
return true;
|
||||
}
|
||||
bool on_double( double, string_view sv, error_code& )
|
||||
bool on_double( double, string_view sv, system::error_code& )
|
||||
{
|
||||
captured.append(sv.data(), sv.size());
|
||||
captured += 'd';
|
||||
return true;
|
||||
}
|
||||
bool on_bool( bool, error_code& ) { return true; }
|
||||
bool on_null( error_code& ) { return true; }
|
||||
bool on_comment_part( string_view, error_code& ) { return true; }
|
||||
bool on_comment( string_view, error_code& ) { return true; }
|
||||
bool on_bool( bool, system::error_code& ) { return true; }
|
||||
bool on_null( system::error_code& ) { return true; }
|
||||
bool on_comment_part( string_view, system::error_code& ) { return true; }
|
||||
bool on_comment( string_view, system::error_code& ) { return true; }
|
||||
};
|
||||
|
||||
basic_parser<handler> p_;
|
||||
@@ -1534,7 +1534,7 @@ public:
|
||||
bool more,
|
||||
char const* data,
|
||||
std::size_t size,
|
||||
error_code& ec)
|
||||
system::error_code& ec)
|
||||
{
|
||||
auto const n = p_.write_some(
|
||||
more, data, size, ec);
|
||||
@@ -1562,7 +1562,7 @@ public:
|
||||
i < sv.size(); ++i)
|
||||
{
|
||||
literal_parser p;
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
if(i != 0)
|
||||
{
|
||||
p.write(true,
|
||||
@@ -1606,10 +1606,10 @@ public:
|
||||
{
|
||||
{
|
||||
null_parser p;
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
p.write("*", 1, ec);
|
||||
BOOST_TEST(ec);
|
||||
error_code ec2;
|
||||
system::error_code ec2;
|
||||
p.write("[]", 2, ec2);
|
||||
BOOST_TEST(ec2 == ec);
|
||||
p.reset();
|
||||
@@ -1622,13 +1622,13 @@ public:
|
||||
throw_parser p(1);
|
||||
try
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
p.write(false, "null", 4, ec);
|
||||
BOOST_TEST_FAIL();
|
||||
}
|
||||
catch(std::exception const&)
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
p.write(false, "null", 4, ec);
|
||||
BOOST_TEST(ec == error::exception);
|
||||
BOOST_TEST(ec.has_location());
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace boost {
|
||||
namespace json {
|
||||
|
||||
class checking_resource
|
||||
: public memory_resource
|
||||
: public container::pmr::memory_resource
|
||||
{
|
||||
storage_ptr upstream_;
|
||||
std::map<void const*, std::pair<std::size_t, std::size_t>> allocs_;
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace std {
|
||||
namespace pmr {
|
||||
|
||||
template< class T >
|
||||
using vector = std::vector< T, polymorphic_allocator< T > >;
|
||||
using vector = std::vector< T, boost::container::pmr::polymorphic_allocator< T > >;
|
||||
|
||||
} // namespace pmr
|
||||
} // namespace std
|
||||
@@ -118,7 +118,7 @@ struct T {};
|
||||
monotonic_resource mr;
|
||||
|
||||
// Construct a vector using the monotonic buffer resource
|
||||
vector< T > v1(( polymorphic_allocator< T >(&mr) ));
|
||||
vector< T > v1(( boost::container::pmr::polymorphic_allocator< T >(&mr) ));
|
||||
|
||||
// Or this way, since construction from memory_resource* is implicit:
|
||||
vector< T > v2( &mr );
|
||||
@@ -145,7 +145,7 @@ vector< T > v2( &mr );
|
||||
|
||||
//----------------------------------------------------------
|
||||
|
||||
struct my_resource : memory_resource
|
||||
struct my_resource : container::pmr::memory_resource
|
||||
{
|
||||
void* do_allocate ( size_t, size_t ) override { return 0; }
|
||||
void do_deallocate( void*, size_t, size_t ) override {}
|
||||
|
||||
@@ -35,7 +35,7 @@ value jv = parse( "[1,2,3,4,5]" );
|
||||
//----------------------------------------------------------
|
||||
{
|
||||
//[doc_parsing_2
|
||||
error_code ec;
|
||||
boost::system::error_code ec;
|
||||
value jv = parse( "[1,2,3,4,5]", ec );
|
||||
if( ec )
|
||||
std::cout << "Parsing failed: " << ec.message() << "\n";
|
||||
@@ -46,7 +46,7 @@ if( ec )
|
||||
//[doc_parsing_3
|
||||
try
|
||||
{
|
||||
error_code ec;
|
||||
boost::system::error_code ec;
|
||||
value jv = parse( "[1,2,3,4,5]", ec );
|
||||
if( ec )
|
||||
std::cout << "Parsing failed: " << ec.message() << "\n";
|
||||
@@ -121,7 +121,7 @@ static void set2() {
|
||||
{
|
||||
//[doc_parsing_8
|
||||
stream_parser p;
|
||||
error_code ec;
|
||||
boost::system::error_code ec;
|
||||
string_view s = "[1,2,3] %HOME%";
|
||||
std::size_t n = p.write_some( s, ec );
|
||||
assert( ! ec && p.done() && n == 8 );
|
||||
@@ -146,7 +146,7 @@ stream_parser p( storage_ptr(), opt ); // The stream_parser will us
|
||||
|
||||
//----------------------------------------------------------
|
||||
//[doc_parsing_10
|
||||
value read_json( std::istream& is, error_code& ec )
|
||||
value read_json( std::istream& is, boost::system::error_code& ec )
|
||||
{
|
||||
stream_parser p;
|
||||
std::string line;
|
||||
@@ -164,7 +164,7 @@ value read_json( std::istream& is, error_code& ec )
|
||||
//]
|
||||
|
||||
//[doc_parsing_14
|
||||
std::vector<value> read_jsons( std::istream& is, error_code& ec )
|
||||
std::vector<value> read_jsons( std::istream& is, boost::system::error_code& ec )
|
||||
{
|
||||
std::vector< value > jvs;
|
||||
stream_parser p;
|
||||
@@ -303,7 +303,7 @@ public:
|
||||
"l12345\n"
|
||||
"6\"!\n"
|
||||
"\"[2]3" );
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
auto jvs = read_jsons( ss, ec );
|
||||
assert( !ec.failed() );
|
||||
assert( jvs.size() == 6 );
|
||||
|
||||
@@ -134,7 +134,7 @@ value jv = parse( "[1, 2, 3]" );
|
||||
//----------------------------------------------------------
|
||||
{
|
||||
//[doc_quick_look_9
|
||||
error_code ec;
|
||||
boost::system::error_code ec;
|
||||
value jv = parse( R"( "Hello, world!" )", ec );
|
||||
//]
|
||||
}
|
||||
@@ -153,7 +153,7 @@ value jv = parse( "[1, 2, 3, ] // array ", &mr, opt );
|
||||
{
|
||||
//[doc_quick_look_11
|
||||
stream_parser p;
|
||||
error_code ec;
|
||||
boost::system::error_code ec;
|
||||
p.reset();
|
||||
p.write( "[1, 2 ", ec );
|
||||
if( ! ec )
|
||||
|
||||
@@ -131,7 +131,7 @@ assert( str.storage().is_shared() ); // shared ownership
|
||||
|
||||
//----------------------------------------------------------
|
||||
//[doc_storage_ptr_10
|
||||
class logging_resource : public memory_resource
|
||||
class logging_resource : public boost::container::pmr::memory_resource
|
||||
{
|
||||
private:
|
||||
void* do_allocate( std::size_t bytes, std::size_t align ) override
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
// Official repository: https://github.com/boostorg/json
|
||||
//
|
||||
|
||||
#include <boost/container/pmr/memory_resource.hpp>
|
||||
#include <boost/json/memory_resource.hpp>
|
||||
#include <boost/json/monotonic_resource.hpp>
|
||||
#include <boost/json/value.hpp>
|
||||
@@ -28,7 +29,7 @@ static void set1() {
|
||||
monotonic_resource mr;
|
||||
|
||||
// Declare a vector of JSON values
|
||||
std::vector< value, polymorphic_allocator< value > > v( &mr );
|
||||
std::vector< value, boost::container::pmr::polymorphic_allocator< value > > v( &mr );
|
||||
|
||||
// The polymorphic allocator will use our resource
|
||||
assert( v.get_allocator().resource() == &mr );
|
||||
@@ -44,7 +45,7 @@ assert( v[0].storage().get() == &mr );
|
||||
{
|
||||
//[doc_uses_allocator_2
|
||||
// This vector will use the default memory resource
|
||||
std::vector< value, polymorphic_allocator < value > > v;
|
||||
std::vector< value, boost::container::pmr::polymorphic_allocator < value > > v;
|
||||
|
||||
// This value will same memory resource as the vector
|
||||
value jv( v.get_allocator() );
|
||||
|
||||
@@ -124,7 +124,7 @@ catch(...)
|
||||
|
||||
value jv = 10.5;
|
||||
|
||||
error_code ec;
|
||||
boost::system::error_code ec;
|
||||
|
||||
// ok, conversion is exact
|
||||
float r1 = jv.to_number< float >( ec );
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
operator()(string_view s, parse_options const& po = {}) const
|
||||
{
|
||||
BOOST_TEST_CHECKPOINT();
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
stream_parser p({}, po);
|
||||
p.write(s.data(), s.size(), ec);
|
||||
if(BOOST_TEST(! ec))
|
||||
@@ -95,7 +95,7 @@ public:
|
||||
const parse_options& po = parse_options())
|
||||
{
|
||||
stream_parser p(storage_ptr(), po);
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
p.reset(std::move(sp));
|
||||
p.write(s.data(), s.size(), ec);
|
||||
if(BOOST_TEST(! ec))
|
||||
@@ -165,7 +165,7 @@ public:
|
||||
fail_resource mr;
|
||||
mr.fail_max = 0;
|
||||
stream_parser p(storage_ptr(), po);
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
p.reset(&mr);
|
||||
p.write(s.data(), i, ec);
|
||||
if(BOOST_TEST(! ec))
|
||||
|
||||
@@ -214,7 +214,7 @@ public:
|
||||
string::max_size() + 1, '*');
|
||||
auto const js =
|
||||
"\"" + big + "\":null";
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
auto jv = parse(js, ec);
|
||||
BOOST_TEST(ec == error::string_too_large);
|
||||
BOOST_TEST(ec.has_location());
|
||||
@@ -227,7 +227,7 @@ public:
|
||||
string::max_size() + 1, '*');
|
||||
auto const js =
|
||||
"{\"" + big + "\":null}";
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
auto jv = parse(js, ec);
|
||||
BOOST_TEST(ec == error::key_too_large);
|
||||
BOOST_TEST(ec.has_location());
|
||||
@@ -260,13 +260,13 @@ public:
|
||||
"\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n"
|
||||
"\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n"
|
||||
"\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\"";
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
auto jv = parse(s, ec);
|
||||
BOOST_TEST(! ec);
|
||||
}
|
||||
// overflow in on_key_part
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
std::string big;
|
||||
big = "\\b";
|
||||
big += std::string(
|
||||
@@ -280,7 +280,7 @@ public:
|
||||
|
||||
// overflow in on_key
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
std::string big;
|
||||
big = "\\b";
|
||||
big += std::string(
|
||||
@@ -294,7 +294,7 @@ public:
|
||||
|
||||
// overflow in on_string_part
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
std::string big;
|
||||
big = "\\b";
|
||||
big += std::string(
|
||||
@@ -308,7 +308,7 @@ public:
|
||||
|
||||
// overflow in on_string
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
std::string big;
|
||||
big = "\\b";
|
||||
big += std::string(
|
||||
@@ -323,7 +323,7 @@ public:
|
||||
|
||||
// object overflow
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
string_view s = R"({
|
||||
"00":0,"01":0,"02":0,"03":0,"04":0,"05":0,"06":0,"07":0,"08":0,"09":0,
|
||||
"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,
|
||||
@@ -337,7 +337,7 @@ public:
|
||||
|
||||
// array overflow
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
string_view s = "["
|
||||
"0,0,0,0,0,0,0,0,0,0,"
|
||||
"0,0,0,0,0,0,0,0,0,0,"
|
||||
@@ -361,7 +361,7 @@ public:
|
||||
precise.numbers = number_precision::precise;
|
||||
|
||||
stream_parser p( {}, precise );
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
p.write( buffer.data(), 1, ec );
|
||||
BOOST_TEST_THROWS_WITH_LOCATION(
|
||||
p.write( buffer.data() + 1, buffer.size() - 1, ec ));
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
// Official repository: https://github.com/boostorg/json
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include <boost/json/memory_resource.hpp>
|
||||
#include <boost/json/monotonic_resource.hpp>
|
||||
#include <boost/json/value.hpp>
|
||||
#include <boost/container/pmr/vector.hpp>
|
||||
@@ -25,8 +23,7 @@ public:
|
||||
void
|
||||
testBoostPmr()
|
||||
{
|
||||
using allocator_type =
|
||||
polymorphic_allocator<value>;
|
||||
using allocator_type = container::pmr::polymorphic_allocator<value>;
|
||||
|
||||
// pass polymorphic_allocator
|
||||
// where storage_ptr is expected
|
||||
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
void
|
||||
run()
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
value jv = parse(" 1 ", ec);
|
||||
BOOST_TEST( !ec.failed() );
|
||||
BOOST_TEST( jv == 1 );
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool hasLocation(error_code const& ec)
|
||||
bool hasLocation(system::error_code const& ec)
|
||||
{
|
||||
return ec.has_location();
|
||||
}
|
||||
@@ -71,14 +71,14 @@ public:
|
||||
void
|
||||
good(string_view s)
|
||||
{
|
||||
good_impl<error_code>(s);
|
||||
good_impl<system::error_code>(s);
|
||||
good_impl<std::error_code>(s);
|
||||
}
|
||||
|
||||
void
|
||||
bad(string_view s)
|
||||
{
|
||||
bad_impl<error_code>(s);
|
||||
bad_impl<system::error_code>(s);
|
||||
bad_impl<std::error_code>(s);
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
std::string json = serialize( value_from( t1 ) );
|
||||
|
||||
T t2{};
|
||||
error_code jec;
|
||||
system::error_code jec;
|
||||
parse_into(t2, json, jec);
|
||||
BOOST_TEST( !jec.failed() ) && BOOST_TEST( t1 == t2 );
|
||||
|
||||
@@ -131,7 +131,7 @@ public:
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wmissing-field-initializers"
|
||||
#endif
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
T t{};
|
||||
std::string json = serialize(sample);
|
||||
parser_for<T> p( parse_options{}, &t );
|
||||
@@ -196,7 +196,7 @@ public:
|
||||
double d1 = 12;
|
||||
std::string json = serialize( value_from( 12 ) );
|
||||
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
double d2;
|
||||
parse_into(d2, json, ec);
|
||||
BOOST_TEST( !ec.failed() );
|
||||
@@ -456,7 +456,7 @@ public:
|
||||
|
||||
{
|
||||
int n;
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
parse_into( n, "12 1", ec);
|
||||
BOOST_TEST( ec == error::extra_data );
|
||||
BOOST_TEST( ec.has_location() );
|
||||
@@ -465,7 +465,7 @@ public:
|
||||
{
|
||||
std::stringstream is("12 1");
|
||||
int n;
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
parse_into( n, is, ec);
|
||||
BOOST_TEST( ec == error::extra_data );
|
||||
BOOST_TEST( ec.has_location() );
|
||||
@@ -475,7 +475,7 @@ public:
|
||||
int n;
|
||||
std::stringstream is("1");
|
||||
is.setstate( std::ios::failbit );
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
parse_into(n, is, ec);
|
||||
BOOST_TEST( ec == error::input_error );
|
||||
BOOST_TEST( ec.has_location() );
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
}
|
||||
|
||||
bool
|
||||
hasLocation(error_code const& ec)
|
||||
hasLocation(system::error_code const& ec)
|
||||
{
|
||||
return ec.has_location();
|
||||
}
|
||||
@@ -370,7 +370,7 @@ public:
|
||||
run()
|
||||
{
|
||||
testCtors();
|
||||
testMembers<error_code>();
|
||||
testMembers<system::error_code>();
|
||||
testMembers<std::error_code>();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace json {
|
||||
class pointer_test
|
||||
{
|
||||
bool
|
||||
hasLocation(error_code const& ec)
|
||||
hasLocation(system::error_code const& ec)
|
||||
{
|
||||
return ec.has_location();
|
||||
}
|
||||
@@ -354,10 +354,10 @@ public:
|
||||
testEscaped();
|
||||
testNested();
|
||||
testErrors();
|
||||
testNonThrowing<error_code>();
|
||||
testNonThrowing<system::error_code>();
|
||||
testNonThrowing<std::error_code>();
|
||||
testSet();
|
||||
testSetNonThrowing<error_code>();
|
||||
testSetNonThrowing<system::error_code>();
|
||||
testSetNonThrowing<std::error_code>();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include <boost/json/system_error.hpp>
|
||||
#include <boost/json/result_for.hpp>
|
||||
// Test that header file is properly guarder
|
||||
#include <boost/json/system_error.hpp>
|
||||
#include <boost/json/result_for.hpp>
|
||||
|
||||
#include <boost/json/value_to.hpp>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
namespace boost {
|
||||
namespace json {
|
||||
|
||||
class system_error_test
|
||||
class result_for_test
|
||||
{
|
||||
public:
|
||||
void
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
TEST_SUITE(system_error_test, "boost.json.system_error");
|
||||
TEST_SUITE(result_for_test, "boost.json.result_for");
|
||||
|
||||
} // namespace json
|
||||
} // namespace boost
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
string_view name = {})
|
||||
{
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
auto const s1 = serialize(jv);
|
||||
auto const jv2 = parse(s1, ec);
|
||||
if(! BOOST_TEST(equal(jv, jv2)))
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
|
||||
// large buffer
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
serializer sr;
|
||||
sr.reset(&jv);
|
||||
string js;
|
||||
@@ -563,7 +563,7 @@ public:
|
||||
"[1,2,3,4,5]"
|
||||
})
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
auto const jv1 = parse(js, ec);
|
||||
if(! BOOST_TEST(! ec))
|
||||
return;
|
||||
|
||||
@@ -88,19 +88,23 @@ tag_invoke( const try_value_to_tag< ip_address >&, value const& jv )
|
||||
if( arr.size() != 4 )
|
||||
return make_error_code( std::errc::invalid_argument );
|
||||
|
||||
result< unsigned char > oct1 = try_value_to< unsigned char >( arr[0] );
|
||||
boost::system::result< unsigned char > oct1
|
||||
= try_value_to< unsigned char >( arr[0] );
|
||||
if( !oct1 )
|
||||
return make_error_code( std::errc::invalid_argument );
|
||||
|
||||
result< unsigned char > oct2 = try_value_to< unsigned char >( arr[1] );
|
||||
boost::system::result< unsigned char > oct2
|
||||
= try_value_to< unsigned char >( arr[1] );
|
||||
if( !oct2 )
|
||||
return make_error_code( std::errc::invalid_argument );
|
||||
|
||||
result< unsigned char > oct3 = try_value_to< unsigned char >( arr[2] );
|
||||
boost::system::result< unsigned char > oct3
|
||||
= try_value_to< unsigned char >( arr[2] );
|
||||
if( !oct3 )
|
||||
return make_error_code( std::errc::invalid_argument );
|
||||
|
||||
result< unsigned char > oct4 = try_value_to< unsigned char >( arr[3] );
|
||||
boost::system::result< unsigned char > oct4
|
||||
= try_value_to< unsigned char >( arr[3] );
|
||||
if( !oct4 )
|
||||
return make_error_code( std::errc::invalid_argument );
|
||||
|
||||
@@ -849,7 +853,8 @@ usingExchange()
|
||||
//[snippet_nothrow_2
|
||||
value jv = parse( R"([127,0,0,12])" );
|
||||
|
||||
result< ip_address > addr = try_value_to< ip_address >( jv );
|
||||
boost::system::result< ip_address > addr
|
||||
= try_value_to< ip_address >( jv );
|
||||
assert( addr.has_value() );
|
||||
|
||||
ip_address addr2{ 127, 0, 0, 12 };
|
||||
@@ -927,7 +932,7 @@ usingPointer()
|
||||
value* elem2 = [&]() -> value*
|
||||
{
|
||||
//[snippet_pointer_3
|
||||
error_code ec;
|
||||
boost::system::error_code ec;
|
||||
return jv.find_pointer("/one/foo/1", ec);
|
||||
//]
|
||||
}();
|
||||
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
static value jv2;
|
||||
|
||||
struct throwing
|
||||
: memory_resource
|
||||
: container::pmr::memory_resource
|
||||
{
|
||||
throwing()
|
||||
{
|
||||
@@ -154,7 +154,7 @@ public:
|
||||
|
||||
struct my_resource
|
||||
: other
|
||||
, memory_resource
|
||||
, container::pmr::memory_resource
|
||||
{
|
||||
void*
|
||||
do_allocate(
|
||||
|
||||
@@ -140,14 +140,14 @@ public:
|
||||
void
|
||||
testMembers()
|
||||
{
|
||||
// write_some(char const*, size_t, error_code&)
|
||||
// write_some(char const*, size_t, system::error_code&)
|
||||
// write_some(char const*, size_t, std::error_code&)
|
||||
// write_some(string_view, error_code&)
|
||||
// write_some(string_view, system::error_code&)
|
||||
// write_some(string_view, std::error_code&)
|
||||
{
|
||||
{
|
||||
stream_parser p;
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
BOOST_TEST(p.write_some(
|
||||
"[]*", ec) == 2);
|
||||
BOOST_TEST(! ec);
|
||||
@@ -161,7 +161,7 @@ public:
|
||||
}
|
||||
{
|
||||
stream_parser p;
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
BOOST_TEST(p.write_some(
|
||||
"[*", ec) == 1);
|
||||
BOOST_TEST(ec);
|
||||
@@ -189,14 +189,14 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
// write(char const*, size_t, error_code&)
|
||||
// write(char const*, size_t, system::error_code&)
|
||||
// write(char const*, size_t, std::error_code&)
|
||||
// write(string_view, error_code&)
|
||||
// write(string_view, system::error_code&)
|
||||
// write(string_view, std::error_code&)
|
||||
{
|
||||
{
|
||||
stream_parser p;
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
BOOST_TEST(p.write(
|
||||
"null", ec) == 4);
|
||||
BOOST_TEST(! ec);
|
||||
@@ -210,7 +210,7 @@ public:
|
||||
}
|
||||
{
|
||||
stream_parser p;
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
p.write("[]*", ec),
|
||||
BOOST_TEST(
|
||||
ec == error::extra_data);
|
||||
@@ -258,7 +258,7 @@ public:
|
||||
{
|
||||
stream_parser p;
|
||||
p.write("[1,2");
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
p.finish(ec);
|
||||
BOOST_TEST(
|
||||
ec == error::incomplete);
|
||||
@@ -267,7 +267,7 @@ public:
|
||||
{
|
||||
stream_parser p;
|
||||
p.write("[1,2");
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
p.finish(ec);
|
||||
BOOST_TEST_THROWS_WITH_LOCATION( p.finish() );
|
||||
}
|
||||
@@ -311,7 +311,7 @@ public:
|
||||
}
|
||||
{
|
||||
stream_parser p;
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
p.write("[]*", ec);
|
||||
BOOST_TEST(
|
||||
ec == error::extra_data);
|
||||
@@ -332,7 +332,7 @@ public:
|
||||
const parse_options& po = parse_options())
|
||||
{
|
||||
stream_parser p(storage_ptr(), po);
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
p.reset(std::move(sp));
|
||||
p.write(s.data(), s.size(), ec);
|
||||
if(BOOST_TEST(! ec))
|
||||
@@ -402,7 +402,7 @@ public:
|
||||
fail_resource mr;
|
||||
mr.fail_max = 0;
|
||||
stream_parser p(storage_ptr(), po);
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
p.reset(&mr);
|
||||
p.write(s.data(), i, ec);
|
||||
if(BOOST_TEST(! ec))
|
||||
@@ -562,7 +562,7 @@ public:
|
||||
std::string js;
|
||||
js = "\"" + big + "\"";
|
||||
auto const N = js.size() / 2;
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
stream_parser p;
|
||||
p.write(js.data(), N, ec);
|
||||
if(BOOST_TEST(! ec))
|
||||
@@ -594,7 +594,7 @@ public:
|
||||
operator()(string_view s) const
|
||||
{
|
||||
BOOST_TEST_CHECKPOINT();
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
stream_parser p;
|
||||
p.write(s.data(), s.size(), ec);
|
||||
if(BOOST_TEST(! ec))
|
||||
@@ -890,7 +890,7 @@ public:
|
||||
|
||||
// depth
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
parse_options opt;
|
||||
opt.max_depth = 0;
|
||||
stream_parser p(storage_ptr(), opt);
|
||||
@@ -957,7 +957,7 @@ public:
|
||||
|
||||
// depth
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
parse_options opt;
|
||||
opt.max_depth = 0;
|
||||
stream_parser p(storage_ptr(), opt);
|
||||
@@ -977,16 +977,16 @@ public:
|
||||
"{\"1\":{},\"2\":[],\"3\":\"x\",\"4\":1,"
|
||||
"\"5\":-1,\"6\":1.0,\"7\":false,\"8\":null}";
|
||||
|
||||
// parse(string_view, error_code)
|
||||
// parse(string_view, system::error_code)
|
||||
{
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
auto jv = parse(js, ec);
|
||||
BOOST_TEST(! ec);
|
||||
check_round_trip(jv);
|
||||
}
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
auto jv = parse("xxx", ec);
|
||||
BOOST_TEST(ec);
|
||||
BOOST_TEST(ec.has_location());
|
||||
@@ -994,10 +994,10 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
// parse(string_view, storage_ptr, error_code)
|
||||
// parse(string_view, storage_ptr, system::error_code)
|
||||
{
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
monotonic_resource mr;
|
||||
auto jv = parse(js, ec, &mr);
|
||||
BOOST_TEST(! ec);
|
||||
@@ -1005,7 +1005,7 @@ public:
|
||||
}
|
||||
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
monotonic_resource mr;
|
||||
auto jv = parse("xxx", ec, &mr);
|
||||
BOOST_TEST(ec);
|
||||
@@ -1079,7 +1079,7 @@ R"xx({
|
||||
storage_ptr sp =
|
||||
make_shared_resource<monotonic_resource>();
|
||||
stream_parser p(sp);
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
p.write(in.data(), in.size(), ec);
|
||||
if(BOOST_TEST(! ec))
|
||||
p.finish(ec);
|
||||
@@ -1310,7 +1310,7 @@ R"xx({
|
||||
while( static_cast<std::size_t>( INT_MAX - zeroes.size() ) > count )
|
||||
count += p.write( zeroes.data(), zeroes.size() );
|
||||
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
p.write(zeroes.data(), zeroes.size(), ec);
|
||||
BOOST_TEST( ec == error::exponent_overflow );
|
||||
}
|
||||
@@ -1323,7 +1323,7 @@ R"xx({
|
||||
while( static_cast<std::size_t>( INT_MAX - zeroes.size() ) > count )
|
||||
count += p.write( zeroes.data(), zeroes.size() );
|
||||
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
p.write(zeroes.data(), zeroes.size(), ec);
|
||||
BOOST_TEST( ec == error::exponent_overflow );
|
||||
}
|
||||
@@ -1344,7 +1344,7 @@ R"xx({
|
||||
std::string const int_min = std::to_string(INT_MIN);
|
||||
p.write( int_min.data(), int_min.size() );
|
||||
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
p.finish(ec);
|
||||
BOOST_TEST( ec == error::exponent_overflow );
|
||||
}
|
||||
@@ -1366,7 +1366,7 @@ R"xx({
|
||||
std::string const int_max = std::to_string(INT_MAX);
|
||||
p.write( int_max.data(), int_max.size() );
|
||||
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
p.finish(ec);
|
||||
BOOST_TEST( ec == error::exponent_overflow );
|
||||
}
|
||||
|
||||
198
test/test.hpp
198
test/test.hpp
@@ -40,7 +40,7 @@ struct test_failure : std::exception
|
||||
};
|
||||
|
||||
struct fail_resource
|
||||
: memory_resource
|
||||
: container::pmr::memory_resource
|
||||
{
|
||||
std::size_t fail_max = 0;
|
||||
std::size_t fail = 0;
|
||||
@@ -113,7 +113,7 @@ fail_loop(F&& f)
|
||||
//----------------------------------------------------------
|
||||
|
||||
struct unique_resource
|
||||
: memory_resource
|
||||
: container::pmr::memory_resource
|
||||
{
|
||||
unique_resource() = default;
|
||||
|
||||
@@ -155,24 +155,24 @@ class null_parser
|
||||
constexpr static std::size_t max_key_size = std::size_t(-1);
|
||||
constexpr static std::size_t max_string_size = std::size_t(-1);
|
||||
|
||||
bool on_document_begin( error_code& ) { return true; }
|
||||
bool on_document_end( error_code& ) { return true; }
|
||||
bool on_object_begin( error_code& ) { return true; }
|
||||
bool on_object_end( std::size_t, error_code& ) { return true; }
|
||||
bool on_array_begin( error_code& ) { return true; }
|
||||
bool on_array_end( std::size_t, error_code& ) { return true; }
|
||||
bool on_key_part( string_view, std::size_t, error_code& ) { return true; }
|
||||
bool on_key( string_view, std::size_t, error_code& ) { return true; }
|
||||
bool on_string_part( string_view, std::size_t, error_code& ) { return true; }
|
||||
bool on_string( string_view, std::size_t, error_code& ) { return true; }
|
||||
bool on_number_part( string_view, error_code&) { return true; }
|
||||
bool on_int64( std::int64_t, string_view, error_code& ) { return true; }
|
||||
bool on_uint64( std::uint64_t, string_view, error_code& ) { return true; }
|
||||
bool on_double( double, string_view, error_code& ) { return true; }
|
||||
bool on_bool( bool, error_code& ) { return true; }
|
||||
bool on_null( error_code& ) { return true; }
|
||||
bool on_comment_part( string_view, error_code& ) { return true; }
|
||||
bool on_comment( string_view, error_code& ) { return true; }
|
||||
bool on_document_begin( system::error_code& ) { return true; }
|
||||
bool on_document_end( system::error_code& ) { return true; }
|
||||
bool on_object_begin( system::error_code& ) { return true; }
|
||||
bool on_object_end( std::size_t, system::error_code& ) { return true; }
|
||||
bool on_array_begin( system::error_code& ) { return true; }
|
||||
bool on_array_end( std::size_t, system::error_code& ) { return true; }
|
||||
bool on_key_part( string_view, std::size_t, system::error_code& ) { return true; }
|
||||
bool on_key( string_view, std::size_t, system::error_code& ) { return true; }
|
||||
bool on_string_part( string_view, std::size_t, system::error_code& ) { return true; }
|
||||
bool on_string( string_view, std::size_t, system::error_code& ) { return true; }
|
||||
bool on_number_part( string_view, system::error_code&) { return true; }
|
||||
bool on_int64( std::int64_t, string_view, system::error_code& ) { return true; }
|
||||
bool on_uint64( std::uint64_t, string_view, system::error_code& ) { return true; }
|
||||
bool on_double( double, string_view, system::error_code& ) { return true; }
|
||||
bool on_bool( bool, system::error_code& ) { return true; }
|
||||
bool on_null( system::error_code& ) { return true; }
|
||||
bool on_comment_part( string_view, system::error_code& ) { return true; }
|
||||
bool on_comment( string_view, system::error_code& ) { return true; }
|
||||
};
|
||||
|
||||
basic_parser<handler> p_;
|
||||
@@ -199,7 +199,7 @@ public:
|
||||
write(
|
||||
char const* data,
|
||||
std::size_t size,
|
||||
error_code& ec)
|
||||
system::error_code& ec)
|
||||
{
|
||||
auto const n = p_.write_some(
|
||||
false, data, size, ec);
|
||||
@@ -228,7 +228,7 @@ class fail_parser
|
||||
}
|
||||
|
||||
bool
|
||||
maybe_fail(error_code& ec)
|
||||
maybe_fail(system::error_code& ec)
|
||||
{
|
||||
if(n && --n > 0)
|
||||
return true;
|
||||
@@ -238,21 +238,21 @@ class fail_parser
|
||||
|
||||
bool
|
||||
on_document_begin(
|
||||
error_code& ec)
|
||||
system::error_code& ec)
|
||||
{
|
||||
return maybe_fail(ec);
|
||||
}
|
||||
|
||||
bool
|
||||
on_document_end(
|
||||
error_code& ec)
|
||||
system::error_code& ec)
|
||||
{
|
||||
return maybe_fail(ec);
|
||||
}
|
||||
|
||||
bool
|
||||
on_object_begin(
|
||||
error_code& ec)
|
||||
system::error_code& ec)
|
||||
{
|
||||
return maybe_fail(ec);
|
||||
}
|
||||
@@ -260,14 +260,14 @@ class fail_parser
|
||||
bool
|
||||
on_object_end(
|
||||
std::size_t,
|
||||
error_code& ec)
|
||||
system::error_code& ec)
|
||||
{
|
||||
return maybe_fail(ec);
|
||||
}
|
||||
|
||||
bool
|
||||
on_array_begin(
|
||||
error_code& ec)
|
||||
system::error_code& ec)
|
||||
{
|
||||
return maybe_fail(ec);
|
||||
}
|
||||
@@ -275,7 +275,7 @@ class fail_parser
|
||||
bool
|
||||
on_array_end(
|
||||
std::size_t,
|
||||
error_code& ec)
|
||||
system::error_code& ec)
|
||||
{
|
||||
return maybe_fail(ec);
|
||||
}
|
||||
@@ -284,7 +284,7 @@ class fail_parser
|
||||
on_key_part(
|
||||
string_view,
|
||||
std::size_t,
|
||||
error_code& ec)
|
||||
system::error_code& ec)
|
||||
{
|
||||
return maybe_fail(ec);
|
||||
}
|
||||
@@ -293,7 +293,7 @@ class fail_parser
|
||||
on_key(
|
||||
string_view,
|
||||
std::size_t,
|
||||
error_code& ec)
|
||||
system::error_code& ec)
|
||||
{
|
||||
return maybe_fail(ec);
|
||||
}
|
||||
@@ -302,7 +302,7 @@ class fail_parser
|
||||
on_string_part(
|
||||
string_view,
|
||||
std::size_t,
|
||||
error_code& ec)
|
||||
system::error_code& ec)
|
||||
{
|
||||
return maybe_fail(ec);
|
||||
}
|
||||
@@ -311,7 +311,7 @@ class fail_parser
|
||||
on_string(
|
||||
string_view,
|
||||
std::size_t,
|
||||
error_code& ec)
|
||||
system::error_code& ec)
|
||||
{
|
||||
return maybe_fail(ec);
|
||||
}
|
||||
@@ -319,7 +319,7 @@ class fail_parser
|
||||
bool
|
||||
on_number_part(
|
||||
string_view,
|
||||
error_code& ec)
|
||||
system::error_code& ec)
|
||||
{
|
||||
return maybe_fail(ec);
|
||||
}
|
||||
@@ -328,7 +328,7 @@ class fail_parser
|
||||
on_int64(
|
||||
int64_t,
|
||||
string_view,
|
||||
error_code& ec)
|
||||
system::error_code& ec)
|
||||
{
|
||||
return maybe_fail(ec);
|
||||
}
|
||||
@@ -337,7 +337,7 @@ class fail_parser
|
||||
on_uint64(
|
||||
uint64_t,
|
||||
string_view,
|
||||
error_code& ec)
|
||||
system::error_code& ec)
|
||||
{
|
||||
return maybe_fail(ec);
|
||||
}
|
||||
@@ -346,7 +346,7 @@ class fail_parser
|
||||
on_double(
|
||||
double,
|
||||
string_view,
|
||||
error_code& ec)
|
||||
system::error_code& ec)
|
||||
{
|
||||
return maybe_fail(ec);
|
||||
}
|
||||
@@ -354,13 +354,13 @@ class fail_parser
|
||||
bool
|
||||
on_bool(
|
||||
bool,
|
||||
error_code& ec)
|
||||
system::error_code& ec)
|
||||
{
|
||||
return maybe_fail(ec);
|
||||
}
|
||||
|
||||
bool
|
||||
on_null(error_code& ec)
|
||||
on_null(system::error_code& ec)
|
||||
{
|
||||
return maybe_fail(ec);
|
||||
}
|
||||
@@ -368,7 +368,7 @@ class fail_parser
|
||||
bool
|
||||
on_comment_part(
|
||||
string_view,
|
||||
error_code& ec)
|
||||
system::error_code& ec)
|
||||
{
|
||||
return maybe_fail(ec);
|
||||
}
|
||||
@@ -376,53 +376,53 @@ class fail_parser
|
||||
bool
|
||||
on_comment(
|
||||
string_view,
|
||||
error_code& ec)
|
||||
system::error_code& ec)
|
||||
{
|
||||
return maybe_fail(ec);
|
||||
}
|
||||
};
|
||||
|
||||
basic_parser<handler> p_;
|
||||
|
||||
public:
|
||||
fail_parser()
|
||||
: p_(parse_options())
|
||||
{
|
||||
return maybe_fail(ec);
|
||||
}
|
||||
};
|
||||
|
||||
basic_parser<handler> p_;
|
||||
explicit
|
||||
fail_parser(
|
||||
std::size_t n,
|
||||
parse_options po = parse_options())
|
||||
: p_(po)
|
||||
{
|
||||
p_.handler().n = n;
|
||||
}
|
||||
|
||||
public:
|
||||
fail_parser()
|
||||
: p_(parse_options())
|
||||
{
|
||||
}
|
||||
explicit
|
||||
fail_parser(parse_options po)
|
||||
: p_(po)
|
||||
{
|
||||
}
|
||||
|
||||
explicit
|
||||
fail_parser(
|
||||
std::size_t n,
|
||||
parse_options po = parse_options())
|
||||
: p_(po)
|
||||
{
|
||||
p_.handler().n = n;
|
||||
}
|
||||
void
|
||||
reset()
|
||||
{
|
||||
p_.reset();
|
||||
}
|
||||
|
||||
explicit
|
||||
fail_parser(parse_options po)
|
||||
: p_(po)
|
||||
{
|
||||
}
|
||||
bool
|
||||
done() const noexcept
|
||||
{
|
||||
return p_.done();
|
||||
}
|
||||
|
||||
void
|
||||
reset()
|
||||
{
|
||||
p_.reset();
|
||||
}
|
||||
|
||||
bool
|
||||
done() const noexcept
|
||||
{
|
||||
return p_.done();
|
||||
}
|
||||
|
||||
std::size_t
|
||||
write_some(
|
||||
bool more,
|
||||
char const* data,
|
||||
std::size_t size,
|
||||
error_code& ec)
|
||||
std::size_t
|
||||
write_some(
|
||||
bool more,
|
||||
char const* data,
|
||||
std::size_t size,
|
||||
system::error_code& ec)
|
||||
{
|
||||
return p_.write_some(
|
||||
more, data, size, ec);
|
||||
@@ -433,7 +433,7 @@ public:
|
||||
bool more,
|
||||
char const* data,
|
||||
std::size_t size,
|
||||
error_code& ec)
|
||||
system::error_code& ec)
|
||||
{
|
||||
auto const n = p_.write_some(
|
||||
more, data, size, ec);
|
||||
@@ -482,21 +482,21 @@ class throw_parser
|
||||
|
||||
bool
|
||||
on_document_begin(
|
||||
error_code&)
|
||||
system::error_code&)
|
||||
{
|
||||
return maybe_throw();
|
||||
}
|
||||
|
||||
bool
|
||||
on_document_end(
|
||||
error_code&)
|
||||
system::error_code&)
|
||||
{
|
||||
return maybe_throw();
|
||||
}
|
||||
|
||||
bool
|
||||
on_object_begin(
|
||||
error_code&)
|
||||
system::error_code&)
|
||||
{
|
||||
return maybe_throw();
|
||||
}
|
||||
@@ -504,14 +504,14 @@ class throw_parser
|
||||
bool
|
||||
on_object_end(
|
||||
std::size_t,
|
||||
error_code&)
|
||||
system::error_code&)
|
||||
{
|
||||
return maybe_throw();
|
||||
}
|
||||
|
||||
bool
|
||||
on_array_begin(
|
||||
error_code&)
|
||||
system::error_code&)
|
||||
{
|
||||
return maybe_throw();
|
||||
}
|
||||
@@ -519,7 +519,7 @@ class throw_parser
|
||||
bool
|
||||
on_array_end(
|
||||
std::size_t,
|
||||
error_code&)
|
||||
system::error_code&)
|
||||
{
|
||||
return maybe_throw();
|
||||
}
|
||||
@@ -528,7 +528,7 @@ class throw_parser
|
||||
on_key_part(
|
||||
string_view,
|
||||
std::size_t,
|
||||
error_code&)
|
||||
system::error_code&)
|
||||
{
|
||||
return maybe_throw();
|
||||
}
|
||||
@@ -537,7 +537,7 @@ class throw_parser
|
||||
on_key(
|
||||
string_view,
|
||||
std::size_t,
|
||||
error_code&)
|
||||
system::error_code&)
|
||||
{
|
||||
return maybe_throw();
|
||||
}
|
||||
@@ -546,7 +546,7 @@ class throw_parser
|
||||
on_string_part(
|
||||
string_view,
|
||||
std::size_t,
|
||||
error_code&)
|
||||
system::error_code&)
|
||||
{
|
||||
return maybe_throw();
|
||||
}
|
||||
@@ -555,7 +555,7 @@ class throw_parser
|
||||
on_string(
|
||||
string_view,
|
||||
std::size_t,
|
||||
error_code&)
|
||||
system::error_code&)
|
||||
{
|
||||
return maybe_throw();
|
||||
}
|
||||
@@ -563,7 +563,7 @@ class throw_parser
|
||||
bool
|
||||
on_number_part(
|
||||
string_view,
|
||||
error_code&)
|
||||
system::error_code&)
|
||||
{
|
||||
return maybe_throw();
|
||||
}
|
||||
@@ -572,7 +572,7 @@ class throw_parser
|
||||
on_int64(
|
||||
int64_t,
|
||||
string_view,
|
||||
error_code&)
|
||||
system::error_code&)
|
||||
{
|
||||
return maybe_throw();
|
||||
}
|
||||
@@ -581,7 +581,7 @@ class throw_parser
|
||||
on_uint64(
|
||||
uint64_t,
|
||||
string_view,
|
||||
error_code&)
|
||||
system::error_code&)
|
||||
{
|
||||
return maybe_throw();
|
||||
}
|
||||
@@ -590,7 +590,7 @@ class throw_parser
|
||||
on_double(
|
||||
double,
|
||||
string_view,
|
||||
error_code&)
|
||||
system::error_code&)
|
||||
{
|
||||
return maybe_throw();
|
||||
}
|
||||
@@ -598,13 +598,13 @@ class throw_parser
|
||||
bool
|
||||
on_bool(
|
||||
bool,
|
||||
error_code&)
|
||||
system::error_code&)
|
||||
{
|
||||
return maybe_throw();
|
||||
}
|
||||
|
||||
bool
|
||||
on_null(error_code&)
|
||||
on_null(system::error_code&)
|
||||
{
|
||||
return maybe_throw();
|
||||
}
|
||||
@@ -612,7 +612,7 @@ class throw_parser
|
||||
bool
|
||||
on_comment_part(
|
||||
string_view,
|
||||
error_code&)
|
||||
system::error_code&)
|
||||
{
|
||||
return maybe_throw();
|
||||
}
|
||||
@@ -620,7 +620,7 @@ class throw_parser
|
||||
bool
|
||||
on_comment(
|
||||
string_view,
|
||||
error_code&)
|
||||
system::error_code&)
|
||||
{
|
||||
return maybe_throw();
|
||||
}
|
||||
@@ -660,7 +660,7 @@ public:
|
||||
bool more,
|
||||
char const* data,
|
||||
std::size_t size,
|
||||
error_code& ec)
|
||||
system::error_code& ec)
|
||||
{
|
||||
auto const n = p_.write_some(
|
||||
more, data, size, ec);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#define TEST_SUITE_HPP
|
||||
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/system/system_error.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
@@ -682,7 +683,7 @@ using log_type = detail::log_ostream<char>;
|
||||
"system_error", __FILE__, __LINE__, \
|
||||
TEST_SUITE_FUNCTION); \
|
||||
} \
|
||||
catch (::boost::json::system_error const& exc) \
|
||||
catch (::boost::system::system_error const& exc) \
|
||||
{ \
|
||||
::test_suite::detail::current()->maybe_fail( \
|
||||
exc.code().has_location(), "has_location()", __FILE__, __LINE__, \
|
||||
|
||||
@@ -1686,7 +1686,7 @@ public:
|
||||
}
|
||||
|
||||
{
|
||||
error_code ec;
|
||||
system::error_code ec;
|
||||
value(nullptr).to_number<double>(ec);
|
||||
BOOST_TEST(ec == error::not_number);
|
||||
BOOST_TEST(ec.has_location());
|
||||
|
||||
@@ -135,7 +135,7 @@ void
|
||||
tag_invoke(
|
||||
::boost::json::value_from_tag,
|
||||
::boost::json::value& jv,
|
||||
::boost::json::error_code& ec,
|
||||
::boost::system::error_code& ec,
|
||||
T8 const& t8)
|
||||
{
|
||||
if( t8.error )
|
||||
@@ -163,7 +163,7 @@ tag_invoke(
|
||||
if( t9.num == 0 )
|
||||
throw std::invalid_argument("");
|
||||
if( t9.num < 0 )
|
||||
throw ::boost::json::system_error(
|
||||
throw ::boost::system::system_error(
|
||||
make_error_code(::boost::json::error::syntax));
|
||||
|
||||
jv = "T9";
|
||||
|
||||
@@ -40,7 +40,7 @@ struct T1 { };
|
||||
//----------------------------------------------------------
|
||||
struct T2 { };
|
||||
|
||||
boost::json::result<T2>
|
||||
boost::system::result<T2>
|
||||
tag_invoke(
|
||||
boost::json::try_value_to_tag<T2>,
|
||||
boost::json::value const& jv)
|
||||
@@ -61,7 +61,7 @@ tag_invoke(
|
||||
{
|
||||
boost::json::string const* str = jv.if_string();
|
||||
if( !str )
|
||||
throw boost::json::system_error(
|
||||
throw boost::system::system_error(
|
||||
make_error_code(boost::json::error::not_string));
|
||||
if ( *str != "T3" )
|
||||
throw std::invalid_argument("");
|
||||
@@ -157,7 +157,7 @@ struct custom_context
|
||||
struct T9
|
||||
{ };
|
||||
|
||||
boost::json::result<T9>
|
||||
boost::system::result<T9>
|
||||
tag_invoke(
|
||||
boost::json::try_value_to_tag<T9>,
|
||||
boost::json::value const& jv,
|
||||
@@ -581,7 +581,7 @@ public:
|
||||
{
|
||||
BOOST_TEST_THROWS(
|
||||
value_to<::value_to_test_ns::T2>( value(), ctx... ),
|
||||
system_error);
|
||||
system::system_error);
|
||||
}
|
||||
// nonthrowing overload falls back to throwing customization
|
||||
{
|
||||
@@ -749,7 +749,7 @@ public:
|
||||
BOOST_TEST_THROWS(
|
||||
value_to<value_to_test_ns::T9>(
|
||||
value(), value_to_test_ns::custom_context() ),
|
||||
system_error);
|
||||
system::system_error);
|
||||
}
|
||||
|
||||
struct run_templated_tests
|
||||
|
||||
Reference in New Issue
Block a user