• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ XPathResult类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中XPathResult的典型用法代码示例。如果您正苦于以下问题:C++ XPathResult类的具体用法?C++ XPathResult怎么用?C++ XPathResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了XPathResult类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: throwError

JSValue* JSXPathResultPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
{
    if (!thisObj->inherits(&JSXPathResult::info))
      return throwError(exec, TypeError);

    XPathResult* imp = static_cast<XPathResult*>(static_cast<JSXPathResult*>(thisObj)->impl());

    switch (id) {
    case JSXPathResult::IterateNextFuncNum: {
        ExceptionCode ec = 0;


        KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->iterateNext(ec)));
        setDOMException(exec, ec);
        return result;
    }
    case JSXPathResult::SnapshotItemFuncNum: {
        ExceptionCode ec = 0;
        bool indexOk;
        unsigned index = args[0]->toInt32(exec, indexOk);
        if (!indexOk) {
            setDOMException(exec, TYPE_MISMATCH_ERR);
            return jsUndefined();
        }


        KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->snapshotItem(index, ec)));
        setDOMException(exec, ec);
        return result;
    }
    }
    return 0;
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:33,代码来源:JSXPathResult.cpp


示例2: evaluationContext

XPathResult* XPathExpression::evaluate(Node* contextNode,
                                       unsigned short type,
                                       const ScriptValue&,
                                       ExceptionState& exceptionState) {
    if (!isValidContextNode(contextNode)) {
        exceptionState.throwDOMException(
            NotSupportedError, "The node provided is '" + contextNode->nodeName() +
            "', which is not a valid context node type.");
        return nullptr;
    }

    EvaluationContext evaluationContext(*contextNode);
    XPathResult* result = XPathResult::create(
                              evaluationContext, m_topExpression->evaluate(evaluationContext));

    if (evaluationContext.hadTypeConversionError) {
        // It is not specified what to do if type conversion fails while evaluating
        // an expression.
        exceptionState.throwDOMException(
            SyntaxError, "Type conversion failed while evaluating the expression.");
        return nullptr;
    }

    if (type != XPathResult::kAnyType) {
        result->convertTo(type, exceptionState);
        if (exceptionState.hadException())
            return nullptr;
    }

    return result;
}
开发者ID:mirror,项目名称:chromium,代码行数:31,代码来源:XPathExpression.cpp


示例3: jsXPathResultResultType

JSValue jsXPathResultResultType(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSXPathResult* castedThis = static_cast<JSXPathResult*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    XPathResult* imp = static_cast<XPathResult*>(castedThis->impl());
    JSValue result = jsNumber(imp->resultType());
    return result;
}
开发者ID:mulriple,项目名称:Webkit-Projects,代码行数:8,代码来源:JSXPathResult.cpp


示例4: jsXPathResultInvalidIteratorState

JSValue jsXPathResultInvalidIteratorState(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSXPathResult* castedThis = static_cast<JSXPathResult*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    XPathResult* imp = static_cast<XPathResult*>(castedThis->impl());
    JSValue result = jsBoolean(imp->invalidIteratorState());
    return result;
}
开发者ID:mulriple,项目名称:Webkit-Projects,代码行数:8,代码来源:JSXPathResult.cpp


示例5: jsXPathResultBooleanValue

JSValue jsXPathResultBooleanValue(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSXPathResult* castedThis = static_cast<JSXPathResult*>(asObject(slotBase));
    ExceptionCode ec = 0;
    XPathResult* imp = static_cast<XPathResult*>(castedThis->impl());
    JSC::JSValue result = jsBoolean(imp->booleanValue(ec));
    setDOMException(exec, ec);
    return result;
}
开发者ID:mulriple,项目名称:Webkit-Projects,代码行数:9,代码来源:JSXPathResult.cpp


示例6: jsXPathResultSingleNodeValue

JSValue jsXPathResultSingleNodeValue(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSXPathResult* castedThis = static_cast<JSXPathResult*>(asObject(slotBase));
    ExceptionCode ec = 0;
    XPathResult* imp = static_cast<XPathResult*>(castedThis->impl());
    JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->singleNodeValue(ec)));
    setDOMException(exec, ec);
    return result;
}
开发者ID:mulriple,项目名称:Webkit-Projects,代码行数:9,代码来源:JSXPathResult.cpp


示例7: jsXPathResultSnapshotLength

JSValue jsXPathResultSnapshotLength(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSXPathResult* castedThis = static_cast<JSXPathResult*>(asObject(slotBase));
    ExceptionCode ec = 0;
    XPathResult* imp = static_cast<XPathResult*>(castedThis->impl());
    JSC::JSValue result = jsNumber(imp->snapshotLength(ec));
    setDOMException(exec, ec);
    return result;
}
开发者ID:mulriple,项目名称:Webkit-Projects,代码行数:9,代码来源:JSXPathResult.cpp


示例8: GetAssignmentFor

nsINode*
nsXMLBindingValues::GetNodeAssignmentFor(nsXULTemplateResultXML* aResult,
                                         nsXMLBinding* aBinding,
                                         int32_t aIndex)
{
  XPathResult* result = GetAssignmentFor(aResult, aBinding, aIndex,
                                         XPathResult::FIRST_ORDERED_NODE_TYPE);

  ErrorResult rv;
  return result ? result->GetSingleNodeValue(rv) : nullptr;
}
开发者ID:70599,项目名称:Waterfox,代码行数:11,代码来源:nsXMLBinding.cpp


示例9: snapshotLengthAttrGetter

static v8::Handle<v8::Value> snapshotLengthAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    INC_STATS("DOM.XPathResult.snapshotLength._get");
    XPathResult* imp = V8XPathResult::toNative(info.Holder());
    ExceptionCode ec = 0;
    unsigned v = imp->snapshotLength(ec);
    if (UNLIKELY(ec)) {
        V8Proxy::setDOMException(ec);
        return v8::Handle<v8::Value>();
    }
    return v8::Integer::NewFromUnsigned(v);
}
开发者ID:Treeeater,项目名称:chrome_bindings,代码行数:12,代码来源:V8XPathResult.cpp


示例10: singleNodeValueAttrGetter

static v8::Handle<v8::Value> singleNodeValueAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    INC_STATS("DOM.XPathResult.singleNodeValue._get");
    XPathResult* imp = V8XPathResult::toNative(info.Holder());
    ExceptionCode ec = 0;
    RefPtr<Node> v = imp->singleNodeValue(ec);
    if (UNLIKELY(ec)) {
        V8Proxy::setDOMException(ec);
        return v8::Handle<v8::Value>();
    }
    return toV8(v.release());
}
开发者ID:Treeeater,项目名称:chrome_bindings,代码行数:12,代码来源:V8XPathResult.cpp


示例11: booleanValueAttrGetter

static v8::Handle<v8::Value> booleanValueAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    INC_STATS("DOM.XPathResult.booleanValue._get");
    XPathResult* imp = V8XPathResult::toNative(info.Holder());
    ExceptionCode ec = 0;
    bool v = imp->booleanValue(ec);
    if (UNLIKELY(ec)) {
        V8Proxy::setDOMException(ec);
        return v8::Handle<v8::Value>();
    }
    return v8Boolean(v);
}
开发者ID:Treeeater,项目名称:chrome_bindings,代码行数:12,代码来源:V8XPathResult.cpp


示例12: jsXPathResultPrototypeFunctionIterateNext

JSValue* jsXPathResultPrototypeFunctionIterateNext(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
    if (!thisValue->isObject(&JSXPathResult::s_info))
        return throwError(exec, TypeError);
    JSXPathResult* castedThisObj = static_cast<JSXPathResult*>(thisValue);
    XPathResult* imp = static_cast<XPathResult*>(castedThisObj->impl());
    ExceptionCode ec = 0;


    KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->iterateNext(ec)));
    setDOMException(exec, ec);
    return result;
}
开发者ID:Gin-Rye,项目名称:duibrowser,代码行数:13,代码来源:JSXPathResult.cpp


示例13: jsXPathResultPrototypeFunctionSnapshotItem

JSValue* jsXPathResultPrototypeFunctionSnapshotItem(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
    if (!thisValue->isObject(&JSXPathResult::s_info))
        return throwError(exec, TypeError);
    JSXPathResult* castedThisObj = static_cast<JSXPathResult*>(thisValue);
    XPathResult* imp = static_cast<XPathResult*>(castedThisObj->impl());
    ExceptionCode ec = 0;
    unsigned index = args[0]->toInt32(exec);


    KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->snapshotItem(index, ec)));
    setDOMException(exec, ec);
    return result;
}
开发者ID:Gin-Rye,项目名称:duibrowser,代码行数:14,代码来源:JSXPathResult.cpp


示例14: jsXPathResultPrototypeFunctionIterateNext

EncodedJSValue JSC_HOST_CALL jsXPathResultPrototypeFunctionIterateNext(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSXPathResult::s_info))
        return throwVMTypeError(exec);
    JSXPathResult* castedThis = static_cast<JSXPathResult*>(asObject(thisValue));
    XPathResult* imp = static_cast<XPathResult*>(castedThis->impl());
    ExceptionCode ec = 0;


    JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->iterateNext(ec)));
    setDOMException(exec, ec);
    return JSValue::encode(result);
}
开发者ID:13W,项目名称:phantomjs,代码行数:14,代码来源:JSXPathResult.cpp


示例15: iterateNextCallback

static v8::Handle<v8::Value> iterateNextCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.XPathResult.iterateNext");
    XPathResult* imp = V8XPathResult::toNative(args.Holder());
    ExceptionCode ec = 0;
    {
    RefPtr<Node> result = imp->iterateNext(ec);
    if (UNLIKELY(ec))
        goto fail;
    return toV8(result.release());
    }
    fail:
    V8Proxy::setDOMException(ec);
    return v8::Handle<v8::Value>();
}
开发者ID:Treeeater,项目名称:chrome_bindings,代码行数:15,代码来源:V8XPathResult.cpp


示例16: snapshotItemCallback

static v8::Handle<v8::Value> snapshotItemCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.XPathResult.snapshotItem");
    XPathResult* imp = V8XPathResult::toNative(args.Holder());
    ExceptionCode ec = 0;
    {
    EXCEPTION_BLOCK(unsigned, index, toUInt32(args[0]));
    RefPtr<Node> result = imp->snapshotItem(index, ec);
    if (UNLIKELY(ec))
        goto fail;
    return toV8(result.release());
    }
    fail:
    V8Proxy::setDOMException(ec);
    return v8::Handle<v8::Value>();
}
开发者ID:Treeeater,项目名称:chrome_bindings,代码行数:16,代码来源:V8XPathResult.cpp


示例17: jsXPathResultPrototypeFunctionSnapshotItem

EncodedJSValue JSC_HOST_CALL jsXPathResultPrototypeFunctionSnapshotItem(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSXPathResult::s_info))
        return throwVMTypeError(exec);
    JSXPathResult* castedThis = static_cast<JSXPathResult*>(asObject(thisValue));
    XPathResult* imp = static_cast<XPathResult*>(castedThis->impl());
    ExceptionCode ec = 0;
    unsigned index(exec->argument(0).toUInt32(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());


    JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->snapshotItem(index, ec)));
    setDOMException(exec, ec);
    return JSValue::encode(result);
}
开发者ID:13W,项目名称:phantomjs,代码行数:17,代码来源:JSXPathResult.cpp


示例18: throw

VXPathResult * XPathContext::evaluate(string xpath) throw (invalid_argument) {




    //-- Evaluate
    xmlXPathObjectPtr results = xmlXPathEvalExpression((const xmlChar*)xpath.c_str(),this->xpathCtx);
    if (results == NULL) {

        //-- Return error
        stringstream ss;
        ss << "Could not evaluate XPATH expression /"<<xpath<<"/ failed: " << (this->xpathCtx->lastError.message);
        throw invalid_argument(ss.str());

    }

    //-- Fill up results
    //--------------------
    XPathResult * result = new XPathResult();
    unsigned int nodesetSize = results->nodesetval ? results->nodesetval->nodeNr : 0;

    for (unsigned int i=0;i<nodesetSize ; i++) {

        // Get Node Pointer
        xmlNodePtr node = results->nodesetval->nodeTab[i];

        // Convert to Object
        VDOMNode * nodeObject = DOMNode::toNode(node,this->document);
        if (nodeObject!=NULL)
            result->getNodeList().push_back(nodeObject);

    }

    //-- Free
    xmlXPathFreeObject(results);

    return result;

}
开发者ID:,项目名称:,代码行数:39,代码来源:


示例19: toCoreStringWithUndefinedOrNullCheck

void MainThreadDebugger::xpathSelectorCallback(
    const v8::FunctionCallbackInfo<v8::Value>& info) {
  if (info.Length() < 1)
    return;
  String selector = toCoreStringWithUndefinedOrNullCheck(info[0]);
  if (selector.isEmpty())
    return;
  Node* node = secondArgumentAsNode(info);
  if (!node || !node->isContainerNode())
    return;

  ExceptionState exceptionState(ExceptionState::ExecutionContext, "$x",
                                "CommandLineAPI", info.Holder(),
                                info.GetIsolate());
  XPathResult* result = XPathEvaluator::create()->evaluate(
      selector, node, nullptr, XPathResult::kAnyType, ScriptValue(),
      exceptionState);
  if (exceptionState.hadException() || !result)
    return;
  if (result->resultType() == XPathResult::kNumberType) {
    info.GetReturnValue().Set(toV8(result->numberValue(exceptionState),
                                   info.Holder(), info.GetIsolate()));
  } else if (result->resultType() == XPathResult::kStringType) {
    info.GetReturnValue().Set(toV8(result->stringValue(exceptionState),
                                   info.Holder(), info.GetIsolate()));
  } else if (result->resultType() == XPathResult::kBooleanType) {
    info.GetReturnValue().Set(toV8(result->booleanValue(exceptionState),
                                   info.Holder(), info.GetIsolate()));
  } else {
    v8::Isolate* isolate = info.GetIsolate();
    v8::Local<v8::Context> context = isolate->GetCurrentContext();
    v8::Local<v8::Array> nodes = v8::Array::New(isolate);
    size_t index = 0;
    while (Node* node = result->iterateNext(exceptionState)) {
      if (exceptionState.hadException())
        return;
      if (!createDataPropertyInArray(
               context, nodes, index++,
               toV8(node, info.Holder(), info.GetIsolate()))
               .FromMaybe(false))
        return;
    }
    info.GetReturnValue().Set(nodes);
  }
}
开发者ID:mirror,项目名称:chromium,代码行数:45,代码来源:MainThreadDebugger.cpp


示例20: switch

JSValue* JSXPathResult::getValueProperty(ExecState* exec, int token) const
{
    switch (token) {
    case ResultTypeAttrNum: {
        XPathResult* imp = static_cast<XPathResult*>(impl());
        return jsNumber(exec, imp->resultType());
    }
    case NumberValueAttrNum: {
        ExceptionCode ec = 0;
        XPathResult* imp = static_cast<XPathResult*>(impl());
        KJS::JSValue* result = jsNumber(exec, imp->numberValue(ec));
        setDOMException(exec, ec);
        return result;
    }
    case StringValueAttrNum: {
        ExceptionCode ec = 0;
        XPathResult* imp = static_cast<XPathResult*>(impl());
        KJS::JSValue* result = jsString(exec, imp->stringValue(ec));
        setDOMException(exec, ec);
        return result;
    }
    case BooleanValueAttrNum: {
        ExceptionCode ec = 0;
        XPathResult* imp = static_cast<XPathResult*>(impl());
        KJS::JSValue* result = jsBoolean(imp->booleanValue(ec));
        setDOMException(exec, ec);
        return result;
    }
    case SingleNodeValueAttrNum: {
        ExceptionCode ec = 0;
        XPathResult* imp = static_cast<XPathResult*>(impl());
        KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->singleNodeValue(ec)));
        setDOMException(exec, ec);
        return result;
    }
    case InvalidIteratorStateAttrNum: {
        XPathResult* imp = static_cast<XPathResult*>(impl());
        return jsBoolean(imp->invalidIteratorState());
    }
    case SnapshotLengthAttrNum: {
        ExceptionCode ec = 0;
        XPathResult* imp = static_cast<XPathResult*>(impl());
        KJS::JSValue* result = jsNumber(exec, imp->snapshotLength(ec));
        setDOMException(exec, ec);
        return result;
    }
    case ConstructorAttrNum:
        return getConstructor(exec);
    }
    return 0;
}
开发者ID:Gin-Rye,项目名称:duibrowser,代码行数:51,代码来源:JSXPathResult.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ XQuery_t类代码示例发布时间:2022-05-31
下一篇:
C++ XPathExecutionContext类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap