diff -r 000000000000 -r f58d6ec98e88 reszip/src/resdict.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/reszip/src/resdict.cpp Thu Dec 17 09:14:18 2009 +0200 @@ -0,0 +1,204 @@ +/* +* Copyright (c) 1997-1999 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include + +#include "resdict.h" +#include "resentry.h" + +// TDictEntry + +TDictEntry::TDictEntry() + { + iUses = 0; + iRef = 0; + iEmbedded = 0; + } + +void TDictEntry::Close() + { + delete iEmbedded; + iEmbedded = NULL; + } + + + +TDesC8& TDictEntry::Data() + { + return iData; + } + +TInt TDictEntry::Use() + { + return ((iUses + iRef - 1) * (Data().Length()-1)); + } + + +void TDictEntry::CreateEmbeddedDict(TInt aDictIndex,CDictArray* aDict) + { + // Create list of embedded dictionary strings + iEmbedded = new(ELeave)CResEntry(aDict); + iEmbedded->AddPlainDataL((TUint8*)iData.Ptr(), iData.Length()); + iEmbedded->MatchDictL(aDictIndex); + } + + +// CDictArray + +CDictArray::CDictArray() +:CArrayFixFlat(10) + { + } + +CDictArray::~CDictArray() + { + TInt count = Count(); + for (TInt ii=0; iiSize(iDictionaryBits); + } + + size = (size + 7) / 8; + + // Add dictionary index + size += (count * 2); + + // Add dictionary header + + size += 2; + + return size; + } + +TInt CDictArray::DictionarySizeWithoutIndex() + { + TInt count = Count(); + TInt size = 0; + for (TInt jj=0; jjSize(iDictionaryBits); + } + size = (size + 7) / 8; + return size; + } + + + +TInt CDictArray::BitSize(TInt aIndex) + { + return At(aIndex).iEmbedded->Size(iDictionaryBits); + } + + +void CDictArray::WriteBitStreamL(TInt aIndex, TBitWriter& aWriter) + { + RDebug::Print(_L("Dictionary Entry: %d"), aIndex); + At(aIndex).iEmbedded->WriteBitStreamL(aWriter,iDictionaryBits); + } + + + +CDictArray* CDictArray::DuplicateL() + { + CDictArray* newDict = new(ELeave)CDictArray(); + CleanupStack::PushL(newDict); + TInt count = Count(); + for (TInt ii=0; iiAppendL(At(ii)); + } + CleanupStack::Pop(); // newDict; + return newDict; + } +