williamr@4
|
1 |
// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@4
|
2 |
// All rights reserved.
|
williamr@4
|
3 |
// This component and the accompanying materials are made available
|
williamr@4
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
williamr@4
|
5 |
// which accompanies this distribution, and is available
|
williamr@4
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
williamr@4
|
7 |
//
|
williamr@4
|
8 |
// Initial Contributors:
|
williamr@4
|
9 |
// Nokia Corporation - initial contribution.
|
williamr@4
|
10 |
//
|
williamr@4
|
11 |
// Contributors:
|
williamr@4
|
12 |
//
|
williamr@4
|
13 |
// Description:
|
williamr@4
|
14 |
// Result of XPath expression
|
williamr@4
|
15 |
//
|
williamr@4
|
16 |
|
williamr@4
|
17 |
|
williamr@4
|
18 |
|
williamr@4
|
19 |
/**
|
williamr@4
|
20 |
@file
|
williamr@4
|
21 |
@publishedAll
|
williamr@4
|
22 |
@released
|
williamr@4
|
23 |
*/
|
williamr@4
|
24 |
#ifndef XMLENGXPATHRESULT_H
|
williamr@4
|
25 |
#define XMLENGXPATHRESULT_H
|
williamr@4
|
26 |
|
williamr@4
|
27 |
#include <xml/dom/xmlengnodeset.h>
|
williamr@4
|
28 |
|
williamr@4
|
29 |
/**
|
williamr@4
|
30 |
Represents the result of a XPath expression.
|
williamr@4
|
31 |
|
williamr@4
|
32 |
The result may be one of the standard types: string, boolean, number (float),
|
williamr@4
|
33 |
node set or be undefined in the case of error.
|
williamr@4
|
34 |
|
williamr@4
|
35 |
The returned result should be freed after use.
|
williamr@4
|
36 |
*/
|
williamr@4
|
37 |
class RXmlEngXPathResult
|
williamr@4
|
38 |
{
|
williamr@4
|
39 |
friend class RXmlEngXPathExpression;
|
williamr@4
|
40 |
friend class TXmlEngXPathEvaluationContextImpl;
|
williamr@4
|
41 |
|
williamr@4
|
42 |
public:
|
williamr@4
|
43 |
/**
|
williamr@4
|
44 |
Result types of a XPath expression.
|
williamr@4
|
45 |
See http://w3.org/TR/xpath#section-Introduction
|
williamr@4
|
46 |
*/
|
williamr@4
|
47 |
enum TXmlEngXPathResultType
|
williamr@4
|
48 |
{
|
williamr@4
|
49 |
EUndefined = 0,
|
williamr@4
|
50 |
ENodeset = 1,
|
williamr@4
|
51 |
EBoolean = 2,
|
williamr@4
|
52 |
ENumber = 3,
|
williamr@4
|
53 |
EString = 4
|
williamr@4
|
54 |
//Other node types defined in XPath are not supported.
|
williamr@4
|
55 |
} ;
|
williamr@4
|
56 |
|
williamr@4
|
57 |
public:
|
williamr@4
|
58 |
/** Default constructor */
|
williamr@4
|
59 |
IMPORT_C RXmlEngXPathResult();
|
williamr@4
|
60 |
|
williamr@4
|
61 |
/** Frees any allocated memory */
|
williamr@4
|
62 |
IMPORT_C void Free();
|
williamr@4
|
63 |
|
williamr@4
|
64 |
/** Frees any allocated memory */
|
williamr@4
|
65 |
inline void Close();
|
williamr@4
|
66 |
|
williamr@4
|
67 |
/**
|
williamr@4
|
68 |
Retrieves the type of the result (e.g. boolean, number, string, etc.).
|
williamr@4
|
69 |
The type of a result should always be checked before using the result.
|
williamr@4
|
70 |
|
williamr@4
|
71 |
If there was an error and no value was set, undefined is returned.
|
williamr@4
|
72 |
Otherwise nodeset is returned.
|
williamr@4
|
73 |
|
williamr@4
|
74 |
@return Type of result.
|
williamr@4
|
75 |
|
williamr@4
|
76 |
@see TXmlEngXPathResultType
|
williamr@4
|
77 |
*/
|
williamr@4
|
78 |
IMPORT_C TXmlEngXPathResultType Type() const;
|
williamr@4
|
79 |
|
williamr@4
|
80 |
/**
|
williamr@4
|
81 |
Retrieves a node-set result. A Non-RXmlEngNodeSet result will return NULL.
|
williamr@4
|
82 |
No conversion is done from other types.
|
williamr@4
|
83 |
|
williamr@4
|
84 |
For more information no NULL nodes:
|
williamr@4
|
85 |
@see TXmlEngNode
|
williamr@4
|
86 |
|
williamr@4
|
87 |
@return Node-set result
|
williamr@4
|
88 |
*/
|
williamr@4
|
89 |
IMPORT_C RXmlEngNodeSet AsNodeSet() const;
|
williamr@4
|
90 |
|
williamr@4
|
91 |
/**
|
williamr@4
|
92 |
Retrieves a string copy of result.
|
williamr@4
|
93 |
@param A buffer allocated by the caller that holds the result string
|
williamr@4
|
94 |
@leave KErrNoMemory if out of memory situation occurs.
|
williamr@4
|
95 |
@leave - Otherwise any of the system wide errors.
|
williamr@4
|
96 |
*/
|
williamr@4
|
97 |
IMPORT_C void AsStringL(RBuf8& aOutput) const;
|
williamr@4
|
98 |
|
williamr@4
|
99 |
/**
|
williamr@4
|
100 |
Retrieves a numeric value result. Conversion can occur from other types.
|
williamr@4
|
101 |
|
williamr@4
|
102 |
Node sets, strings, and booleans will be cast to numbers. Anything else
|
williamr@4
|
103 |
will return NAN (i.e. not a number).
|
williamr@4
|
104 |
|
williamr@4
|
105 |
@return Numeric value of the result.
|
williamr@4
|
106 |
|
williamr@4
|
107 |
@see Math
|
williamr@4
|
108 |
*/
|
williamr@4
|
109 |
IMPORT_C TReal AsNumber() const;
|
williamr@4
|
110 |
|
williamr@4
|
111 |
/**
|
williamr@4
|
112 |
Retrieves a boolean result. Conversion can occur from other types.
|
williamr@4
|
113 |
|
williamr@4
|
114 |
Numbers will be returned as true unless it is not a number or 0.0.
|
williamr@4
|
115 |
A string of 0 length will return false, otherwise true.
|
williamr@4
|
116 |
If the node exists it will be returned as true, otherwise false.
|
williamr@4
|
117 |
|
williamr@4
|
118 |
@return Boolean value of the result
|
williamr@4
|
119 |
*/
|
williamr@4
|
120 |
IMPORT_C TBool AsBoolean() const;
|
williamr@4
|
121 |
|
williamr@4
|
122 |
private:
|
williamr@4
|
123 |
/**
|
williamr@4
|
124 |
Constructor
|
williamr@4
|
125 |
@param aData Internal representation of XPath result
|
williamr@4
|
126 |
*/
|
williamr@4
|
127 |
RXmlEngXPathResult(void* aData);
|
williamr@4
|
128 |
|
williamr@4
|
129 |
private:
|
williamr@4
|
130 |
void* iInternal;
|
williamr@4
|
131 |
};
|
williamr@4
|
132 |
|
williamr@4
|
133 |
#include <xml/dom/xmlengxpathresult.inl>
|
williamr@4
|
134 |
|
williamr@4
|
135 |
#endif /* XMLENGXPATHRESULT_H */
|
williamr@4
|
136 |
|