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 |
// XPath Utils
|
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 XMLENGXPATHUTILS_H
|
williamr@4
|
25 |
#define XMLENGXPATHUTILS_H
|
williamr@4
|
26 |
|
williamr@4
|
27 |
#include <xml/dom/xmlengnodeset.h>
|
williamr@4
|
28 |
|
williamr@4
|
29 |
/**
|
williamr@4
|
30 |
Implements utility functions such as conversion methods for XPath objects.
|
williamr@4
|
31 |
|
williamr@4
|
32 |
The XPath specification considers a node result as a set of only one node,
|
williamr@4
|
33 |
however, in this API it is possible to perform conversion routines
|
williamr@4
|
34 |
directly on nodes.
|
williamr@4
|
35 |
*/
|
williamr@4
|
36 |
class XmlEngXPathUtils
|
williamr@4
|
37 |
{
|
williamr@4
|
38 |
public:
|
williamr@4
|
39 |
/**
|
williamr@4
|
40 |
Converts node to number
|
williamr@4
|
41 |
@param aNode Node to be converted
|
williamr@4
|
42 |
@return The number represented by the node or NaN if cannot convert.
|
williamr@4
|
43 |
@leave KErrNoMemory Memory allocation failure
|
williamr@4
|
44 |
*/
|
williamr@4
|
45 |
IMPORT_C static TReal ToNumberL(const TXmlEngNode& aNode);
|
williamr@4
|
46 |
|
williamr@4
|
47 |
/**
|
williamr@4
|
48 |
Converts a node-set to a number by taking the node in the node set that
|
williamr@4
|
49 |
appears first in the document and converting that to a number.
|
williamr@4
|
50 |
|
williamr@4
|
51 |
@param aNodeSet Node-set to be converted
|
williamr@4
|
52 |
@return The number represented by the node set or NaN if cannot convert.
|
williamr@4
|
53 |
@leave KErrNoMemory Memory allocation failure
|
williamr@4
|
54 |
*/
|
williamr@4
|
55 |
IMPORT_C static TReal ToNumberL(const RXmlEngNodeSet& aNodeSet);
|
williamr@4
|
56 |
|
williamr@4
|
57 |
/**
|
williamr@4
|
58 |
Converts TBool value to TReal
|
williamr@4
|
59 |
@param aValue TBool value to be converted
|
williamr@4
|
60 |
@return 1.0 if ETrue and 0.0 otherwise
|
williamr@4
|
61 |
@leave - Does not leave
|
williamr@4
|
62 |
*/
|
williamr@4
|
63 |
IMPORT_C static TReal ToNumberL(TBool aValue);
|
williamr@4
|
64 |
|
williamr@4
|
65 |
/**
|
williamr@4
|
66 |
Converts a string to a number
|
williamr@4
|
67 |
@param aString String to be converted
|
williamr@4
|
68 |
@return The number respresented by the string or NaN if cannot convert.
|
williamr@4
|
69 |
@leave KErrNoMemory Memory allocation failure
|
williamr@4
|
70 |
*/
|
williamr@4
|
71 |
IMPORT_C static TReal ToNumberL(const TDesC8& aString);
|
williamr@4
|
72 |
|
williamr@4
|
73 |
/**
|
williamr@4
|
74 |
Converts a node to a string. Any existing text in aOutput is destroyed.
|
williamr@4
|
75 |
This method allocates memory for the buffer.
|
williamr@4
|
76 |
|
williamr@4
|
77 |
@param aNode The node to be converted
|
williamr@4
|
78 |
@param aOutput A buffer owned by the caller that holds the returned string
|
williamr@4
|
79 |
@leave KErrNoMemory Memory allocation failure
|
williamr@4
|
80 |
*/
|
williamr@4
|
81 |
IMPORT_C static void ToStringL(const TXmlEngNode& aNode, RBuf8& aOutput );
|
williamr@4
|
82 |
|
williamr@4
|
83 |
/**
|
williamr@4
|
84 |
Converts a node-set to a string by taking the node in the node set that
|
williamr@4
|
85 |
appears first in the document and converting that to a string. Any
|
williamr@4
|
86 |
existing text in aOutput is destroyed. This method allocates memory for
|
williamr@4
|
87 |
the buffer.
|
williamr@4
|
88 |
|
williamr@4
|
89 |
@param aNodeSet The node-set to be converted
|
williamr@4
|
90 |
@param aOutput A buffer owned by the caller that holds the returned string
|
williamr@4
|
91 |
@leave KErrNoMemory Memory allocation failure
|
williamr@4
|
92 |
*/
|
williamr@4
|
93 |
IMPORT_C static void ToStringL(const RXmlEngNodeSet& aNodeSet, RBuf8&
|
williamr@4
|
94 |
aOutput );
|
williamr@4
|
95 |
|
williamr@4
|
96 |
/**
|
williamr@4
|
97 |
Converts a TBool value to a string. Any existing text in aOutput is
|
williamr@4
|
98 |
destroyed. This method allocates memory for the buffer.
|
williamr@4
|
99 |
|
williamr@4
|
100 |
@param aValue The TBool value to be converted
|
williamr@4
|
101 |
@param aOutput A buffer owned by the caller that holds the returned string.
|
williamr@4
|
102 |
"true" if ETrue and "false" otherwise.
|
williamr@4
|
103 |
@leave KErrNoMemory Memory allocation failure
|
williamr@4
|
104 |
*/
|
williamr@4
|
105 |
IMPORT_C static void ToStringL(TBool aValue, RBuf8& aOutput );
|
williamr@4
|
106 |
|
williamr@4
|
107 |
/**
|
williamr@4
|
108 |
Converts a TReal value to a string. Any existing text in aOutput is
|
williamr@4
|
109 |
destroyed. This method allocates memory for the buffer.
|
williamr@4
|
110 |
|
williamr@4
|
111 |
@param aValue The TReal value to be converted
|
williamr@4
|
112 |
@param aOutput A buffer owned by the caller that holds the returned string.
|
williamr@4
|
113 |
@leave KErrNoMemory Memory allocation failure
|
williamr@4
|
114 |
*/
|
williamr@4
|
115 |
IMPORT_C static void ToStringL(TReal aValue, RBuf8& aOutput );
|
williamr@4
|
116 |
|
williamr@4
|
117 |
/**
|
williamr@4
|
118 |
Converts a node to a TBool
|
williamr@4
|
119 |
@param aNode Node to be converted
|
williamr@4
|
120 |
@return ETrue if the node is not NULL, EFalse otherwise
|
williamr@4
|
121 |
*/
|
williamr@4
|
122 |
IMPORT_C static TBool ToBoolean(const TXmlEngNode& aNode);
|
williamr@4
|
123 |
|
williamr@4
|
124 |
/**
|
williamr@4
|
125 |
Converts a node-set to a TBool
|
williamr@4
|
126 |
@param aNodeSet Node-set to be converted
|
williamr@4
|
127 |
@return ETrue if the nodeset is not NULL, EFalse otherwise
|
williamr@4
|
128 |
*/
|
williamr@4
|
129 |
IMPORT_C static TBool ToBoolean(const RXmlEngNodeSet& aNodeSet);
|
williamr@4
|
130 |
|
williamr@4
|
131 |
/**
|
williamr@4
|
132 |
Converts a string to a TBool
|
williamr@4
|
133 |
@param aValue String that should be converted
|
williamr@4
|
134 |
@return ETrue if the string is not an empty string, EFalse otherwise
|
williamr@4
|
135 |
*/
|
williamr@4
|
136 |
IMPORT_C static TBool ToBoolean(const TDesC8& aValue);
|
williamr@4
|
137 |
|
williamr@4
|
138 |
/**
|
williamr@4
|
139 |
Converts a string to a TBool
|
williamr@4
|
140 |
@deprecated This function is deprecated and will be removed in future
|
williamr@4
|
141 |
releases. ToBoolean() should be used instead.
|
williamr@4
|
142 |
@param aValue String that should be converted
|
williamr@4
|
143 |
@return ETrue if the string is not an empty string, EFalse otherwise
|
williamr@4
|
144 |
@leave - Does not leave
|
williamr@4
|
145 |
*/
|
williamr@4
|
146 |
IMPORT_C static TBool ToBooleanL(const TDesC8& aValue);
|
williamr@4
|
147 |
|
williamr@4
|
148 |
/**
|
williamr@4
|
149 |
Converts a TReal value to a TBool
|
williamr@4
|
150 |
@param aValue TReal value to be converted
|
williamr@4
|
151 |
@return EFalse if aValue is NaN or 0.0, ETrue otherwise
|
williamr@4
|
152 |
*/
|
williamr@4
|
153 |
IMPORT_C static TBool ToBoolean(TReal aValue);
|
williamr@4
|
154 |
|
williamr@4
|
155 |
private:
|
williamr@4
|
156 |
/** Default constructor */
|
williamr@4
|
157 |
inline XmlEngXPathUtils();
|
williamr@4
|
158 |
};
|
williamr@4
|
159 |
|
williamr@4
|
160 |
#include <xml/dom/xmlengxpathutils.inl>
|
williamr@4
|
161 |
|
williamr@4
|
162 |
#endif /* XMLENGXPATHUTILS_H */
|
williamr@4
|
163 |
|