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


C++ URI::normalize方法代码示例

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


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

示例1: equals

bool URI::equals(URI& uri)
{
    char* own = this->normalize();
    char* other = uri.normalize();
    unsigned int length = strlen(own);
    bool inEncoding = false;
    
    if( strlen(own) != strlen(other) )
        return false;
    else {
        for( unsigned int i = 0; i < length; i++ ) {
            if( ! inEncoding ) {
                if( own[i] != other[i] )
                    return false;
                
                if( own[i] == '%' )
                    inEncoding = true;
            }
            else {
                if( own[i] != other[i] ) {
                    /* Compare them in a case insensitive way. */
                    int result = (int)(own[i] - other[i]);
                    if( result != 32 && result != -32 )
                        return false;
                }
                
                /* See if we are at the end of the encoded string */
                if( i > 0 && ( own[i - 1] != '%' ) )
                    inEncoding = false;
            }
        }
    }
    
    return true;
}
开发者ID:Esaud17,项目名称:AmayaOS,代码行数:35,代码来源:URI.cpp

示例2: resolve

URI URI::resolve(const URI &other) const
{
    //### According to w3c, this is handled in 3 cases

    //## 1
    if (opaque || other.isAbsolute())
        return other;

    //## 2
    if (!other.fragment.empty()     &&
        other.path.empty()          &&
        other.scheme == SCHEME_NONE &&
        other.authority.empty()     &&
        other.query.empty())
        {
        URI fragUri = *this;
        fragUri.fragment = other.fragment;
        return fragUri;
        }

    //## 3 http://www.ietf.org/rfc/rfc2396.txt, section 5.2
    URI newUri;
    //# 3.1
    newUri.scheme    = scheme;
    newUri.schemeStr = schemeStr;
    newUri.query     = other.query;
    newUri.fragment  = other.fragment;
    if (!other.authority.empty())
        {
        //# 3.2
        if (absolute || other.absolute)
            newUri.absolute = true;
        newUri.authority = other.authority;
        newUri.port      = other.port;//part of authority
        newUri.path      = other.path;
        }
    else
        {
        //# 3.3
        if (other.absolute)
            {
            newUri.absolute = true;
            newUri.path     = other.path;
            }
        else
            {
            int pos = findLast(path, '/');
            if (pos >= 0)
                {
                newUri.path.clear();
                //# append my path up to and including the '/'
                for (int i = 0; i<=pos ; i++)
                       newUri.path.push_back(path[i]);
                //# append other path
                for (unsigned int i = 0; i<other.path.size() ; i++)
                       newUri.path.push_back(other.path[i]);
                }
            else
                newUri.path = other.path;
            }
        }

    newUri.normalize();

    return newUri;
}
开发者ID:Spin0za,项目名称:inkscape,代码行数:66,代码来源:uri.cpp


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