networkingtestandutils/networkingunittest/tdummyetel/mpbutil.h
changeset 0 af10295192d8
equal deleted inserted replaced
-1:000000000000 0:af10295192d8
       
     1 // Copyright (c) 1997-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 __MPBUTIL_H__
       
    17 #define	__MPBUTIL_H__
       
    18 
       
    19 #include "ETELMM.H"		// for RMobilePhoneBookStore
       
    20 /**
       
    21 @internalComponent
       
    22 */
       
    23 const TInt KFieldEntrySize = 8;
       
    24 const TInt KErrStartOfNewEntry = -1;
       
    25 const TInt KMaxUint16Val = 0xFFFF;
       
    26 
       
    27 class CPhoneBookBuffer : public CBase
       
    28 /**
       
    29 This class enables the conversion from integer or descriptor data type into 
       
    30 the TLV (Tag-Length-Value) format and vice versa.
       
    31 @internalComponent
       
    32 */
       
    33 	{
       
    34 public:
       
    35 	IMPORT_C CPhoneBookBuffer();
       
    36 	IMPORT_C void Set(TDes8* aData);
       
    37 	IMPORT_C TInt AddNewEntryTag();
       
    38 	IMPORT_C TInt PutTagAndValue(TUint8 aTagValue, TUint8 aInteger);
       
    39 	IMPORT_C TInt PutTagAndValue(TUint8 aTagValue, TUint16 aInteger);
       
    40 	IMPORT_C TInt PutTagAndValue(TUint8 aTagValue, TUint32 aInteger);
       
    41 	IMPORT_C TInt PutTagAndValue(TUint8 aTagValue, const TDesC8 &aData);
       
    42 	IMPORT_C TInt PutTagAndValue(TUint8 aTagValue, const TDesC16 &aData);
       
    43 	IMPORT_C TInt RemovePartialEntry();
       
    44 	IMPORT_C void StartRead();
       
    45 
       
    46 	enum TPhBkTagType
       
    47 		{
       
    48 		EPhBkTypeNoData,
       
    49 		EPhBkTypeInt8,
       
    50 		EPhBkTypeInt16,
       
    51 		EPhBkTypeInt32,
       
    52 		EPhBkTypeDes8,
       
    53 		EPhBkTypeDes16,
       
    54 		};
       
    55 
       
    56 	IMPORT_C TInt GetTagAndType(TUint8 &aTagValue, TPhBkTagType &aDataType);
       
    57 	IMPORT_C TInt GetValue(TUint8 &aInteger);
       
    58 	IMPORT_C TInt GetValue(TUint16 &aInteger);
       
    59 	IMPORT_C TInt GetValue(TUint32 &aInteger);
       
    60 	IMPORT_C TInt GetValue(TPtrC8 &aData);
       
    61 	IMPORT_C TInt GetValue(TPtrC16 &aData);
       
    62 	IMPORT_C void SkipValue(TPhBkTagType aDataType);
       
    63 	IMPORT_C TInt BufferLength();
       
    64 	IMPORT_C TInt RemainingReadLength();
       
    65 
       
    66 private:
       
    67 	TInt AppendInt8(TUint8 aInteger);
       
    68 	TInt AppendInt16(TUint16 aInteger);
       
    69 	TInt AppendInt32(TUint32 aInteger);
       
    70 
       
    71 private:
       
    72 	TDes8*  iPtr;   // Points to supplied Data buffer
       
    73 	TPtrC8 iRead;   // Points to populated TLV buffer
       
    74 	TPtr8 iMonitor; // Used to remove partially populated entries from TLV buffer
       
    75 	};
       
    76 
       
    77 #endif