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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
24 #ifndef XMLENGXPATHUTILS_H
25 #define XMLENGXPATHUTILS_H
27 #include <xml/dom/xmlengnodeset.h>
30 Implements utility functions such as conversion methods for XPath objects.
32 The XPath specification considers a node result as a set of only one node,
33 however, in this API it is possible to perform conversion routines
36 class XmlEngXPathUtils
40 Converts node to number
41 @param aNode Node to be converted
42 @return The number represented by the node or NaN if cannot convert.
43 @leave KErrNoMemory Memory allocation failure
45 IMPORT_C static TReal ToNumberL(const TXmlEngNode& aNode);
48 Converts a node-set to a number by taking the node in the node set that
49 appears first in the document and converting that to a number.
51 @param aNodeSet Node-set to be converted
52 @return The number represented by the node set or NaN if cannot convert.
53 @leave KErrNoMemory Memory allocation failure
55 IMPORT_C static TReal ToNumberL(const RXmlEngNodeSet& aNodeSet);
58 Converts TBool value to TReal
59 @param aValue TBool value to be converted
60 @return 1.0 if ETrue and 0.0 otherwise
61 @leave - Does not leave
63 IMPORT_C static TReal ToNumberL(TBool aValue);
66 Converts a string to a number
67 @param aString String to be converted
68 @return The number respresented by the string or NaN if cannot convert.
69 @leave KErrNoMemory Memory allocation failure
71 IMPORT_C static TReal ToNumberL(const TDesC8& aString);
74 Converts a node to a string. Any existing text in aOutput is destroyed.
75 This method allocates memory for the buffer.
77 @param aNode The node to be converted
78 @param aOutput A buffer owned by the caller that holds the returned string
79 @leave KErrNoMemory Memory allocation failure
81 IMPORT_C static void ToStringL(const TXmlEngNode& aNode, RBuf8& aOutput );
84 Converts a node-set to a string by taking the node in the node set that
85 appears first in the document and converting that to a string. Any
86 existing text in aOutput is destroyed. This method allocates memory for
89 @param aNodeSet The node-set to be converted
90 @param aOutput A buffer owned by the caller that holds the returned string
91 @leave KErrNoMemory Memory allocation failure
93 IMPORT_C static void ToStringL(const RXmlEngNodeSet& aNodeSet, RBuf8&
97 Converts a TBool value to a string. Any existing text in aOutput is
98 destroyed. This method allocates memory for the buffer.
100 @param aValue The TBool value to be converted
101 @param aOutput A buffer owned by the caller that holds the returned string.
102 "true" if ETrue and "false" otherwise.
103 @leave KErrNoMemory Memory allocation failure
105 IMPORT_C static void ToStringL(TBool aValue, RBuf8& aOutput );
108 Converts a TReal value to a string. Any existing text in aOutput is
109 destroyed. This method allocates memory for the buffer.
111 @param aValue The TReal value to be converted
112 @param aOutput A buffer owned by the caller that holds the returned string.
113 @leave KErrNoMemory Memory allocation failure
115 IMPORT_C static void ToStringL(TReal aValue, RBuf8& aOutput );
118 Converts a node to a TBool
119 @param aNode Node to be converted
120 @return ETrue if the node is not NULL, EFalse otherwise
122 IMPORT_C static TBool ToBoolean(const TXmlEngNode& aNode);
125 Converts a node-set to a TBool
126 @param aNodeSet Node-set to be converted
127 @return ETrue if the nodeset is not NULL, EFalse otherwise
129 IMPORT_C static TBool ToBoolean(const RXmlEngNodeSet& aNodeSet);
132 Converts a string to a TBool
133 @param aValue String that should be converted
134 @return ETrue if the string is not an empty string, EFalse otherwise
136 IMPORT_C static TBool ToBoolean(const TDesC8& aValue);
139 Converts a string to a TBool
140 @deprecated This function is deprecated and will be removed in future
141 releases. ToBoolean() should be used instead.
142 @param aValue String that should be converted
143 @return ETrue if the string is not an empty string, EFalse otherwise
144 @leave - Does not leave
146 IMPORT_C static TBool ToBooleanL(const TDesC8& aValue);
149 Converts a TReal value to a TBool
150 @param aValue TReal value to be converted
151 @return EFalse if aValue is NaN or 0.0, ETrue otherwise
153 IMPORT_C static TBool ToBoolean(TReal aValue);
156 /** Default constructor */
157 inline XmlEngXPathUtils();
160 #include <xml/dom/xmlengxpathutils.inl>
162 #endif /* XMLENGXPATHUTILS_H */