26
|
1 |
/*
|
|
2 |
* Copyright (c) 2006 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: Impelements Variants for widgetmodel data.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
//INCLUDES
|
|
21 |
|
|
22 |
|
|
23 |
#include <alf/ialfmodelbase.h>
|
|
24 |
#include <osn/ustring.h>
|
|
25 |
#include <osn/alfptrvector.h>
|
|
26 |
#include <alf/alfvarianttype.h>
|
|
27 |
#include <osn/osncommon.h>
|
|
28 |
#include <osn/ustring.h>
|
|
29 |
#include <alf/alfexceptions.h>
|
|
30 |
//#include "alf/alfperf.h"
|
|
31 |
#include <osn/osnnew.h>
|
|
32 |
#include "alfsort.h"
|
|
33 |
|
|
34 |
using osncore::UString;
|
|
35 |
using osncore::AlfPtrVector;
|
|
36 |
|
|
37 |
using std::auto_ptr;
|
|
38 |
|
|
39 |
|
|
40 |
// Forward declared inside the Alf namespace
|
|
41 |
namespace Alf
|
|
42 |
{
|
|
43 |
|
|
44 |
union UData
|
|
45 |
{
|
|
46 |
bool mBool; // Boolean
|
|
47 |
int mInt; // 32-bit integer
|
|
48 |
uint mUint; // 32-bit unsigned integer
|
|
49 |
double mReal; // 64-bit real
|
|
50 |
UString* mString;
|
|
51 |
Alf::IAlfModelBase* mBasePtr;
|
|
52 |
};
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
//Internal class used to store the VariantData type
|
|
57 |
//These classes are not exposed.
|
|
58 |
class AlfVariantDataImpl
|
|
59 |
{
|
|
60 |
public:
|
|
61 |
//Default Constructor
|
|
62 |
AlfVariantDataImpl()
|
|
63 |
{
|
|
64 |
mData.mString = NULL;
|
|
65 |
}
|
|
66 |
//Destructor
|
|
67 |
~AlfVariantDataImpl()
|
|
68 |
{
|
|
69 |
if(mType == IAlfVariantType::EString)
|
|
70 |
{
|
|
71 |
if(mData.mString)
|
|
72 |
{
|
|
73 |
delete mData.mString;
|
|
74 |
mData.mString = NULL;
|
|
75 |
}
|
|
76 |
}
|
|
77 |
if(mType == IAlfVariantType::ECustomData)
|
|
78 |
{
|
|
79 |
if(mData.mBasePtr)
|
|
80 |
{
|
|
81 |
delete mData.mBasePtr;
|
|
82 |
mData.mBasePtr = NULL;
|
|
83 |
}
|
|
84 |
}
|
|
85 |
|
|
86 |
}
|
|
87 |
//Union that actually stores the variant Data
|
|
88 |
uint8 mType;
|
|
89 |
UData mData;
|
|
90 |
};
|
|
91 |
|
|
92 |
|
|
93 |
//Internal class used to store the Conatiner Data type
|
|
94 |
//These classes are not exposed.
|
|
95 |
class AlfContainerDataImpl
|
|
96 |
{
|
|
97 |
public:
|
|
98 |
//Default Constructor
|
|
99 |
AlfContainerDataImpl()
|
|
100 |
{
|
|
101 |
mArray.setAutoDelete();
|
|
102 |
}
|
|
103 |
//Destructor
|
|
104 |
~AlfContainerDataImpl()
|
|
105 |
{
|
|
106 |
mArray.clear();
|
|
107 |
}
|
|
108 |
AlfPtrVector<IAlfVariantType> mArray;
|
|
109 |
|
|
110 |
};
|
|
111 |
|
|
112 |
|
|
113 |
|
|
114 |
//Internal class used to store the Conatiner Data type
|
|
115 |
//These classes are not exposed.
|
|
116 |
class MapItem
|
|
117 |
{
|
|
118 |
public:
|
|
119 |
//Default Constructor
|
|
120 |
MapItem():mData(0),mName(0)
|
|
121 |
{
|
|
122 |
|
|
123 |
}
|
|
124 |
//Destructor
|
|
125 |
~MapItem()
|
|
126 |
{
|
|
127 |
if(mData)
|
|
128 |
{
|
|
129 |
delete mData;
|
|
130 |
mData = NULL;
|
|
131 |
}
|
|
132 |
if(mName)
|
|
133 |
{
|
|
134 |
delete mName;
|
|
135 |
mName = NULL;
|
|
136 |
}
|
|
137 |
}
|
|
138 |
IAlfVariantType* mData;
|
|
139 |
UString* mName;
|
|
140 |
};
|
|
141 |
|
|
142 |
//Internal class used to store the Branch Data type
|
|
143 |
//These classes are not exposed.
|
|
144 |
class AlfMapDataImpl
|
|
145 |
{
|
|
146 |
public:
|
|
147 |
AlfMapDataImpl()
|
|
148 |
{
|
|
149 |
|
|
150 |
}
|
|
151 |
~AlfMapDataImpl()
|
|
152 |
{
|
|
153 |
|
|
154 |
mArray.clear();
|
|
155 |
}
|
|
156 |
//Array to hold the Map Item
|
|
157 |
AlfPtrVector<MapItem> mArray;
|
|
158 |
};
|
|
159 |
|
|
160 |
//owned
|
|
161 |
class AlfBranchDataImpl
|
|
162 |
{
|
|
163 |
public:
|
|
164 |
AlfBranchDataImpl():mCurrentData(0),mChildData(0)
|
|
165 |
{
|
|
166 |
|
|
167 |
}
|
|
168 |
~AlfBranchDataImpl()
|
|
169 |
{
|
|
170 |
if(mCurrentData)
|
|
171 |
{
|
|
172 |
delete mCurrentData;
|
|
173 |
mCurrentData=NULL;
|
|
174 |
}
|
|
175 |
|
|
176 |
if(mChildData)
|
|
177 |
{
|
|
178 |
delete mChildData;
|
|
179 |
mChildData=NULL;
|
|
180 |
}
|
|
181 |
}
|
|
182 |
IAlfMap* mCurrentData;
|
|
183 |
IAlfMap* mChildData;
|
|
184 |
};
|
|
185 |
|
|
186 |
|
|
187 |
////////////////////// AlfVariantType //////////////////////
|
|
188 |
|
|
189 |
// ---------------------------------------------------------------------------
|
|
190 |
// Description :Initialize the VarianType with an Unsigned 8 bit Integer Value
|
|
191 |
// ---------------------------------------------------------------------------
|
|
192 |
//
|
|
193 |
|
|
194 |
void AlfVariantType::construct(Type aType)
|
|
195 |
{
|
|
196 |
mVarData.reset( new (EMM) AlfVariantDataImpl() );
|
|
197 |
mVarData->mType = aType;
|
|
198 |
}
|
|
199 |
|
|
200 |
OSN_EXPORT AlfVariantType::AlfVariantType()
|
|
201 |
{
|
|
202 |
mVarData.reset( new (EMM) AlfVariantDataImpl() );
|
|
203 |
}
|
|
204 |
|
|
205 |
// ---------------------------------------------------------------------------
|
|
206 |
// Description : Parameterized Constructor for an Integer
|
|
207 |
// ---------------------------------------------------------------------------
|
|
208 |
//
|
|
209 |
OSN_EXPORT AlfVariantType::AlfVariantType(IAlfModelBase* aValue)
|
|
210 |
{
|
|
211 |
construct(ECustomData);
|
|
212 |
mVarData->mData.mBasePtr = aValue;
|
|
213 |
}
|
|
214 |
|
|
215 |
|
|
216 |
// ---------------------------------------------------------------------------
|
|
217 |
// Description : Parameterized Constructor for an Integer
|
|
218 |
// ---------------------------------------------------------------------------
|
|
219 |
//
|
|
220 |
OSN_EXPORT AlfVariantType::AlfVariantType(const UString& aValue)
|
|
221 |
{
|
|
222 |
construct(EString);
|
|
223 |
mVarData->mData.mString = new(EMM) UString(aValue);
|
|
224 |
}
|
|
225 |
|
|
226 |
|
|
227 |
|
|
228 |
// ---------------------------------------------------------------------------
|
|
229 |
// Description : Parameterized Constructor for an Integer value
|
|
230 |
// ---------------------------------------------------------------------------
|
|
231 |
//
|
|
232 |
OSN_EXPORT AlfVariantType::AlfVariantType(const int& aValue)
|
|
233 |
{
|
|
234 |
construct(EInt);
|
|
235 |
mVarData->mData.mInt = aValue;
|
|
236 |
}
|
|
237 |
|
|
238 |
|
|
239 |
// ---------------------------------------------------------------------------
|
|
240 |
// Description : Parameterized Constructor for an Unsigned Int value
|
|
241 |
// ---------------------------------------------------------------------------
|
|
242 |
//
|
|
243 |
OSN_EXPORT AlfVariantType::AlfVariantType(const uint& aValue)
|
|
244 |
{
|
|
245 |
construct(EUint);
|
|
246 |
mVarData->mData.mUint = aValue;
|
|
247 |
}
|
|
248 |
|
|
249 |
// ---------------------------------------------------------------------------
|
|
250 |
// Description : Parameterized Constructor for an Double value
|
|
251 |
// ---------------------------------------------------------------------------
|
|
252 |
//
|
|
253 |
OSN_EXPORT AlfVariantType::AlfVariantType(const double& aValue)
|
|
254 |
{
|
|
255 |
construct(EReal);
|
|
256 |
mVarData->mData.mReal = aValue;
|
|
257 |
}
|
|
258 |
|
|
259 |
// ---------------------------------------------------------------------------
|
|
260 |
// Description : Parameterized Constructor for an Bool value
|
|
261 |
// ---------------------------------------------------------------------------
|
|
262 |
//
|
|
263 |
OSN_EXPORT AlfVariantType::AlfVariantType(const bool& aValue)
|
|
264 |
{
|
|
265 |
construct(EBool);
|
|
266 |
mVarData->mData.mBool = aValue;
|
|
267 |
}
|
|
268 |
|
|
269 |
|
|
270 |
// ---------------------------------------------------------------------------
|
|
271 |
// Description : Class Destructor
|
|
272 |
// ---------------------------------------------------------------------------
|
|
273 |
//
|
|
274 |
OSN_EXPORT AlfVariantType::~AlfVariantType()
|
|
275 |
{
|
|
276 |
}
|
|
277 |
|
|
278 |
// ---------------------------------------------------------------------------
|
|
279 |
// Description : Sets Data to be stored in the Variant Data Type
|
|
280 |
// ---------------------------------------------------------------------------
|
|
281 |
//
|
|
282 |
OSN_EXPORT void AlfVariantType::set(IAlfVariantType& aValue)
|
|
283 |
{
|
|
284 |
if( mVarData->mType == EString)
|
|
285 |
{
|
|
286 |
delete mVarData->mData.mString;
|
|
287 |
mVarData->mData.mString = 0;
|
|
288 |
}
|
|
289 |
|
|
290 |
// Set the type
|
|
291 |
mVarData->mType = aValue.type();
|
|
292 |
|
|
293 |
// Copy/create the new data
|
|
294 |
if (aValue.type() == EBool)
|
|
295 |
{
|
|
296 |
mVarData->mData.mBool = aValue.boolean();
|
|
297 |
}
|
|
298 |
else if (aValue.type() <= EInt)
|
|
299 |
{
|
|
300 |
mVarData->mData.mInt = aValue.integer();
|
|
301 |
}
|
|
302 |
else if (aValue.type() <= EUint)
|
|
303 |
{
|
|
304 |
mVarData->mData.mUint = aValue.uinteger();
|
|
305 |
}
|
|
306 |
else if (aValue.type() <= EReal)
|
|
307 |
{
|
|
308 |
mVarData->mData.mReal = aValue.real();
|
|
309 |
}
|
|
310 |
else if (aValue.type() == EString)
|
|
311 |
{
|
|
312 |
mVarData->mData.mString = new (EMM) UString(aValue.string());
|
|
313 |
}
|
|
314 |
else if (aValue.type() == ECustomData)
|
|
315 |
{
|
|
316 |
mVarData->mData.mBasePtr = aValue.customData();
|
|
317 |
}
|
|
318 |
else
|
|
319 |
{
|
|
320 |
ALF_THROW(AlfDataException,EInvalidVariantDataType,"AlfVariantType")
|
|
321 |
}
|
|
322 |
}
|
|
323 |
|
|
324 |
// ---------------------------------------------------------------------------
|
|
325 |
// Description : Gets the Type of the Variant Data Type
|
|
326 |
// ---------------------------------------------------------------------------
|
|
327 |
//
|
|
328 |
OSN_EXPORT IAlfVariantType::Type AlfVariantType::type() const
|
|
329 |
{
|
|
330 |
return (Type)mVarData->mType;
|
|
331 |
}
|
|
332 |
|
|
333 |
|
|
334 |
// ---------------------------------------------------------------------------
|
|
335 |
// Description : Returns the Boolean value if the data type in the variant
|
|
336 |
// structure is a bool
|
|
337 |
// ---------------------------------------------------------------------------
|
|
338 |
//
|
|
339 |
OSN_EXPORT bool AlfVariantType::boolean() const
|
|
340 |
{
|
|
341 |
if (type() != EBool)
|
|
342 |
{
|
|
343 |
ALF_THROW(AlfDataException,EInvalidVariantDataType,"AlfVariantType")
|
|
344 |
}
|
|
345 |
return mVarData->mData.mBool;
|
|
346 |
}
|
|
347 |
|
|
348 |
|
|
349 |
// ---------------------------------------------------------------------------
|
|
350 |
// Description : Returns the int value if the data type in the variant
|
|
351 |
// structure is a int
|
|
352 |
// ---------------------------------------------------------------------------
|
|
353 |
//
|
|
354 |
OSN_EXPORT int AlfVariantType::integer() const
|
|
355 |
{
|
|
356 |
if (type() != EInt && type() != EUint) // Signed-unsigned conversion allowed
|
|
357 |
{
|
|
358 |
ALF_THROW(AlfDataException,EInvalidVariantDataType,"AlfVariantType")
|
|
359 |
}
|
|
360 |
return mVarData->mData.mInt;
|
|
361 |
}
|
|
362 |
|
|
363 |
// ---------------------------------------------------------------------------
|
|
364 |
// Description : Returns the Unsigned value if the data type in the variant
|
|
365 |
// structure is a unsigned int
|
|
366 |
// ---------------------------------------------------------------------------
|
|
367 |
//
|
|
368 |
OSN_EXPORT uint AlfVariantType::uinteger() const
|
|
369 |
{
|
|
370 |
if (type() != EInt && type() != EUint) // Signed-unsigned conversion allowed
|
|
371 |
{
|
|
372 |
ALF_THROW(AlfDataException,EInvalidVariantDataType,"AlfVariantType")
|
|
373 |
}
|
|
374 |
return mVarData->mData.mUint;
|
|
375 |
}
|
|
376 |
|
|
377 |
// ---------------------------------------------------------------------------
|
|
378 |
// Description : Returns the Real value if the data type in the variant
|
|
379 |
// structure is a Real data
|
|
380 |
// ---------------------------------------------------------------------------
|
|
381 |
//
|
|
382 |
OSN_EXPORT double AlfVariantType::real() const
|
|
383 |
{
|
|
384 |
if (type() != EReal)
|
|
385 |
{
|
|
386 |
ALF_THROW(AlfDataException,EInvalidVariantDataType,"AlfVariantType")
|
|
387 |
}
|
|
388 |
return mVarData->mData.mReal;
|
|
389 |
}
|
|
390 |
|
|
391 |
// ---------------------------------------------------------------------------
|
|
392 |
// Description : Returns the Descriptor value if the data type in the variant
|
|
393 |
// structure is a string data
|
|
394 |
// ---------------------------------------------------------------------------
|
|
395 |
//
|
|
396 |
OSN_EXPORT const UString& AlfVariantType::string() const
|
|
397 |
{
|
|
398 |
if (type() != EString)
|
|
399 |
{
|
|
400 |
ALF_THROW(AlfDataException,EInvalidVariantDataType,"AlfVariantType")
|
|
401 |
}
|
|
402 |
return *mVarData->mData.mString;
|
|
403 |
}
|
|
404 |
|
|
405 |
// ---------------------------------------------------------------------------
|
|
406 |
// Description : Returns the Container if the data type in the variant
|
|
407 |
// structure is a collection
|
|
408 |
// ---------------------------------------------------------------------------
|
|
409 |
//
|
|
410 |
OSN_EXPORT IAlfContainer* AlfVariantType::container()
|
|
411 |
{
|
|
412 |
ALF_THROW(AlfDataException,EInvalidVariantDataType,"AlfVariantType")
|
|
413 |
}
|
|
414 |
|
|
415 |
|
|
416 |
// ---------------------------------------------------------------------------
|
|
417 |
// Description : Returns the Map if the data type in the variant
|
|
418 |
// structure is a map
|
|
419 |
// ---------------------------------------------------------------------------
|
|
420 |
//
|
|
421 |
OSN_EXPORT IAlfMap* AlfVariantType::map()
|
|
422 |
{
|
|
423 |
ALF_THROW(AlfDataException,EInvalidVariantDataType,"AlfVariantType")
|
|
424 |
}
|
|
425 |
|
|
426 |
// ---------------------------------------------------------------------------
|
|
427 |
// Description : Returns the Branch if the data type in the variant
|
|
428 |
// structure is a map
|
|
429 |
// ---------------------------------------------------------------------------
|
|
430 |
//
|
|
431 |
OSN_EXPORT IAlfBranch* AlfVariantType::branch()
|
|
432 |
{
|
|
433 |
ALF_THROW(AlfDataException,EInvalidVariantDataType,"AlfVariantType")
|
|
434 |
}
|
|
435 |
|
|
436 |
// ---------------------------------------------------------------------------
|
|
437 |
// Description : Returns the User Defined Data Pointer if the data type in the variant
|
|
438 |
// structure is IAlfModelBase
|
|
439 |
// ---------------------------------------------------------------------------
|
|
440 |
//
|
|
441 |
OSN_EXPORT IAlfModelBase* AlfVariantType::customData()
|
|
442 |
{
|
|
443 |
if (type() != ECustomData)
|
|
444 |
{
|
|
445 |
ALF_THROW(AlfDataException,EInvalidVariantDataType,"AlfVariantType")
|
|
446 |
}
|
|
447 |
return mVarData->mData.mBasePtr;
|
|
448 |
}
|
|
449 |
|
|
450 |
// ---------------------------------------------------------------------------
|
|
451 |
// Description : Returns true, if objects are equal, false otherwise.
|
|
452 |
// ---------------------------------------------------------------------------
|
|
453 |
//
|
|
454 |
|
|
455 |
OSN_EXPORT bool AlfVariantType::operator==(const IAlfVariantType &aOther) const
|
|
456 |
{
|
|
457 |
// Set the type
|
|
458 |
bool equals = false;
|
|
459 |
if (type() == aOther.type() )
|
|
460 |
{
|
|
461 |
switch( type() )
|
|
462 |
{
|
|
463 |
case EBool:
|
|
464 |
equals = ( bool() == aOther.boolean() );
|
|
465 |
break;
|
|
466 |
case EInt:
|
|
467 |
equals = ( int() == aOther.integer() );
|
|
468 |
break;
|
|
469 |
case EUint:
|
|
470 |
equals = ( uint() == aOther.uinteger() );
|
|
471 |
break;
|
|
472 |
case EReal:
|
|
473 |
equals = ( real() == aOther.real() );
|
|
474 |
break;
|
|
475 |
case EString:
|
|
476 |
equals = ( string() == aOther.string() );
|
|
477 |
break;
|
|
478 |
case ECustomData: //not known how to compare.
|
|
479 |
break;
|
|
480 |
default:
|
|
481 |
ALF_THROW(AlfDataException,EInvalidVariantDataType,"AlfVariantType")
|
|
482 |
|
|
483 |
}
|
|
484 |
}
|
|
485 |
|
|
486 |
return equals;
|
|
487 |
}
|
|
488 |
|
|
489 |
////////////////////// AlfContainer //////////////////////
|
|
490 |
|
|
491 |
|
|
492 |
|
|
493 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
494 |
|
|
495 |
|
|
496 |
// ---------------------------------------------------------------------------
|
|
497 |
// Description : Default Constructor for the Container Data Type
|
|
498 |
// ---------------------------------------------------------------------------
|
|
499 |
//
|
|
500 |
OSN_EXPORT AlfContainer::AlfContainer()
|
|
501 |
{
|
|
502 |
construct();
|
|
503 |
}
|
|
504 |
|
|
505 |
|
|
506 |
// ---------------------------------------------------------------------------
|
|
507 |
// Description : Default Construtor
|
|
508 |
// ---------------------------------------------------------------------------
|
|
509 |
//
|
|
510 |
void AlfContainer::construct()
|
|
511 |
{
|
|
512 |
mContainerData.reset( new( EMM ) AlfContainerDataImpl() );
|
|
513 |
}
|
|
514 |
|
|
515 |
// ---------------------------------------------------------------------------
|
|
516 |
// Description : Class Destructor
|
|
517 |
// ---------------------------------------------------------------------------
|
|
518 |
//
|
|
519 |
OSN_EXPORT AlfContainer::~AlfContainer()
|
|
520 |
{
|
|
521 |
}
|
|
522 |
|
|
523 |
// ---------------------------------------------------------------------------
|
|
524 |
// Description : Adds an AlfVariantType into the container
|
|
525 |
// ---------------------------------------------------------------------------
|
|
526 |
//
|
|
527 |
OSN_EXPORT void AlfContainer::addItem(IAlfVariantType* aData)
|
|
528 |
{
|
|
529 |
mContainerData->mArray.resize(mContainerData->mArray.count()+1);
|
|
530 |
mContainerData->mArray.insert(mContainerData->mArray.count(),aData);
|
|
531 |
}
|
|
532 |
|
|
533 |
// ---------------------------------------------------------------------------
|
|
534 |
// Description : Adds an AlfVariantType into the container
|
|
535 |
// ---------------------------------------------------------------------------
|
|
536 |
//
|
|
537 |
OSN_EXPORT void AlfContainer::addItem(uint aIndex, IAlfVariantType* aData)
|
|
538 |
{
|
|
539 |
if( aIndex > mContainerData->mArray.count() )
|
|
540 |
{
|
|
541 |
ALF_THROW(AlfDataException,EInvalidArrayIndex,"AlfContainer")
|
|
542 |
}
|
|
543 |
else
|
|
544 |
{
|
|
545 |
mContainerData->mArray.resize(mContainerData->mArray.count()+1);
|
|
546 |
mContainerData->mArray.insert(aIndex, aData);
|
|
547 |
}
|
|
548 |
}
|
|
549 |
|
|
550 |
// ---------------------------------------------------------------------------
|
|
551 |
// Description : Gets the Size of the container
|
|
552 |
// ---------------------------------------------------------------------------
|
|
553 |
//
|
|
554 |
OSN_EXPORT int AlfContainer::count()
|
|
555 |
{
|
|
556 |
return mContainerData->mArray.count();
|
|
557 |
}
|
|
558 |
|
|
559 |
// ---------------------------------------------------------------------------
|
|
560 |
// Description : Gets the Item at a given index in the container
|
|
561 |
// ---------------------------------------------------------------------------
|
|
562 |
//
|
|
563 |
OSN_EXPORT IAlfVariantType* AlfContainer::item(uint aIndex)
|
|
564 |
{
|
|
565 |
uint cmpIndex =0; //To remove RVCT compiler warning
|
|
566 |
if(aIndex < mContainerData->mArray.count() && aIndex >= cmpIndex )
|
|
567 |
{
|
|
568 |
return mContainerData->mArray[aIndex];
|
|
569 |
}
|
|
570 |
else
|
|
571 |
{
|
|
572 |
return NULL;
|
|
573 |
}
|
|
574 |
}
|
|
575 |
|
|
576 |
// ---------------------------------------------------------------------------
|
|
577 |
// Description : Clones the existing conatiner and returns a new COntainer
|
|
578 |
// ---------------------------------------------------------------------------
|
|
579 |
//
|
|
580 |
OSN_EXPORT IAlfContainer* AlfContainer::clone()
|
|
581 |
{
|
|
582 |
try
|
|
583 |
{
|
|
584 |
//ALF_PERF_START( perfdata, "AlfContainer-Clone-Cloning Container")
|
|
585 |
auto_ptr<AlfContainer> clone( new( EMM ) AlfContainer() );
|
|
586 |
auto_ptr<IAlfVariantType> childData;
|
|
587 |
|
|
588 |
for ( int i = 0; i < mContainerData->mArray.count(); ++i )
|
|
589 |
{
|
|
590 |
if( mContainerData->mArray[i]->type()== IAlfVariantType::EInt )
|
|
591 |
{
|
|
592 |
childData.reset( new(EMM) AlfVariantType(mContainerData->mArray[i]->integer()) );
|
|
593 |
}
|
|
594 |
else if( mContainerData->mArray[i]->type()== IAlfVariantType::EUint )
|
|
595 |
{
|
|
596 |
childData.reset( new(EMM) AlfVariantType(mContainerData->mArray[i]->uinteger()) );
|
|
597 |
}
|
|
598 |
else if(mContainerData->mArray[i]->type()== IAlfVariantType::EBool)
|
|
599 |
{
|
|
600 |
childData.reset( new (EMM) AlfVariantType(mContainerData->mArray[i]->boolean()) );
|
|
601 |
}
|
|
602 |
else if( mContainerData->mArray[i]->type()== IAlfVariantType::EReal )
|
|
603 |
{
|
|
604 |
childData.reset( new(EMM) AlfVariantType(mContainerData->mArray[i]->real()) );
|
|
605 |
}
|
|
606 |
else if( mContainerData->mArray[i]->type()== IAlfVariantType::EString )
|
|
607 |
{
|
|
608 |
childData.reset( new(EMM) AlfVariantType(mContainerData->mArray[i]->string()) );
|
|
609 |
}
|
|
610 |
else if( mContainerData->mArray[i]->type()== IAlfVariantType::EMap )
|
|
611 |
{
|
|
612 |
childData.reset( (IAlfMap*)(mContainerData->mArray[i]->map())->clone() );
|
|
613 |
}
|
|
614 |
else if( mContainerData->mArray[i]->type()== IAlfVariantType::EContainer )
|
|
615 |
{
|
|
616 |
childData.reset( (IAlfContainer*)(mContainerData->mArray[i]->container())->clone() );
|
|
617 |
}
|
|
618 |
else if ( mContainerData->mArray[i]->type()== IAlfVariantType::EBranch )
|
|
619 |
{
|
|
620 |
childData.reset( mContainerData->mArray[i]->branch()->clone() );
|
|
621 |
}
|
|
622 |
else
|
|
623 |
{
|
|
624 |
ALF_THROW(AlfDataException,EInvalidVariantDataType,"AlfContainer")
|
|
625 |
}
|
|
626 |
clone->mContainerData->mArray.resize( clone->mContainerData->mArray.count() + 1 );
|
|
627 |
clone->mContainerData->mArray.insert( clone->mContainerData->mArray.count(), childData.get() );
|
|
628 |
childData.release(); // ownership was transferred.
|
|
629 |
}
|
|
630 |
//ALF_PERF_STOP( perfdata, "AlfContainer-Clone-Cloning Container")
|
|
631 |
return clone.release();
|
|
632 |
}
|
|
633 |
catch(...)
|
|
634 |
{
|
|
635 |
ALF_THROW(AlfDataException,EInvalidContainerOperation,"AlfContainer")
|
|
636 |
}
|
|
637 |
}
|
|
638 |
|
|
639 |
// ---------------------------------------------------------------------------
|
|
640 |
// Description : Sorts the container using user defined callback method
|
|
641 |
// ---------------------------------------------------------------------------
|
|
642 |
//
|
|
643 |
OSN_EXPORT void AlfContainer::sort( const IAlfSortFunction& aSortFunction )
|
|
644 |
{
|
|
645 |
IAlfVariantType** d = mContainerData->mArray.data();
|
|
646 |
AlfSort::sort( d, mContainerData->mArray.count(), aSortFunction );
|
|
647 |
}
|
|
648 |
|
|
649 |
// ---------------------------------------------------------------------------
|
|
650 |
// Description : Sets Data to be stored in the Variant Data Type
|
|
651 |
// ---------------------------------------------------------------------------
|
|
652 |
//
|
|
653 |
OSN_EXPORT void AlfContainer::set(IAlfVariantType& /*aValue*/)
|
|
654 |
{
|
|
655 |
ALF_THROW(AlfDataException,EInvalidContainerOperation,"AlfContainer")
|
|
656 |
}
|
|
657 |
|
|
658 |
// ---------------------------------------------------------------------------
|
|
659 |
// Description : Gets the Type of the Variant Data Type
|
|
660 |
// ---------------------------------------------------------------------------
|
|
661 |
//
|
|
662 |
OSN_EXPORT IAlfVariantType::Type AlfContainer::type() const
|
|
663 |
{
|
|
664 |
return IAlfVariantType::EContainer;
|
|
665 |
}
|
|
666 |
|
|
667 |
// ---------------------------------------------------------------------------
|
|
668 |
// Description : Returns the Boolean value if the data type in the variant
|
|
669 |
// structure is a bool
|
|
670 |
// ---------------------------------------------------------------------------
|
|
671 |
//
|
|
672 |
OSN_EXPORT bool AlfContainer::boolean() const
|
|
673 |
{
|
|
674 |
ALF_THROW(AlfDataException,EInvalidContainerOperation,"AlfContainer")
|
|
675 |
}
|
|
676 |
|
|
677 |
// ---------------------------------------------------------------------------
|
|
678 |
// Description : Returns the int value if the data type in the variant
|
|
679 |
// structure is a int
|
|
680 |
// ---------------------------------------------------------------------------
|
|
681 |
//
|
|
682 |
OSN_EXPORT int AlfContainer::integer() const
|
|
683 |
{
|
|
684 |
ALF_THROW(AlfDataException,EInvalidContainerOperation,"AlfContainer")
|
|
685 |
}
|
|
686 |
|
|
687 |
// ---------------------------------------------------------------------------
|
|
688 |
// Description : Returns the Unsigned value if the data type in the variant
|
|
689 |
// structure is a unsigned int
|
|
690 |
// ---------------------------------------------------------------------------
|
|
691 |
//
|
|
692 |
OSN_EXPORT uint AlfContainer::uinteger() const
|
|
693 |
{
|
|
694 |
ALF_THROW(AlfDataException,EInvalidContainerOperation,"AlfContainer")
|
|
695 |
}
|
|
696 |
|
|
697 |
// ---------------------------------------------------------------------------
|
|
698 |
// Description : Returns the Real value if the data type in the variant
|
|
699 |
// structure is a Real data
|
|
700 |
// ---------------------------------------------------------------------------
|
|
701 |
//
|
|
702 |
OSN_EXPORT double AlfContainer::real() const
|
|
703 |
{
|
|
704 |
ALF_THROW(AlfDataException,EInvalidContainerOperation,"AlfContainer")
|
|
705 |
}
|
|
706 |
|
|
707 |
// ---------------------------------------------------------------------------
|
|
708 |
// Description : Returns the Descriptor value if the data type in the variant
|
|
709 |
// structure is a string data
|
|
710 |
// ---------------------------------------------------------------------------
|
|
711 |
//
|
|
712 |
OSN_EXPORT const UString& AlfContainer::string() const
|
|
713 |
{
|
|
714 |
ALF_THROW(AlfDataException,EInvalidContainerOperation,"AlfContainer");
|
|
715 |
}
|
|
716 |
|
|
717 |
// ---------------------------------------------------------------------------
|
|
718 |
// Description : Returns the Container if the data type in the variant
|
|
719 |
// structure is a collection
|
|
720 |
// ---------------------------------------------------------------------------
|
|
721 |
//
|
|
722 |
OSN_EXPORT IAlfContainer* AlfContainer::container()
|
|
723 |
{
|
|
724 |
return this;
|
|
725 |
}
|
|
726 |
|
|
727 |
// ---------------------------------------------------------------------------
|
|
728 |
// Description : Returns the Map if the data type in the variant
|
|
729 |
// structure is a map
|
|
730 |
// ---------------------------------------------------------------------------
|
|
731 |
//
|
|
732 |
OSN_EXPORT IAlfMap* AlfContainer::map()
|
|
733 |
{
|
|
734 |
ALF_THROW(AlfDataException,EInvalidContainerOperation,"AlfContainer")
|
|
735 |
}
|
|
736 |
|
|
737 |
// ---------------------------------------------------------------------------
|
|
738 |
// Description : Returns the Branch if the data type in the variant
|
|
739 |
// structure is a map
|
|
740 |
// ---------------------------------------------------------------------------
|
|
741 |
//
|
|
742 |
OSN_EXPORT IAlfBranch* AlfContainer::branch()
|
|
743 |
{
|
|
744 |
ALF_THROW(AlfDataException,EInvalidContainerOperation,"AlfContainer")
|
|
745 |
}
|
|
746 |
|
|
747 |
|
|
748 |
// ---------------------------------------------------------------------------
|
|
749 |
// Description : Returns the User Defined Data Pointer if the data type in the variant
|
|
750 |
// structure is IAlfModelBase
|
|
751 |
// ---------------------------------------------------------------------------
|
|
752 |
//
|
|
753 |
OSN_EXPORT IAlfModelBase* AlfContainer::customData()
|
|
754 |
{
|
|
755 |
ALF_THROW(AlfDataException,EInvalidContainerOperation,"AlfContainer")
|
|
756 |
}
|
|
757 |
////////////////////// AlfContainer //////////////////////
|
|
758 |
|
|
759 |
|
|
760 |
|
|
761 |
|
|
762 |
// ---------------------------------------------------------------------------
|
|
763 |
// Description : Remove a item from the Container
|
|
764 |
// ---------------------------------------------------------------------------
|
|
765 |
//
|
|
766 |
OSN_EXPORT void AlfContainer::removeItem(uint aIndex)
|
|
767 |
{
|
|
768 |
uint cmpIndex=0;
|
|
769 |
if(aIndex >= mContainerData->mArray.count() || (aIndex < cmpIndex))
|
|
770 |
{
|
|
771 |
ALF_THROW(AlfDataException,EInvalidArrayIndex,"AlfContainer")
|
|
772 |
}
|
|
773 |
|
|
774 |
mContainerData->mArray.remove(aIndex);
|
|
775 |
}
|
|
776 |
|
|
777 |
|
|
778 |
// ---------------------------------------------------------------------------
|
|
779 |
// Description : Clears the contents of the Container
|
|
780 |
// ---------------------------------------------------------------------------
|
|
781 |
//
|
|
782 |
OSN_EXPORT void AlfContainer::clear()
|
|
783 |
{
|
|
784 |
mContainerData->mArray.clear();
|
|
785 |
}
|
|
786 |
|
|
787 |
|
|
788 |
// ---------------------------------------------------------------------------
|
|
789 |
// Description : Replaces the items of the container at a given index with the new data
|
|
790 |
// ---------------------------------------------------------------------------
|
|
791 |
//
|
|
792 |
OSN_EXPORT void AlfContainer::replaceItem(uint aIndex, IAlfVariantType* aNewData )
|
|
793 |
{
|
|
794 |
if((aIndex < mContainerData->mArray.count()) && aNewData)
|
|
795 |
{
|
|
796 |
try
|
|
797 |
{
|
|
798 |
mContainerData->mArray.remove(aIndex);
|
|
799 |
mContainerData->mArray.insert(aIndex,aNewData);
|
|
800 |
}
|
|
801 |
catch(...)
|
|
802 |
{
|
|
803 |
ALF_THROW(AlfDataException,EInvalidContainerOperation,"AlfContainer")
|
|
804 |
}
|
|
805 |
}
|
|
806 |
else
|
|
807 |
ALF_THROW(AlfDataException,EInvalidArrayIndex,"AlfContainer")
|
|
808 |
}
|
|
809 |
|
|
810 |
// ---------------------------------------------------------------------------
|
|
811 |
// Description : Returns true, if objects are equal, false otherwise.
|
|
812 |
// ---------------------------------------------------------------------------
|
|
813 |
//
|
|
814 |
OSN_EXPORT bool AlfContainer::operator==(const IAlfVariantType &/*aOther*/) const
|
|
815 |
{
|
|
816 |
ALF_THROW(AlfDataException,EInvalidContainerOperation,"AlfContainer")
|
|
817 |
}
|
|
818 |
|
|
819 |
|
|
820 |
////////////////////// AlfMap //////////////////////
|
|
821 |
|
|
822 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
823 |
|
|
824 |
|
|
825 |
|
|
826 |
// ---------------------------------------------------------------------------
|
|
827 |
// Description : 1st Phase Constructor. Leaves the object onto the cleanup stack
|
|
828 |
// ---------------------------------------------------------------------------
|
|
829 |
//
|
|
830 |
OSN_EXPORT AlfMap::AlfMap()
|
|
831 |
{
|
|
832 |
construct();
|
|
833 |
}
|
|
834 |
|
|
835 |
// ---------------------------------------------------------------------------
|
|
836 |
// Description : Map Constructor
|
|
837 |
// ---------------------------------------------------------------------------
|
|
838 |
//
|
|
839 |
void AlfMap::construct()
|
|
840 |
{
|
|
841 |
mMapDataImpl.reset( new (EMM) AlfMapDataImpl() );
|
|
842 |
}
|
|
843 |
|
|
844 |
// ---------------------------------------------------------------------------
|
|
845 |
// Description : Sets Data to be stored in the Variant Data Type
|
|
846 |
// ---------------------------------------------------------------------------
|
|
847 |
//
|
|
848 |
OSN_EXPORT void AlfMap::set(IAlfVariantType& aValue)
|
|
849 |
{
|
|
850 |
(void)aValue;
|
|
851 |
ALF_THROW(AlfDataException,EInvalidMapOperation,"AlfMap")
|
|
852 |
}
|
|
853 |
|
|
854 |
// ---------------------------------------------------------------------------
|
|
855 |
// Description : Gets the Type of the Variant Data Type
|
|
856 |
// ---------------------------------------------------------------------------
|
|
857 |
//
|
|
858 |
OSN_EXPORT IAlfVariantType::Type AlfMap::type() const
|
|
859 |
{
|
|
860 |
return IAlfVariantType::EMap;
|
|
861 |
}
|
|
862 |
|
|
863 |
|
|
864 |
// ---------------------------------------------------------------------------
|
|
865 |
// Description : Returns the Boolean value if the data type in the variant
|
|
866 |
// structure is a bool
|
|
867 |
// ---------------------------------------------------------------------------
|
|
868 |
//
|
|
869 |
OSN_EXPORT bool AlfMap::boolean() const
|
|
870 |
{
|
|
871 |
ALF_THROW(AlfDataException,EInvalidMapOperation,"AlfMap")
|
|
872 |
}
|
|
873 |
|
|
874 |
|
|
875 |
// ---------------------------------------------------------------------------
|
|
876 |
// Description : Returns the int value if the data type in the variant
|
|
877 |
// structure is a int
|
|
878 |
// ---------------------------------------------------------------------------
|
|
879 |
//
|
|
880 |
OSN_EXPORT int AlfMap::integer() const
|
|
881 |
{
|
|
882 |
ALF_THROW(AlfDataException,EInvalidMapOperation,"AlfMap")
|
|
883 |
}
|
|
884 |
|
|
885 |
// ---------------------------------------------------------------------------
|
|
886 |
// Description : Returns the Unsigned value if the data type in the variant
|
|
887 |
// structure is a unsigned int
|
|
888 |
// ---------------------------------------------------------------------------
|
|
889 |
//
|
|
890 |
OSN_EXPORT uint AlfMap::uinteger() const
|
|
891 |
{
|
|
892 |
ALF_THROW(AlfDataException,EInvalidMapOperation,"AlfMap")
|
|
893 |
}
|
|
894 |
|
|
895 |
// ---------------------------------------------------------------------------
|
|
896 |
// Description : Returns the Real value if the data type in the variant
|
|
897 |
// structure is a Real data
|
|
898 |
// ---------------------------------------------------------------------------
|
|
899 |
//
|
|
900 |
OSN_EXPORT double AlfMap::real() const
|
|
901 |
{
|
|
902 |
ALF_THROW(AlfDataException,EInvalidMapOperation,"AlfMap")
|
|
903 |
}
|
|
904 |
|
|
905 |
// ---------------------------------------------------------------------------
|
|
906 |
// Description : Returns the Descriptor value if the data type in the variant
|
|
907 |
// structure is a string data
|
|
908 |
// ---------------------------------------------------------------------------
|
|
909 |
//
|
|
910 |
OSN_EXPORT const UString& AlfMap::string() const
|
|
911 |
{
|
|
912 |
ALF_THROW(AlfDataException,EInvalidMapOperation,"AlfMap")
|
|
913 |
}
|
|
914 |
|
|
915 |
// ---------------------------------------------------------------------------
|
|
916 |
// Description : Returns the Container if the data type in the variant
|
|
917 |
// structure is a collection
|
|
918 |
// ---------------------------------------------------------------------------
|
|
919 |
//
|
|
920 |
OSN_EXPORT IAlfContainer* AlfMap::container()
|
|
921 |
{
|
|
922 |
ALF_THROW(AlfDataException,EInvalidMapOperation,"AlfMap")
|
|
923 |
}
|
|
924 |
|
|
925 |
|
|
926 |
// ---------------------------------------------------------------------------
|
|
927 |
// Description : Returns the Map if the data type in the variant
|
|
928 |
// structure is a map
|
|
929 |
// ---------------------------------------------------------------------------
|
|
930 |
//
|
|
931 |
OSN_EXPORT IAlfMap* AlfMap::map()
|
|
932 |
{
|
|
933 |
return this;
|
|
934 |
}
|
|
935 |
|
|
936 |
// ---------------------------------------------------------------------------
|
|
937 |
// Description : Returns the Branch if the data type in the variant
|
|
938 |
// structure is a map
|
|
939 |
// ---------------------------------------------------------------------------
|
|
940 |
//
|
|
941 |
OSN_EXPORT IAlfBranch* AlfMap::branch()
|
|
942 |
{
|
|
943 |
ALF_THROW(AlfDataException,EInvalidMapOperation,"AlfMap")
|
|
944 |
}
|
|
945 |
|
|
946 |
// ---------------------------------------------------------------------------
|
|
947 |
// Description : Returns the User Defined Data Pointer if the data type in the variant
|
|
948 |
// structure is IAlfModelBase
|
|
949 |
// ---------------------------------------------------------------------------
|
|
950 |
//
|
|
951 |
OSN_EXPORT IAlfModelBase* AlfMap::customData()
|
|
952 |
{
|
|
953 |
ALF_THROW(AlfDataException,EInvalidMapOperation,"AlfMap")
|
|
954 |
}
|
|
955 |
|
|
956 |
////////////////////// AlfContainer //////////////////////
|
|
957 |
|
|
958 |
|
|
959 |
|
|
960 |
|
|
961 |
|
|
962 |
// ---------------------------------------------------------------------------
|
|
963 |
// Description : Map Destructor
|
|
964 |
// ---------------------------------------------------------------------------
|
|
965 |
//
|
|
966 |
OSN_EXPORT AlfMap::~AlfMap()
|
|
967 |
{
|
|
968 |
}
|
|
969 |
|
|
970 |
|
|
971 |
// ---------------------------------------------------------------------------
|
|
972 |
// Description : APi to get the name of the data item in the map
|
|
973 |
// ---------------------------------------------------------------------------
|
|
974 |
//
|
|
975 |
OSN_EXPORT const UString& AlfMap::name(uint aIndex) const
|
|
976 |
{
|
|
977 |
uint cmpIndex=0;
|
|
978 |
if( aIndex >= mMapDataImpl->mArray.count() || (aIndex < cmpIndex))
|
|
979 |
{
|
|
980 |
ALF_THROW(AlfDataException,EInvalidArrayIndex,"AlfMap")
|
|
981 |
}
|
|
982 |
return *mMapDataImpl->mArray[aIndex]->mName;
|
|
983 |
}
|
|
984 |
|
|
985 |
|
|
986 |
// ---------------------------------------------------------------------------
|
|
987 |
// Description : APi to add an VariantData into the map
|
|
988 |
// ---------------------------------------------------------------------------
|
|
989 |
//
|
|
990 |
void AlfMap::addItem(IAlfVariantType* aData, const UString &aName)
|
|
991 |
{
|
|
992 |
auto_ptr<MapItem> item( new( EMM ) MapItem() );
|
|
993 |
|
|
994 |
item->mName = new( EMM ) UString( aName );
|
|
995 |
|
|
996 |
mMapDataImpl->mArray.resize( mMapDataImpl->mArray.count() + 1 );
|
|
997 |
mMapDataImpl->mArray.insert( mMapDataImpl->mArray.count(), item.get() );
|
|
998 |
|
|
999 |
// Take the ownership only if there was no exception.
|
|
1000 |
// Otherwise the client is resp. of cleaning up the object.
|
|
1001 |
item->mData = aData;
|
|
1002 |
item.release();
|
|
1003 |
}
|
|
1004 |
|
|
1005 |
// ---------------------------------------------------------------------------
|
|
1006 |
// Description : APi to add an VariantData into the map
|
|
1007 |
// ---------------------------------------------------------------------------
|
|
1008 |
//
|
|
1009 |
void AlfMap::addItem(uint aIndex, IAlfVariantType* aData, const UString& aName)
|
|
1010 |
{
|
|
1011 |
if( aIndex > mMapDataImpl->mArray.count() )
|
|
1012 |
{
|
|
1013 |
ALF_THROW(AlfDataException,EInvalidArrayIndex,"AlfMap")
|
|
1014 |
}
|
|
1015 |
else
|
|
1016 |
{
|
|
1017 |
auto_ptr<MapItem> item( new( EMM ) MapItem() );
|
|
1018 |
|
|
1019 |
item->mName = new( EMM ) UString( aName );
|
|
1020 |
|
|
1021 |
mMapDataImpl->mArray.resize( mMapDataImpl->mArray.count() + 1 );
|
|
1022 |
mMapDataImpl->mArray.insert( aIndex, item.get() );
|
|
1023 |
|
|
1024 |
// Take the ownership only if there was no exception.
|
|
1025 |
// Otherwise the client is resp. of cleaning up the object.
|
|
1026 |
item->mData = aData;
|
|
1027 |
item.release();
|
|
1028 |
}
|
|
1029 |
}
|
|
1030 |
|
|
1031 |
|
|
1032 |
// ---------------------------------------------------------------------------
|
|
1033 |
// Description : Gets the size of the map
|
|
1034 |
// ---------------------------------------------------------------------------
|
|
1035 |
//
|
|
1036 |
OSN_EXPORT int AlfMap::count() const
|
|
1037 |
{
|
|
1038 |
return mMapDataImpl->mArray.count();
|
|
1039 |
}
|
|
1040 |
|
|
1041 |
|
|
1042 |
// ---------------------------------------------------------------------------
|
|
1043 |
// Description : Gets the Element at a given index
|
|
1044 |
// ---------------------------------------------------------------------------
|
|
1045 |
//
|
|
1046 |
OSN_EXPORT IAlfVariantType* AlfMap::item(uint aIndex)
|
|
1047 |
{
|
|
1048 |
uint cmpIndex=0;
|
|
1049 |
if( aIndex >= mMapDataImpl->mArray.count() || aIndex <cmpIndex )
|
|
1050 |
{
|
|
1051 |
return NULL;
|
|
1052 |
}
|
|
1053 |
else
|
|
1054 |
{
|
|
1055 |
return mMapDataImpl->mArray[aIndex]->mData;
|
|
1056 |
}
|
|
1057 |
}
|
|
1058 |
|
|
1059 |
|
|
1060 |
// ---------------------------------------------------------------------------
|
|
1061 |
// Description : Clones the map
|
|
1062 |
// ---------------------------------------------------------------------------
|
|
1063 |
//
|
|
1064 |
OSN_EXPORT IAlfMap* AlfMap::clone()
|
|
1065 |
{
|
|
1066 |
try
|
|
1067 |
{
|
|
1068 |
//ALF_PERF_START( perfdata, "AlfContainer-Clone-Cloning Map")
|
|
1069 |
auto_ptr<AlfMap> clone( new(EMM) AlfMap() );
|
|
1070 |
auto_ptr<MapItem> cloneItem;
|
|
1071 |
|
|
1072 |
for (int i = 0; i < mMapDataImpl->mArray.count(); ++i)
|
|
1073 |
{
|
|
1074 |
cloneItem.reset( new(EMM) MapItem() );
|
|
1075 |
if( !(mMapDataImpl->mArray[i]->mName->getUtf8() == ""))
|
|
1076 |
{
|
|
1077 |
cloneItem->mName = new(EMM) UString(*(mMapDataImpl->mArray[i]->mName));
|
|
1078 |
}
|
|
1079 |
if(mMapDataImpl->mArray[i]->mData->type()== IAlfVariantType::EInt)
|
|
1080 |
{
|
|
1081 |
cloneItem->mData = new(EMM) AlfVariantType(mMapDataImpl->mArray[i]->mData->integer());
|
|
1082 |
}
|
|
1083 |
else if(mMapDataImpl->mArray[i]->mData->type()== IAlfVariantType::EUint)
|
|
1084 |
{
|
|
1085 |
cloneItem->mData = new(EMM) AlfVariantType(mMapDataImpl->mArray[i]->mData->uinteger());
|
|
1086 |
}
|
|
1087 |
else if(mMapDataImpl->mArray[i]->mData->type()== IAlfVariantType::EBool)
|
|
1088 |
{
|
|
1089 |
cloneItem->mData = new (EMM)AlfVariantType(mMapDataImpl->mArray[i]->mData->boolean());
|
|
1090 |
}
|
|
1091 |
else if(mMapDataImpl->mArray[i]->mData->type()== IAlfVariantType::EReal)
|
|
1092 |
{
|
|
1093 |
cloneItem->mData = new(EMM) AlfVariantType(mMapDataImpl->mArray[i]->mData->real());
|
|
1094 |
}
|
|
1095 |
else if(mMapDataImpl->mArray[i]->mData->type()== IAlfVariantType::EString)
|
|
1096 |
{
|
|
1097 |
cloneItem->mData = new(EMM) AlfVariantType(mMapDataImpl->mArray[i]->mData->string());
|
|
1098 |
}
|
|
1099 |
else if(mMapDataImpl->mArray[i]->mData->type()== IAlfVariantType::EMap)
|
|
1100 |
{
|
|
1101 |
cloneItem->mData = (IAlfMap*)(mMapDataImpl->mArray[i]->mData->map())->clone();
|
|
1102 |
}
|
|
1103 |
else if(mMapDataImpl->mArray[i]->mData->type()== IAlfVariantType::EContainer)
|
|
1104 |
{
|
|
1105 |
cloneItem->mData = (IAlfContainer*)(mMapDataImpl->mArray[i]->mData->container())->clone();
|
|
1106 |
}
|
|
1107 |
else if (mMapDataImpl->mArray[i]->mData->type()== IAlfVariantType::EBranch)
|
|
1108 |
{
|
|
1109 |
cloneItem->mData = mMapDataImpl->mArray[i]->mData->branch()->clone();
|
|
1110 |
}
|
|
1111 |
else
|
|
1112 |
{
|
|
1113 |
ALF_THROW(AlfDataException,EInvalidVariantDataType,"AlfMap")
|
|
1114 |
}
|
|
1115 |
|
|
1116 |
clone->mMapDataImpl->mArray.resize(clone->mMapDataImpl->mArray.count()+1);
|
|
1117 |
clone->mMapDataImpl->mArray.insert(clone->mMapDataImpl->mArray.count(),cloneItem.get() );
|
|
1118 |
cloneItem.release();
|
|
1119 |
}
|
|
1120 |
//ALF_PERF_STOP( perfdata, "AlfContainer-Clone-Cloning Map")
|
|
1121 |
|
|
1122 |
return clone.release();
|
|
1123 |
}
|
|
1124 |
catch(...)
|
|
1125 |
{
|
|
1126 |
ALF_THROW(AlfDataException,EInvalidMapOperation,"AlfMap")
|
|
1127 |
}
|
|
1128 |
}
|
|
1129 |
|
|
1130 |
|
|
1131 |
// ---------------------------------------------------------------------------
|
|
1132 |
// Description : Gets the map item with the given name
|
|
1133 |
// ---------------------------------------------------------------------------
|
|
1134 |
//
|
|
1135 |
OSN_EXPORT IAlfVariantType* AlfMap::item(const UString &aName)
|
|
1136 |
{
|
|
1137 |
for (int i = 0; i < mMapDataImpl->mArray.count(); ++i)
|
|
1138 |
{
|
|
1139 |
if ( *mMapDataImpl->mArray[i]->mName == aName)
|
|
1140 |
{
|
|
1141 |
return mMapDataImpl->mArray[i]->mData;
|
|
1142 |
}
|
|
1143 |
}
|
|
1144 |
return NULL;
|
|
1145 |
}
|
|
1146 |
|
|
1147 |
// ---------------------------------------------------------------------------
|
|
1148 |
// Description : Gets the index of the map item with the given name
|
|
1149 |
// ---------------------------------------------------------------------------
|
|
1150 |
//
|
|
1151 |
OSN_EXPORT int AlfMap::itemIndex(const UString &aName)
|
|
1152 |
{
|
|
1153 |
for (int i = 0; i < mMapDataImpl->mArray.count(); ++i)
|
|
1154 |
{
|
|
1155 |
if ( *mMapDataImpl->mArray[i]->mName == aName)
|
|
1156 |
{
|
|
1157 |
return i;
|
|
1158 |
}
|
|
1159 |
}
|
|
1160 |
return -1;
|
|
1161 |
}
|
|
1162 |
|
|
1163 |
|
|
1164 |
// ---------------------------------------------------------------------------
|
|
1165 |
// Description : Remove a item from the Map at a given index
|
|
1166 |
// ---------------------------------------------------------------------------
|
|
1167 |
//
|
|
1168 |
OSN_EXPORT void AlfMap::removeItem(uint aIndex)
|
|
1169 |
{
|
|
1170 |
try
|
|
1171 |
{
|
|
1172 |
uint cmpIndex =0;
|
|
1173 |
if(aIndex < mMapDataImpl->mArray.count() && aIndex>= cmpIndex )
|
|
1174 |
{
|
|
1175 |
mMapDataImpl->mArray.remove(aIndex);
|
|
1176 |
}
|
|
1177 |
}
|
|
1178 |
catch(...)
|
|
1179 |
{
|
|
1180 |
ALF_THROW(AlfDataException,EInvalidMapOperation,"AlfMap")
|
|
1181 |
}
|
|
1182 |
}
|
|
1183 |
|
|
1184 |
|
|
1185 |
// ---------------------------------------------------------------------------
|
|
1186 |
// Description : Clears the contents of the Map
|
|
1187 |
// ---------------------------------------------------------------------------
|
|
1188 |
//
|
|
1189 |
OSN_EXPORT void AlfMap::clear()
|
|
1190 |
{
|
|
1191 |
mMapDataImpl->mArray.clear();
|
|
1192 |
}
|
|
1193 |
|
|
1194 |
|
|
1195 |
// ---------------------------------------------------------------------------
|
|
1196 |
// Description : Replaces the items of the container at a given index with the new data
|
|
1197 |
// ---------------------------------------------------------------------------
|
|
1198 |
//
|
|
1199 |
OSN_EXPORT void AlfMap::replaceItem(uint aIndex, IAlfVariantType* aNewData )
|
|
1200 |
{
|
|
1201 |
try
|
|
1202 |
{
|
|
1203 |
uint cmpIndex =0;
|
|
1204 |
if ( aIndex < mMapDataImpl->mArray.count()&& aIndex >= cmpIndex )
|
|
1205 |
{
|
|
1206 |
auto_ptr<MapItem> newData( new( EMM ) MapItem() );
|
|
1207 |
newData.get()->mData = aNewData;
|
|
1208 |
newData.get()->mName = new( EMM ) UString(
|
|
1209 |
*( mMapDataImpl->mArray[aIndex]->mName ) );
|
|
1210 |
|
|
1211 |
mMapDataImpl->mArray.remove(aIndex);
|
|
1212 |
mMapDataImpl->mArray.insert(aIndex,newData.get());
|
|
1213 |
|
|
1214 |
newData.release(); // ownership transferred away
|
|
1215 |
}
|
|
1216 |
}
|
|
1217 |
catch(...)
|
|
1218 |
{
|
|
1219 |
ALF_THROW(AlfDataException,EInvalidMapOperation,"AlfMap")
|
|
1220 |
}
|
|
1221 |
}
|
|
1222 |
|
|
1223 |
|
|
1224 |
// ---------------------------------------------------------------------------
|
|
1225 |
// Description : Replaces the items of the container at a given index with the Given name
|
|
1226 |
// ---------------------------------------------------------------------------
|
|
1227 |
//
|
|
1228 |
OSN_EXPORT void AlfMap::replaceItem(const UString &aName,IAlfVariantType* aNewData)
|
|
1229 |
{
|
|
1230 |
|
|
1231 |
try
|
|
1232 |
{
|
|
1233 |
for (int i = 0; i < mMapDataImpl->mArray.count(); ++i)
|
|
1234 |
{
|
|
1235 |
if ( *mMapDataImpl->mArray[i]->mName == aName)
|
|
1236 |
{
|
|
1237 |
auto_ptr<MapItem> newData( new( EMM ) MapItem() );
|
|
1238 |
|
|
1239 |
newData.get()->mData = aNewData;
|
|
1240 |
newData.get()->mName = new( EMM ) UString(*(mMapDataImpl->mArray[i]->mName));
|
|
1241 |
|
|
1242 |
mMapDataImpl->mArray.remove(i);
|
|
1243 |
mMapDataImpl->mArray.insert(i,newData.get());
|
|
1244 |
|
|
1245 |
newData.release(); // ownership transferred away
|
|
1246 |
break;
|
|
1247 |
}
|
|
1248 |
}
|
|
1249 |
}
|
|
1250 |
catch(...)
|
|
1251 |
{
|
|
1252 |
ALF_THROW(AlfDataException,EInvalidMapOperation,"AlfMap")
|
|
1253 |
//aNewData might not have been deleted. In case of this exception the user should delete the variant data passed
|
|
1254 |
}
|
|
1255 |
|
|
1256 |
}
|
|
1257 |
|
|
1258 |
|
|
1259 |
// ---------------------------------------------------------------------------
|
|
1260 |
// Description : Remove a item from the Map with a given name
|
|
1261 |
// ---------------------------------------------------------------------------
|
|
1262 |
//
|
|
1263 |
OSN_EXPORT void AlfMap::removeItem(const UString &aName)
|
|
1264 |
{
|
|
1265 |
try
|
|
1266 |
{
|
|
1267 |
for(int i=0; i< mMapDataImpl->mArray.count();i++)
|
|
1268 |
{
|
|
1269 |
if ( *mMapDataImpl->mArray[i]->mName == aName)
|
|
1270 |
{
|
|
1271 |
mMapDataImpl->mArray.remove(i);
|
|
1272 |
break;
|
|
1273 |
}
|
|
1274 |
}
|
|
1275 |
}
|
|
1276 |
catch(...)
|
|
1277 |
{
|
|
1278 |
ALF_THROW(AlfDataException,EInvalidMapOperation,"AlfMap")
|
|
1279 |
}
|
|
1280 |
|
|
1281 |
}
|
|
1282 |
|
|
1283 |
////////////////////// AlfBranch //////////////////////
|
|
1284 |
|
|
1285 |
// ---------------------------------------------------------------------------
|
|
1286 |
// Description : 2nd Phase Constructor
|
|
1287 |
// ---------------------------------------------------------------------------
|
|
1288 |
//
|
|
1289 |
void AlfBranch::construct( IAlfMap* aData, IAlfMap* aChildData)
|
|
1290 |
{
|
|
1291 |
mBranchData.reset( new( EMM ) AlfBranchDataImpl() );
|
|
1292 |
|
|
1293 |
// Take the ownership of the parameter objects
|
|
1294 |
mBranchData->mCurrentData = aData;
|
|
1295 |
mBranchData->mChildData = aChildData;
|
|
1296 |
// No throwing code after the ownership has been transferred,
|
|
1297 |
// it would result to double deletion crash.
|
|
1298 |
|
|
1299 |
}
|
|
1300 |
|
|
1301 |
// ---------------------------------------------------------------------------
|
|
1302 |
// Description : 1st Phase Constructor. Leaves the object onto the cleanup stack
|
|
1303 |
// ---------------------------------------------------------------------------
|
|
1304 |
//
|
|
1305 |
OSN_EXPORT AlfBranch::AlfBranch(IAlfMap* aData, IAlfMap* aChildData)
|
|
1306 |
{
|
|
1307 |
construct( aData, aChildData );
|
|
1308 |
}
|
|
1309 |
|
|
1310 |
// ---------------------------------------------------------------------------
|
|
1311 |
// Description : Default Construtor
|
|
1312 |
// ---------------------------------------------------------------------------
|
|
1313 |
//
|
|
1314 |
OSN_EXPORT AlfBranch::AlfBranch()
|
|
1315 |
{
|
|
1316 |
mBranchData.reset( new(EMM) AlfBranchDataImpl() );
|
|
1317 |
}
|
|
1318 |
|
|
1319 |
// ---------------------------------------------------------------------------
|
|
1320 |
// Description : Map Destructor
|
|
1321 |
// ---------------------------------------------------------------------------
|
|
1322 |
//
|
|
1323 |
OSN_EXPORT AlfBranch::~AlfBranch()
|
|
1324 |
{
|
|
1325 |
}
|
|
1326 |
|
|
1327 |
// ---------------------------------------------------------------------------
|
|
1328 |
// Description : Sorts the branch using user defined callback method
|
|
1329 |
// ---------------------------------------------------------------------------
|
|
1330 |
//
|
|
1331 |
OSN_EXPORT void AlfBranch::sort( const IAlfSortFunction& aSortFunction )
|
|
1332 |
{
|
|
1333 |
try
|
|
1334 |
{
|
|
1335 |
for (int i = 0; i < mBranchData->mChildData->count(); ++i)
|
|
1336 |
{
|
|
1337 |
if (mBranchData->mChildData->item(i)->type() == EContainer)
|
|
1338 |
{
|
|
1339 |
IAlfContainer* container =
|
|
1340 |
mBranchData->mChildData->item(i)->container();
|
|
1341 |
container->sort(aSortFunction);
|
|
1342 |
}
|
|
1343 |
}
|
|
1344 |
}
|
|
1345 |
catch(...)
|
|
1346 |
{
|
|
1347 |
ALF_THROW(AlfDataException,EInvalidMapOperation,"AlfMap")
|
|
1348 |
}
|
|
1349 |
}
|
|
1350 |
// ---------------------------------------------------------------------------
|
|
1351 |
// Description : returns the data for this branch as a IAlfMap interface
|
|
1352 |
// ---------------------------------------------------------------------------
|
|
1353 |
//
|
|
1354 |
OSN_EXPORT IAlfMap* AlfBranch::data()
|
|
1355 |
{
|
|
1356 |
return mBranchData->mCurrentData;
|
|
1357 |
}
|
|
1358 |
|
|
1359 |
|
|
1360 |
// ---------------------------------------------------------------------------
|
|
1361 |
// Description : Set the data for this branch
|
|
1362 |
// ---------------------------------------------------------------------------
|
|
1363 |
//
|
|
1364 |
OSN_EXPORT void AlfBranch::setData( IAlfMap* aData )
|
|
1365 |
{
|
|
1366 |
delete mBranchData->mCurrentData;
|
|
1367 |
mBranchData->mCurrentData = aData;
|
|
1368 |
}
|
|
1369 |
|
|
1370 |
// ---------------------------------------------------------------------------
|
|
1371 |
// Description : returns the child data at the given index
|
|
1372 |
// ---------------------------------------------------------------------------
|
|
1373 |
//
|
|
1374 |
OSN_EXPORT IAlfVariantType* AlfBranch::childData(int aIndex)
|
|
1375 |
{
|
|
1376 |
if(aIndex <0 || mBranchData->mChildData->count() <=0)
|
|
1377 |
return NULL;
|
|
1378 |
|
|
1379 |
int count = 0;
|
|
1380 |
|
|
1381 |
// Start counting from the first child (item number 1)
|
|
1382 |
for (int i = 0; i < mBranchData->mChildData->count(); ++i)
|
|
1383 |
{
|
|
1384 |
|
|
1385 |
if ( mBranchData->mChildData->item(i)->type() == IAlfVariantType::EMap || mBranchData->mChildData->item(i)->type() == IAlfVariantType::EBranch )
|
|
1386 |
{
|
|
1387 |
// Map contains the data for a single child
|
|
1388 |
|
|
1389 |
if(count == aIndex)
|
|
1390 |
{
|
|
1391 |
return mBranchData->mChildData->item(aIndex);
|
|
1392 |
}
|
|
1393 |
count++;
|
|
1394 |
}
|
|
1395 |
|
|
1396 |
if (mBranchData->mChildData->item(i)->type() == IAlfVariantType::EContainer)
|
|
1397 |
{
|
|
1398 |
IAlfContainer* container = mBranchData->mChildData->item(i)->container();
|
|
1399 |
for ( int j = 0; j < container->count(); ++j )
|
|
1400 |
{
|
|
1401 |
// Container contains data for multiple children
|
|
1402 |
|
|
1403 |
if(count == aIndex)
|
|
1404 |
{
|
|
1405 |
return mBranchData->mChildData->item(i)->container()->item(aIndex);
|
|
1406 |
}
|
|
1407 |
count ++;
|
|
1408 |
}
|
|
1409 |
}
|
|
1410 |
}
|
|
1411 |
|
|
1412 |
return NULL;
|
|
1413 |
}
|
|
1414 |
|
|
1415 |
|
|
1416 |
|
|
1417 |
// ---------------------------------------------------------------------------
|
|
1418 |
// Description : returns the child name at the given index
|
|
1419 |
// ---------------------------------------------------------------------------
|
|
1420 |
//
|
|
1421 |
OSN_EXPORT const UString& AlfBranch::childName(int aIndex)
|
|
1422 |
{
|
|
1423 |
|
|
1424 |
int count = 0;
|
|
1425 |
|
|
1426 |
// Start counting from the first child (item number 1)
|
|
1427 |
for (int i = 0; i < mBranchData->mChildData->count(); ++i)
|
|
1428 |
{
|
|
1429 |
|
|
1430 |
if ( mBranchData->mChildData->item(i)->type() == IAlfVariantType::EMap || mBranchData->mChildData->item(i)->type() == IAlfVariantType::EBranch )
|
|
1431 |
{
|
|
1432 |
// Map contains the data for a single child
|
|
1433 |
|
|
1434 |
if(count == aIndex)
|
|
1435 |
{
|
|
1436 |
return mBranchData->mChildData->name(i);
|
|
1437 |
}
|
|
1438 |
count++;
|
|
1439 |
}
|
|
1440 |
if (mBranchData->mChildData->item(i)->type() == IAlfVariantType::EContainer)
|
|
1441 |
{
|
|
1442 |
IAlfContainer* container = mBranchData->mChildData->item(i)->container();
|
|
1443 |
|
|
1444 |
if(aIndex >= count && aIndex < (count + container->count()) )
|
|
1445 |
{
|
|
1446 |
return mBranchData->mChildData->name(i);
|
|
1447 |
}
|
|
1448 |
count+= container->count();
|
|
1449 |
|
|
1450 |
}
|
|
1451 |
}
|
|
1452 |
UString* ret(0);
|
|
1453 |
return *ret;
|
|
1454 |
}
|
|
1455 |
|
|
1456 |
|
|
1457 |
|
|
1458 |
// ---------------------------------------------------------------------------
|
|
1459 |
// Description : returns the Data for all childs
|
|
1460 |
// ---------------------------------------------------------------------------
|
|
1461 |
//
|
|
1462 |
OSN_EXPORT IAlfMap* AlfBranch::childData()
|
|
1463 |
{
|
|
1464 |
return mBranchData->mChildData;
|
|
1465 |
}
|
|
1466 |
|
|
1467 |
// ---------------------------------------------------------------------------
|
|
1468 |
// Description : Set the data for children of this branch
|
|
1469 |
// ---------------------------------------------------------------------------
|
|
1470 |
//
|
|
1471 |
OSN_EXPORT void AlfBranch::setChildData( IAlfMap* aChildData )
|
|
1472 |
{
|
|
1473 |
delete mBranchData->mChildData;
|
|
1474 |
mBranchData->mChildData = aChildData;
|
|
1475 |
}
|
|
1476 |
|
|
1477 |
// ---------------------------------------------------------------------------
|
|
1478 |
// Description : Api to get the Number of children of a branch
|
|
1479 |
// ---------------------------------------------------------------------------
|
|
1480 |
//
|
|
1481 |
OSN_EXPORT uint AlfBranch::childrenCount()
|
|
1482 |
{
|
|
1483 |
|
|
1484 |
uint count = 0;
|
|
1485 |
|
|
1486 |
// Start counting from the first child (item number 1)
|
|
1487 |
for (int i = 0; i < mBranchData->mChildData->count(); ++i)
|
|
1488 |
{
|
|
1489 |
if ( mBranchData->mChildData->item(i)->type() == IAlfVariantType::EMap ||
|
|
1490 |
mBranchData->mChildData->item(i)->type() == IAlfVariantType::EBranch )
|
|
1491 |
{
|
|
1492 |
// Map contains the data for a single child
|
|
1493 |
count++;
|
|
1494 |
}
|
|
1495 |
if (mBranchData->mChildData->item(i)->type() == IAlfVariantType::EContainer)
|
|
1496 |
{
|
|
1497 |
// Container contains data for multiple children
|
|
1498 |
count += mBranchData->mChildData->item(i)->container()->count();
|
|
1499 |
}
|
|
1500 |
}
|
|
1501 |
|
|
1502 |
return count;
|
|
1503 |
}
|
|
1504 |
|
|
1505 |
// ---------------------------------------------------------------------------
|
|
1506 |
// Description : Sets Data to be stored in the Variant Data Type
|
|
1507 |
// ---------------------------------------------------------------------------
|
|
1508 |
//
|
|
1509 |
OSN_EXPORT void AlfBranch::set(IAlfVariantType& aValue)
|
|
1510 |
{
|
|
1511 |
(void)aValue;
|
|
1512 |
ALF_THROW(AlfDataException,EInvalidBranchOperation,"AlfBranch")
|
|
1513 |
}
|
|
1514 |
|
|
1515 |
// ---------------------------------------------------------------------------
|
|
1516 |
// Description : Gets the Type of the Variant Data Type
|
|
1517 |
// ---------------------------------------------------------------------------
|
|
1518 |
//
|
|
1519 |
OSN_EXPORT IAlfVariantType::Type AlfBranch::type() const
|
|
1520 |
{
|
|
1521 |
return IAlfVariantType::EBranch;
|
|
1522 |
}
|
|
1523 |
|
|
1524 |
// ---------------------------------------------------------------------------
|
|
1525 |
// Description : Returns the Boolean value if the data type in the variant
|
|
1526 |
// structure is a bool
|
|
1527 |
// ---------------------------------------------------------------------------
|
|
1528 |
//
|
|
1529 |
OSN_EXPORT bool AlfBranch::boolean() const
|
|
1530 |
{
|
|
1531 |
ALF_THROW(AlfDataException,EInvalidBranchOperation,"AlfBranch")
|
|
1532 |
}
|
|
1533 |
|
|
1534 |
// ---------------------------------------------------------------------------
|
|
1535 |
// Description : Returns the int value if the data type in the variant
|
|
1536 |
// structure is a int
|
|
1537 |
// ---------------------------------------------------------------------------
|
|
1538 |
//
|
|
1539 |
OSN_EXPORT int AlfBranch::integer() const
|
|
1540 |
{
|
|
1541 |
ALF_THROW(AlfDataException,EInvalidBranchOperation,"AlfBranch")
|
|
1542 |
}
|
|
1543 |
|
|
1544 |
// ---------------------------------------------------------------------------
|
|
1545 |
// Description : Returns the Unsigned value if the data type in the variant
|
|
1546 |
// structure is a unsigned int
|
|
1547 |
// ---------------------------------------------------------------------------
|
|
1548 |
//
|
|
1549 |
OSN_EXPORT uint AlfBranch::uinteger() const
|
|
1550 |
{
|
|
1551 |
ALF_THROW(AlfDataException,EInvalidBranchOperation,"AlfBranch")
|
|
1552 |
}
|
|
1553 |
|
|
1554 |
// ---------------------------------------------------------------------------
|
|
1555 |
// Description : Returns the Real value if the data type in the variant
|
|
1556 |
// structure is a Real data
|
|
1557 |
// ---------------------------------------------------------------------------
|
|
1558 |
//
|
|
1559 |
OSN_EXPORT double AlfBranch::real() const
|
|
1560 |
{
|
|
1561 |
ALF_THROW(AlfDataException,EInvalidBranchOperation,"AlfBranch")
|
|
1562 |
}
|
|
1563 |
|
|
1564 |
// ---------------------------------------------------------------------------
|
|
1565 |
// Description : Returns the Descriptor value if the data type in the variant
|
|
1566 |
// structure is a string data
|
|
1567 |
// ---------------------------------------------------------------------------
|
|
1568 |
//
|
|
1569 |
OSN_EXPORT const UString& AlfBranch::string() const
|
|
1570 |
{
|
|
1571 |
ALF_THROW(AlfDataException,EInvalidBranchOperation,"AlfBranch")
|
|
1572 |
}
|
|
1573 |
|
|
1574 |
// ---------------------------------------------------------------------------
|
|
1575 |
// Description : Returns the Container if the data type in the variant
|
|
1576 |
// structure is a collection
|
|
1577 |
// ---------------------------------------------------------------------------
|
|
1578 |
//
|
|
1579 |
OSN_EXPORT IAlfContainer* AlfBranch::container()
|
|
1580 |
{
|
|
1581 |
ALF_THROW(AlfDataException,EInvalidBranchOperation,"AlfBranch")
|
|
1582 |
}
|
|
1583 |
|
|
1584 |
|
|
1585 |
// ---------------------------------------------------------------------------
|
|
1586 |
// Description : Returns the Map if the data type in the variant
|
|
1587 |
// structure is a map
|
|
1588 |
// ---------------------------------------------------------------------------
|
|
1589 |
//
|
|
1590 |
OSN_EXPORT IAlfMap* AlfBranch::map()
|
|
1591 |
{
|
|
1592 |
ALF_THROW(AlfDataException,EInvalidBranchOperation,"AlfBranch")
|
|
1593 |
}
|
|
1594 |
|
|
1595 |
// ---------------------------------------------------------------------------
|
|
1596 |
// Description : Returns the Branch if the data type in the variant
|
|
1597 |
// structure is a map
|
|
1598 |
// ---------------------------------------------------------------------------
|
|
1599 |
//
|
|
1600 |
OSN_EXPORT IAlfBranch* AlfBranch::branch()
|
|
1601 |
{
|
|
1602 |
return this;
|
|
1603 |
}
|
|
1604 |
|
|
1605 |
|
|
1606 |
// ---------------------------------------------------------------------------
|
|
1607 |
// Description : Returns the User Defined Data Pointer if the data type in the variant
|
|
1608 |
// structure is IAlfModelBase
|
|
1609 |
// ---------------------------------------------------------------------------
|
|
1610 |
//
|
|
1611 |
OSN_EXPORT IAlfModelBase* AlfBranch::customData()
|
|
1612 |
{
|
|
1613 |
ALF_THROW(AlfDataException,EInvalidBranchOperation,"AlfBranch")
|
|
1614 |
}
|
|
1615 |
// ---------------------------------------------------------------------------
|
|
1616 |
// Description : Clones the branch
|
|
1617 |
// ---------------------------------------------------------------------------
|
|
1618 |
//
|
|
1619 |
OSN_EXPORT IAlfBranch* AlfBranch::clone()
|
|
1620 |
{
|
|
1621 |
try
|
|
1622 |
{
|
|
1623 |
auto_ptr<IAlfMap> currentData( mBranchData->mCurrentData->clone() );
|
|
1624 |
auto_ptr<IAlfMap> childData( mBranchData->mChildData->clone() );
|
|
1625 |
IAlfBranch* clone = new(EMM) AlfBranch( currentData.get(), childData.get() );
|
|
1626 |
currentData.release(); // ownership transferred away
|
|
1627 |
childData.release(); // ownership transferred away
|
|
1628 |
|
|
1629 |
return clone;
|
|
1630 |
}
|
|
1631 |
catch(...)
|
|
1632 |
{
|
|
1633 |
ALF_THROW(AlfDataException,EInvalidBranchOperation,"AlfBranch")
|
|
1634 |
}
|
|
1635 |
}
|
|
1636 |
|
|
1637 |
// ---------------------------------------------------------------------------
|
|
1638 |
// Description : Returns true, if objects are equal, false otherwise.
|
|
1639 |
// ---------------------------------------------------------------------------
|
|
1640 |
//
|
|
1641 |
OSN_EXPORT bool AlfBranch::operator==(const IAlfVariantType &/*aOther*/) const
|
|
1642 |
{
|
|
1643 |
ALF_THROW(AlfDataException,EInvalidBranchOperation,"AlfBranch")
|
|
1644 |
}
|
|
1645 |
|
|
1646 |
} // namespace Alf
|