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


C++ Replacements::SetScheme方法代码示例

本文整理汇总了C++中kurlgoogleprivate::Replacements::SetScheme方法的典型用法代码示例。如果您正苦于以下问题:C++ Replacements::SetScheme方法的具体用法?C++ Replacements::SetScheme怎么用?C++ Replacements::SetScheme使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kurlgoogleprivate::Replacements的用法示例。


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

示例1: setProtocol

bool KURL::setProtocol(const String& protocol)
{
    // Firefox and IE remove everything after the first ':'.
    int separatorPosition = protocol.find(':');
    String newProtocol = protocol.substring(0, separatorPosition);

    // If KURL is given an invalid scheme, it returns failure without modifying
    // the URL at all. This is in contrast to most other setters which modify
    // the URL and set "m_isValid."
    url_canon::RawCanonOutputT<char> canonProtocol;
    url_parse::Component protocolComponent;
    if (!url_canon::CanonicalizeScheme(newProtocol.characters(),
                                       url_parse::Component(0, newProtocol.length()),
                                       &canonProtocol, &protocolComponent)
        || !protocolComponent.is_nonempty())
        return false;

    KURLGooglePrivate::Replacements replacements;
    replacements.SetScheme(CharactersOrEmpty(newProtocol),
                           url_parse::Component(0, newProtocol.length()));
    m_url.replaceComponents(replacements);

    // isValid could be false but we still return true here. This is because
    // WebCore or JS scripts can build up a URL by setting individual
    // components, and a JS exception is based on the return value of this
    // function. We want to throw the exception and stop the script only when
    // its trying to set a bad protocol, and not when it maybe just hasn't
    // finished building up its final scheme.
    return true;
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.vendor,代码行数:30,代码来源:KURLGoogle.cpp

示例2: setProtocol

void KURL::setProtocol(const String& protocol)
{
    KURLGooglePrivate::Replacements replacements;
    replacements.SetScheme(CharactersOrEmpty(protocol),
                           url_parse::Component(0, protocol.length()));
    m_url.replaceComponents(replacements);
}
开发者ID:flying-dutchmen,项目名称:3DS_w3Browser,代码行数:7,代码来源:KURLGoogle.cpp


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