2 Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
4 Governed by the TrueCrypt License 3.0 the full text of which is contained in
5 the file License.txt included in TrueCrypt binary and source code distribution
9 #ifndef TC_HEADER_Platform_Serializable
10 #define TC_HEADER_Platform_Serializable
13 #include "PlatformBase.h"
15 #include "Serializer.h"
16 #include "SerializerFactory.h"
23 virtual ~Serializable () { }
25 virtual void Deserialize (shared_ptr <Stream> stream) = 0;
26 static string DeserializeHeader (shared_ptr <Stream> stream);
27 static Serializable *DeserializeNew (shared_ptr <Stream> stream);
30 static shared_ptr <T> DeserializeNew (shared_ptr <Stream> stream)
32 shared_ptr <T> p (dynamic_cast <T *> (DeserializeNew (stream)));
34 throw std::runtime_error (SRC_POS);
39 static void DeserializeList (shared_ptr <Stream> stream, list < shared_ptr <T> > &dataList)
41 if (DeserializeHeader (stream) != string ("list<") + SerializerFactory::GetName (typeid (T)) + ">")
42 throw std::runtime_error (SRC_POS);
44 Serializer sr (stream);
46 sr.Deserialize ("ListSize", listSize);
48 for (size_t i = 0; i < listSize; i++)
50 shared_ptr <T> p (dynamic_cast <T *> (DeserializeNew (stream)));
52 throw std::runtime_error (SRC_POS);
53 dataList.push_back (p);
57 virtual void Serialize (shared_ptr <Stream> stream) const;
60 static void SerializeList (shared_ptr <Stream> stream, const list < shared_ptr <T> > &dataList)
62 Serializer sr (stream);
63 SerializeHeader (sr, string ("list<") + SerializerFactory::GetName (typeid (T)) + ">");
65 sr.Serialize ("ListSize", (uint64) dataList.size());
66 foreach_ref (const T &item, dataList)
67 item.Serialize (stream);
70 static void SerializeHeader (Serializer &serializer, const string &name);
77 #define TC_SERIALIZABLE(TYPE) \
78 static Serializable *GetNewSerializable () { return new TYPE(); } \
79 virtual void Deserialize (shared_ptr <Stream> stream); \
80 virtual void Serialize (shared_ptr <Stream> stream) const
82 #endif // TC_HEADER_Platform_Serializable
This page took
0.031383 seconds and
3 git commands to generate. Download a nemesis OSX (sierra+high sierra, tested/working) binary, with fuse-ext3 via e2fsprogs, at
this link. application and installer are signed by screwjack, llc. must install fuse with macFUSE layer first.