S60 3rd Edition SDK for Symbian OS
Example Applications Guide

TChatSdpAttributeParser Class Reference

#include <ChatSdpAttributeParser.h>

List of all members.

Public Types

enum  TNodeCommand {
  ECheckType, ECheckValue, ECheckEnd, ESkip,
  EReadValue, EFinished
}

Public Member Functions

 TChatSdpAttributeParser (RArray< TChatSdpAttributeParser::TChatSdpAttributeNode > &aNodeList, MChatSdpAttributeNotifier &aObserver)
virtual ~TChatSdpAttributeParser ()
TBool HasFinished () const
void VisitAttributeValueL (CSdpAttrValue &aValue, TSdpElementType aType)
void StartListL (CSdpAttrValueList &aList)
void EndListL ()

Private Member Functions

void CheckTypeL (TSdpElementType aElementType) const
void CheckValueL (CSdpAttrValue &aValue) const
void ReadValueL (CSdpAttrValue &aValue) const
void AdvanceL ()

Private Attributes

MChatSdpAttributeNotifier & iObserver
RArray< TChatSdpAttributeParser::TChatSdpAttributeNode > & iNodeList
TInt iCurrentNodeIndex
TChatSdpAttributeNode iCurrentNode

Classes

class  TChatSdpAttributeNode


Detailed Description

TChatSdpAttributeParser An instance of TChatSdpAttributeParser is used to check an SDP attribute value, and read selected parts

Definition at line 31 of file ChatSdpAttributeParser.h.


Member Enumeration Documentation

enum TChatSdpAttributeParser::TNodeCommand
 

TNodeCommand The command to be carried out at a node ECheckType. Check the type of the value ECheckValue. Check the type and the value ECheckEnd. Check that a list ends at this point ESkip. Do not check this value - can not match a list end EReadValue. Pass the value onto the observer EFinished. Marks the end of the node list

Definition at line 45 of file ChatSdpAttributeParser.h.

00046             {
00047             ECheckType,     
00048             ECheckValue,  
00049             ECheckEnd,      
00050             ESkip,        
00051             EReadValue,    
00052             EFinished
00053             };


Constructor & Destructor Documentation

TChatSdpAttributeParser::TChatSdpAttributeParser (  RArray< TChatSdpAttributeParser::TChatSdpAttributeNode > &  aNodeList,
MChatSdpAttributeNotifier &  aObserver
) 
 

TChatSdpAttributeParser Construct a TChatSdpAttributeParser

Parameters:
aNodeList the list of expected nodes
aObserver an observer to read specified node values

Definition at line 30 of file ChatSdpAttributeParser.cpp.

References iCurrentNode, iCurrentNodeIndex, and iNodeList.

00032                                            : 
00033     iObserver( aObserver ),
00034     iNodeList( aNodeList ),
00035     iCurrentNodeIndex( 0 )
00036     {
00037     iCurrentNode = iNodeList[iCurrentNodeIndex];
00038     }

TChatSdpAttributeParser::~TChatSdpAttributeParser (   )  [virtual]
 

~TChatSdpAttributeParser Destructor

Definition at line 45 of file ChatSdpAttributeParser.cpp.

00046         {
00047         // No implementation needed     
00048         }


Member Function Documentation

TBool TChatSdpAttributeParser::HasFinished (   )  const
 

HasFinished Check if parsing processed the whole list

Returns:
true is the index refers to the EFinished node

Definition at line 55 of file ChatSdpAttributeParser.cpp.

References TChatSdpAttributeParser::TChatSdpAttributeNode::Command(), and iCurrentNode.

00056     {
00057     return ( iCurrentNode.Command() == EFinished );
00058     }

void TChatSdpAttributeParser::VisitAttributeValueL (  CSdpAttrValue &  aValue,
TSdpElementType  aType
) 
 

VisitAttributeValueL Process a data element

Parameters:
aValue the data element
aType the type of the data element

Definition at line 65 of file ChatSdpAttributeParser.cpp.

References CheckTypeL(), CheckValueL(), TChatSdpAttributeParser::TChatSdpAttributeNode::Command(), iCurrentNode, and ReadValueL().

00067     {
00068     switch ( iCurrentNode.Command() )
00069         {
00070         case ECheckType:
00071             CheckTypeL( aType );
00072             break;
00073 
00074         case ECheckValue:
00075             CheckTypeL( aType );
00076             CheckValueL( aValue );
00077             break;
00078 
00079         case ECheckEnd:
00080             User::Leave( KErrTooBig ); //list element contains too many items
00081             break;
00082 
00083         case ESkip:
00084             break;  // no checking required
00085 
00086         case EReadValue:
00087             CheckTypeL( aType );
00088             ReadValueL( aValue );
00089             break;
00090 
00091         case EFinished:
00092             User::Leave( KErrEof ); // element is after 
00093             return;                     // value should have ended
00094 
00095         default:
00096             Panic( EChatSdpAttributeParserInvalidCommand );
00097         }
00098 
00099     AdvanceL();
00100     }

void TChatSdpAttributeParser::StartListL (  CSdpAttrValueList &  aList  ) 
 

StartListL Process the start of a data element list

Parameters:
aList the data element list

Definition at line 107 of file ChatSdpAttributeParser.cpp.

00108     {
00109     // no checks done here
00110     }

void TChatSdpAttributeParser::EndListL (   ) 
 

EndListL Process the end of a data element list

Definition at line 117 of file ChatSdpAttributeParser.cpp.

References TChatSdpAttributeParser::TChatSdpAttributeNode::Command(), and iCurrentNode.

00118     {
00119     // check we are at the end of a list
00120     if ( iCurrentNode.Command() != ECheckEnd )
00121         {
00122         User::Leave( KErrGeneral );
00123         }
00124 
00125     AdvanceL();
00126     }

void TChatSdpAttributeParser::CheckTypeL (  TSdpElementType  aElementType  )  const [private]
 

CheckTypeL Check the type of the current node is the same as the specified type.

Parameters:
aElementType the type of the current data element

Definition at line 133 of file ChatSdpAttributeParser.cpp.

References iCurrentNode, and TChatSdpAttributeParser::TChatSdpAttributeNode::Type().

00134     {
00135     if ( iCurrentNode.Type() != aElementType )
00136         {
00137         User::Leave( KErrGeneral );
00138         }
00139     }

void TChatSdpAttributeParser::CheckValueL (  CSdpAttrValue &  aValue  )  const [private]
 

CheckValueL Check the value of the current node is the same as the specified value

Parameters:
aValue the value of the current data element.

Definition at line 146 of file ChatSdpAttributeParser.cpp.

References iCurrentNode, and TChatSdpAttributeParser::TChatSdpAttributeNode::Value().

00147     {
00148     switch ( aValue.Type() )
00149         {
00150         case ETypeNil:
00151             Panic( EChatSdpAttributeParserNoValue );
00152             break;
00153 
00154         case ETypeUint:
00155             if ( aValue.Uint() != ( TUint ) iCurrentNode.Value() )
00156                 {
00157                 User::Leave( KErrArgument );
00158                 }
00159             break;
00160 
00161         case ETypeInt:
00162             if ( aValue.Int() != iCurrentNode.Value() )
00163                 {
00164                 User::Leave( KErrArgument );
00165                 }
00166             break;
00167 
00168         case ETypeBoolean:
00169             if ( aValue.Bool() != iCurrentNode.Value() )
00170                 {
00171                 User::Leave( KErrArgument );
00172                 }
00173             break;
00174 
00175         case ETypeUUID:
00176             if ( aValue.UUID() != TUUID( iCurrentNode.Value() ) )
00177                 {
00178                 User::Leave( KErrArgument );
00179                 }
00180             break;
00181 
00182         case ETypeDES:
00183         case ETypeDEA:
00184             Panic( EChatSdpAttributeParserValueIsList );
00185             break;
00186 
00187         default:
00188             Panic( EChatSdpAttributeParserValueTypeUnsupported );
00189             break;
00190         }
00191     }

void TChatSdpAttributeParser::ReadValueL (  CSdpAttrValue &  aValue  )  const [private]
 

ReadValueL Pass the data element value to the observer

Parameters:
aValue the value of the current data element.

Definition at line 198 of file ChatSdpAttributeParser.cpp.

References MChatSdpAttributeNotifier::FoundElementL(), iCurrentNode, iObserver, and TChatSdpAttributeParser::TChatSdpAttributeNode::Value().

00199     {
00200     iObserver.FoundElementL( iCurrentNode.Value(), aValue );
00201     }

void TChatSdpAttributeParser::AdvanceL (   )  [private]
 

AdvanceL Advance to the next node. Leaves with KErrEof if at the finished node.

Definition at line 208 of file ChatSdpAttributeParser.cpp.

References TChatSdpAttributeParser::TChatSdpAttributeNode::Command(), and iCurrentNode.

00209     {
00210     // check not at end
00211     if ( iCurrentNode.Command() == EFinished )
00212         {
00213         User::Leave( KErrEof );
00214         }
00215 
00216     // move to the next item
00217     iCurrentNode = iNodeList[++iCurrentNodeIndex];
00218     }


Member Data Documentation

MChatSdpAttributeNotifier& TChatSdpAttributeParser::iObserver [private]
 

iObserver the observer to read values

Definition at line 225 of file ChatSdpAttributeParser.h.

RArray<TChatSdpAttributeParser::TChatSdpAttributeNode>& TChatSdpAttributeParser::iNodeList [private]
 

iNodeList a list defining the expected structure of the value

Definition at line 231 of file ChatSdpAttributeParser.h.

TInt TChatSdpAttributeParser::iCurrentNodeIndex [private]
 

iCurrentNodeIndex the index of the current node in iNodeList

Definition at line 236 of file ChatSdpAttributeParser.h.

TChatSdpAttributeNode TChatSdpAttributeParser::iCurrentNode [private]
 

iCurrentNode the current node

Definition at line 241 of file ChatSdpAttributeParser.h.


© Nokia 2006

Back to top