|
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 // XPath evaluation context declaration |
|
15 // |
|
16 |
|
17 |
|
18 |
|
19 /** |
|
20 @file |
|
21 @internalComponent |
|
22 @released |
|
23 */ |
|
24 #ifndef XMLENGXPATHEVALCTXT_IMPL_H |
|
25 #define XMLENGXPATHEVALCTXT_IMPL_H |
|
26 |
|
27 #include <xml/dom/xmlengxpathevaluationcontext.h> |
|
28 #include <libxml2_xpathinternals.h> |
|
29 |
|
30 /** |
|
31 * XPath evaluation context |
|
32 * |
|
33 */ |
|
34 class TXmlEngXPathEvaluationContextImpl: public MXmlEngXPathEvaluationContext |
|
35 { |
|
36 public: |
|
37 /** |
|
38 * Constructor |
|
39 * |
|
40 * @param aContext Pointer to XPath parser context |
|
41 * @param aArgCount Number of arguments |
|
42 */ |
|
43 TXmlEngXPathEvaluationContextImpl(xmlXPathParserContextPtr aContext, TUint aArgCount) |
|
44 : iContext(aContext), |
|
45 iArgCount(aArgCount), |
|
46 iCurrentResult(NULL), |
|
47 iOOM(EFalse) {} |
|
48 |
|
49 /** |
|
50 * Get number of arguments provided |
|
51 * |
|
52 * @return Number of arguments provided |
|
53 * |
|
54 * @note |
|
55 * The implementation of extension function should not check |
|
56 * that ArgCount() returns value in the range [ MinArity() ; MaxArity() ] |
|
57 * - the function is called iif the statement holds:<br> |
|
58 * <b>MinArity()</b> =< <i>arg.count</i> =< <b>MaxArity()</b> |
|
59 */ |
|
60 TUint ArgCount(); |
|
61 |
|
62 /** |
|
63 * Retrieves arguments by index (zero-based) |
|
64 * |
|
65 * @return N-th argument of the function |
|
66 * |
|
67 * @note |
|
68 * - Argument index starts at 0 |
|
69 * - Returned result should not be freed |
|
70 */ |
|
71 const RXmlEngXPathResult Argument(TUint aIndex); |
|
72 |
|
73 /** |
|
74 * Get the result written so far. |
|
75 * |
|
76 * @return Result evaluated by the function so far. |
|
77 * |
|
78 * Initially, function result is undefined. It can be changed |
|
79 * by SetResult() functions for a boolean, string or number values |
|
80 * or by combined use of InitializeNodeSetResult() and AppendToResult() methods |
|
81 */ |
|
82 const RXmlEngXPathResult Result(); |
|
83 |
|
84 /** |
|
85 * Sets a NODESET type of the result (floating-point number): an empty |
|
86 * instance of NodeSet is created. |
|
87 * |
|
88 * The node set is to be filled up by methods AppendToResult(TXmlEngNode) and AppendToResult(RXmlEngNodeSet) |
|
89 * This method replaces any existing prepared result so far |
|
90 * (even an initialized already node set) |
|
91 * @see AppendToResult(TXmlEngNode), AppendToResult(RXmlEngNodeSet) |
|
92 * |
|
93 */ |
|
94 void InitializeNodeSetResult(); |
|
95 |
|
96 /** |
|
97 * Appends a node to the node set result. |
|
98 * @note InitializeNodeSetResult() should be called prior any call to |
|
99 * AppendToResult(TXmlEngNode) or AppendToResult(RXmlEngNodeSet) |
|
100 * |
|
101 * @param aNode Node that should be add |
|
102 */ |
|
103 void AppendToResult(const TXmlEngNode aNode); |
|
104 void AppendToResult(const TXmlEngNamespace aAppendedNsNode, const TXmlEngElement aNsParentNode); |
|
105 /** |
|
106 * Appends a node set to the node set result. Nodes are merged into resulting node set. |
|
107 * @note InitializeNodeSetResult() should be called prior any call to |
|
108 * AppendToResult(TXmlEngNode) or AppendToResult(RXmlEngNodeSet) |
|
109 * |
|
110 * @param aNodeSet Nodes that should be add |
|
111 */ |
|
112 void AppendToResult(const RXmlEngNodeSet aNodeSet); |
|
113 |
|
114 /** |
|
115 * Sets a NUMBER type of the result (a floating-point number) |
|
116 * |
|
117 * @param aNumber New number |
|
118 */ |
|
119 void SetResult(TReal aNumber); |
|
120 |
|
121 /** |
|
122 * Sets a BOOLEAN type of the result |
|
123 * |
|
124 * @param aBoolean New value |
|
125 */ |
|
126 void SetResult(TBool aBoolean); |
|
127 |
|
128 /** |
|
129 * Sets a STRING type of the result |
|
130 * |
|
131 * @param aString New string value |
|
132 */ |
|
133 void SetResultL(const TDesC8& aString); |
|
134 |
|
135 /** |
|
136 * Gets data specified in RXmlEngXPathExpression::SetExtendedContext(void*) method |
|
137 * for the expression currently being evaluated. |
|
138 * |
|
139 */ |
|
140 void* ExtendedContext(); |
|
141 |
|
142 /** |
|
143 * Allocates memory for function result |
|
144 * |
|
145 * @return TRUE is succeeded, FALSE if OOM has happened |
|
146 */ |
|
147 TBool Initialize(); |
|
148 |
|
149 private: |
|
150 /** XPath parser */ |
|
151 xmlXPathParserContextPtr iContext; |
|
152 /** Arguments count */ |
|
153 TUint iArgCount; |
|
154 /** XPath object */ |
|
155 xmlXPathObjectPtr iCurrentResult; |
|
156 /** OOM flag */ |
|
157 TBool iOOM; |
|
158 }; |
|
159 |
|
160 #endif /* XMLENGXPATHEVALCTXT_IMPL_H */ |