JUCE: ToVar Class Reference

JUCE

- Main Page
- Related Pages
- Topics
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Loading...
Searching...
No Matches
Public Types | Static Public Member Functions | List of all members
ToVar Class Reference
juce_core » javascript

Allows converting an object of arbitrary type to var. More...

`#include <juce_JSONSerialisation.h>`

## Public Types
using | Options = ToVarOptions

## Static Public Member Functions
template<typename T >
static std::optional< var > | convert (const T &t, const Options &options={})
| Attempts to convert the argument to a var using the serialisation utilities specified for that type.

## Detailed Description

Allows converting an object of arbitrary type to var.

To use this, you must first ensure that the type passed to convert is set up for serialisation. For details of what this entails, see the docs for SerialisationTraits.

In short, the constant 'marshallingVersion', and either the single function 'serialise()', or the function pair 'load()' and 'save()' must be defined for the type. These may be defined as public members of the type T itself, or as public members of juce::SerialisationTraits<T>, which is a specialisation of the SerialisationTraits template struct for the type T.

See also
  FromVar

## Member Typedef Documentation

## ◆ Options

using ToVar::Options = ToVarOptions

## Member Function Documentation

## ◆ convert()

template<typename T >

static std::optional< var > ToVar::convert | ( | const T & | t,
|  | const Options & | options = `{}`
| ) |  |
| static

Attempts to convert the argument to a var using the serialisation utilities specified for that type.

This will return a non-null optional if conversion succeeds, or nullopt if conversion fails.

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

- juce_JSONSerialisation.h