|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __SDP_ATTRIBUTE_PARSER_H__ |
|
20 #define __SDP_ATTRIBUTE_PARSER_H__ |
|
21 |
|
22 #include <btsdp.h> |
|
23 #include "StaticArrayC.h" |
|
24 |
|
25 class MSdpAttributeNotifier; |
|
26 |
|
27 /*! |
|
28 @class TSdpAttributeParser |
|
29 |
|
30 @discussion An instance of TSdpAttributeParser is used to check an SDP |
|
31 attribute value, and read selected parts |
|
32 */ |
|
33 class TSdpAttributeParser : public MSdpAttributeValueVisitor |
|
34 { |
|
35 public: |
|
36 |
|
37 /*! |
|
38 @enum TNodeCommand |
|
39 |
|
40 @discussion The command to be carried out at a node |
|
41 @value ECheckType check the type of the value |
|
42 @value ECheckValue check the type and the value |
|
43 @value ECheckEnd check that a list ends at this point |
|
44 @value ESkip do not check this value - can not match a list end |
|
45 @value EReadValue pass the value onto the observer |
|
46 @value EFinished marks the end of the node list |
|
47 */ |
|
48 enum TNodeCommand |
|
49 { |
|
50 ECheckType, |
|
51 ECheckValue, |
|
52 ECheckEnd, |
|
53 ESkip, |
|
54 EReadValue, |
|
55 EFinished |
|
56 }; |
|
57 |
|
58 /*! |
|
59 struct SSdpAttributeNode |
|
60 |
|
61 @discussion An instance of SSdpAttributeNode is used to determine how |
|
62 to parse an SDP attribute value data element |
|
63 */ |
|
64 struct SSdpAttributeNode |
|
65 { |
|
66 /*! @var iCommand the command for the node */ |
|
67 TNodeCommand iCommand; |
|
68 |
|
69 /*! @var iType the expected type */ |
|
70 TSdpElementType iType; |
|
71 |
|
72 /*! @var iValue the expected value for ECheckValue, the value of aKey |
|
73 passed to the observer for EReadValue */ |
|
74 TInt iValue; |
|
75 }; |
|
76 |
|
77 typedef const TStaticArrayC<SSdpAttributeNode> TSdpAttributeList; |
|
78 |
|
79 /*! |
|
80 @function TSdpAttributeParser |
|
81 |
|
82 @discussion Construct a TSdpAttributeParser |
|
83 @param aNodeList the list of expected nodes |
|
84 @param aObserver an observer to read specified node values |
|
85 */ |
|
86 TSdpAttributeParser(TSdpAttributeList& aNodeList, MSdpAttributeNotifier& aObserver); |
|
87 |
|
88 /*! |
|
89 @function HasFinished |
|
90 |
|
91 @discussion Check if parsing processed the whole list |
|
92 @result true is the index refers to the EFinished node |
|
93 */ |
|
94 TBool HasFinished() const; |
|
95 |
|
96 public: // from MSdpAttributeValueVisitor |
|
97 |
|
98 /*! |
|
99 @function VisitAttributeValueL |
|
100 |
|
101 @discussion Process a data element |
|
102 @param aValue the data element |
|
103 @param aType the type of the data element |
|
104 */ |
|
105 void VisitAttributeValueL(CSdpAttrValue& aValue, TSdpElementType aType); |
|
106 |
|
107 /*! |
|
108 @function StartListL |
|
109 |
|
110 @discussion Process the start of a data element list |
|
111 @param aList the data element list |
|
112 */ |
|
113 void StartListL(CSdpAttrValueList& aList); |
|
114 |
|
115 /*! |
|
116 @function EndListL |
|
117 |
|
118 @discussion Process the end of a data element list |
|
119 */ |
|
120 void EndListL(); |
|
121 |
|
122 private: |
|
123 |
|
124 /*! |
|
125 @function CheckTypeL |
|
126 |
|
127 @discussion Check the type of the current node is the same as the specified type |
|
128 @param aElementType the type of the current data element |
|
129 */ |
|
130 void CheckTypeL(TSdpElementType aElementType) const; |
|
131 |
|
132 /*! |
|
133 @function CheckValueL |
|
134 |
|
135 @discussion Check the value of the current node is the same as the specified value |
|
136 @param aValue the value of the current data element. |
|
137 */ |
|
138 void CheckValueL(CSdpAttrValue& aValue) const; |
|
139 |
|
140 /*! |
|
141 @function ReadValueL |
|
142 |
|
143 @discussion Pass the data element value to the observer |
|
144 @param aValue the value of the current data element. |
|
145 */ |
|
146 void ReadValueL(CSdpAttrValue& aValue) const; |
|
147 |
|
148 /*! |
|
149 @function CurrentNode |
|
150 |
|
151 @discussion Get the current node |
|
152 @result the current node |
|
153 */ |
|
154 const SSdpAttributeNode& CurrentNode() const; |
|
155 |
|
156 /*! |
|
157 @function AdvanceL |
|
158 |
|
159 @discussion Advance to the next node. Leaves with KErrEof if at the finished node. |
|
160 */ |
|
161 void AdvanceL(); |
|
162 |
|
163 private: |
|
164 |
|
165 /*! @var iObserver the observer to read values */ |
|
166 MSdpAttributeNotifier& iObserver; |
|
167 |
|
168 /*! @var iNodeList a list defining the expected structure of the value */ |
|
169 TSdpAttributeList& iNodeList; |
|
170 |
|
171 /*! @var iCurrentNodeIndex the index of the current node in iNodeList */ |
|
172 TInt iCurrentNodeIndex; |
|
173 }; |
|
174 |
|
175 #endif // __SDP_ATTRIBUTE_PARSER_H__ |