API  4.0
For C++ developers
OpenSim::ComponentPath Class Reference

A class for handling Paths for Components, deriving from Path. More...

+ Inheritance diagram for OpenSim::ComponentPath:

Public Member Functions

 ComponentPath ()
 The default-constructed path is empty (an empty string). More...
 
 ComponentPath (const std::string &path)
 Construct a ComponentPath from a string. More...
 
 ComponentPath (const std::vector< std::string > &pathVec, bool isAbsolute)
 Constructor a ComponentPath from a vector that contains all subtree node names and a bool that indicates if the path is an absolute path. More...
 
bool operator== (const ComponentPath &other) const
 
bool operator!= (const ComponentPath &other) const
 
const char getSeparator () const override
 Pure virtual function that returns a char for the designated separator. More...
 
const std::string getInvalidChars () const override
 Pure virtual function that returns a string of invalid characters. More...
 
ComponentPath formAbsolutePath (const ComponentPath &otherPath) const
 Get an absolute path by resolving it relative to a given otherPath. More...
 
ComponentPath formRelativePath (const ComponentPath &otherPath) const
 Find the relative Path between this Path and another Path (otherPath) (i.e. More...
 
ComponentPath getParentPath () const
 Return the sub-path that contains all subdirectory levels except for the last one. More...
 
std::string getParentPathString () const
 Return the parent path as a string. More...
 
std::string getSubcomponentNameAtLevel (size_t index) const
 Return a string of a subdirectory name at a specified level. More...
 
std::string getComponentName () const
 Return a string of the name of the Component related to a ComponentPath. More...
 
- Public Member Functions inherited from OpenSim::Path
 Path (const char separator, const std::string invalidChars)
 Create an empty path. More...
 
 Path (const std::string path, const char separator, const std::string invalidChars)
 Construct Path from a string, given separator character and a string of invalidChars. More...
 
 Path (const std::vector< std::string > pathVec, const char separator, const std::string invalidChars, bool isAbsolute)
 Construct Path from a vector of strings (pathVec), given separator character and a string of invalidChars. More...
 
 Path (const Path &)=default
 Use default copy constructor and assignment operator. More...
 
Pathoperator= (const Path &)=default
 
virtual ~Path ()=default
 Destructor. More...
 
std::string toString () const
 Write out the path to a string with each element separated by the specified separator. More...
 
bool isAbsolute () const
 Return true if this Path is an absolute path. More...
 
size_t getNumPathLevels () const
 Return the number of levels (or elements) in the Path. More...
 
void pushBack (const std::string &pathElement)
 Push a string to the back of a path (i.e. More...
 
bool isLegalPathElement (const std::string &pathElement) const
 Return true if pathElement does not contain any chars from the list of getInvalidChars() More...
 
void trimDotAndDotDotElements ()
 This removes "." elements and resolves ".." elements if possible (i.e., it will not remove leading ".." but otherwise will remove pairs of ".." and the preceding element). More...
 

Additional Inherited Members

- Protected Member Functions inherited from OpenSim::Path
std::vector< std::string > formAbsolutePathVec (const Path &otherPath) const
 Get an absolute path by resolving it relative to a given otherPath. More...
 
std::vector< std::string > formRelativePathVec (const Path &otherPath) const
 Find the relative Path between this Path and another Path (otherPath) (i.e. More...
 
std::vector< std::string > getParentPathVec () const
 Return the sub-path that contains all pathElements except for the last one. More...
 
std::string getPathElement (size_t pos) const
 Return the pathElement from the specified position as a string. More...
 
std::string getPathName () const
 Return the last pathElement as a string. More...
 

Detailed Description

A class for handling Paths for Components, deriving from Path.

A ComponentPath uses a forward-slash ('/') as a separator always. It also specifies invalid characters in a Component name:

  • back-slash ('\')
  • forward-slash ('/')
  • asterisk ('*')
  • plus-sign ('+')
Author
Carmichael Ong

Constructor & Destructor Documentation

◆ ComponentPath() [1/3]

OpenSim::ComponentPath::ComponentPath ( )

The default-constructed path is empty (an empty string).

◆ ComponentPath() [2/3]

OpenSim::ComponentPath::ComponentPath ( const std::string &  path)

Construct a ComponentPath from a string.

This will clean up the path, removing and resolving "." and ".." when possible.

◆ ComponentPath() [3/3]

OpenSim::ComponentPath::ComponentPath ( const std::vector< std::string > &  pathVec,
bool  isAbsolute 
)

Constructor a ComponentPath from a vector that contains all subtree node names and a bool that indicates if the path is an absolute path.

Member Function Documentation

◆ formAbsolutePath()

ComponentPath OpenSim::ComponentPath::formAbsolutePath ( const ComponentPath otherPath) const

Get an absolute path by resolving it relative to a given otherPath.

If the current Path is already absolute, return the same Path.

◆ formRelativePath()

ComponentPath OpenSim::ComponentPath::formRelativePath ( const ComponentPath otherPath) const

Find the relative Path between this Path and another Path (otherPath) (i.e.

the Path to go FROM otherPath TO this Path). Both Paths must be absolute.

◆ getComponentName()

std::string OpenSim::ComponentPath::getComponentName ( ) const

Return a string of the name of the Component related to a ComponentPath.

This is just the last level of a ComponentPath.

Referenced by OpenSim::AbstractSocket::checkConnecteePathProperty(), and OpenSim::Component::findComponent().

◆ getInvalidChars()

const std::string OpenSim::ComponentPath::getInvalidChars ( ) const
inlineoverridevirtual

Pure virtual function that returns a string of invalid characters.

Implements OpenSim::Path.

◆ getParentPath()

ComponentPath OpenSim::ComponentPath::getParentPath ( ) const

Return the sub-path that contains all subdirectory levels except for the last one.

◆ getParentPathString()

std::string OpenSim::ComponentPath::getParentPathString ( ) const

Return the parent path as a string.

◆ getSeparator()

const char OpenSim::ComponentPath::getSeparator ( ) const
inlineoverridevirtual

Pure virtual function that returns a char for the designated separator.

Implements OpenSim::Path.

◆ getSubcomponentNameAtLevel()

std::string OpenSim::ComponentPath::getSubcomponentNameAtLevel ( size_t  index) const

Return a string of a subdirectory name at a specified level.

This is 0 indexed.

Referenced by OpenSim::Input< T >::finalizeConnection(), and OpenSim::Component::traversePathToComponent().

◆ operator!=()

bool OpenSim::ComponentPath::operator!= ( const ComponentPath other) const
inline

◆ operator==()

bool OpenSim::ComponentPath::operator== ( const ComponentPath other) const
inline

The documentation for this class was generated from the following file: