First public contribution.
2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
19 #include <caf/dirstreamable.h>
21 const TUint KCDirArrayGranularity=0x200;
23 using namespace ContentAccess;
26 EXPORT_C CDirStreamable* CDirStreamable::NewL(CDir &aDir)
28 CDirStreamable* self = new (ELeave) CDirStreamable;
29 CleanupStack::PushL(self);
30 self->ConstructL(aDir);
31 CleanupStack::Pop(self);
35 EXPORT_C CDirStreamable* CDirStreamable::NewL()
37 CDirStreamable* self = new (ELeave) CDirStreamable;
38 CleanupStack::PushL(self);
40 CleanupStack::Pop(self);
45 EXPORT_C CDirStreamable* CDirStreamable::NewL(RReadStream aStream)
47 CDirStreamable* self = new (ELeave) CDirStreamable;
48 CleanupStack::PushL(self);
50 self->InternalizeL(aStream);
51 CleanupStack::Pop(self);
55 CDirStreamable::CDirStreamable()
60 void CDirStreamable::ConstructL()
62 iArray=new(ELeave) CArrayPakFlat<TEntry>(KCDirArrayGranularity);
65 void CDirStreamable::ConstructL(CDir& aDir)
67 iArray=new(ELeave) CArrayPakFlat<TEntry>(KCDirArrayGranularity);
69 // copy entries to ourselves
71 for(i = 0; i < aDir.Count(); i++)
73 TEntry entry = aDir[i];
78 CDirStreamable::~CDirStreamable()
82 EXPORT_C void CDirStreamable::AddL(const TEntry &aEntry)
87 EXPORT_C TInt CDirStreamable::Count() const
92 EXPORT_C const TEntry& CDirStreamable::operator[](TInt aIndex) const
94 return CDir::operator [](aIndex);
97 EXPORT_C TInt CDirStreamable::Sort(TUint aEntrySortKey)
99 return CDir::Sort(aEntrySortKey);
102 EXPORT_C void CDirStreamable::ExternalizeL(RWriteStream& aStream) const
105 TInt count = Count();
106 aStream.WriteInt32L(count);
107 for(i = 0; i < count; i++)
109 TEntry aEntry = (*this)[i];
110 TPckgC <TEntry> pckg(aEntry);
111 aStream.WriteL(pckg);
115 void CDirStreamable::InternalizeL(RReadStream& aStream)
118 TInt count = aStream.ReadInt32L();
119 for(i = 0; i < count; i++)
122 TPckg<TEntry> pckg(aEntry);
125 // add to CDir base class array