\ 212 do{ \ 213 AddFieldSerializer(this,&CLASS::FIELD,L#FIELD); \ 214 }while(0) 215 } 216 } 217 218 #endif
糞?猟周?
1 #include "VL_Serialization.h"
2
3 namespace vl
4 {
5 namespace serialization
6 {
7
8 /*********************************************************************************************************
9 VL_SerializableObject
10 *********************************************************************************************************/
11
12 VL_SerializableObject::FieldSerializerBase::FieldSerializerBase(VUnicodeString FieldName)
13 {
14 FFieldName=FieldName;
15 }
16
17 VL_SerializableObject::VL_SerializableObject()
18 {
19 }
20
21 VL_SerializableObject::~VL_SerializableObject()
22 {
23 }
24
25 void VL_SerializableObject::Serialize(VL_Serializer* Serializer , VL_CommonObject& ClassObject)
26 {
27 for(VInt i=0;i<FFieldSerializers.GetCount();i++)
28 {
29 FFieldSerializers[i]->Serialize(Serializer,ClassObject);
30 }
31 }
32
33 VBool VL_SerializableObject::Deserialize(VL_Serializer* Serializer , const VL_CommonObject& ClassObject)
34 {
35 return false;
36 }
37
38 /*********************************************************************************************************
39 VL_Serializer
40 *********************************************************************************************************/
41
42 VL_Serializer::VL_Serializer()
43 {
44 }
45
46 VL_Serializer::~VL_Serializer()
47 {
48 }
49
50 void VL_Serializer::RegisterClass(ClassSerializerBase* aClassSerializer)
51 {
52 FClassSerializers.Add(aClassSerializer);
53 }
54
55 VL_Serializer::ClassSerializerBase* VL_Serializer::SelectClass(VL_SerializableObject* Object)
56 {
57 for(VInt i=0;i<FClassSerializers.GetCount();i++)
58 {
59 ClassSerializerBase* Class=FClassSerializers[i].Object();
60 if(Class->Accept(Object))
61 {
62 return Class;
63 }
64 }
65 return 0;
66 }
67
68 VL_CommonObject VL_Serializer::Serialize(VL_SerializableObject* Object)
69 {
70 if(Object)
71 {
72 ClassSerializerBase* Class=SelectClass(Object);
73 if(Class)
74 {
75 VL_CommonObject ClassObject=VL_CommonObject::CreateClass(Class->GetClassTypeName());
76 Object->Serialize(this,ClassObject);
77 return ClassObject;
78
|