本文整理汇总了C++中SystemPath::isAbsolute方法的典型用法代码示例。如果您正苦于以下问题:C++ SystemPath::isAbsolute方法的具体用法?C++ SystemPath::isAbsolute怎么用?C++ SystemPath::isAbsolute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SystemPath
的用法示例。
在下文中一共展示了SystemPath::isAbsolute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toRelative
SystemPath SystemPath::toRelative( SystemPath const& aBaseSystemPath ) const
{
// 1. "" (empty) means Model itself, which is invalid for this method.
// 2. Not absolute is invalid (not absolute implies not empty).
if( ! isAbsolute() || isModel() )
{
return *this;
}
if( ! aBaseSystemPath.isAbsolute() || aBaseSystemPath.isModel() )
{
THROW_EXCEPTION( BadSystemPath,
"[" + aBaseSystemPath.asString() +
"] is not an absolute SystemPath" );
}
SystemPath aThisPathCopy;
SystemPath const* thisPath;
if ( !isCanonicalized() )
{
aThisPathCopy = *this;
aThisPathCopy.canonicalize();
thisPath = &aThisPathCopy;
}
else
{
thisPath = this;
}
SystemPath aBaseSystemPathCopy;
SystemPath const* aCanonicalizedBaseSystemPath;
if ( !aBaseSystemPath.isCanonicalized() )
{
aCanonicalizedBaseSystemPath = &aBaseSystemPath;
}
else
{
aBaseSystemPathCopy = aBaseSystemPath;
aBaseSystemPathCopy.canonicalize();
aCanonicalizedBaseSystemPath = &aBaseSystemPathCopy;
}
SystemPath aRetval;
StringVector::const_iterator j( thisPath->theComponents.begin() ),
je( thisPath->theComponents.end() );
StringVector::const_iterator
i( aCanonicalizedBaseSystemPath->theComponents.begin() ),
ie( aCanonicalizedBaseSystemPath->theComponents.end() );
while ( i != ie && j != je )
{
String const& aComp( *i );
if ( aComp != *j )
{
break;
}
++i, ++j;
}
if ( i != ie )
{
while ( i != ie )
{
aRetval.theComponents.push_back( ".." );
++i;
}
}
std::copy( j, je, std::back_inserter( aRetval.theComponents ) );
if ( aRetval.theComponents.empty() )
{
aRetval.theComponents.push_back( "." );
}
return aRetval;
}