OSVR-Core
|
Class representing a host and resource path in the OSVR logical system. More...
#include <ResourcePath.h>
Public Member Functions | |
ResourcePath () | |
Default constructor - initializes to osvr://localhost/ (root) | |
ResourcePath (std::string const &url) | |
Constructs from a URL string. | |
ResourcePath (const char *url) | |
ResourcePath | GetParent () const |
Go to parent path. More... | |
ResourcePath | GetChild (std::string const &childName) const |
Go to the named child. More... | |
ResourcePath | GetChild (const char *childName) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Does not take ownership of the argument. More... | |
Base Portion String Accessors | |
At any time, "osvr://" + GetHostString() + GetPathString() is the canonical form of a path. Gets the entire path as a string. | |
std::string | GetString () const |
std::string | GetHostString () const |
Gets the host portion of the path as a string. | |
std::string | GetPathString () const |
Gets the path following the hostname as a string, starting with a leading slash. More... | |
Component-wise Accessors | |
Gets the number of named components. A path at the root is defined to have depth 0. | |
std::size_t | GetDepth () const |
std::string | GetComponent (std::size_t i) const |
Gets the identified component, where 0 is the name of the component immediately under the root. More... | |
Class representing a host and resource path in the OSVR logical system.
Instances of this class always refer to an absolute path, with host and full path from the root. No assertions are made that the path is meaningful.
Paths are essentially URLs, and follow the same rules. Canonical form of ResourcePaths does not end in a slash, and usage of the .
and ..
pseudo-entries (for current directory and parent directory) is not supported for simplicity and security.
Paths are immutable: navigating functions return a new ResourcePath.
Enumeration ("browsing") is out of scope for this class - it may be supported in some cases by other code.
|
explicit |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
ResourcePath osvr::util::ResourcePath::GetChild | ( | std::string const & | childName | ) | const |
Go to the named child.
The name may include slashes for multiple levels.
ResourcePath osvr::util::ResourcePath::GetChild | ( | const char * | childName | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Does not take ownership of the argument.
std::string osvr::util::ResourcePath::GetComponent | ( | std::size_t | i | ) | const |
Gets the identified component, where 0 is the name of the component immediately under the root.
Requires that i < GetDepth()
std::out_of_range | if precondition violated. |
ResourcePath osvr::util::ResourcePath::GetParent | ( | ) | const |
Go to parent path.
If at the root on a host, this is a no-op
std::string osvr::util::ResourcePath::GetPathString | ( | ) | const |
Gets the path following the hostname as a string, starting with a leading slash.