本文整理汇总了C++中xmlXPathIsNaN函数的典型用法代码示例。如果您正苦于以下问题:C++ xmlXPathIsNaN函数的具体用法?C++ xmlXPathIsNaN怎么用?C++ xmlXPathIsNaN使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xmlXPathIsNaN函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exsltMathLowest
static xmlNodeSetPtr
exsltMathLowest (xmlNodeSetPtr ns) {
xmlNodeSetPtr ret = xmlXPathNodeSetCreate(NULL);
double min, cur;
int i;
if ((ns == NULL) || (ns->nodeNr == 0))
return(ret);
min = xmlXPathCastNodeToNumber(ns->nodeTab[0]);
if (xmlXPathIsNaN(min))
return(ret);
else
xmlXPathNodeSetAddUnique(ret, ns->nodeTab[0]);
for (i = 1; i < ns->nodeNr; i++) {
cur = xmlXPathCastNodeToNumber(ns->nodeTab[i]);
if (xmlXPathIsNaN(cur)) {
xmlXPathEmptyNodeSet(ret);
return(ret);
}
if (cur > min)
continue;
if (cur < min) {
min = cur;
xmlXPathEmptyNodeSet(ret);
xmlXPathNodeSetAddUnique(ret, ns->nodeTab[i]);
continue;
}
xmlXPathNodeSetAddUnique(ret, ns->nodeTab[i]);
}
return(ret);
}
示例2: exsltMathPower
/**
* exsltMathPower:
* @base: a double
* @power: a double
*
* Implements the EXSLT - Math power() function:
* number math:power (number, number)
*
* Returns the power base and power arguments, or xmlXPathNAN
* if either @base or @power is Nan.
*/
static double
exsltMathPower (double base, double power) {
double ret;
if ((xmlXPathIsNaN(base) || xmlXPathIsNaN(power)))
return(xmlXPathNAN);
ret = pow(base, power);
return(ret);
}
示例3: exsltMathAtan2
/**
* exsltMathAtan2:
* @y: a double
* @x: a double
*
* Implements the EXSLT - Math atan2() function:
* number math:atan2 (number, number)
*
* Returns the arc tangent function of the y/x arguments, or xmlXPathNAN
* if either @y or @x is Nan.
*/
static double
exsltMathAtan2 (double y, double x) {
double ret;
if ((xmlXPathIsNaN(y) || xmlXPathIsNaN(x)))
return(xmlXPathNAN);
ret = atan2(y, x);
return(ret);
}
示例4: xpath_number
Datum
xpath_number(PG_FUNCTION_ARGS)
{
text *document = PG_GETARG_TEXT_P(0);
text *xpathsupp = PG_GETARG_TEXT_P(1); /* XPath expression */
xmlChar *xpath;
float4 fRes;
xmlXPathObjectPtr res;
xpath_workspace workspace;
xpath = pgxml_texttoxmlchar(xpathsupp);
res = pgxml_xpath(document, xpath, &workspace);
pfree(xpath);
if (res == NULL)
PG_RETURN_NULL();
fRes = xmlXPathCastToNumber(res);
cleanup_workspace(&workspace);
if (xmlXPathIsNaN(fRes))
PG_RETURN_NULL();
PG_RETURN_FLOAT4(fRes);
}
示例5: xpath_number
Datum
xpath_number(PG_FUNCTION_ARGS)
{
xmlChar *xpath;
int32 pathsize;
text *xpathsupp;
float4 fRes;
xmlXPathObjectPtr res;
/* PG_GETARG_TEXT_P(0) is document buffer */
xpathsupp = PG_GETARG_TEXT_P(1); /* XPath expression */
pathsize = VARSIZE(xpathsupp) - VARHDRSZ;
xpath = pgxml_texttoxmlchar(xpathsupp);
res = pgxml_xpath(PG_GETARG_TEXT_P(0), xpath);
pfree(xpath);
if (res == NULL)
PG_RETURN_NULL();
fRes = xmlXPathCastToNumber(res);
if (xmlXPathIsNaN(fRes))
PG_RETURN_NULL();
PG_RETURN_FLOAT4(fRes);
}
示例6: convertXPathObjectToR
SEXP
convertXPathObjectToR(xmlXPathObjectPtr obj, SEXP fun, int encoding, SEXP manageMemory)
{
SEXP ans = NULL_USER_OBJECT;
switch(obj->type) {
case XPATH_NODESET:
ans = convertNodeSetToR(obj->nodesetval, fun, encoding, manageMemory);
break;
case XPATH_BOOLEAN:
ans = ScalarLogical(obj->boolval);
break;
case XPATH_NUMBER:
ans = ScalarReal(obj->floatval);
if(xmlXPathIsInf(obj->floatval))
REAL(ans)[0] = xmlXPathIsInf(obj->floatval) < 0 ? R_NegInf : R_PosInf;
else if(xmlXPathIsNaN(obj->floatval))
REAL(ans)[0] = NA_REAL;
break;
case XPATH_STRING:
ans = mkString(XMLCHAR_TO_CHAR(obj->stringval)); //XXX encoding
break;
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
case XPATH_USERS:
PROBLEM "currently unsupported xmlXPathObject type %d in convertXPathObjectToR. Please send mail to maintainer.", obj->type
WARN
default:
ans = R_NilValue;
}
return(ans);
}
示例7: exsltMathLog
/**
* exsltMathLog:
* @num: a double
*
* Implements the EXSLT - Math log() function:
* number math:log (number)
*
* Returns the natural log of the argument, or xmlXPathNAN if @num is Nan.
*/
static double
exsltMathLog (double num) {
double ret;
if (xmlXPathIsNaN(num))
return(xmlXPathNAN);
ret = log(num);
return(ret);
}
示例8: exsltMathCos
/**
* exsltMathCos:
* @num: a double
*
* Implements the EXSLT - Math cos() function:
* number math:cos (number)
*
* Returns the cosine of the argument, or xmlXPathNAN if @num is Nan.
*/
static double
exsltMathCos (double num) {
double ret;
if (xmlXPathIsNaN(num))
return(xmlXPathNAN);
ret = cos(num);
return(ret);
}
示例9: exsltMathAtan
/**
* exsltMathAtan:
* @num: a double
*
* Implements the EXSLT - Math atan() function:
* number math:atan (number)
*
* Returns the arc tangent of the argument, or xmlXPathNAN if @num is Nan.
*/
static double
exsltMathAtan (double num) {
double ret;
if (xmlXPathIsNaN(num))
return(xmlXPathNAN);
ret = atan(num);
return(ret);
}
示例10: exsltMathSqrt
/**
* exsltMathSqrt:
* @num: a double
*
* Implements the EXSLT - Math sqrt() function:
* number math:sqrt (number)
*
* Returns the square root of the argument, or xmlXPathNAN if @num is Nan.
*/
static double
exsltMathSqrt (double num) {
double ret;
if (xmlXPathIsNaN(num))
return(xmlXPathNAN);
ret = sqrt(num);
return(ret);
}
示例11: exsltMathExp
/**
* exsltMathExp:
* @num: a double
*
* Implements the EXSLT - Math exp() function:
* number math:exp (number)
*
* Returns the exponential function of the argument, or xmlXPathNAN if
* @num is Nan.
*/
static double
exsltMathExp (double num) {
double ret;
if (xmlXPathIsNaN(num))
return(xmlXPathNAN);
ret = exp(num);
return(ret);
}
示例12: exsltMathMin
/**
* exsltMathMin:
* @ns: a node-set
*
* Implements the EXSLT - Math min() function:
* number math:min (node-set)
*
* Returns the minimum value of the nodes passed as the argument, or
* xmlXPathNAN if @ns is NULL or empty or if one of the nodes
* turns into NaN.
*/
static double
exsltMathMin (xmlNodeSetPtr ns) {
double ret, cur;
int i;
if ((ns == NULL) || (ns->nodeNr == 0))
return(xmlXPathNAN);
ret = xmlXPathCastNodeToNumber(ns->nodeTab[0]);
if (xmlXPathIsNaN(ret))
return(xmlXPathNAN);
for (i = 1; i < ns->nodeNr; i++) {
cur = xmlXPathCastNodeToNumber(ns->nodeTab[i]);
if (xmlXPathIsNaN(cur))
return(xmlXPathNAN);
if (cur < ret)
ret = cur;
}
return(ret);
}
示例13: xmlSchematronRunTest
/**
* xmlSchematronRunTest:
* @ctxt: the schema validation context
* @test: the current test
* @instance: the document instace tree
* @cur: the current node in the instance
*
* Validate a rule against a tree instance at a given position
*
* Returns 1 in case of success, 0 if error and -1 in case of internal error
*/
static int
xmlSchematronRunTest(xmlSchematronValidCtxtPtr ctxt,
xmlSchematronTestPtr test, xmlDocPtr instance, xmlNodePtr cur, xmlSchematronPatternPtr pattern)
{
xmlXPathObjectPtr ret;
int failed;
failed = 0;
ctxt->xctxt->doc = instance;
ctxt->xctxt->node = cur;
ret = xmlXPathCompiledEval(test->comp, ctxt->xctxt);
if (ret == NULL) {
failed = 1;
} else {
switch (ret->type) {
case XPATH_XSLT_TREE:
case XPATH_NODESET:
if ((ret->nodesetval == NULL) ||
(ret->nodesetval->nodeNr == 0))
failed = 1;
break;
case XPATH_BOOLEAN:
failed = !ret->boolval;
break;
case XPATH_NUMBER:
if ((xmlXPathIsNaN(ret->floatval)) ||
(ret->floatval == 0.0))
failed = 1;
break;
case XPATH_STRING:
if ((ret->stringval == NULL) ||
(ret->stringval[0] == 0))
failed = 1;
break;
case XPATH_UNDEFINED:
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
case XPATH_USERS:
failed = 1;
break;
}
xmlXPathFreeObject(ret);
}
if ((failed) && (test->type == XML_SCHEMATRON_ASSERT))
ctxt->nberrors++;
else if ((!failed) && (test->type == XML_SCHEMATRON_REPORT))
ctxt->nberrors++;
xmlSchematronReportSuccess(ctxt, test, cur, pattern, !failed);
return(!failed);
}
示例14: xsltNumberFormatInsertNumbers
static void
xsltNumberFormatInsertNumbers(xsltNumberDataPtr data,
double *numbers,
int numbers_max,
xsltFormatPtr tokens,
xmlBufferPtr buffer)
{
int i = 0;
double number;
xsltFormatTokenPtr token;
/*
* Handle initial non-alphanumeric token
*/
if (tokens->start != NULL)
xmlBufferCat(buffer, tokens->start);
for (i = 0; i < numbers_max; i++) {
/* Insert number */
number = numbers[(numbers_max - 1) - i];
/* Round to nearest like XSLT 2.0 */
number = floor(number + 0.5);
/*
* XSLT 1.0 isn't clear on how to handle negative numbers, but XSLT
* 2.0 says:
*
* It is a non-recoverable dynamic error if any undiscarded item
* in the atomized sequence supplied as the value of the value
* attribute of xsl:number cannot be converted to an integer, or
* if the resulting integer is less than 0 (zero).
*/
if (number < 0.0) {
xsltTransformError(NULL, NULL, NULL,
"xsl-number : negative value\n");
/* Recover by treating negative values as zero. */
number = 0.0;
}
if (i < tokens->nTokens) {
/*
* The "n"th format token will be used to format the "n"th
* number in the list
*/
token = &(tokens->tokens[i]);
} else if (tokens->nTokens > 0) {
/*
* If there are more numbers than format tokens, then the
* last format token will be used to format the remaining
* numbers.
*/
token = &(tokens->tokens[tokens->nTokens - 1]);
} else {
/*
* If there are no format tokens, then a format token of
* 1 is used to format all numbers.
*/
token = &default_token;
}
/* Print separator, except for the first number */
if (i > 0) {
if (token->separator != NULL)
xmlBufferCat(buffer, token->separator);
else
xmlBufferCCat(buffer, DEFAULT_SEPARATOR);
}
switch (xmlXPathIsInf(number)) {
case -1:
xmlBufferCCat(buffer, "-Infinity");
break;
case 1:
xmlBufferCCat(buffer, "Infinity");
break;
default:
if (xmlXPathIsNaN(number)) {
xmlBufferCCat(buffer, "NaN");
} else {
switch (token->token) {
case 'A':
xsltNumberFormatAlpha(data, buffer, number, TRUE);
break;
case 'a':
xsltNumberFormatAlpha(data, buffer, number, FALSE);
break;
case 'I':
xsltNumberFormatRoman(data, buffer, number, TRUE);
break;
case 'i':
xsltNumberFormatRoman(data, buffer, number, FALSE);
break;
default:
if (IS_DIGIT_ZERO(token->token)) {
xsltNumberFormatDecimal(buffer,
number,
token->token,
token->width,
data->digitsPerGroup,
data->groupingCharacter,
data->groupingCharacterLen);
//.........这里部分代码省略.........
示例15: xsltNumberFormatInsertNumbers
static void
xsltNumberFormatInsertNumbers(xsltNumberDataPtr data,
double *numbers,
int numbers_max,
xsltFormatPtr tokens,
xmlBufferPtr buffer)
{
int i = 0;
double number;
xsltFormatTokenPtr token;
/*
* Handle initial non-alphanumeric token
*/
if (tokens->start != NULL)
xmlBufferCat(buffer, tokens->start);
for (i = 0; i < numbers_max; i++) {
/* Insert number */
number = numbers[(numbers_max - 1) - i];
if (i < tokens->nTokens) {
/* The "n"th format token will be used to format the "n"th
* number in the list */
token = &(tokens->tokens[i]);
} else if (tokens->nTokens > 0) {
/* If there are more numbers than format tokens, then the
* last format token will be used to format the remaining
* numbers. */
token = &(tokens->tokens[tokens->nTokens - 1]);
} else {
/* If there are no format tokens, then a format token of
* 1 is used to format all numbers. */
token = &default_token;
}
/* Print separator, except for the first number */
if (i > 0) {
if (token->separator != NULL)
xmlBufferCat(buffer, token->separator);
else
xmlBufferCCat(buffer, DEFAULT_SEPARATOR);
}
switch (xmlXPathIsInf(number)) {
case -1:
xmlBufferCCat(buffer, "-Infinity");
break;
case 1:
xmlBufferCCat(buffer, "Infinity");
break;
default:
if (xmlXPathIsNaN(number)) {
xmlBufferCCat(buffer, "NaN");
} else {
switch (token->token) {
case 'A':
xsltNumberFormatAlpha(buffer,
number,
TRUE);
break;
case 'a':
xsltNumberFormatAlpha(buffer,
number,
FALSE);
break;
case 'I':
xsltNumberFormatRoman(buffer,
number,
TRUE);
break;
case 'i':
xsltNumberFormatRoman(buffer,
number,
FALSE);
break;
default:
if (IS_DIGIT_ZERO(token->token)) {
xsltNumberFormatDecimal(buffer,
number,
token->token,
token->width,
data->digitsPerGroup,
data->groupingCharacter);
}
break;
}
}
}
}
/*
* Handle final non-alphanumeric token
*/
if (tokens->end != NULL)
//.........这里部分代码省略.........