|
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 interface |
|
15 // |
|
16 |
|
17 |
|
18 |
|
19 /** |
|
20 @file |
|
21 @publishedAll |
|
22 @released |
|
23 */ |
|
24 #ifndef XMLENGXPATHEVALCTXT_H |
|
25 #define XMLENGXPATHEVALCTXT_H |
|
26 |
|
27 #include <xml/dom/xmlengxpathresult.h> |
|
28 #include <xml/dom/xmlengelement.h> |
|
29 |
|
30 /** |
|
31 Provides the XPath evaluation context interface. An object of this type |
|
32 provides the argument values to an extension function to be evalutated |
|
33 and stores the result of evalutation. |
|
34 |
|
35 @see MXmlEngXPathExtensionFunction |
|
36 @see MXmlEngXPathExtensionFunction::Evaluate() |
|
37 |
|
38 Objects of this type are not registered with the XPath library and must |
|
39 be destroyed by their owner. |
|
40 |
|
41 Any memory allocated by this object must be freed when the object is |
|
42 destroyed. |
|
43 */ |
|
44 class MXmlEngXPathEvaluationContext |
|
45 { |
|
46 public: |
|
47 /** |
|
48 Gets the number of arguments provided. |
|
49 @return The number of arguments provided |
|
50 */ |
|
51 virtual TUint ArgCount() = 0; |
|
52 |
|
53 /** |
|
54 Gets an argument by index. Does not transfer ownership. Index starts at 0. |
|
55 @pre 0 <= aIndex < ArgCount(). Function panics if precondition not met. |
|
56 @return The n-th argument of the function |
|
57 */ |
|
58 virtual const RXmlEngXPathResult Argument(TUint aIndex) = 0; |
|
59 |
|
60 /** |
|
61 Gets the result written so far. The result is undefined before SetResult(), |
|
62 InitializeNodeSetResult() or AppendToResult() have been called. |
|
63 |
|
64 @pre SetResult() or InitializeNodeSetResult() and AppendToResult() have |
|
65 been previously called. |
|
66 @return The result evaluated by the function so far. |
|
67 */ |
|
68 virtual const RXmlEngXPathResult Result() = 0; |
|
69 |
|
70 /** |
|
71 Sets the type of result to node set and initializes a new node set. Any |
|
72 existing result node set is replaced. |
|
73 |
|
74 @see AppendToResult(const TXmlEngNode) |
|
75 @see AppendToResult(const RXmlEngNodeSet) |
|
76 @see AppendToResult(const TXmlEngNamespace, const TXmlEngElement) |
|
77 */ |
|
78 virtual void InitializeNodeSetResult() = 0; |
|
79 |
|
80 /** |
|
81 Appends a node to the node set result. InitializeNodeSetResult() should be |
|
82 called prior to the first call to an AppendToResult() method. |
|
83 |
|
84 This method will return and do nothing if a previous OOM condition in the |
|
85 underlying libxml2 library has not been cleared. See libxml2_modules.h. |
|
86 |
|
87 @pre OOM_FLAG==0, otherwise method returns and does nothing. |
|
88 @param aNode Node to be added |
|
89 */ |
|
90 virtual void AppendToResult(const TXmlEngNode aNode) = 0; |
|
91 |
|
92 /** |
|
93 Appends a namespace node to the node set result. InitializeNodeSetResult() |
|
94 should be called prior to the first call to an AppendToResult() method. |
|
95 |
|
96 A namespace node is the representation of an existing namespace declaration |
|
97 within an element node. This function cannot be used to add a new namespace |
|
98 declaration, rather it adds an existing namespace declaration attached to |
|
99 aNsParentNode. |
|
100 |
|
101 @see TXmlEngNamespace |
|
102 |
|
103 This method will return and do nothing if a previous OOM condition in the |
|
104 underlying libxml2 library has not been cleared. See libxml2_modules.h. |
|
105 |
|
106 @pre OOM_FLAG==0, otherwise method returns and does nothing. |
|
107 @param aAppendedNsNode A namspace node to add to the node set result. |
|
108 @param aNsParentNode An element node that holds the namespace declaration |
|
109 represented by aAppendedNsNode. |
|
110 */ |
|
111 virtual void AppendToResult(const TXmlEngNamespace aAppendedNsNode, |
|
112 const TXmlEngElement aNsParentNode) = 0; |
|
113 |
|
114 /** |
|
115 Appends a node set to the node set result. Nodes are merged into a |
|
116 resulting node set. InitializeNodeSetResult() should be called prior to |
|
117 the first call to an AppendToResult() method. |
|
118 |
|
119 This method will return and do nothing if a previous OOM condition in the |
|
120 underlying libxml2 library has not been cleared. See libxml2_modules.h. |
|
121 |
|
122 @pre OOM_FLAG==0, otherwise method returns and does nothing. |
|
123 @param aNodeSet The node set to be appended |
|
124 */ |
|
125 virtual void AppendToResult(const RXmlEngNodeSet aNodeSet) = 0; |
|
126 |
|
127 /** |
|
128 Sets the type of result to floating point number and stores the number as |
|
129 the result. |
|
130 @param aNumber The number to store as the result |
|
131 */ |
|
132 virtual void SetResult(TReal aNumber) = 0; |
|
133 |
|
134 /** |
|
135 Sets the type of result to boolean and stores the value as the result. |
|
136 @param aBoolean The value to store as the result |
|
137 */ |
|
138 virtual void SetResult(TBool aBoolean) = 0; |
|
139 |
|
140 /** |
|
141 Sets the type of result to string and stores the string as the result. |
|
142 @param aString The string to store as the result |
|
143 */ |
|
144 virtual void SetResultL(const TDesC8& aString) = 0; |
|
145 |
|
146 /** |
|
147 Gets the data specified in RXmlEngXPathExpression::SetExtendedContext() |
|
148 for the expression currently being evaluated. |
|
149 */ |
|
150 virtual void* ExtendedContext() = 0; |
|
151 }; |
|
152 |
|
153 #endif /* XMLENGXPATHEVALCTXT_H */ |
|
154 |