Katana Plug-in APIs 0.1
Classes | Functions

Geolib3PathUtils

Classes

struct  Foundry::Katana::Util::Path::FnMatchInfo

Functions

std::string Foundry::Katana::Util::Path::GetLocationParent (FnPlatform::StringView locationPath)
std::string Foundry::Katana::Util::Path::GetLeafName (FnPlatform::StringView locationPath)
void Foundry::Katana::Util::Path::GetLocationStack (std::vector< std::string > &returnStack, const std::string &locationPath, const std::string &rootPath=std::string())
bool Foundry::Katana::Util::Path::IsAncestorOrEqual (FnPlatform::StringView locA, FnPlatform::StringView locB)
bool Foundry::Katana::Util::Path::IsAncestor (FnPlatform::StringView locA, FnPlatform::StringView locB)
std::string Foundry::Katana::Util::Path::RelativeToAbsPath (const std::string &rootPath, const std::string &path)
std::string Foundry::Katana::Util::Path::NormalizedRelativePath (const std::string &rootpath, const std::string &path)
std::string Foundry::Katana::Util::Path::RelativePath (const std::string &rootPath, const std::string &path)
void Foundry::Katana::Util::Path::FnMatch (FnMatchInfo &matchInfo, FnPlatform::StringView testpath, FnPlatform::StringView pattern)
void Foundry::Katana::Util::Path::FnMatchIncludingAncestors (FnMatchInfo &matchInfo, FnPlatform::StringView testpath, FnPlatform::StringView pattern)
void Foundry::Katana::Util::Path::ExactMatch (FnMatchInfo &matchInfo, FnPlatform::StringView testpath, FnPlatform::StringView pattern)
int Foundry::Katana::Util::Path::Compare (FnPlatform::StringView pathA, FnPlatform::StringView pathB)
 Compares two scene graph location paths.

Detailed Description

All of these functions (which take as input an absolute scene graph location path) assume a properly normalized scene graph path:

Examples of normalized locations:

      /root
      /root/world/geo
      /root/world/taco/a/b

Examples of un-normalised locations:

      /root/
      /root/world/
      /root/world/../a
      /root/world/taco//a/b

Function Documentation

int Foundry::Katana::Util::Path::Compare ( FnPlatform::StringView  pathA,
FnPlatform::StringView  pathB 
)

Compares two scene graph location paths.

Each path component of pathA is compared lexicographically with the corresponding component of pathB. The function assumes normalized, absolute paths (except for superfluous trailing slashes, which are ignored).

Parameters:
pathAscene graph location path A
pathBscene graph location path A
Returns:
a negative value if pathA sorts before pathB, zero if both paths compare equal, and a positive value if pathA sorts after pathB.
void Foundry::Katana::Util::Path::ExactMatch ( FnMatchInfo &  matchInfo,
FnPlatform::StringView  testpath,
FnPlatform::StringView  pattern 
)
Note:
testpath and pattern should be absolute scene graph paths, normalized in the style of pystring::normpath_posix
Parameters:
matchInfoinstance of match info
testpathscene graph path to be tested
patternpattern to match against.
void Foundry::Katana::Util::Path::FnMatch ( FnMatchInfo &  matchInfo,
FnPlatform::StringView  testpath,
FnPlatform::StringView  pattern 
)
Note:
testpath and pattern should be absolute scene graph paths, normalized in the style of pystring::normpath_posix
Parameters:
matchInfoinstance of match info
testpathscene graph path to be tested
patternpattern to match against.
void Foundry::Katana::Util::Path::FnMatchIncludingAncestors ( FnMatchInfo &  matchInfo,
FnPlatform::StringView  testpath,
FnPlatform::StringView  pattern 
)
Note:
testpath and pattern should be absolute scene graph paths, normalized in the style of pystring::normpath_posix
Parameters:
matchInfoinstance of match info
testpathscene graph path to be tested
patternpattern to match against.
std::string Foundry::Katana::Util::Path::GetLeafName ( FnPlatform::StringView  locationPath)
Returns:
the leaf for the given input e.g.
 GetLeafName('/a/b/c') => 'c'
std::string Foundry::Katana::Util::Path::GetLocationParent ( FnPlatform::StringView  locationPath)
Returns:
the parent scene graph location path for the given input e.g.
  GetLocationParent('/root/world/geo') => '/root/world'
  GetLocationParent('/root') => ''
void Foundry::Katana::Util::Path::GetLocationStack ( std::vector< std::string > &  returnStack,
const std::string &  locationPath,
const std::string &  rootPath = std::string() 
)

Example:

 GetLocationStack('/a/b/c') => ['/a','/a/b','/a/b/c']
 GetLocationStack('/a/b/c/d/e', root='/a/b/c') => ['/a/b/c', '/a/b/c/d', '/a/b/c/d/e']
 GetLocationStack('/a/b/c', root='/a/b/c') => ['/a/b/c']
Parameters:
returnStackcontainer that will be populated with the return stack
locationPaththe location path to be processed
rootPathan optional 'root' location from which to begin.
bool Foundry::Katana::Util::Path::IsAncestor ( FnPlatform::StringView  locA,
FnPlatform::StringView  locB 
)

Example

 IsAncestor('/root/a','/root/a/b/c') => true
 IsAncestor('/root/a','/root/a') => false
Parameters:
locAscene graph location A
locBscene graph location B
Returns:
true if location A is an ancestor of location B
bool Foundry::Katana::Util::Path::IsAncestorOrEqual ( FnPlatform::StringView  locA,
FnPlatform::StringView  locB 
)

Example:

 IsAncestorOrEqual('/root/a','/root/a/b/c') => true
 IsAncestorOrEqual('/root/a','/root/a') => true
Parameters:
locAscene graph location A
locBscene graph location B
Returns:
true if location A is an ancestor or equal of location B
std::string Foundry::Katana::Util::Path::NormalizedRelativePath ( const std::string &  rootpath,
const std::string &  path 
)

Given a rootpath, and either a relative or absolute path, create a normalized relative path.

Note:
This function will throw an exception if root is not ancestor or equal to path.

Example:

 NormalizedRelativePath('/root','/root/world') -> 'world'
 NormalizedRelativePath('/root','/root/world/geo') -> 'world/geo'
 NormalizedRelativePath('/root','/root') -> ''
 NormalizedRelativePath('/root','/notroot') -> EXCEPTION
 NormalizedRelativePath('/root','a/b/c') -> 'a/b/c'
Parameters:
rootpaththe root path
paththe full path from which to generate the relative path.
Returns:
a normalized relative path
std::string Foundry::Katana::Util::Path::RelativePath ( const std::string &  rootPath,
const std::string &  path 
)

Given two absolute paths, create a relative path from rootPath to path even if rootPath is not an ancestor of path).

Example:

 RelativePath('/root/world/geo', '/root/world/geo/a') -> 'a'
 RelativePath('/root/world/geo/a', '/root/world/geo') -> '..'
 RelativePath('/root/world/geo/a', '/root/world/geo/b') -> '../b'
 RelativePath('/root/world/geo/a', '/root/world/geo/a') -> ''
 RelativePath('/root/world/geo/a', '/root/world/cam/a') -> '../../cam/a'
Parameters:
rootPaththe root path
pathpath to generate the relative path to.
Returns:
a relative path from rootPath to path
std::string Foundry::Katana::Util::Path::RelativeToAbsPath ( const std::string &  rootPath,
const std::string &  path 
)

Example:

 RelativeToAbsPath('/root/world','../') => '/root'
Parameters:
rootPaththe path from which to generate the new absolute path
paththe relative path specifier.
Returns:
a new absolute path given the rootPath and path.
 All Classes Functions Variables Typedefs Enumerations Enumerator