mrdocs::dom

Objects representing JSON‐like values.

Description

This class is a variant‐like container for holding any kind of value that can be represented in JSON, with extensions for functions and "safe strings".

The class supports the following types:

  • Undefined

  • Null

  • Boolean

  • Integer

  • String

  • SafeString

  • Array

  • Object

  • Function

The class provides type‐safe accessors for each type, as well as methods to check the type of the contained value.

Example:

{.cpp}
        dom::Value v1 = 42; // Integer
        dom::Value v2 = "Hello, World!"; // String
        dom::Value v3 = dom::Array{v1, v2}; // Array

        if (v1.isInteger())
        {
            std::cout << "v1 is an integer: " << v1.getInteger() << "\n";
        }

        if (v2.isString())
        {
            std::cout << "v2 is a string: " << v2.getString() << "\n";
        }

        if (v3.isArray())
        {
            std::cout << "v3 is an array with " << v3.getArray().size() << " elements.\n";
        }

Namespaces

Name

Description

JSON

JSON serialization helpers for DOM values.

Types

Name

Description

Array

An array of values

ArrayImpl

Abstract array interface.

DefaultArrayImpl

The default array implementation.

DefaultFunctionImpl

Function implementation that wraps a fixed‐arity callable.

DefaultObjectImpl

The default Object implementation.

Function

Value‐semantic wrapper over a callable exposed to the DOM layer.

FunctionImpl

Value‐semantic wrapper over a callable exposed to the DOM layer.

LazyArrayImpl

Lazy array implementation

LazyArrayImpl

Lazy array implementation

LazyObjectImpl

Lazy object implementation.

LazyObjectImpl

Lazy object implementation.

LazyObjectMapTag

Customization point tag.

Object

A container of key and value pairs.

ObjectImpl

Abstract object interface.

String

UTF‐8 string value used by the DOM.

Value

A variant container for any kind of Dom value.

ValueFromTag

Customization point tag.

VariadicFunctionImpl

Function implementation that forwards the entire Array to a callable.

function_traits

Helper traits to extract return and argument types from callables.

function_traits<F>

Traits specialization for functors/lambdas.

function_traits<R(*)(Args...)>

Traits specialization for function pointers.

function_traits<R(Args...)>

Traits specialization for free functions.

function_traits<R const volatile(C::*)(Args...)>

Traits specialization for member functions.

Enums

Name

Description

Kind

The type of data in a Value.

Functions

Name

Description

LazyArray

LazyArray overloads

LazyObject

LazyObject overloads

TransformArray

Return a new dom::Array based on a transformed lazy array implementation.

ValueFrom

ValueFrom overloads

makeInvocable

Create a Function from a fixed‐arity invocable.

makeVariadicInvocable

Create a Function that receives the argument Array directly.

newArray

Return a new array using a custom implementation.

newFunction

Return a diagnostic string.

newObject

Return a new object using a custom implementation.

operator&&

Return the first dom::Value that is not truthy, or the last one.

operator+

Addition operators

operator||

Return the first dom::Value that is truthy, or the last one.

stringOrNull

Return a non‐empty string, or a null.

swap

swap overloads

toString

toString overloads

operator==

Equality operators

operator!=

Return the result of comparing two strings.

operator<=>

Three‐way comparison operators

Concepts

Name

Description

HasLazyObjectMap

Determine if T can be converted to dom::Value.

HasLazyObjectMapWithContext

Concept to determine if a type can be mapped to a dom::LazyObjectImpl with a user‐provided conversion.

HasLazyObjectMapWithoutContext

Concept to determine if a type can be mapped to a dom::LazyObjectImpl with a user‐provided conversion.

HasStandaloneValueFrom

Determine if ` T` can be converted to dom::Value without a context.

HasValueFrom

Determine if T can be converted to dom::Value.

HasValueFromWithContext

Concept to determine if a type can be converted to a dom::Value with a user‐provided conversion.

HasValueFromWithoutContext

Concept to determine if a type can be converted to a dom::Value with a user‐provided conversion.

StringLikeTy

Satisfied if StringTy is convertible to String but not a String.

function_traits_convertible_to_value

Concept selecting callables convertible to dom::Value.

has_function_args_for_default_function_impl

Concept requiring all arguments be convertible to dom::Value.

has_function_traits

Concept true when function_traits is defined for F.

has_function_traits_for_default_function_impl

Concept combining argument and return constraints for default wrapper.

has_invoke_expected_result_convertible_to_dom_value

Concept true when F returns Expected<dom::Value> or Expected<void>.

has_invoke_result_convertible_to_dom_value

Concept true when F returns a dom::Value or void.

has_invoke_result_for_default_function_impl

Concept enabling default function wrapper for supported return types.

Created with MrDocs