JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
Classes | Namespaces | Macros | Functions
juce_Serialisation.h File Reference

Go to the source code of this file.

Classes

struct  juce::SerialisationTraits< T >
 Allows serialisation functions to be attached to a specific type without having to modify the declaration of that type. More...
 
struct  juce::Named< T >
 Combines an object with a name. More...
 
struct  juce::SerialisationSize< T >
 Holds a reference to some kind of size value, used to indicate that an object being marshalled is of variable size (e.g. More...
 

Namespaces

namespace  juce
 JUCE Namespace.
 

Macros

#define JUCE_COMPARISON_OPS
 
#define X(op)
 
#define X(op)
 

Functions

template<typename T >
constexpr auto juce::named (std::string_view c, T &t)
 Produces a Named instance that holds a mutable reference.
 
template<typename T >
constexpr auto juce::named (std::string_view c, const T &t)
 Produces a Named instance that holds an immutable reference.
 
template<typename T >
constexpr auto juce::serialisationSize (T &t) -> std::enable_if_t< std::is_integral_v< T >, SerialisationSize< T > >
 Produces a SerialisationSize instance that holds a mutable reference to a size value.
 
template<typename T >
constexpr auto juce::serialisationSize (const T &t) -> std::enable_if_t< std::is_integral_v< T >, SerialisationSize< const T > >
 Produces a SerialisationSize instance that holds an immutable reference to a size value.
 

Class Documentation

◆ juce::SerialisationTraits

struct juce::SerialisationTraits
template<typename T>
struct juce::SerialisationTraits< T >

Allows serialisation functions to be attached to a specific type without having to modify the declaration of that type.

A specialisation of SerialisationTraits must include:

  • A static constexpr data member named 'marshallingVersion' with a value that is convertible to std::optional<int>.
  • Either:
    • Normally, a single function with the following signature:
      template <typename Archive, typename Item>
      static void serialise (Archive& archive, Item& item);
      Type unalignedPointerCast(void *ptr) noexcept
      Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
      Definition juce_Memory.h:88
    • For types that must do slightly different work when loading and saving, you may supply two functions with the following signatures, where "T" is a placeholder for the type on which SerialisationTraits is specialised:
      template <typename Archive>
      static void load (Archive& archive, T& item);
      template <typename Archive>
      static void save (Archive& archive, const T& item);

If the marshallingVersion converts to a null optional, then all versioning information will be ignored when marshalling the type. Otherwise, if the value converts to a non-null optional, this versioning information will be included when serialising the type.

Inside serialise() and load() you may call archive.getVersion() to find the detected version of the object being deserialised. archive.getVersion() will return an std::optional<int>, where 'nullopt' indicates that no versioning information was detected.

Marshalling functions can also be specified directly inside the type to be marshalled. This approach may be preferable as it is more concise. Internal marshalling functions are written in exactly the same way as external ones; i.e. the type must include a marshallingVersion, and either a single serialise function, or a load/save pair of functions, as specified above.

@tags{Core}

Definition at line 65 of file juce_Serialisation.h.

Macro Definition Documentation

◆ JUCE_COMPARISON_OPS

#define JUCE_COMPARISON_OPS

Definition at line 70 of file juce_Serialisation.h.

◆ X [1/2]

#define X (   op)

Definition at line 89 of file juce_Serialisation.h.

◆ X [2/2]

#define X (   op)

Definition at line 89 of file juce_Serialisation.h.