|
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 Utils |
|
15 // |
|
16 |
|
17 |
|
18 |
|
19 /** |
|
20 @file |
|
21 @publishedAll |
|
22 @released |
|
23 */ |
|
24 #ifndef XMLENGXPATHUTILS_H |
|
25 #define XMLENGXPATHUTILS_H |
|
26 |
|
27 #include <xml/dom/xmlengnodeset.h> |
|
28 |
|
29 /** |
|
30 Implements utility functions such as conversion methods for XPath objects. |
|
31 |
|
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 |
|
34 directly on nodes. |
|
35 */ |
|
36 class XmlEngXPathUtils |
|
37 { |
|
38 public: |
|
39 /** |
|
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 |
|
44 */ |
|
45 IMPORT_C static TReal ToNumberL(const TXmlEngNode& aNode); |
|
46 |
|
47 /** |
|
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. |
|
50 |
|
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 |
|
54 */ |
|
55 IMPORT_C static TReal ToNumberL(const RXmlEngNodeSet& aNodeSet); |
|
56 |
|
57 /** |
|
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 |
|
62 */ |
|
63 IMPORT_C static TReal ToNumberL(TBool aValue); |
|
64 |
|
65 /** |
|
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 |
|
70 */ |
|
71 IMPORT_C static TReal ToNumberL(const TDesC8& aString); |
|
72 |
|
73 /** |
|
74 Converts a node to a string. Any existing text in aOutput is destroyed. |
|
75 This method allocates memory for the buffer. |
|
76 |
|
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 |
|
80 */ |
|
81 IMPORT_C static void ToStringL(const TXmlEngNode& aNode, RBuf8& aOutput ); |
|
82 |
|
83 /** |
|
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 |
|
87 the buffer. |
|
88 |
|
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 |
|
92 */ |
|
93 IMPORT_C static void ToStringL(const RXmlEngNodeSet& aNodeSet, RBuf8& |
|
94 aOutput ); |
|
95 |
|
96 /** |
|
97 Converts a TBool value to a string. Any existing text in aOutput is |
|
98 destroyed. This method allocates memory for the buffer. |
|
99 |
|
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 |
|
104 */ |
|
105 IMPORT_C static void ToStringL(TBool aValue, RBuf8& aOutput ); |
|
106 |
|
107 /** |
|
108 Converts a TReal value to a string. Any existing text in aOutput is |
|
109 destroyed. This method allocates memory for the buffer. |
|
110 |
|
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 |
|
114 */ |
|
115 IMPORT_C static void ToStringL(TReal aValue, RBuf8& aOutput ); |
|
116 |
|
117 /** |
|
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 |
|
121 */ |
|
122 IMPORT_C static TBool ToBoolean(const TXmlEngNode& aNode); |
|
123 |
|
124 /** |
|
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 |
|
128 */ |
|
129 IMPORT_C static TBool ToBoolean(const RXmlEngNodeSet& aNodeSet); |
|
130 |
|
131 /** |
|
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 |
|
135 */ |
|
136 IMPORT_C static TBool ToBoolean(const TDesC8& aValue); |
|
137 |
|
138 /** |
|
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 |
|
145 */ |
|
146 IMPORT_C static TBool ToBooleanL(const TDesC8& aValue); |
|
147 |
|
148 /** |
|
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 |
|
152 */ |
|
153 IMPORT_C static TBool ToBoolean(TReal aValue); |
|
154 |
|
155 private: |
|
156 /** Default constructor */ |
|
157 inline XmlEngXPathUtils(); |
|
158 }; |
|
159 |
|
160 #include <xml/dom/xmlengxpathutils.inl> |
|
161 |
|
162 #endif /* XMLENGXPATHUTILS_H */ |
|
163 |