diff -r 000000000000 -r dfb7c4ff071f commsfwtools/commstools/utracedecoder/src/messagedefparser/contextidentifier.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/commsfwtools/commstools/utracedecoder/src/messagedefparser/contextidentifier.cpp Thu Dec 17 09:22:25 2009 +0200 @@ -0,0 +1,103 @@ +// Copyright (c) 2007-2009 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 +#include +#include +#include + +#include "messagedefparser\contextidentifier.h" + +namespace Parser +{ + +void CContextIdentifier::AddMember(TMember* aMember) + { + assert(aMember); + assert(aMember->iMemberType->Type() == Parser::EPadTypeIdentifier || aMember->iMemberName[0] != 0); + assert(!FindMember(aMember->iMemberName)); + iMembers.push_back(aMember); + aMember->iOffset = iSize; + iSize += aMember->iMemberType->TotalSize() * aMember->iArraySize; + } + + +void CContextIdentifier::SetBaseContext(const CContextIdentifier* aBaseContext) + { + iBaseContext = aBaseContext; + } + + +int CContextIdentifier::TotalSize() const + { + if (iBaseContext) + { + return Size() + iBaseContext->TotalSize(); + } + else + { + return Size(); + } + } + + +const TMember* CContextIdentifier::FindMember(const std::string& aName) + { + unsigned int i; + TMember* tmp; + + if (aName[0] == 0) + { + return NULL; + } + + for (i=0; iiMemberName.c_str(), aName.c_str())) + { + return tmp; + } + } + return NULL; + } + + +void CContextIdentifier::Describe(const unsigned char* aData, unsigned int aLength, const void* aOptions, std::ostream& aOutput) const + { + int baseSize = 0; + if (iBaseContext) + { + baseSize = iBaseContext->TotalSize(); + iBaseContext->Describe(aData, baseSize, NULL, aOutput); + } + + unsigned int i; + TMember* member; + for (i=0; iiMemberName[0] != 0) // padding members have no name + { + aOutput << "[" + std::string(member->iMemberName) + "="; + member->iMemberType->Describe(aData + baseSize + member->iOffset, member->iMemberType->Size(), member->iIdentifierOptions, aOutput); + aOutput << "] "; + } + } + } + +} // namespace Parser +