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< SequentialWriter > | getWriter (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. | |
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.
Definition at line 19 of file metawriters.h.
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. |
|
static |
Registers a container factory for the given container and value classes.
TContainer | The container class to register the writer for |
TClass | The 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:
TReturn reserve(int)
TReturn append(TClass)
Definition at line 283 of file metawriters.h.
|
static |
Registers a container factory for the given container and value classes.
metaTypeId | The type to register the writer for |
factory | A 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.