1 /* |
|
2 * Copyright (c) 2009 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: Reads selected parts of SDP attribute values. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __SDP_ATTRIBUTE_PARSER_H__ |
|
20 #define __SDP_ATTRIBUTE_PARSER_H__ |
|
21 |
|
22 // INCLUDES |
|
23 #include <btsdp.h> |
|
24 #include "staticarrayc.h" |
|
25 |
|
26 // FORWARD DECLARATIONS |
|
27 class MSdpAttributeNotifier; |
|
28 |
|
29 // CLASS DECLARATIONS |
|
30 /** |
|
31 * TSdpAttributeParser |
|
32 * An instance of TSdpAttributeParser is used to check an SDP |
|
33 * attribute value, and read selected parts |
|
34 */ |
|
35 class TSdpAttributeParser : public MSdpAttributeValueVisitor |
|
36 { |
|
37 public: // Enumerations |
|
38 |
|
39 /** |
|
40 * TNodeCommand |
|
41 * The command to be carried out at a node |
|
42 * ECheckType. Check the type of the value |
|
43 * ECheckValue. Check the type and the value |
|
44 * ECheckEnd. Check that a list ends at this point |
|
45 * ESkip. Do not check this value - can not match a list end |
|
46 * EReadValue. Pass the value onto the observer |
|
47 * EFinished. Marks the end of the node list |
|
48 */ |
|
49 enum TNodeCommand |
|
50 { |
|
51 ECheckType, |
|
52 ECheckValue, |
|
53 ECheckEnd, |
|
54 ESkip, |
|
55 EReadValue, |
|
56 EFinished |
|
57 }; |
|
58 |
|
59 /** |
|
60 * SSdpAttributeNode |
|
61 * An instance of SSdpAttributeNode is used to determine how |
|
62 * to parse an SDP attribute value data element |
|
63 */ |
|
64 struct SSdpAttributeNode |
|
65 { |
|
66 /** iCommand the command for the node */ |
|
67 TNodeCommand iCommand; |
|
68 |
|
69 /** iType the expected type */ |
|
70 TSdpElementType iType; |
|
71 |
|
72 /** iValue the expected value for ECheckValue,the value of aKey |
|
73 * passed to the observer for EReadValue |
|
74 */ |
|
75 TInt iValue; |
|
76 }; |
|
77 |
|
78 typedef const TStaticArrayC< SSdpAttributeNode > TSdpAttributeList; |
|
79 |
|
80 /** |
|
81 * TSdpAttributeParser |
|
82 * 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, |
|
87 MSdpAttributeNotifier& aObserver ); |
|
88 |
|
89 /** |
|
90 * HasFinished |
|
91 * Check if parsing processed the whole list |
|
92 * @return true is the index refers to the EFinished node |
|
93 */ |
|
94 TBool HasFinished() const; |
|
95 |
|
96 public: // from MSdpAttributeValueVisitor |
|
97 |
|
98 /** |
|
99 * VisitAttributeValueL |
|
100 * Process a data element |
|
101 * @param aValue the data element |
|
102 * @param aType the type of the data element |
|
103 */ |
|
104 void VisitAttributeValueL( CSdpAttrValue& aValue, |
|
105 TSdpElementType aType ); |
|
106 |
|
107 /** |
|
108 * StartListL |
|
109 * Process the start of a data element list |
|
110 * @param aList the data element list |
|
111 */ |
|
112 void StartListL( CSdpAttrValueList& aList ); |
|
113 |
|
114 /** |
|
115 * EndListL |
|
116 * Process the end of a data element list |
|
117 */ |
|
118 void EndListL(); |
|
119 |
|
120 private: // Functions from base classes |
|
121 |
|
122 /** |
|
123 * CheckTypeL |
|
124 * Check the type of the current node is the same as |
|
125 * the specified type. |
|
126 * @param aElementType the type of the current data element |
|
127 */ |
|
128 void CheckTypeL( TSdpElementType aElementType ) const; |
|
129 |
|
130 /** |
|
131 * CheckValueL |
|
132 * Check the value of the current node is the same as the specified value |
|
133 * @param aValue the value of the current data element. |
|
134 */ |
|
135 void CheckValueL( CSdpAttrValue& aValue ) const; |
|
136 |
|
137 /** |
|
138 * ReadValueL |
|
139 * Pass the data element value to the observer |
|
140 * @param aValue the value of the current data element. |
|
141 */ |
|
142 void ReadValueL( CSdpAttrValue& aValue ) const; |
|
143 |
|
144 /** |
|
145 * CurrentNode |
|
146 * Get the current node |
|
147 * @return the current node |
|
148 */ |
|
149 const SSdpAttributeNode& CurrentNode() const; |
|
150 |
|
151 /** |
|
152 * AdvanceL |
|
153 * Advance to the next node. Leaves with KErrEof |
|
154 * if at the finished node. |
|
155 */ |
|
156 void AdvanceL(); |
|
157 |
|
158 private: // data |
|
159 |
|
160 /** iObserver the observer to read values */ |
|
161 MSdpAttributeNotifier& iObserver; |
|
162 |
|
163 /** iNodeList a list defining the expected |
|
164 * structure of the value |
|
165 */ |
|
166 TSdpAttributeList& iNodeList; |
|
167 |
|
168 /** iCurrentNodeIndex the index of the current node in iNodeList */ |
|
169 TInt iCurrentNodeIndex; |
|
170 }; |
|
171 |
|
172 #endif // __SDP_ATTRIBUTE_PARSER_H__ |
|
173 |
|
174 // End of File |
|