本文整理汇总了C++中Url::GetHost方法的典型用法代码示例。如果您正苦于以下问题:C++ Url::GetHost方法的具体用法?C++ Url::GetHost怎么用?C++ Url::GetHost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Url
的用法示例。
在下文中一共展示了Url::GetHost方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isMatchThirdParty
bool FilterRule::isMatchThirdParty(const Url &mainURL, const Url &other)
{
if(!this->m_filterThirdParty)
return true;
if(mainURL.GetString().empty())
return true;
return boost::iends_with(other.GetHost(),mainURL.GetHost()) == this->m_matchFirstParty;
}
示例2: getcssRules
std::string RuleMap::getcssRules(const Url & url)
{
std::string res;
StringVector dotsplits;
boost::split(dotsplits,url.GetHost(),boost::is_any_of("."));
if(dotsplits.size()<=1) //domain error? no dot? at least g.cn
return res;
int ignore=2;
std::string l2domain=dotsplits[dotsplits.size()-2];
if(l2domain =="com" ||
l2domain=="net" ||
l2domain=="org" ||
l2domain=="edu")
ignore=3;
for(int i=dotsplits.size()-ignore;i>=0;i--)
{
std::string domain=dotsplits[i];
for(int j=i+1;j<dotsplits.size();j++)
{
domain=domain+"."+dotsplits[j];
}
HideRuleMap::iterator it=this->m_HideRules.find(domain);
if(it!=m_HideRules.end())
{
res=res.empty()?it->second:res+","+it->second;
}
}
return res;
}
示例3: shouldFilterByDomain
int RuleMap::shouldFilterByDomain(const Url & mainURL,const Url & url,FilterType t,bool & isFind)
{
int iRet = 0;
StringVector dotsplits;
this->m_DomainFilterRules.prepareStartFind();
this->m_DomainWhiteRules.prepareStartFind();
boost::split(dotsplits,url.GetHost(),boost::is_any_of("."));
if (dotsplits.size() <= 1) //domain error? no dot? at least g.cn
return false;
for (int i = dotsplits.size() - 2; i >= 0; i--) {
std::string domain = dotsplits[i];
for (int j = i + 1; j < dotsplits.size(); j++) {
domain = domain + "." + dotsplits[j];
}
iRet=m_DomainWhiteRules.doFilter(mainURL, domain, url, t);
if (iRet != 0)
{
isFind = true;
return 0;
}
iRet=m_DomainFilterRules.doFilter(mainURL, domain, url, t);
if (iRet != 0)
{
isFind = true;
return iRet;
}
}
return iRet;
}
示例4: checkConfigHost
int FilterManager::checkConfigHost(const Url & url,bool &bFind,std::string &strMatchHost,int cfgFlag)
{
readLock rdLock(rw_cfgmutex);
std::string res;
StringVector dotsplits;
boost::split(dotsplits,url.GetHost(),boost::is_any_of("."));
if(dotsplits.size()<=1) //domain error? no dot? at least g.cn
return false;
int ignore=2;
std::string l2domain=dotsplits[dotsplits.size()-2];
if(l2domain =="com" ||
l2domain=="net" ||
l2domain=="org" ||
l2domain=="edu")
ignore=3;
for(int i=dotsplits.size()-ignore;i>=0;i--)
{
std::string domain=dotsplits[i];
for(int j=i+1;j<dotsplits.size();j++) {
domain=domain+"."+dotsplits[j];
}
if (cfgFlag & CFG_CHECK_WHITE)
{
ConfigRuleMap::iterator it_White=this->m_ConfigWhiteRules.find(domain);
if(it_White!=m_ConfigWhiteRules.end())
{
bFind = true;
return 0;
}
}
if (cfgFlag & CFG_CHECK_VIDEO)
{
ConfigRuleMap::iterator it_video=map_VideoState.find(domain);
if(it_video!=map_VideoState.end())
{
strMatchHost = domain;
bFind = true;
return it_video->second;
}
}
}
return 0;
}
示例5: updateConfigWhiteHost
// true:添加到白名单
// false:从白名单中删除
bool FilterManager::updateConfigWhiteHost(const Url & url,bool bEnable)
{
writeLock wrlock(rw_cfgmutex);
std::string host = url.GetHost();
//ConfigRuleMap::iterator hit=this->m_ConfigWhileRules.find(host);
if (bEnable)
{
ConfigRuleMap::iterator hit=this->m_ConfigWhiteRules.find(host);
if(hit == m_ConfigWhiteRules.end())
{
m_ConfigWhiteRules.insert(ConfigRuleMap::value_type(host, 0));
}
}
else
{
m_ConfigWhiteRules.erase(host);
}
return true;
}
示例6: updateConfigVideoHost
// 0:弹框
// 1:过滤
// 2:不过滤
bool FilterManager::updateConfigVideoHost(const Url & url,int istate)
{
writeLock wrlock(rw_cfgmutex);
std::string host = url.GetHost();
if (host.empty())
{
return false;
}
ConfigRuleMap::iterator hit=map_VideoState.find(host);
if(hit!=map_VideoState.end())
{
hit->second=istate;
}
else {
map_VideoState.insert(ConfigRuleMap::value_type(host, istate));
}
return true;
}
示例7: getreplaceRules
void RuleMap::getreplaceRules(const Url & url,std::vector<std::string> & v_replace)
{
StringVector dotsplits;
this->m_DomainReplaceRules.prepareStartFind();
boost::split(dotsplits,url.GetHost(),boost::is_any_of("."));
if (dotsplits.size() >= 1) //domain error? no dot? at least g.cn
{
for (int i = dotsplits.size() - 2; i >= 0; i--)
{
std::string domain = dotsplits[i];
for (int j = i + 1; j < dotsplits.size(); j++)
{
domain = domain + "." + dotsplits[j];
}
m_DomainReplaceRules.getReplace(domain,url,v_replace);
}
}
}
示例8: isMatchDomains
bool FilterRule::isMatchDomains(const Url &url)
{
//String h=url.host().lower();
std::string h = url.GetHost();
if(m_domains.empty() && m_inverseDomains.empty()) //not specify which domains;
return true;
for(StringVector::iterator it=this->m_domains.begin();it!=m_domains.end();++it) {
if(boost::iends_with(h,*it))
return true;
}
if(m_inverseDomains.empty()) //no inverse domains,so this filter rule should not apply
return false;
for(StringVector::iterator it=this->m_inverseDomains.begin();
it!=m_inverseDomains.end();++it) {
if(boost::iends_with(h,*it))
return false;
}
return true;
}
示例9: shouldRedirect
bool RuleMap::shouldRedirect(const Url & mainURL,const Url & url, std::string& strRedirect)
{
StringVector dotsplits;
this->m_DomainRedirectRules.prepareStartFind();
boost::split(dotsplits,url.GetHost(),boost::is_any_of("."));
if (dotsplits.size() >= 1) //domain error? no dot? at least g.cn
{
for (int i = dotsplits.size() - 2; i >= 0; i--)
{
std::string domain = dotsplits[i];
for (int j = i + 1; j < dotsplits.size(); j++)
{
domain = domain + "." + dotsplits[j];
}
if ( m_DomainRedirectRules.shouldRedirect(domain,url,strRedirect))
{
return true;
}
}
}
return false;
}