#include <cafSerializer.h>
|
enum class | SerializationType { DATA_FULL
, DATA_SKELETON
, SCHEMA
} |
|
using | FieldSelector = std::function< bool(const FieldHandle *)> |
|
|
static std::string | serializationTypeLabel (SerializationType type) |
|
|
ObjectFactory * | m_objectFactory |
|
FieldSelector | m_fieldSelector |
|
SerializationType | m_serializationType |
|
bool | m_serializeUuids |
|
Interface for Serializer. Can be implemented for different types of text serialization.
◆ Serializer()
Constructor
- Parameters
-
objectFactory | The factory used when creating new objects. Not relevant when writing. |
◆ copyAndCastBySerialization()
virtual std::shared_ptr<ObjectHandle> caffa::Serializer::copyAndCastBySerialization |
( |
const ObjectHandle * |
object, |
|
|
const std::string & |
destinationClassKeyword |
|
) |
| const |
|
pure virtual |
Copy the object by serializing to text string but cast to a different class keyword. Note, it is still returned as a base class pointer.
- Parameters
-
object | The object to copy |
destinationClassKeyword | The class of the object to create. |
- Returns
- unique ptr containing a new copy
Implemented in caffa::JsonSerializer.
◆ copyBySerialization()
Copy the object by serializing to text string and reading in again
- Parameters
-
- Returns
- unique ptr containing a new copy
Implemented in caffa::JsonSerializer.
◆ createObjectFromString()
virtual std::shared_ptr<ObjectHandle> caffa::Serializer::createObjectFromString |
( |
const std::string & |
string | ) |
const |
|
pure virtual |
Create a new object from a JSON text string
- Parameters
-
string | The JSON text string |
- Returns
- unique ptr to new object
Implemented in caffa::JsonSerializer.
◆ fieldSelector()
Serializer::FieldSelector Serializer::fieldSelector |
( |
| ) |
const |
Get the field selector
- Returns
- field selector
◆ objectFactory()
Get the object factory
- Returns
- object factory
◆ readObjectFromString()
virtual void caffa::Serializer::readObjectFromString |
( |
ObjectHandle * |
object, |
|
|
const std::string & |
string |
|
) |
| const |
|
pure virtual |
Convenience method to read this particular object (with children) from a json string
- Parameters
-
object | ObjectHandle to read in to. |
string | The text string containing the object |
Implemented in caffa::JsonSerializer.
◆ readStream()
virtual void caffa::Serializer::readStream |
( |
ObjectHandle * |
object, |
|
|
std::istream & |
stream |
|
) |
| const |
|
pure virtual |
Read object from an input stream
- Parameters
-
object | Pointer to object to read into |
stream | The input stream |
Implemented in caffa::JsonSerializer.
◆ readUUIDFromObjectString()
virtual std::string caffa::Serializer::readUUIDFromObjectString |
( |
const std::string & |
string | ) |
const |
|
pure virtual |
Convenience method for reading the class keyword and uuid from a string. This is used to extract the necessary information to find the object in the object hierarchy.
- Parameters
-
string | The text string containing the object |
- Returns
- pair of keyword and uuid in that order.
Implemented in caffa::JsonSerializer.
◆ serializationType()
Serializer::SerializationType Serializer::serializationType |
( |
| ) |
const |
Check which type of serialization we're doing
- Returns
- The type of serialization to do
◆ serializeUuids()
bool Serializer::serializeUuids |
( |
| ) |
const |
Check if we're meant to serialize UUIDs. UUIDs are used for dynamic connection to runtime objects, not for writing to file. Only makes a difference when serializing data.
- Returns
- true if we should write the UUIDs
◆ setFieldSelector()
Serializer & Serializer::setFieldSelector |
( |
FieldSelector |
fieldSelector | ) |
|
Set Field Selector Since it returns a reference it can be used like: Serializer(objectFactory).setFieldSelector(functor);
- Parameters
-
- Returns
- cafSerializer& reference to this
◆ setSerializationType()
Serializer & Serializer::setSerializationType |
( |
SerializationType |
type | ) |
|
Set what to serialize (data, schema, etc) Since it returns a reference it can be used like: Serializer(objectFactory).setSerializationTypes(...);
- Parameters
-
- Returns
- cafSerializer& reference to this
◆ setSerializeUuids()
Serializer & Serializer::setSerializeUuids |
( |
bool |
serializeUuids | ) |
|
Set whether to serialize UUIDs. Only makes a difference when serializing data Since it returns a reference, it can be used like: Serializer(objectFactory).setSerializeUuids(false);
- Parameters
-
- Returns
- cafSerializer& reference to this
◆ writeObjectToString()
virtual std::string caffa::Serializer::writeObjectToString |
( |
const ObjectHandle * |
object | ) |
const |
|
pure virtual |
Write an object to ext string
- Parameters
-
object | The object handle to write to string. |
- Returns
- A text string
Implemented in caffa::JsonSerializer.
◆ writeStream()
virtual void caffa::Serializer::writeStream |
( |
const ObjectHandle * |
object, |
|
|
std::ostream & |
stream |
|
) |
| const |
|
pure virtual |
Write object to output stream
- Parameters
-
object | Pointer to object to write |
stream | The output stream |
Implemented in caffa::JsonSerializer.
The documentation for this class was generated from the following files:
- /home/glindkvist/Projects/aru-server-app/frameworks/caffa/Core/cafSerializer.h
- /home/glindkvist/Projects/aru-server-app/frameworks/caffa/Core/cafSerializer.cpp