Re: [xml] Retrieving boolean/number/string value from XPath objects




Le 11/05/01 14:59:57, Thomas Broyer a écrit :
Why isn't there "basic" functions to convert values to
number/boolean/string?

OK, here it is (see attached patch):

 · New xmlXPathWrapString and xmlXPathWrapCString functions
+xmlXPathObjectPtr xmlXPathWrapString           (xmlChar *val);
+xmlXPathObjectPtr xmlXPathWrapCString          (char *val);

 · New xmlXPathCastXToY and xmlXPathCastToY functions
+int               xmlXPathCastNumberToBoolean  (double val);
+int               xmlXPathCastStringToBoolean  (const xmlChar * val);
+int               xmlXPathCastNodeToBoolean    (xmlNodeSetPtr ns);
+int               xmlXPathCastToBoolean        (xmlXPathObjectPtr val);
+
+double            xmlXPathCastBooleanToNumber  (int val);
+double            xmlXPathCastStringToNumber   (const xmlChar * val);
+double            xmlXPathCastNodeToNumber     (xmlNodePtr node);
+double            xmlXPathCastNodeSetToNumber  (xmlNodeSetPtr ns);
+double            xmlXPathCastToNumber         (xmlXPathObjectPtr val);
+
+xmlChar *         xmlXPathCastBooleanToString  (int val);
+xmlChar *         xmlXPathCastNumberToString   (double val);
+xmlChar *         xmlXPathCastNodeToString     (xmlNodePtr node);
+xmlChar *         xmlXPathCastNodeSetToString  (xmlNodeSetPtr ns);
+xmlChar *         xmlXPathCastToString         (xmlXPathObjectPtr val);

 · Replaced POP_FLOAT with CAST_TO_NUMBER; CHECK_TYPE(XPATH_NUMBER);
   to follow xmlXPath*Function design. This was not really necessary.
   It implies values are no longer popped when conversion fails, this
   shouldn't impact much.

 · Improvements using the new functions in xmlXPath*Values functions,
   xmlXPathCompareNodeSet* functions, xmlXPathIdFunction and
   xmlXPathSumFunction

Tom.

Attachment: xpathval.diff
Description: Text document



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]