QtJsonSerializer  4.0.0
A library to perform generic seralization and deserialization of QObjects
Classes | Public Member Functions | Static Public Member Functions | List of all members
QtJsonSerializer::MetaWriters::SequentialWriter Class Referenceabstract

The writer class for sequential containers. More...

#include <metawriters.h>

Inherited by QtJsonSerializer::MetaWriters::Implementations::SequentialWriterImpl< TContainer, TClass >, QtJsonSerializer::MetaWriters::Implementations::SequentialWriterImpl< QLinkedList, TClass >, QtJsonSerializer::MetaWriters::Implementations::SequentialWriterImpl< QList, QVariant >, and QtJsonSerializer::MetaWriters::Implementations::SequentialWriterImpl< QSet, TClass >.

Classes

struct  SequenceInfo
 Information about a sequential container. More...
 

Public Member Functions

virtual SequenceInfo info () const =0
 Return the information for the wrapped container.
 
virtual void reserve (int size)=0
 Reserves space for size elements in the container.
 
virtual void add (const QVariant &value)=0
 Adds an element to the "end" of the container.
 

Static Public Member Functions

template<template< typename > class TContainer, typename TClass >
static void registerWriter ()
 Registers a container factory for the given container and value classes. More...
 
static void registerWriter (int metaTypeId, SequentialWriterFactory *factory)
 Registers a container factory for the given container and value classes. More...
 
static bool canWrite (int metaTypeId)
 Checks if a writer exists for the given type.
 
static QSharedPointer< SequentialWritergetWriter (QVariant &data)
 Returns a writer instance for the given data, or nullptr if none found.
 
static SequenceInfo getInfo (int metaTypeId)
 Returns the information details of the given type.
 

Detailed Description

The writer class for sequential containers.

The sequential writer is used to provide write access to such containers. They must first be registered via Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE and then via SequentialWriter::registerWriter. For most containers, you can simply use the generic variant of this method. If you have containers that are not supported by the generic variant, extend the writer instead and use the non-generic variant of the method.

See also
MetaWriters::SequentialWriterFactory, MetaWriters::AssociativeWriter

Definition at line 19 of file metawriters.h.


Class Documentation

◆ QtJsonSerializer::MetaWriters::SequentialWriter::SequenceInfo

struct QtJsonSerializer::MetaWriters::SequentialWriter::SequenceInfo

Information about a sequential container.

Definition at line 25 of file metawriters.h.

Class Members
bool isSet Specifies if the container is a finite set.

Member Function Documentation

◆ registerWriter() [1/2]

template<template< typename > class TContainer, typename TClass >
QtJsonSerializer::MetaWriters::SequentialWriter::registerWriter ( )
static

Registers a container factory for the given container and value classes.

Template Parameters
TContainerThe container class to register the writer for
TClassThe value held by the container to register the writer for

This methods assumes a type of the format TContainer<TClass> exists. Furthermore, the container must provide the following methods:

See also
SequentialWriter::getWriter

Definition at line 283 of file metawriters.h.

◆ registerWriter() [2/2]

QtJsonSerializer::MetaWriters::SequentialWriter::registerWriter ( int  metaTypeId,
SequentialWriterFactory factory 
)
static

Registers a container factory for the given container and value classes.

Parameters
metaTypeIdThe type to register the writer for
factoryA factory to create writer instances for the given type

Use this method if the generic one does not work for you. You have to implement the SequentialWriter and provide a SequentialWriterFactory that generates it.

See also
SequentialWriter::getWriter, SequentialWriterFactory

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