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


C++ Url::GetScheme方法代码示例

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


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

示例1: shouldRedirect

bool RedirectRule::shouldRedirect(const Url & u)
{
	std::string url=u.GetString();
	if (m_reParse.empty() || url.find(m_reParse.c_str()) != std::string::npos)
	{
		return false;
	}

	if(!this->m_isMatchProtocol) 
	{
		//url=url.substr(url.length()-u.GetScheme().length());
		if (!u.GetScheme().empty())
		{
			url=url.substr(u.GetScheme().length()+3);
		}
	}
	if (!m_vwhiteContent.empty() && isMatchContent(m_vwhiteContent,url))
	{
		return false;
	}
	
	if (!m_vblackContent.empty() && !isMatchContent(m_vblackContent,url))
	{
		return false;
	}
	
	bool ret = adbMatch(url.c_str(),m_reRedirect.c_str());
	if (ret)
	{
		m_rule;
	}
	
	return ret;
}
开发者ID:fanliaokeji,项目名称:lvdun,代码行数:34,代码来源:ADBFilter.cpp

示例2: shouldFilter

int FilterRule::shouldFilter(const Url & mainURL,const Url & u,FilterType t)
{
	if (!m_stateDomains.empty() && !isMatchState(m_stateDomains))
	{
		return 0;
	}
	std::string url=u.GetString();
	bool ret;
    if(!this->m_isMatchProtocol) {
		//url=url.substr(url.length()-u.GetScheme().length());
		if (!u.GetScheme().empty())
		{
			url=url.substr(u.GetScheme().length()+3);
		}
	}
    if(!this->isMatchThirdParty(mainURL,u)) {
        return 0;
    }
    if(!this->isMatchDomains(u) || !this->isMatchDomains(mainURL)) {
        return 0;
    }
    if(!isMatchType(u,t)) {
        return 0;
    }
    ret=adbMatch(url.c_str(),m_reFilter.c_str());
	if (ret)
	{
		if (m_iresponse > 0 && m_iresponse<1000)
		{
			return m_iresponse;  
		}
		return 1;
	}
	return 0;
}
开发者ID:fanliaokeji,项目名称:lvdun,代码行数:35,代码来源:ADBFilter.cpp

示例3: shouldReplace

bool ReplaceRule::shouldReplace(const Url & u)
{
	if (!m_stateDomains.empty() && !isMatchState(m_stateDomains))
	{
		return false;
	}

	std::string url=u.GetString();
	bool ret;
	if(!this->m_isMatchProtocol) 
	{
		//url=url.substr(url.length()-u.GetScheme().length());
		if (!u.GetScheme().empty())
		{
			url=url.substr(u.GetScheme().length()+3);
		}
	}
	ret=adbMatch(url.c_str(),m_reReplace.c_str());
	return ret;
}
开发者ID:fanliaokeji,项目名称:lvdun,代码行数:20,代码来源:ADBFilter.cpp

示例4: Parse

Url Url::Parse(const std::string& strRawUrl)
{
    // <scheme>://<user>:<password>@<host>:<port>/<path>?<query>#<frag>
    // <scheme>:opaque?query#fragment
    Url url;
    if (strRawUrl.empty())
        return url;
    do 
    {
        // Firstly, we will split fragment and query string.
        std::string strPrefix;
        auto spList = base::strings::Split(strRawUrl, "#");
        if (spList.size() > 2)
            break;
        strPrefix = spList[0];
        if (spList.size() == 2)
            url.m_strFragment = base::Unescape(spList[1]);
        spList = base::strings::Split(strPrefix, "?");
        if (spList.size() > 2)
            break;
        strPrefix = spList[0];
        if (spList.size() == 2)
            url.m_strRawQuery = spList[1];
        
        // Parse scheme.
        std::string strRest;
        if (!ParseScheme(strPrefix, url.m_strScheme, strRest))
            break;
        if (url.GetScheme() == "http")
            url.SetPort(80);
        else if (url.GetScheme() == "https")
            url.SetPort(443);

        if (strRest.empty())
            break;
        
        // <scheme>:opaque
        if (!url.m_strScheme.empty() && strRest[0] != '/')
        {
            url.m_strOpaque = strRest;
            break;
        } // !if <scheme>:opaque

        // Invalid URL.
        if (!url.m_strScheme.empty()
            && !base::strings::StartsWith(strRest, "//"))
            break;

        // Relative path.
        if (url.m_strScheme.empty()
            && !base::strings::StartsWith(strRest, "//"))
        {
            url.m_strPath = base::Unescape(strRest);
            break;
        }

        // Secondly, we will parse the particular case.
        // <scheme>:///<path>
        if (strRest[2] == '/')
        {
            auto pos1 = strRest.find_first_not_of('/');
            if (std::string::npos == pos1)
                break;
            url.m_strPath = base::Unescape(strRest.substr(pos1 - 1));
            break;
        } // !if <scheme>:///<path>

        // <scheme>://<user>:<password>@<host>:<port>/<path>
        auto pos1 = strRest.find_first_not_of('/');
        if (std::string::npos == pos1)
            break;
        auto pos2 = strRest.find_first_of("/", pos1);
        std::string strAuthority;
        if (std::string::npos == pos2)
            strAuthority = strRest.substr(pos1);
        else
            strAuthority = strRest.substr(pos1, pos2 - pos1);
        if (!ParseAuthority(strAuthority, url.m_strUserName, url.m_strPassword,
                            url.m_strHost, url.m_iPort))
        {
            url.m_strUserName = "";
            url.m_strPassword = "";
            url.m_strHost = "";
            url.m_iPort = 0;
            break;
        }
        if (pos2 == std::string::npos)
        {
            url.m_strPath = "/";
            break;
        }
        url.m_strPath = base::Unescape(strRest.substr(pos2));
        
    } while (0);
    
    return url;
}
开发者ID:whrool,项目名称:Net,代码行数:97,代码来源:url.cpp


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