|
1 /* |
|
2 * Copyright (c) 2006-2007 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: Capsulating Rule parameters |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32std.h> |
|
25 #include <s32mem.h> |
|
26 |
|
27 #include "cmparam.h" |
|
28 #include "msdebug.h" |
|
29 |
|
30 |
|
31 // ======== LOCAL FUNCTIONS ======== |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // NewL |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 CCmParam* CCmParam::NewL() |
|
38 { |
|
39 CCmParam* self = CCmParam::NewLC(); |
|
40 CleanupStack::Pop( self ); |
|
41 return self; |
|
42 } |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // NewLC |
|
46 // --------------------------------------------------------------------------- |
|
47 // |
|
48 CCmParam* CCmParam::NewLC() |
|
49 { |
|
50 CCmParam* self = new ( ELeave ) CCmParam(); |
|
51 CleanupStack::PushL( self ); |
|
52 self->ConstructL(); |
|
53 return self; |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // Destructor |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 CCmParam::~CCmParam() |
|
61 { |
|
62 delete iDataField; |
|
63 } |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // Retrieve param info |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 void CCmParam::Param( TPtrC8* aParam ) |
|
70 { |
|
71 aParam->Set( *iDataField ); |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------------------------- |
|
75 // Retrieve param info |
|
76 // --------------------------------------------------------------------------- |
|
77 // |
|
78 void CCmParam::Param( TInt& aParam ) |
|
79 { |
|
80 aParam = iDataFieldIndexed; |
|
81 } |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // Sets datafield value |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 void CCmParam::SetComparisonDataL( const TDesC8& aComparisonData ) |
|
88 { |
|
89 delete iDataField; |
|
90 iDataField = NULL; |
|
91 iDataField = aComparisonData.AllocL(); |
|
92 } |
|
93 |
|
94 // --------------------------------------------------------------------------- |
|
95 // Sets datafield value ( indexed ) |
|
96 // --------------------------------------------------------------------------- |
|
97 // |
|
98 void CCmParam::SetComparisonData( TInt aComparisonData ) |
|
99 { |
|
100 iDataFieldIndexed = aComparisonData; |
|
101 } |
|
102 |
|
103 // --------------------------------------------------------------------------- |
|
104 // Returns datafield |
|
105 // --------------------------------------------------------------------------- |
|
106 // |
|
107 const TDesC8& CCmParam::ComparisonData() const |
|
108 { |
|
109 return *iDataField; |
|
110 } |
|
111 |
|
112 // --------------------------------------------------------------------------- |
|
113 // CCmParam::ExternalizeL |
|
114 // C++ default constructor can NOT contain any code, that |
|
115 // might leave. |
|
116 // --------------------------------------------------------------------------- |
|
117 // |
|
118 void CCmParam::ExternalizeL( RWriteStream& aStream ) const |
|
119 { |
|
120 aStream.WriteInt32L( iDataField->Length() ); |
|
121 |
|
122 if ( iDataField ) |
|
123 { |
|
124 aStream << *iDataField; |
|
125 } |
|
126 else |
|
127 { |
|
128 aStream << KNullDesC8(); |
|
129 } |
|
130 |
|
131 aStream.WriteInt32L( iDataFieldIndexed ); |
|
132 } |
|
133 |
|
134 // --------------------------------------------------------------------------- |
|
135 // CCmParam::InternalizeL |
|
136 // C++ default constructor can NOT contain any code, that |
|
137 // might leave. |
|
138 // --------------------------------------------------------------------------- |
|
139 // |
|
140 void CCmParam::InternalizeL( RReadStream& aStream ) |
|
141 { |
|
142 // Content |
|
143 delete iDataField; |
|
144 iDataField = NULL; |
|
145 |
|
146 TInt bufLength = aStream.ReadInt32L(); |
|
147 iDataField = HBufC8::NewL( aStream, bufLength ); |
|
148 iDataFieldIndexed = aStream.ReadInt32L(); |
|
149 } |
|
150 |
|
151 // --------------------------------------------------------------------------- |
|
152 // Default constructor |
|
153 // --------------------------------------------------------------------------- |
|
154 // |
|
155 CCmParam::CCmParam() |
|
156 { |
|
157 } |
|
158 |
|
159 // --------------------------------------------------------------------------- |
|
160 // ConstructL |
|
161 // --------------------------------------------------------------------------- |
|
162 // |
|
163 void CCmParam::ConstructL() |
|
164 { |
|
165 iDataField = KNullDesC8().AllocL(); |
|
166 } |
|
167 |
|
168 // End of file |
|
169 |