commsfwtools/commstools/utracedecoder/inc/messagedefparser/integeridentifier.h
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 #ifndef INTEGERIDENTIFIER_H
       
    17 #define INTEGERIDENTIFIER_H
       
    18 
       
    19 #include "identifierbase.h"
       
    20 
       
    21 namespace Parser
       
    22 {
       
    23 struct TIntegerIdentifierOptions
       
    24     {
       
    25     public:
       
    26         TIntegerIdentifierOptions()
       
    27             : iFormatAsHex(true)
       
    28             {
       
    29             }
       
    30 
       
    31         TIntegerIdentifierOptions(bool aFormatAsHex)
       
    32             : iFormatAsHex(aFormatAsHex)
       
    33             {
       
    34             }
       
    35 
       
    36         bool iFormatAsHex;
       
    37     };
       
    38 
       
    39 class CIntegerTypeIdentifier : public CIdentifierBase
       
    40     {
       
    41     public:
       
    42         explicit CIntegerTypeIdentifier(const char* aName, int aSize)
       
    43             : CIdentifierBase(Parser::EIntegerTypeIdentifier, aName), iSigned(false)
       
    44             {
       
    45             iSize = aSize;
       
    46             }
       
    47 
       
    48         explicit CIntegerTypeIdentifier(const char* aName, int aSize, bool aSigned)
       
    49             : CIdentifierBase(Parser::EIntegerTypeIdentifier, aName), iSigned(aSigned)
       
    50             {
       
    51             iSize = aSize;
       
    52             }
       
    53 
       
    54         virtual void Describe(const unsigned char* aData, unsigned int aLength, const void* aOptions, std::ostream& aDescription) const;
       
    55 
       
    56     protected:
       
    57         explicit CIntegerTypeIdentifier(Parser::TIdentifierType aType, const char* aName)
       
    58             : CIdentifierBase(aType, aName), iSigned(false)
       
    59             {
       
    60             }
       
    61 
       
    62         explicit CIntegerTypeIdentifier(Parser::TIdentifierType aType, const char* aName, bool aSigned)
       
    63             : CIdentifierBase(aType, aName), iSigned(aSigned)
       
    64             {
       
    65             }
       
    66 
       
    67     public:
       
    68         bool ValueInRange(int aValue) const;
       
    69         bool ValueInRange(unsigned int aValue) const;
       
    70         static bool ValueInRange(unsigned int aSize, int aValue);
       
    71         static bool ValueInRange(unsigned int aSize, unsigned int aValue);
       
    72 
       
    73         inline void SetSigned(bool aSigned)
       
    74             {
       
    75             iSigned = aSigned;
       
    76             }
       
    77 
       
    78         inline bool Signed() const
       
    79             {
       
    80             return iSigned;
       
    81             }
       
    82 
       
    83     protected:
       
    84         bool iSigned;
       
    85     };
       
    86     
       
    87 } // namespace Parser
       
    88 
       
    89 #endif
       
    90 // INTEGERIDENTIFIER_H
       
    91