GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
grem::json::VariantBase< Allocator > Class Template Reference

JSON value type. More...

#include <GREM/core/formats/json.hpp>

Inheritance diagram for grem::json::VariantBase< Allocator >:

Public Types

using allocator_type = Allocator<VariantBase>
 Allocator type used by the value.
Public Types inherited from grem::Variant< Null, Boolean, StringBase< Allocator >, Number, ObjectBase< Allocator >, ArrayBase< Allocator > >
using index_type
 Index type used to encode the active alternative type.

Public Member Functions

 VariantBase () noexcept
 Construct a Null value.
 VariantBase (const allocator_type &allocator) noexcept
 Construct a Null value.
 VariantBase (Null, const allocator_type &allocator) noexcept
 Construct a Null value.
 VariantBase (Null) noexcept
 Construct a Null value.
 VariantBase (std::nullptr_t, const allocator_type &allocator) noexcept
 Construct a Null value.
 VariantBase (std::nullptr_t) noexcept
 Construct a Null value.
 VariantBase (Boolean value, const allocator_type &allocator) noexcept
 Construct a Boolean value with the given underlying value.
 VariantBase (Boolean value) noexcept
 Construct a Boolean value with the given underlying value.
 VariantBase (const StringBase< Allocator > &value, const allocator_type &allocator)
 Construct a String value with the given underlying value.
 VariantBase (const StringBase< Allocator > &value)
 Construct a String value with the given underlying value.
 VariantBase (StringBase< Allocator > &&value, const allocator_type &allocator) noexcept
 Construct a String value from the given underlying value.
 VariantBase (StringBase< Allocator > &&value) noexcept
 Construct a String value from the given underlying value.
 VariantBase (const char *value, const allocator_type &allocator)
 Construct a String value with the given underlying value.
 VariantBase (const char *value)
 Construct a String value with the given underlying value.
 VariantBase (StringView value, const allocator_type &allocator)
 Construct a String value with the given underlying value.
 VariantBase (StringView value)
 Construct a String value with the given underlying value.
 VariantBase (CStringView value, const allocator_type &allocator)
 Construct a String value with the given underlying value.
 VariantBase (CStringView value)
 Construct a String value with the given underlying value.
 VariantBase (const char8_t *value, const allocator_type &allocator)
 Construct a String value with the given underlying value.
 VariantBase (const char8_t *value)
 Construct a String value with the given underlying value.
 VariantBase (UTF8StringView value, const allocator_type &allocator)
 Construct a String value with the given underlying value.
 VariantBase (UTF8StringView value)
 Construct a String value with the given underlying value.
 VariantBase (UTF8CStringView value, const allocator_type &allocator)
 Construct a String value with the given underlying value.
 VariantBase (UTF8CStringView value)
 Construct a String value with the given underlying value.
 VariantBase (strict_arithmetic auto value, const allocator_type &allocator) noexcept
 Construct a Number value with the given underlying value.
 VariantBase (strict_arithmetic auto value) noexcept
 Construct a Number value with the given underlying value.
 VariantBase (const ObjectBase< Allocator > &value, const allocator_type &allocator)
 Construct an Object value with the given underlying value.
 VariantBase (const ObjectBase< Allocator > &value)
 Construct an Object value with the given underlying value.
 VariantBase (ObjectBase< Allocator > &&value, const allocator_type &allocator) noexcept
 Construct an Object value from the given underlying value.
 VariantBase (ObjectBase< Allocator > &&value) noexcept
 Construct an Object value from the given underlying value.
 VariantBase (const ArrayBase< Allocator > &value, const allocator_type &allocator)
 Construct an Array value with the given underlying value.
 VariantBase (const ArrayBase< Allocator > &value)
 Construct an Array value with the given underlying value.
 VariantBase (ArrayBase< Allocator > &&value, const allocator_type &allocator) noexcept
 Construct an Array value from the given underlying value.
 VariantBase (ArrayBase< Allocator > &&value) noexcept
 Construct an Array value from the given underlying value.
 ~VariantBase ()=default
 Destructor.
 VariantBase (const VariantBase &other, const allocator_type &allocator) noexcept
 Copy constructor.
 VariantBase (const VariantBase &other)
 Copy constructor.
 VariantBase (VariantBase &&other, const allocator_type &allocator) noexcept
 Move constructor.
 VariantBase (VariantBase &&other) noexcept
 Move constructor.
VariantBase & operator= (const VariantBase &other)
 Copy assignment.
VariantBase & operator= (VariantBase &&other) noexcept(std::allocator_traits< allocator_type >::propagate_on_container_move_assignment::value||//NOLINT(cppcoreguidelines-noexcept-move-operations, performance-noexcept-move-constructor) std::allocator_traits< allocator_type >::is_always_equal::value)
 Move assignment.
allocator_type get_allocator () const noexcept
 Get the allocator used by the value.
StringBase< Allocator > toString (const SerializationOptions &options={}, const allocator_type &stringAllocator=allocator_type()) const
 Get a JSON string representation of the value.
GREM_ALWAYS_INLINE bool operator== (const VariantBase &other) const
 Compare this value to another for equality.
GREM_ALWAYS_INLINE std::partial_ordering operator<=> (const VariantBase &other) const
 Compare this value to another.
Public Member Functions inherited from grem::Variant< Null, Boolean, StringBase< Allocator >, Number, ObjectBase< Allocator >, ArrayBase< Allocator > >
constexpr Variant () noexcept(std::is_nothrow_default_constructible_v< variant_alternative_t< 0, Variant > >)
 Default-construct a variant with the first variant alternative, if it is default-constructible.
constexpr Variant (U &&value) noexcept(std::is_nothrow_constructible_v< decltype(F(std::forward< U >(value))), U >)
 Converting constructor.
constexpr Variant (std::in_place_type_t< T > type, Args &&... args)
 Construct a variant alternative in-place given its type.
constexpr Variant (std::in_place_type_t< T > type, std::initializer_list< U > ilist, Args &&... args)
 Construct a variant alternative in-place given its type, with an initializer list as the first constructor argument.
constexpr Variant (std::in_place_index_t< Index > index, Args &&... args)
 Construct a variant alternative in-place given its index.
constexpr Variant (std::in_place_index_t< Index > index, std::initializer_list< U > ilist, Args &&... args)
 Construct a variant alternative in-place given its index, with an initializer list as the first constructor argument.
constexpr ~Variant ()
 Destructor.
constexpr ~Variant ()=default
 Trivial destructor.
constexpr Variant (const Variant &other)=delete
 Deleted copy constructor.
constexpr Variant (const Variant &other)=default
 Trivial copy constructor.
constexpr Variant (const Variant &other)
 Copy constructor.
constexpr Variant (Variant &&other) noexcept=default
 Trivial move constructor.
constexpr Variant (Variant &&other) noexcept((std::is_nothrow_move_constructible_v< Ts > &&...))
 Move constructor.
constexpr Variant & operator= (const Variant &other)=delete
 Deleted copy assignment.
constexpr Variant & operator= (const Variant &other)=default
 Trivial copy assignment.
constexpr Variant & operator= (const Variant &other)
 Copy assignment.
constexpr Variant & operator= (Variant &&other) noexcept=default
 Trivial move assignment.
constexpr Variant & operator= (Variant &&other) noexcept(((std::is_nothrow_move_constructible_v< Ts > &&//NOLINT(performance-noexcept-move-constructor, cppcoreguidelines-noexcept-move-operations) std::is_nothrow_move_assignable_v< Ts >) &&...))
 Move assignment.
constexpr Variant & operator= (U &&value) noexcept(std::is_nothrow_assignable_v< decltype(F(std::forward< U >(value)))&, U > &&std::is_nothrow_constructible_v< decltype(F(std::forward< U >(value))), U >)
 Converting assignment.
constexpr T & emplace (Args &&... args)
 Construct an alternative given its type, destroying the old value.
constexpr T & emplace (std::initializer_list< U > ilist, Args &&... args)
 Construct an alternative given its type, with an initializer list as the first constructor argument, destroying the old value.
constexpr auto & emplace (Args &&... args)
 Construct an alternative given its index, destroying the old value.
constexpr auto & emplace (std::initializer_list< U > ilist, Args &&... args)
 Construct an alternative given its index, with an initializer list as the first constructor argument, destroying the old value.
constexpr void swap (Variant &other) noexcept(((std::is_nothrow_move_constructible_v< Ts > &&std::is_nothrow_swappable_v< Ts >) &&...))
 Swap this variant's value with that of another.
constexpr index_type index () const noexcept
 Get the alternative index of the currently active value held by the variant.
constexpr bool valueless_by_exception () const noexcept
 Check if the variant is in the valueless by exception state.
constexpr bool is () const noexcept
 Check if the variant currently holds the alternative with the given type.
constexpr bool is () const noexcept
 Check if the variant currently holds the alternative with the given index.
constexpr T & as () &noexcept
 Access the underlying value with the given type without a safety check.
constexpr const T & as () const &noexcept
 Access the underlying value with the given type without a safety check.
constexpr T && as () &&noexcept
 Access the underlying value with the given type without a safety check.
constexpr const T && as () const &&noexcept
 Access the underlying value with the given type without a safety check.
constexpr auto & as () &noexcept
 Access the underlying value with the given index without a safety check.
constexpr const auto & as () const &noexcept
 Access the underlying value with the given index without a safety check.
constexpr auto && as () &&noexcept
 Access the underlying value with the given index without a safety check.
constexpr const auto && as () const &&noexcept
 Access the underlying value with the given index without a safety check.
constexpr T & get () &
 Access the underlying value with the given type.
constexpr const T & get () const &
 Access the underlying value with the given type.
constexpr T && get () &&
 Access the underlying value with the given type.
constexpr const T && get () const &&
 Access the underlying value with the given type.
constexpr auto & get () &
 Access the underlying value with the given index.
constexpr const auto & get () const &
 Access the underlying value with the given index.
constexpr auto && get () &&
 Access the underlying value with the given index.
constexpr const auto && get () const &&
 Access the underlying value with the given index.
constexpr T * get_if () noexcept
 Access the underlying value with the given type if it is the currently active alternative.
constexpr const T * get_if () const noexcept
 Access the underlying value with the given type if it is the currently active alternative.
constexpr auto * get_if () noexcept
 Access the underlying value with the given index if it is the currently active alternative.
constexpr const auto * get_if () const noexcept
 Access the underlying value with the given index if it is the currently active alternative.

Static Public Member Functions

static ValueBase< Allocator > parse (UTF8StringView jsonString, const SourceLocation &source={}, const allocator_type &allocator=allocator_type())
 Parse a value of any JSON type from a UTF-8 JSON string.
static ValueBase< Allocator > parse (StringView jsonString, const SourceLocation &source={}, const allocator_type &allocator=allocator_type())
 Parse a value of any JSON type from a JSON string interpreted as UTF-8.
Static Public Member Functions inherited from grem::Variant< Null, Boolean, StringBase< Allocator >, Number, ObjectBase< Allocator >, ArrayBase< Allocator > >
static constexpr decltype(auto) visit (Visitor &&visitor, V &&variant)
 Call a visitor functor with the currently active underlying value of a variant.
static constexpr decltype(auto) visitIndex (index_type index, Visitor &&visitor)
 Call a visitor functor with the type corresponding to a variant index.
static constexpr decltype(auto) apply (Function &&function)
 Call a functor with all alternative types.

Additional Inherited Members

Static Public Attributes inherited from grem::Variant< Null, Boolean, StringBase< Allocator >, Number, ObjectBase< Allocator >, ArrayBase< Allocator > >
static constexpr index_type npos
 Invalid alternative index, representing the valueless by exception state.

Detailed Description

template<template< typename > typename Allocator>
class grem::json::VariantBase< Allocator >

JSON value type.

Holds a value of one of the following types:

Template Parameters
Allocatorallocator type template to use.

Member Typedef Documentation

◆ allocator_type

template<template< typename > typename Allocator>
using grem::json::VariantBase< Allocator >::allocator_type = Allocator<VariantBase>

Allocator type used by the value.

Constructor & Destructor Documentation

◆ VariantBase() [1/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( )
inlinenoexcept

Construct a Null value.

◆ VariantBase() [2/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( const allocator_type & allocator)
inlineexplicitnoexcept

Construct a Null value.

Parameters
allocatorallocator to use.

◆ VariantBase() [3/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( Null ,
const allocator_type & allocator )
inlinenoexcept

Construct a Null value.

Parameters
allocatorallocator to use.

◆ VariantBase() [4/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( Null )
inlinenoexcept

Construct a Null value.

◆ VariantBase() [5/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( std::nullptr_t ,
const allocator_type & allocator )
inlinenoexcept

Construct a Null value.

Parameters
allocatorallocator to use.

◆ VariantBase() [6/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( std::nullptr_t )
inlinenoexcept

Construct a Null value.

◆ VariantBase() [7/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( Boolean value,
const allocator_type & allocator )
inlinenoexcept

Construct a Boolean value with the given underlying value.

Parameters
valuevalue to copy.
allocatorallocator to use.

◆ VariantBase() [8/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( Boolean value)
inlinenoexcept

Construct a Boolean value with the given underlying value.

Parameters
valuevalue to copy.

◆ VariantBase() [9/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( const StringBase< Allocator > & value,
const allocator_type & allocator )
inline

Construct a String value with the given underlying value.

Parameters
valuevalue to copy.
allocatorallocator to use.
Exceptions
std::bad_allocon allocation failure.

◆ VariantBase() [10/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( const StringBase< Allocator > & value)
inline

Construct a String value with the given underlying value.

Parameters
valuevalue to copy.
Exceptions
std::bad_allocon allocation failure.

◆ VariantBase() [11/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( StringBase< Allocator > && value,
const allocator_type & allocator )
inlinenoexcept

Construct a String value from the given underlying value.

Parameters
valuevalue to take.
allocatorallocator to use.

◆ VariantBase() [12/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( StringBase< Allocator > && value)
inlinenoexcept

Construct a String value from the given underlying value.

Parameters
valuevalue to take.

◆ VariantBase() [13/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( const char * value,
const allocator_type & allocator )
inline

Construct a String value with the given underlying value.

Parameters
valueread-only pointer to the null-terminated string to copy the contents of.
allocatorallocator to use.
Exceptions
std::length_errorif the maximum string length was exceeded.
std::bad_allocon allocation failure.

◆ VariantBase() [14/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( const char * value)
inline

Construct a String value with the given underlying value.

Parameters
valueread-only pointer to the null-terminated string to copy the contents of.
Exceptions
std::length_errorif the maximum string length was exceeded.
std::bad_allocon allocation failure.

◆ VariantBase() [15/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( StringView value,
const allocator_type & allocator )
inline

Construct a String value with the given underlying value.

Parameters
valueread-only view over the string to copy the contents of.
allocatorallocator to use.
Exceptions
std::length_errorif the maximum string length was exceeded.
std::bad_allocon allocation failure.

◆ VariantBase() [16/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( StringView value)
inline

Construct a String value with the given underlying value.

Parameters
valueread-only view over the string to copy the contents of.
Exceptions
std::length_errorif the maximum string length was exceeded.
std::bad_allocon allocation failure.

◆ VariantBase() [17/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( CStringView value,
const allocator_type & allocator )
inline

Construct a String value with the given underlying value.

Parameters
valueread-only view over the string to copy the contents of.
allocatorallocator to use.
Exceptions
std::length_errorif the maximum string length was exceeded.
std::bad_allocon allocation failure.

◆ VariantBase() [18/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( CStringView value)
inline

Construct a String value with the given underlying value.

Parameters
valueread-only view over the string to copy the contents of.
Exceptions
std::length_errorif the maximum string length was exceeded.
std::bad_allocon allocation failure.

◆ VariantBase() [19/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( const char8_t * value,
const allocator_type & allocator )
inline

Construct a String value with the given underlying value.

Parameters
valueread-only pointer to the null-terminated UTF-8 string to copy the contents of.
allocatorallocator to use.
Exceptions
std::length_errorif the maximum string length was exceeded.
std::bad_allocon allocation failure.

◆ VariantBase() [20/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( const char8_t * value)
inline

Construct a String value with the given underlying value.

Parameters
valueread-only pointer to the null-terminated UTF-8 string to copy the contents of.
Exceptions
std::length_errorif the maximum string length was exceeded.
std::bad_allocon allocation failure.

◆ VariantBase() [21/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( UTF8StringView value,
const allocator_type & allocator )
inline

Construct a String value with the given underlying value.

Parameters
valueread-only view over the UTF-8 string to copy the contents of.
allocatorallocator to use.
Exceptions
std::length_errorif the maximum string length was exceeded.
std::bad_allocon allocation failure.

◆ VariantBase() [22/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( UTF8StringView value)
inline

Construct a String value with the given underlying value.

Parameters
valueread-only view over the UTF-8 string to copy the contents of.
Exceptions
std::length_errorif the maximum string length was exceeded.
std::bad_allocon allocation failure.

◆ VariantBase() [23/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( UTF8CStringView value,
const allocator_type & allocator )
inline

Construct a String value with the given underlying value.

Parameters
valueread-only view over the UTF-8 string to copy the contents of.
allocatorallocator to use.
Exceptions
std::length_errorif the maximum string length was exceeded.
std::bad_allocon allocation failure.

◆ VariantBase() [24/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( UTF8CStringView value)
inline

Construct a String value with the given underlying value.

Parameters
valueread-only view over the UTF-8 string to copy the contents of.
Exceptions
std::length_errorif the maximum string length was exceeded.
std::bad_allocon allocation failure.

◆ VariantBase() [25/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( strict_arithmetic auto value,
const allocator_type & allocator )
inlinenoexcept

Construct a Number value with the given underlying value.

Parameters
valuevalue to copy. May be of any fundamental arithmetic type except for bool and character types.
allocatorallocator to use.

◆ VariantBase() [26/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( strict_arithmetic auto value)
inlinenoexcept

Construct a Number value with the given underlying value.

Parameters
valuevalue to copy. May be of any fundamental arithmetic type except for bool and character types.

◆ VariantBase() [27/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( const ObjectBase< Allocator > & value,
const allocator_type & allocator )
inline

Construct an Object value with the given underlying value.

Parameters
valuevalue to copy.
allocatorallocator to use.
Exceptions
std::bad_allocon allocation failure.

◆ VariantBase() [28/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( const ObjectBase< Allocator > & value)
inline

Construct an Object value with the given underlying value.

Parameters
valuevalue to copy.
Exceptions
std::bad_allocon allocation failure.

◆ VariantBase() [29/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( ObjectBase< Allocator > && value,
const allocator_type & allocator )
inlinenoexcept

Construct an Object value from the given underlying value.

Parameters
valuevalue to take.
allocatorallocator to use.

◆ VariantBase() [30/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( ObjectBase< Allocator > && value)
inlinenoexcept

Construct an Object value from the given underlying value.

Parameters
valuevalue to take.

◆ VariantBase() [31/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( const ArrayBase< Allocator > & value,
const allocator_type & allocator )
inline

Construct an Array value with the given underlying value.

Parameters
valuevalue to copy.
allocatorallocator to use.
Exceptions
std::bad_allocon allocation failure.

◆ VariantBase() [32/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( const ArrayBase< Allocator > & value)
inline

Construct an Array value with the given underlying value.

Parameters
valuevalue to copy.
Exceptions
std::bad_allocon allocation failure.

◆ VariantBase() [33/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( ArrayBase< Allocator > && value,
const allocator_type & allocator )
inlinenoexcept

Construct an Array value from the given underlying value.

Parameters
valuevalue to take.
allocatorallocator to use.

◆ VariantBase() [34/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( ArrayBase< Allocator > && value)
inlinenoexcept

Construct an Array value from the given underlying value.

Parameters
valuevalue to take.

◆ ~VariantBase()

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::~VariantBase ( )
default

Destructor.

◆ VariantBase() [35/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( const VariantBase< Allocator > & other,
const allocator_type & allocator )
inlinenoexcept

Copy constructor.

◆ VariantBase() [36/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( const VariantBase< Allocator > & other)
inline

Copy constructor.

◆ VariantBase() [37/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( VariantBase< Allocator > && other,
const allocator_type & allocator )
inlinenoexcept

Move constructor.

◆ VariantBase() [38/38]

template<template< typename > typename Allocator>
grem::json::VariantBase< Allocator >::VariantBase ( VariantBase< Allocator > && other)
inlinenoexcept

Move constructor.

Member Function Documentation

◆ parse() [1/2]

template<template< typename > typename Allocator>
ValueBase< Allocator > grem::json::VariantBase< Allocator >::parse ( UTF8StringView jsonString,
const SourceLocation & source = {},
const allocator_type & allocator = allocator_type() )
inlinestaticnodiscard

Parse a value of any JSON type from a UTF-8 JSON string.

The parser supports JSON5 features such as comments, unquoted identifiers and trailing commas.

Parameters
jsonStringread-only view over the JSON string to parse a value from.
sourcesource location corresponding to the start of the given JSON string.
allocatorallocator to use.
Returns
the parsed value.
Exceptions
json::Erroron failure to parse a JSON value.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ parse() [2/2]

template<template< typename > typename Allocator>
ValueBase< Allocator > grem::json::VariantBase< Allocator >::parse ( StringView jsonString,
const SourceLocation & source = {},
const allocator_type & allocator = allocator_type() )
inlinestaticnodiscard

Parse a value of any JSON type from a JSON string interpreted as UTF-8.

The parser supports JSON5 features such as comments, unquoted identifiers and trailing commas.

Parameters
jsonStringread-only view over the JSON string to parse a value from.
sourcesource location corresponding to the start of the given JSON string.
allocatorallocator to use.
Returns
the parsed value.
Exceptions
json::Erroron failure to parse a JSON value.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ operator=() [1/2]

template<template< typename > typename Allocator>
VariantBase & grem::json::VariantBase< Allocator >::operator= ( const VariantBase< Allocator > & other)
inline

Copy assignment.

◆ operator=() [2/2]

template<template< typename > typename Allocator>
VariantBase & grem::json::VariantBase< Allocator >::operator= ( VariantBase< Allocator > && other)
inlinenoexcept

Move assignment.

◆ get_allocator()

template<template< typename > typename Allocator>
allocator_type grem::json::VariantBase< Allocator >::get_allocator ( ) const
inlinenodiscardnoexcept

Get the allocator used by the value.

Returns
a copy of the value's allocator.

◆ toString()

template<template< typename > typename Allocator>
StringBase< Allocator > grem::json::VariantBase< Allocator >::toString ( const SerializationOptions & options = {},
const allocator_type & stringAllocator = allocator_type() ) const
inlinenodiscard

Get a JSON string representation of the value.

Parameters
optionsoptions for JSON serialization, see SerializationOptions.
stringAllocatorallocator to use.
Returns
a JSON string containing a representation of the value as it would be if it had been serialized to an output stream with the given options.
Exceptions
json::Erroron failure to serialize the value.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ operator==()

template<template< typename > typename Allocator>
GREM_ALWAYS_INLINE bool grem::json::VariantBase< Allocator >::operator== ( const VariantBase< Allocator > & other) const
inlinenodiscard

Compare this value to another for equality.

Parameters
otherthe value to compare this value to.
Returns
true if the values are equal, false otherwise.

◆ operator<=>()

template<template< typename > typename Allocator>
GREM_ALWAYS_INLINE std::partial_ordering grem::json::VariantBase< Allocator >::operator<=> ( const VariantBase< Allocator > & other) const
inlinenodiscard

Compare this value to another.

Parameters
otherthe value to compare this value to.
Returns
a partial ordering between the two values.

The documentation for this class was generated from the following file: