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 propety items |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32std.h> |
|
25 #include <s32mem.h> |
|
26 #include "cmsqlpropertyitem.h" |
|
27 #include "msdebug.h" |
|
28 |
|
29 // ======== LOCAL FUNCTIONS ======== |
|
30 // --------------------------------------------------------------------------- |
|
31 // NewL |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 EXPORT_C CCmSqlPropertyItem* CCmSqlPropertyItem::NewL() |
|
35 { |
|
36 CCmSqlPropertyItem* self = CCmSqlPropertyItem::NewLC(); |
|
37 CleanupStack::Pop( self ); |
|
38 return self; |
|
39 } |
|
40 |
|
41 // --------------------------------------------------------------------------- |
|
42 // NewLC |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 EXPORT_C CCmSqlPropertyItem* CCmSqlPropertyItem::NewLC() |
|
46 { |
|
47 CCmSqlPropertyItem* self = new ( ELeave ) CCmSqlPropertyItem(); |
|
48 CleanupStack::PushL( self ); |
|
49 self->ConstructL(); |
|
50 return self; |
|
51 } |
|
52 |
|
53 // --------------------------------------------------------------------------- |
|
54 // Destructor |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 EXPORT_C CCmSqlPropertyItem::~CCmSqlPropertyItem() |
|
58 { |
|
59 delete iName; |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // CCmSqlPropertyItem::SetId |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 EXPORT_C void CCmSqlPropertyItem::SetId( const TInt64 aId ) |
|
67 { |
|
68 iId = aId; |
|
69 } |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // CCmSqlPropertyItem::SetNameL |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 EXPORT_C void CCmSqlPropertyItem::SetNameL( const TDesC8& aName ) |
|
76 { |
|
77 delete iName; |
|
78 iName = NULL; |
|
79 if( &aName ) |
|
80 { |
|
81 iName = aName.AllocL(); |
|
82 } |
|
83 else |
|
84 { |
|
85 iName = KNullDesC8().AllocL(); |
|
86 } |
|
87 } |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // CCmSqlPropertyItem::SetStatus |
|
91 // --------------------------------------------------------------------------- |
|
92 // |
|
93 EXPORT_C void CCmSqlPropertyItem::SetStatus( const TBool aStatus ) |
|
94 { |
|
95 iStatus = aStatus; |
|
96 } |
|
97 |
|
98 // --------------------------------------------------------------------------- |
|
99 // CCmSqlPropertyItem::Id |
|
100 // --------------------------------------------------------------------------- |
|
101 // |
|
102 EXPORT_C TInt64 CCmSqlPropertyItem::Id() const |
|
103 { |
|
104 return iId; |
|
105 } |
|
106 |
|
107 // --------------------------------------------------------------------------- |
|
108 // CCmSqlPropertyItem::Name |
|
109 // --------------------------------------------------------------------------- |
|
110 // |
|
111 EXPORT_C TDesC8& CCmSqlPropertyItem::Name() const |
|
112 { |
|
113 return *iName; |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------------------------- |
|
117 // CCmSqlPropertyItem::Status |
|
118 // --------------------------------------------------------------------------- |
|
119 // |
|
120 EXPORT_C TBool CCmSqlPropertyItem::Status() const |
|
121 { |
|
122 return iStatus; |
|
123 } |
|
124 |
|
125 // --------------------------------------------------------------------------- |
|
126 // CompareItemsByName |
|
127 // --------------------------------------------------------------------------- |
|
128 // |
|
129 EXPORT_C TInt CCmSqlPropertyItem::CompareItemsByName( |
|
130 const CCmSqlPropertyItem& aFirst, const CCmSqlPropertyItem& aSecond ) |
|
131 { |
|
132 return aFirst.Name().Compare( aSecond.Name() ); |
|
133 } |
|
134 |
|
135 // --------------------------------------------------------------------------- |
|
136 // CCmSqlPropertyItem::ExternalizeL |
|
137 // --------------------------------------------------------------------------- |
|
138 // |
|
139 EXPORT_C void CCmSqlPropertyItem::ExternalizeL( RWriteStream& aStream ) const |
|
140 { |
|
141 aStream.WriteInt32L( iName->Length() ); |
|
142 if ( iName ) |
|
143 { |
|
144 aStream << *iName; |
|
145 } |
|
146 else |
|
147 { |
|
148 aStream << KNullDesC8(); |
|
149 } |
|
150 aStream.WriteUint32L( iId ); |
|
151 aStream.WriteInt32L( iStatus ); |
|
152 } |
|
153 |
|
154 // --------------------------------------------------------------------------- |
|
155 // CCmSqlPropertyItem::InternalizeL |
|
156 // --------------------------------------------------------------------------- |
|
157 // |
|
158 EXPORT_C void CCmSqlPropertyItem::InternalizeL( RReadStream& aStream ) |
|
159 { |
|
160 // Content |
|
161 if ( iName ) |
|
162 { |
|
163 delete iName; |
|
164 iName = NULL; |
|
165 } |
|
166 TInt bufLength = aStream.ReadInt32L(); |
|
167 iName = HBufC8::NewL( aStream, bufLength ); |
|
168 |
|
169 iId = aStream.ReadUint32L(); |
|
170 iStatus = (TBool)aStream.ReadInt32L(); |
|
171 } |
|
172 |
|
173 // --------------------------------------------------------------------------- |
|
174 // Default constructor |
|
175 // --------------------------------------------------------------------------- |
|
176 // |
|
177 CCmSqlPropertyItem::CCmSqlPropertyItem() |
|
178 { |
|
179 } |
|
180 |
|
181 // --------------------------------------------------------------------------- |
|
182 // Copy constructor |
|
183 // --------------------------------------------------------------------------- |
|
184 // |
|
185 EXPORT_C CCmSqlPropertyItem::CCmSqlPropertyItem( |
|
186 const CCmSqlPropertyItem& aItem ) : |
|
187 iId( aItem.iId ), iStatus( aItem.iStatus ) |
|
188 { |
|
189 iName = aItem.Name().Alloc(); |
|
190 } |
|
191 |
|
192 // --------------------------------------------------------------------------- |
|
193 // ConstructL |
|
194 // --------------------------------------------------------------------------- |
|
195 // |
|
196 void CCmSqlPropertyItem::ConstructL() |
|
197 { |
|
198 iName = KNullDesC8().AllocL(); |
|
199 } |
|
200 |
|
201 // End of file |
|
202 |
|