#include <cafJsonSerializer.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 |
|
Implementation of Serializer for JSON serialization.
◆ JsonSerializer()
JsonSerializer::JsonSerializer |
( |
ObjectFactory * |
objectFactory = nullptr | ) |
|
Constructor
- Parameters
-
objectFactory | The factory used when creating new objects. Not relevant when writing. |
◆ copyAndCastBySerialization()
std::shared_ptr< ObjectHandle > JsonSerializer::copyAndCastBySerialization |
( |
const ObjectHandle * |
object, |
|
|
const std::string & |
destinationClassKeyword |
|
) |
| const |
|
overridevirtual |
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
Implements caffa::Serializer.
◆ copyBySerialization()
Copy the object by serializing to text string and reading in again
- Parameters
-
- Returns
- unique ptr containing a new copy
Implements caffa::Serializer.
◆ createObjectFromString()
std::shared_ptr< ObjectHandle > JsonSerializer::createObjectFromString |
( |
const std::string & |
string | ) |
const |
|
overridevirtual |
Create a new object from a JSON text string
- Parameters
-
string | The JSON text string |
- Returns
- unique ptr to new object
Implements caffa::Serializer.
◆ readObjectFromString()
void JsonSerializer::readObjectFromString |
( |
ObjectHandle * |
object, |
|
|
const std::string & |
string |
|
) |
| const |
|
overridevirtual |
Convenience method to read this particular object (with children) from a json string
- Parameters
-
object | ObjectHandle to read in to. |
string | The JSON text string containing the object |
Implements caffa::Serializer.
◆ readStream()
void JsonSerializer::readStream |
( |
ObjectHandle * |
object, |
|
|
std::istream & |
stream |
|
) |
| const |
|
overridevirtual |
Read object from an input stream
- Parameters
-
object | Pointer to object to read into |
stream | The input stream |
Implements caffa::Serializer.
◆ readUUIDFromObjectString()
std::string JsonSerializer::readUUIDFromObjectString |
( |
const std::string & |
string | ) |
const |
|
overridevirtual |
Convenience method for reading the class keyword and uuid from a json string. This is used to extract the necessary information to find the object in the object hierarchy.
- Parameters
-
string | The JSON text string containing the object |
- Returns
- pair of keyword and uuid in that order.
Implements caffa::Serializer.
◆ writeObjectToString()
std::string JsonSerializer::writeObjectToString |
( |
const ObjectHandle * |
object | ) |
const |
|
overridevirtual |
Write an object to JSON text string
- Parameters
-
object | The object handle to write to string. |
- Returns
- A JSON text string
Implements caffa::Serializer.
◆ writeStream()
void JsonSerializer::writeStream |
( |
const ObjectHandle * |
object, |
|
|
std::ostream & |
stream |
|
) |
| const |
|
overridevirtual |
Write object to output stream
- Parameters
-
object | Pointer to object to write |
stream | The output stream |
Implements caffa::Serializer.
The documentation for this class was generated from the following files:
- /home/glindkvist/Projects/aru-server-app/frameworks/caffa/Core/cafJsonSerializer.h
- /home/glindkvist/Projects/aru-server-app/frameworks/caffa/Core/cafJsonSerializer.cpp