本文整理汇总了C++中numeric::Ptr::asString方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::asString方法的具体用法?C++ Ptr::asString怎么用?C++ Ptr::asString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类numeric::Ptr
的用法示例。
在下文中一共展示了Ptr::asString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
FTSelection *FTDistance::optimize(FTContext *ftcontext, bool execute) const
{
XPath2MemoryManager *mm = ftcontext->context->getMemoryManager();
if(execute || range_.arg1->isConstant()) {
Result rangeResult = range_.arg1->createResult(ftcontext->context);
Numeric::Ptr num = (Numeric::Ptr)rangeResult->next(ftcontext->context);
long distance = ::atol(UTF8(num->asString(ftcontext->context)));
switch(range_.type) {
case FTRange::EXACTLY: {
FTSelection *result = new (mm) FTDistanceLiteral(arg_, FTRange::EXACTLY, distance, 0, unit_, mm);
result->setLocationInfo(this);
return result->optimize(ftcontext, execute);
}
case FTRange::AT_LEAST: {
FTSelection *result = new (mm) FTDistanceLiteral(arg_, FTRange::AT_LEAST, distance, 0, unit_, mm);
result->setLocationInfo(this);
return result->optimize(ftcontext, execute);
}
case FTRange::AT_MOST: {
FTSelection *result = new (mm) FTDistanceLiteral(arg_, FTRange::AT_MOST, distance, 0, unit_, mm);
result->setLocationInfo(this);
return result->optimize(ftcontext, execute);
}
case FTRange::FROM_TO: {
Result rangeResult2 = range_.arg2->createResult(ftcontext->context);
Numeric::Ptr num2 = (Numeric::Ptr)rangeResult2->next(ftcontext->context);
long distance2 = ::atol(UTF8(num->asString(ftcontext->context)));
FTSelection *result = new (mm) FTDistanceLiteral(arg_, FTRange::FROM_TO, distance, distance2, unit_, mm);
result->setLocationInfo(this);
return result->optimize(ftcontext, execute);
}
}
}
FTSelection *newarg = arg_->optimize(ftcontext, execute);
if(newarg == 0) return 0;
if(newarg->getType() == WORD) {
return newarg;
}
newarg = new (mm) FTDistance(range_, unit_, newarg, mm);
newarg->setLocationInfo(this);
return newarg;
}
示例2: createSequence
Sequence FunctionRegexGroup::createSequence(DynamicContext *context, int flags) const
{
XPath2MemoryManager *mm = context->getMemoryManager();
const RegexGroupStore *store = context->getRegexGroupStore();
if(store == 0)
return Sequence(context->getItemFactory()->createString(XMLUni::fgZeroLenString, context), mm);
Numeric::Ptr indexItem = getParamNumber(1, context)->next(context);
if(indexItem->isNegative())
return Sequence(context->getItemFactory()->createString(XMLUni::fgZeroLenString, context), mm);
const XMLCh *indexStr = indexItem->asString(context);
int index = 0;
while(*indexStr != 0) {
if(*indexStr >= '0' && *indexStr <= '9') {
index *= 10;
index += *indexStr - '0';
}
++indexStr;
}
const XMLCh *result = store->getGroup(index);
if(result == 0) result = XMLUni::fgZeroLenString;
return Sequence(context->getItemFactory()->createString(result, context), mm);
}