sl@0: /* sl@0: * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: #include sl@0: sl@0: const TUint KCDirArrayGranularity=0x200; sl@0: sl@0: using namespace ContentAccess; sl@0: sl@0: sl@0: EXPORT_C CDirStreamable* CDirStreamable::NewL(CDir &aDir) sl@0: { sl@0: CDirStreamable* self = new (ELeave) CDirStreamable; sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(aDir); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: EXPORT_C CDirStreamable* CDirStreamable::NewL() sl@0: { sl@0: CDirStreamable* self = new (ELeave) CDirStreamable; sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: sl@0: EXPORT_C CDirStreamable* CDirStreamable::NewL(RReadStream aStream) sl@0: { sl@0: CDirStreamable* self = new (ELeave) CDirStreamable; sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: self->InternalizeL(aStream); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: CDirStreamable::CDirStreamable() sl@0: { sl@0: } sl@0: sl@0: sl@0: void CDirStreamable::ConstructL() sl@0: { sl@0: iArray=new(ELeave) CArrayPakFlat(KCDirArrayGranularity); sl@0: } sl@0: sl@0: void CDirStreamable::ConstructL(CDir& aDir) sl@0: { sl@0: iArray=new(ELeave) CArrayPakFlat(KCDirArrayGranularity); sl@0: sl@0: // copy entries to ourselves sl@0: TInt i = 0; sl@0: for(i = 0; i < aDir.Count(); i++) sl@0: { sl@0: TEntry entry = aDir[i]; sl@0: AddL(entry); sl@0: } sl@0: } sl@0: sl@0: CDirStreamable::~CDirStreamable() sl@0: { sl@0: } sl@0: sl@0: EXPORT_C void CDirStreamable::AddL(const TEntry &aEntry) sl@0: { sl@0: CDir::AddL(aEntry); sl@0: } sl@0: sl@0: EXPORT_C TInt CDirStreamable::Count() const sl@0: { sl@0: return CDir::Count(); sl@0: } sl@0: sl@0: EXPORT_C const TEntry& CDirStreamable::operator[](TInt aIndex) const sl@0: { sl@0: return CDir::operator [](aIndex); sl@0: } sl@0: sl@0: EXPORT_C TInt CDirStreamable::Sort(TUint aEntrySortKey) sl@0: { sl@0: return CDir::Sort(aEntrySortKey); sl@0: } sl@0: sl@0: EXPORT_C void CDirStreamable::ExternalizeL(RWriteStream& aStream) const sl@0: { sl@0: TInt i = 0; sl@0: TInt count = Count(); sl@0: aStream.WriteInt32L(count); sl@0: for(i = 0; i < count; i++) sl@0: { sl@0: TEntry aEntry = (*this)[i]; sl@0: TPckgC pckg(aEntry); sl@0: aStream.WriteL(pckg); sl@0: } sl@0: } sl@0: sl@0: void CDirStreamable::InternalizeL(RReadStream& aStream) sl@0: { sl@0: TInt i = 0; sl@0: TInt count = aStream.ReadInt32L(); sl@0: for(i = 0; i < count; i++) sl@0: { sl@0: TEntry aEntry; sl@0: TPckg pckg(aEntry); sl@0: aStream.ReadL(pckg); sl@0: sl@0: // add to CDir base class array sl@0: AddL(aEntry); sl@0: } sl@0: }