williamr@2: /* williamr@2: * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@2: * under the terms of the License "Eclipse Public License v1.0" williamr@2: * which accompanies this distribution, and is available williamr@2: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @file williamr@2: williamr@2: @publishedPartner williamr@2: @released williamr@2: */ williamr@2: williamr@2: williamr@2: #ifndef __DIRSTREAMABLE_H__ williamr@2: #define __DIRSTREAMABLE_H__ williamr@2: williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: williamr@2: namespace ContentAccess williamr@2: { williamr@2: /** Emulates the behavior of a CDir object with the addition of williamr@2: streaming. williamr@2: williamr@2: Functions are not virtual and do not override the CDir williamr@2: functions so most of the time this class will be used as if it was williamr@2: a CDir. It is only when used explicitly as a CDirStreamable that williamr@2: any additional functionality is invoked williamr@2: williamr@2: @publishedPartner williamr@2: @released williamr@2: */ williamr@2: class CDirStreamable : public CDir williamr@2: { williamr@2: public: williamr@2: /** Constuct an empty CDirStreamable williamr@2: @return a CDirStreamable with no entries williamr@2: */ williamr@2: IMPORT_C static CDirStreamable* NewL(); williamr@2: williamr@2: /** Construct a CDirStreamable object from the result williamr@2: of a call to RFs::GetDir() williamr@2: williamr@2: @param aDir A CDir object which has been constructed by a previous call williamr@2: to RFs::GetDir() williamr@2: @return A new CDirStreamable object williamr@2: */ williamr@2: IMPORT_C static CDirStreamable* NewL(CDir& aDir); williamr@2: williamr@2: /** Construct a CDirStreamable object from a stream williamr@2: williamr@2: @param aStream The stream to read the CDirStreamable object from williamr@2: @return A new CDirStreamable object williamr@2: */ williamr@2: IMPORT_C static CDirStreamable* NewL(RReadStream aStream); williamr@2: williamr@2: public: williamr@2: virtual ~CDirStreamable(); williamr@2: williamr@2: /** Add an entry williamr@2: @param aEntry The directory entry to add williamr@2: */ williamr@2: IMPORT_C void AddL(const TEntry &aEntry); williamr@2: williamr@2: /** The number of file system entries in the CDirStreamable williamr@2: williamr@2: @return The number of TEntry objects in the CDirStreamable williamr@2: */ williamr@2: IMPORT_C TInt Count() const; williamr@2: williamr@2: /** Retrieve the file system entry at a particular index williamr@2: williamr@2: @see TEntry williamr@2: williamr@2: @param aIndex The entry to retrieve williamr@2: @return A reference to the TEntry stored by the CDirStreamable williamr@2: */ williamr@2: IMPORT_C const TEntry& operator[](TInt aIndex) const; williamr@2: williamr@2: /** Sort the entries in the specified order williamr@2: @param aEntrySortKey A TEntryKey value used to sort the array. williamr@2: @return KErrNone if sort was successful williamr@2: */ williamr@2: IMPORT_C TInt Sort(TUint aEntrySortKey); williamr@2: williamr@2: public: williamr@2: /** Write this CDirStreamable to a stream williamr@2: @param aStream The stream to write to williamr@2: */ williamr@2: IMPORT_C void ExternalizeL(RWriteStream& aStream) const; williamr@2: williamr@2: private: williamr@2: CDirStreamable(); williamr@2: void ConstructL(); williamr@2: void ConstructL(CDir& aDir); williamr@2: williamr@2: void InternalizeL(RReadStream& aStream); williamr@2: }; williamr@2: } williamr@2: williamr@2: #endif williamr@2: