|
1 /* |
|
2 * Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: common item object for MdE* |
|
15 */ |
|
16 |
|
17 #include "mdcitem.h" |
|
18 |
|
19 /////////////////// |
|
20 // TMdCObject |
|
21 /////////////////// |
|
22 |
|
23 EXPORT_C TMdCObject::TMdCObject() : TMdCItem( EMdCObject ) |
|
24 { |
|
25 } |
|
26 |
|
27 EXPORT_C void TMdCObject::SerializeL(CMdCSerializationBuffer& aBuffer) |
|
28 { |
|
29 TMdCSerializationType::SerializeL( aBuffer, sizeof(*this) ); |
|
30 } |
|
31 |
|
32 EXPORT_C void TMdCObject::DeserializeL(CMdCSerializationBuffer& aBuffer) |
|
33 { |
|
34 TMdCSerializationType::DeserializeL( aBuffer, sizeof(*this) ); |
|
35 } |
|
36 |
|
37 EXPORT_C const TMdCObject& TMdCObject::GetFromBufferL( CMdCSerializationBuffer& aBuffer ) |
|
38 { |
|
39 const TInt bufferPosition = aBuffer.Position(); |
|
40 TMdCObject* object = (TMdCObject*)(aBuffer.Buffer().Ptr() + bufferPosition); |
|
41 if (object->iType != EMdCObject) |
|
42 { |
|
43 __ASSERT_DEBUG( EFalse, User::Panic( _L("No TMdCObject!"), KErrCorrupt ) ); |
|
44 |
|
45 User::Leave( KErrCorrupt ); |
|
46 } |
|
47 const TInt size = sizeof(TMdCObject) % 2 ? sizeof(TMdCObject)+1 : sizeof(TMdCObject); |
|
48 aBuffer.PositionL( bufferPosition + size ); |
|
49 return *object; |
|
50 } |
|
51 |
|
52 /////////////////// |
|
53 // TMdCRelation |
|
54 /////////////////// |
|
55 |
|
56 EXPORT_C TMdCRelation::TMdCRelation() : TMdCItem( EMdCRelation ) |
|
57 { |
|
58 } |
|
59 |
|
60 EXPORT_C void TMdCRelation::SerializeL(CMdCSerializationBuffer& aBuffer) |
|
61 { |
|
62 TMdCSerializationType::SerializeL( aBuffer, sizeof(*this) ); |
|
63 } |
|
64 |
|
65 EXPORT_C void TMdCRelation::DeserializeL(CMdCSerializationBuffer& aBuffer) |
|
66 { |
|
67 TMdCSerializationType::DeserializeL( aBuffer, sizeof(*this) ); |
|
68 } |
|
69 |
|
70 EXPORT_C const TMdCRelation& TMdCRelation::GetFromBufferL( CMdCSerializationBuffer& aBuffer ) |
|
71 { |
|
72 const TInt bufferPosition = aBuffer.Position(); |
|
73 TMdCRelation* relation = (TMdCRelation*)(aBuffer.Buffer().Ptr() + bufferPosition); |
|
74 if (relation->iType != EMdCRelation) |
|
75 { |
|
76 __ASSERT_DEBUG( EFalse, User::Panic( _L("No TMdCRelation!"), KErrCorrupt ) ); |
|
77 |
|
78 User::Leave( KErrCorrupt ); |
|
79 } |
|
80 const TInt size = sizeof(TMdCRelation) % 2 ? sizeof(TMdCRelation)+1 : sizeof(TMdCRelation); |
|
81 aBuffer.PositionL( bufferPosition + size ); |
|
82 return *relation; |
|
83 } |
|
84 |
|
85 |
|
86 /////////////////// |
|
87 // TMdCEvent |
|
88 /////////////////// |
|
89 |
|
90 EXPORT_C TMdCEvent::TMdCEvent() : TMdCItem( EMdCEvent ) |
|
91 { |
|
92 } |
|
93 |
|
94 EXPORT_C void TMdCEvent::SerializeL(CMdCSerializationBuffer& aBuffer) |
|
95 { |
|
96 TMdCSerializationType::SerializeL( aBuffer, sizeof(*this) ); |
|
97 } |
|
98 |
|
99 EXPORT_C void TMdCEvent::DeserializeL(CMdCSerializationBuffer& aBuffer) |
|
100 { |
|
101 TMdCSerializationType::DeserializeL( aBuffer, sizeof(*this) ); |
|
102 } |
|
103 |
|
104 EXPORT_C const TMdCEvent& TMdCEvent::GetFromBufferL( CMdCSerializationBuffer& aBuffer ) |
|
105 { |
|
106 const TInt bufferPosition = aBuffer.Position(); |
|
107 TMdCEvent* event = (TMdCEvent*)(aBuffer.Buffer().Ptr() + bufferPosition); |
|
108 if (event->iType != EMdCEvent) |
|
109 { |
|
110 __ASSERT_DEBUG( EFalse, User::Panic( _L("No TMdCEvent!"), KErrCorrupt ) ); |
|
111 |
|
112 User::Leave( KErrCorrupt ); |
|
113 } |
|
114 const TInt size = sizeof(TMdCEvent) % 2 ? sizeof(TMdCEvent)+1 : sizeof(TMdCEvent); |
|
115 aBuffer.PositionL( bufferPosition + size ); |
|
116 return *event; |
|
117 } |
|
118 |
|
119 |
|
120 /////////////////// |
|
121 // TMdCProperty |
|
122 /////////////////// |
|
123 |
|
124 EXPORT_C TMdCProperty::TMdCProperty() : TMdCSerializationType( EMdCProperty ) |
|
125 { |
|
126 } |
|
127 |
|
128 EXPORT_C void TMdCProperty::SerializeL(CMdCSerializationBuffer& aBuffer) |
|
129 { |
|
130 TMdCSerializationType::SerializeL( aBuffer, sizeof(*this) ); |
|
131 } |
|
132 |
|
133 EXPORT_C void TMdCProperty::DeserializeL(CMdCSerializationBuffer& aBuffer) |
|
134 { |
|
135 TMdCSerializationType::DeserializeL( aBuffer, sizeof(*this) ); |
|
136 } |
|
137 |
|
138 EXPORT_C const TMdCProperty& TMdCProperty::GetFromBufferL( CMdCSerializationBuffer& aBuffer ) |
|
139 { |
|
140 const TInt bufferPosition = aBuffer.Position(); |
|
141 TMdCProperty* property = (TMdCProperty*)(aBuffer.Buffer().Ptr() + bufferPosition); |
|
142 if (property->iType != EMdCProperty) |
|
143 { |
|
144 __ASSERT_DEBUG( EFalse, User::Panic( _L("No TMdCProperty!"), KErrCorrupt ) ); |
|
145 |
|
146 User::Leave( KErrCorrupt ); |
|
147 } |
|
148 const TInt size = sizeof(TMdCProperty) % 2 ? sizeof(TMdCProperty)+1 : sizeof(TMdCProperty); |
|
149 aBuffer.PositionL( bufferPosition + size ); |
|
150 return *property; |
|
151 } |