|
|
1.1 ! root 1: /* ! 2: Copyright (c) 2008 TrueCrypt Foundation. All rights reserved. ! 3: ! 4: Governed by the TrueCrypt License 2.4 the full text of which is contained ! 5: in the file License.txt included in TrueCrypt binary and source code ! 6: distribution packages. ! 7: */ ! 8: ! 9: #ifndef TC_HEADER_Platform_Serializer ! 10: #define TC_HEADER_Platform_Serializer ! 11: ! 12: #include "PlatformBase.h" ! 13: #include "Buffer.h" ! 14: #include "SharedPtr.h" ! 15: #include "Stream.h" ! 16: ! 17: namespace TrueCrypt ! 18: { ! 19: class Serializer ! 20: { ! 21: public: ! 22: Serializer (shared_ptr <Stream> stream) : DataStream (stream) { } ! 23: virtual ~Serializer () { } ! 24: ! 25: void Deserialize (const string &name, bool &data); ! 26: void Deserialize (const string &name, byte &data); ! 27: void Deserialize (const string &name, int32 &data); ! 28: void Deserialize (const string &name, int64 &data); ! 29: void Deserialize (const string &name, uint32 &data); ! 30: void Deserialize (const string &name, uint64 &data); ! 31: void Deserialize (const string &name, string &data); ! 32: void Deserialize (const string &name, wstring &data); ! 33: void Deserialize (const string &name, const BufferPtr &data); ! 34: bool DeserializeBool (const string &name); ! 35: int32 DeserializeInt32 (const string &name); ! 36: int64 DeserializeInt64 (const string &name); ! 37: uint32 DeserializeUInt32 (const string &name); ! 38: uint64 DeserializeUInt64 (const string &name); ! 39: string DeserializeString (const string &name); ! 40: list <string> DeserializeStringList (const string &name); ! 41: wstring DeserializeWString (const string &name); ! 42: list <wstring> DeserializeWStringList (const string &name); ! 43: void Serialize (const string &name, bool data); ! 44: void Serialize (const string &name, byte data); ! 45: void Serialize (const string &name, const char *data); ! 46: void Serialize (const string &name, int32 data); ! 47: void Serialize (const string &name, int64 data); ! 48: void Serialize (const string &name, uint32 data); ! 49: void Serialize (const string &name, uint64 data); ! 50: void Serialize (const string &name, const string &data); ! 51: void Serialize (const string &name, const wstring &data); ! 52: void Serialize (const string &name, const wchar_t *data); ! 53: void Serialize (const string &name, const list <string> &stringList); ! 54: void Serialize (const string &name, const list <wstring> &stringList); ! 55: void Serialize (const string &name, const ConstBufferPtr &data); ! 56: ! 57: protected: ! 58: template <typename T> T Deserialize (); ! 59: string DeserializeString (); ! 60: wstring DeserializeWString (); ! 61: template <typename T> void Serialize (T data); ! 62: void SerializeString (const string &data); ! 63: void SerializeWString (const wstring &data); ! 64: void ValidateName (const string &name); ! 65: ! 66: shared_ptr <Stream> DataStream; ! 67: ! 68: private: ! 69: Serializer (const Serializer &); ! 70: Serializer &operator= (const Serializer &); ! 71: }; ! 72: } ! 73: ! 74: #endif // TC_HEADER_Platform_Serializer
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.