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