当前位置: 首页>>代码示例>>C++>>正文


C++ Ptr::asString方法代码示例

本文整理汇总了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;
}
开发者ID:kanbang,项目名称:Colt,代码行数:48,代码来源:FTDistance.cpp

示例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);
}
开发者ID:zeusever,项目名称:xqilla,代码行数:28,代码来源:FunctionRegexGroup.cpp


注:本文中的numeric::Ptr::asString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。