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";
}
Types
Name |
Description |
An array of values |
|
Abstract array interface. |
|
The default array implementation. |
|
Function implementation that wraps a fixed‐arity callable. |
|
The default Object implementation. |
|
Value‐semantic wrapper over a callable exposed to the DOM layer. |
|
Value‐semantic wrapper over a callable exposed to the DOM layer. |
|
Lazy array implementation |
|
Lazy array implementation |
|
Lazy object implementation. |
|
Lazy object implementation. |
|
Customization point tag. |
|
A container of key and value pairs. |
|
Abstract object interface. |
|
UTF‐8 string value used by the DOM. |
|
A variant container for any kind of Dom value. |
|
Customization point tag. |
|
Function implementation that forwards the entire Array to a callable. |
|
Helper traits to extract return and argument types from callables. |
|
Traits specialization for functors/lambdas. |
|
Traits specialization for function pointers. |
|
Traits specialization for free functions. |
|
|
Traits specialization for member functions. |
Functions
Name |
Description |
|
|
|
|
Return a new dom::Array based on a transformed lazy array implementation. |
|
|
|
Create a Function from a fixed‐arity invocable. |
|
Create a Function that receives the argument Array directly. |
|
Return a new array using a custom implementation. |
|
Return a diagnostic string. |
|
Return a new object using a custom implementation. |
|
Return the first dom::Value that is not truthy, or the last one. |
|
Addition operators |
|
Return the first dom::Value that is truthy, or the last one. |
|
Return a non‐empty string, or a null. |
|
|
|
|
|
Equality operators |
|
Return the result of comparing two strings. |
|
Three‐way comparison operators |
Concepts
Name |
Description |
Determine if |
|
Concept to determine if a type can be mapped to a |
|
Concept to determine if a type can be mapped to a |
|
Determine if ` T` can be converted to |
|
Determine if |
|
Concept to determine if a type can be converted to a |
|
Concept to determine if a type can be converted to a |
|
Satisfied if StringTy is convertible to String but not a String. |
|
|
Concept selecting callables convertible to dom::Value. |
|
Concept requiring all arguments be convertible to dom::Value. |
Concept true when function_traits is defined for F. |
|
|
Concept combining argument and return constraints for default wrapper. |
|
Concept true when F returns Expected<dom::Value> or Expected<void>. |
|
Concept true when F returns a dom::Value or void. |
|
Concept enabling default function wrapper for supported return types. |
Created with MrDocs