realtimenetprots/sipfw/SIP/Codec/src/CSIPUnsignedIntHeaderBase.cpp
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 // Copyright (c) 2005-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 // Name          : CSIPUnsignedIntHeaderBase.cpp
       
    15 // Part of       : SIP Codec
       
    16 // Version       : SIP/4.0 
       
    17 //
       
    18 
       
    19 
       
    20 
       
    21 #include "sipunsignedintheaderbase.h"
       
    22 #include "sipcodecerr.h"
       
    23 #include "SIPSyntaxCheck.h"
       
    24 #include "_sipcodecdefs.h"
       
    25 
       
    26 _LIT8(KTUintFormat, "%u");
       
    27 
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // CSIPUnsignedIntHeaderBase::CSIPUnsignedIntHeaderBase
       
    31 // -----------------------------------------------------------------------------
       
    32 //
       
    33 CSIPUnsignedIntHeaderBase::CSIPUnsignedIntHeaderBase(TUint aValue)
       
    34 : iValue (aValue)
       
    35 	{
       
    36 	}
       
    37 
       
    38 // -----------------------------------------------------------------------------
       
    39 // CSIPUnsignedIntHeaderBase::~CSIPUnsignedIntHeaderBase
       
    40 // -----------------------------------------------------------------------------
       
    41 //
       
    42 EXPORT_C CSIPUnsignedIntHeaderBase::~CSIPUnsignedIntHeaderBase()
       
    43 	{
       
    44 	}
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // CSIPUnsignedIntHeaderBase::SetValue
       
    48 // -----------------------------------------------------------------------------
       
    49 //
       
    50 EXPORT_C void CSIPUnsignedIntHeaderBase::SetValue(TUint aValue)
       
    51 	{
       
    52 	iValue = aValue;
       
    53 	}
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // CSIPUnsignedIntHeaderBase::Value
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 EXPORT_C TUint CSIPUnsignedIntHeaderBase::Value() const
       
    60 	{
       
    61 	return iValue;
       
    62 	}
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // CSIPUnsignedIntHeaderBase::ToTextValueL
       
    66 // From CSIPHeaderBase:
       
    67 // -----------------------------------------------------------------------------
       
    68 //
       
    69 EXPORT_C HBufC8* CSIPUnsignedIntHeaderBase::ToTextValueL() const
       
    70 	{
       
    71 	const TInt KMaxNumericValueAsTextLength = 80;
       
    72 	TBuf8<KMaxNumericValueAsTextLength> value;
       
    73 	value.Format(KTUintFormat, iValue);
       
    74 	return value.AllocL();
       
    75 	}
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // CSIPUnsignedIntHeaderBase::ParseL
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 void CSIPUnsignedIntHeaderBase::ParseL(
       
    82     const TDesC8& aValue,
       
    83     TInt aErrorIfParsingFails)
       
    84 	{
       
    85 	TLex8 lex(aValue);
       
    86 	lex.SkipSpace();
       
    87 	if (!SIPSyntaxCheck::UInt(lex.NextToken(),iValue))
       
    88 		{
       
    89 		User::Leave (aErrorIfParsingFails);
       
    90 		}
       
    91 	lex.SkipSpace();
       
    92 	if (lex.Remainder().Length() != 0) 
       
    93         {
       
    94         User::Leave (aErrorIfParsingFails);
       
    95         }
       
    96 	}
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // CSIPUnsignedIntHeaderBase::DoInternalizeValueL
       
   100 // -----------------------------------------------------------------------------
       
   101 //
       
   102 void CSIPUnsignedIntHeaderBase::DoInternalizeValueL(RReadStream& aReadStream)
       
   103 	{
       
   104 	iValue = aReadStream.ReadUint32L();
       
   105 	}
       
   106 
       
   107 // -----------------------------------------------------------------------------
       
   108 // CSIPUnsignedIntHeaderBase::ExternalizeValueL
       
   109 // From CSIPHeaderBase:
       
   110 // -----------------------------------------------------------------------------
       
   111 //
       
   112 void CSIPUnsignedIntHeaderBase::ExternalizeValueL(
       
   113     RWriteStream& aWriteStream) const
       
   114 	{
       
   115 	aWriteStream.WriteUint32L(iValue);
       
   116 	}