commsfwtools/commstools/utracedecoder/src/messagedefparser/signatureidentifier.cpp
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <cassert>
       
    17 #include <string>
       
    18 #include <iostream>
       
    19 #include <sstream>
       
    20 #include <iomanip>
       
    21 
       
    22 #include "messagedefparser\signatureidentifier.h"
       
    23 
       
    24 namespace Parser
       
    25 {
       
    26 
       
    27 void CSignatureIdentifier::AddMember(TMember* aMember)
       
    28     {
       
    29     assert(aMember);
       
    30     assert(aMember->iMemberType->Type() == Parser::EPadTypeIdentifier || aMember->iMemberName[0] != 0);
       
    31     assert(!FindMember(aMember->iMemberName));
       
    32     iMembers.push_back(aMember);
       
    33     aMember->iOffset = iSize;
       
    34     iSize += aMember->iMemberType->TotalSize() * aMember->iArraySize;
       
    35     }
       
    36 
       
    37 
       
    38 void CSignatureIdentifier::SetBaseSignature(const CSignatureIdentifier* aBaseSignature)
       
    39     {
       
    40     iBaseSignature = aBaseSignature;
       
    41     }
       
    42 
       
    43 
       
    44 const TMember* CSignatureIdentifier::FindMember(const std::string& aName)
       
    45     {
       
    46     unsigned int i;
       
    47     TMember* tmp;
       
    48 
       
    49     if (aName[0] == 0)
       
    50         {
       
    51         return NULL;
       
    52         }
       
    53 
       
    54     for (i=0; i<iMembers.size(); i++)
       
    55         {
       
    56         tmp = iMembers.at(i);
       
    57         if (!_strcmpi(tmp->iMemberName.c_str(), aName.c_str()))
       
    58             {
       
    59             return tmp;
       
    60             }
       
    61         }
       
    62     return NULL;
       
    63     }
       
    64 
       
    65 
       
    66 bool CSignatureIdentifier::IsNodeSignalDerived() const
       
    67     {
       
    68     const CSignatureIdentifier* baseSig = this;
       
    69     while (baseSig)
       
    70         {
       
    71         if (!_strcmpi(baseSig->Name(), "TNodeSignal"))
       
    72             {
       
    73             return true;
       
    74             }
       
    75         baseSig = baseSig->iBaseSignature;
       
    76         }
       
    77     return false;
       
    78     }
       
    79 
       
    80 int CSignatureIdentifier::TotalSize() const
       
    81     {
       
    82     if (iBaseSignature)
       
    83         {
       
    84         return Size() + iBaseSignature->TotalSize();
       
    85         }
       
    86     else
       
    87         {
       
    88         return Size();
       
    89         }
       
    90     }
       
    91 
       
    92 
       
    93 void CSignatureIdentifier::Describe(const unsigned char* aData, unsigned int aLength, const void* aOptions, std::ostream& aOutput) const
       
    94     {
       
    95     if (iBaseSignature)
       
    96         {
       
    97         iBaseSignature->Describe(aData + Size(), aLength - Size(), NULL, aOutput);
       
    98         }
       
    99 
       
   100     unsigned int i;
       
   101     TMember* member;
       
   102     for (i=0; i<iMembers.size(); i++)
       
   103         {
       
   104         member = iMembers.at(i);
       
   105         if (member->iMemberName[0] != 0) // padding members have no name
       
   106             {
       
   107             aOutput << "[" + std::string(member->iMemberName) + "=";
       
   108             member->iMemberType->Describe(aData + member->iOffset, member->iMemberType->Size(), member->iIdentifierOptions, aOutput);
       
   109             aOutput << "] ";
       
   110             }
       
   111         }
       
   112     }
       
   113 
       
   114 } // namespace Parser
       
   115