Loading...
Searching...
No Matches
PathSerialization.hpp
1#pragma once
2#include <score/model/path/Path.hpp>
4#include <score/serialization/JSONVisitor.hpp>
5
6template <typename Object>
7QDataStream& operator<<(QDataStream& stream, const Path<Object>& obj)
8{
9 DataStreamReader reader(stream.device());
10 reader.readFrom(obj.unsafePath());
11 return stream;
12}
13
14template <typename Object>
15QDataStream& operator>>(QDataStream& stream, Path<Object>& obj)
16{
17 DataStreamWriter writer(stream.device());
18 writer.writeTo(obj.unsafePath());
19
20 return stream;
21}
22
23template <typename T>
25{
26 static void readFrom(DataStream::Serializer& s, const Path<T>& path)
27 {
28 s.readFrom(path.unsafePath());
29 }
30
31 static void writeTo(DataStream::Deserializer& s, Path<T>& path)
32 {
33 s.writeTo(path.unsafePath());
34 }
35};
36
37template <typename T>
39{
40 static void readFrom(JSONObject::Serializer& s, const Path<T>& path)
41 {
42 s.readFrom(path.unsafePath());
43 }
44
45 static void writeTo(JSONObject::Deserializer& s, Path<T>& path)
46 {
47 s.writeTo(path.unsafePath());
48 }
49};
Definition VisitorInterface.hpp:53
Definition DataStreamVisitor.hpp:27
void readFrom(const score::Entity< T > &obj)
Called by code that wants to serialize.
Definition DataStreamVisitor.hpp:53
Definition DataStreamVisitor.hpp:202
Definition VisitorInterface.hpp:61
Definition JSONVisitor.hpp:52
void readFrom(const score::Entity< T > &obj)
Definition EntitySerialization.hpp:7
Definition JSONVisitor.hpp:423
The Path class is a typesafe wrapper around ObjectPath.
Definition Path.hpp:52
Definition VisitorInterface.hpp:13