#include "../config/pathan_config.h" /* * Copyright (c) 2001, DecisionSoft Limited All rights reserved. * Please see LICENSE.TXT for more information. */ #include #include #include #include #include #include /*static*/ const XMLCh Mod::name[]={ XERCES_CPP_NAMESPACE_QUALIFIER chLatin_m, XERCES_CPP_NAMESPACE_QUALIFIER chLatin_o, XERCES_CPP_NAMESPACE_QUALIFIER chLatin_d, XERCES_CPP_NAMESPACE_QUALIFIER chNull }; Mod::Mod(const VectorOfDataItems &args, XPath2MemoryManager* memMgr) : DataItemOperator(name, args, memMgr) { } Sequence Mod::collapseTreeInternal(DynamicContext* context, int flags) const { XPath2MemoryManager* memMgr = context->getMemoryManager(); Sequence newArgs = getArithmeticOperatorArguments(context); if(newArgs.getLength() < 2) return Sequence(memMgr); if(!newArgs.first()->isAtomicValue() || !newArgs.second()->isAtomicValue()) { DSLthrow(XPath2ErrorException,X("Mod::collapseTreeInternal"), X("The operator mod has been called on invalid operand types")); } const AnyAtomicType* atom1 = (const AnyAtomicType*)newArgs.first(); const AnyAtomicType* atom2 = (const AnyAtomicType*)newArgs.second(); if(atom1->isNumericValue()) { if(atom2->isNumericValue()) { return Sequence(((const Numeric*)atom1)->mod((const Numeric*)atom2, context), memMgr); } else { DSLthrow(XPath2ErrorException,X("Mod::collapseTreeInternal"), X("An attempt to mod a non numeric type to a numeric type has occurred")); } } DSLthrow(XPath2ErrorException,X("Mod::collapseTreeInternal"), X("The operator mod has been called on invalid operand types")); }