本文整理汇总了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;
}
示例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);
}